1
0
mirror of git://git.suckless.org/sbase synced 2024-12-26 00:42:35 +00:00

Factor out code printing information for the current process

This commit is contained in:
sin 2013-12-01 09:58:02 +00:00
parent f1f0fba630
commit 137ebef3ac

21
id.c
View File

@ -8,6 +8,8 @@
#include <limits.h> #include <limits.h>
#include "util.h" #include "util.h"
static void curproc(void);
static void static void
usage(void) usage(void)
{ {
@ -16,6 +18,19 @@ usage(void)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{
ARGBEGIN {
default:
usage();
} ARGEND;
curproc();
return EXIT_SUCCESS;
}
static void
curproc(void)
{ {
struct passwd *pw; struct passwd *pw;
struct group *gr; struct group *gr;
@ -24,11 +39,6 @@ main(int argc, char *argv[])
int ngroups; int ngroups;
int i; int i;
ARGBEGIN {
default:
usage();
} ARGEND;
/* Print uid/euid info */ /* Print uid/euid info */
uid = getuid(); uid = getuid();
printf("uid=%u", uid); printf("uid=%u", uid);
@ -67,5 +77,4 @@ main(int argc, char *argv[])
printf("(%s)", gr->gr_name); printf("(%s)", gr->gr_name);
} }
putchar('\n'); putchar('\n');
return EXIT_SUCCESS;
} }