k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit b574d181741fb6382338f4c6f243982d2d235b85
parent 43d55a3dfad24a52d629d835d93d65b14a43cb5a
Author: qorg11 <qorg@vxempire.xyz>
Date:   Wed,  8 Jul 2020 11:28:21 +0200

added id.c.

I'm a POSIX disliker.

Diffstat:
Asrc/id.c | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/id.c b/src/id.c @@ -0,0 +1,26 @@ +#include <stdio.h> +#include <pwd.h> +#include <unistd.h> +#include <getopt.h> +int +main(int argc, char *argv[]) +{ + int c = getopt(argc, argv, "Ggnru"); + struct passwd *user_data = getpwnam(getlogin()); + switch(c) + { + case 'g': + case 'u': + printf("%u\n",user_data->pw_gid); + break; + case 'n': + printf("%s\n",user_data->pw_name); + break; + default: + printf("%u %s\n",user_data->pw_gid,user_data->pw_name); /* I know + * it does not work + * like this */ + } + + return 0; +}