logname.c (422B)
1 /* See LICENSE file for copyright and license details. */ 2 #include <stdio.h> 3 #include <unistd.h> 4 5 #include "util.h" 6 7 static void 8 usage(void) 9 { 10 eprintf("usage: %s\n", argv0); 11 } 12 13 int 14 main(int argc, char *argv[]) 15 { 16 char *login; 17 18 argv0 = *argv, argv0 ? (argc--, argv++) : (void *)0; 19 20 if (argc) 21 usage(); 22 23 if ((login = getlogin())) 24 puts(login); 25 else 26 eprintf("no login name\n"); 27 28 return fshut(stdout, "<stdout>"); 29 }