Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/coreutils/logname.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 20  Line 20 
20   * a diagnostic message and an error return.   * a diagnostic message and an error return.
21   */   */
22    
23  #include <stdio.h>  #include "libbb.h"
 #include <stdlib.h>  
 #include <unistd.h>  
 #include "busybox.h"  
24    
25  int logname_main(int argc, char ATTRIBUTE_UNUSED **argv)  /* This is a NOFORK applet. Be very careful! */
26    
27    int logname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
28    int logname_main(int argc, char **argv UNUSED_PARAM)
29  {  {
30   const char *p;   char buf[128];
31    
32   if (argc > 1) {   if (argc > 1) {
33   bb_show_usage();   bb_show_usage();
34   }   }
35    
36   if ((p = getlogin()) != NULL) {   /* Using _r function - avoid pulling in static buffer from libc */
37   puts(p);   if (getlogin_r(buf, sizeof(buf)) == 0) {
38   fflush_stdout_and_exit(EXIT_SUCCESS);   puts(buf);
39     return fflush(stdout);
40   }   }
41    
42   bb_perror_msg_and_die("getlogin");   bb_perror_msg_and_die("getlogin");

Legend:
Removed from v.532  
changed lines
  Added in v.816