Home | History | Annotate | Line # | Download | only in djgpp
      1 /*
      2    libc of DJGPP 2.03 does not offer a pw_gecos entry,
      3    so this version from DJGPP 2.04 CVS tree is supplied.
      4    This file will become superflous and will be removed
      5    from the  distribution as soon as DJGPP 2.04 has been
      6    released.
      7 */
      8 
      9 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
     10 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
     11 #include "djpwd.h"
     12 #include <unistd.h>
     13 #include <stdlib.h>
     14 #include <string.h>
     15 
     16 static char passwd[] = "";
     17 static char slash [] = "/";
     18 static char shell [] = "sh";
     19 
     20 struct passwd *
     21 getpwnam(const char *name)
     22 {
     23   static struct passwd rv;
     24   rv.pw_name = getlogin();
     25   if (strcmp(rv.pw_name, name) != 0)
     26     return 0;
     27   rv.pw_uid = getuid();
     28   rv.pw_gid = getgid();
     29   rv.pw_dir = getenv("HOME");
     30   if (rv.pw_dir == 0)
     31     rv.pw_dir = slash;
     32   rv.pw_shell = getenv("SHELL");
     33   if (rv.pw_shell == 0)
     34     rv.pw_shell = getenv("COMSPEC");
     35   if (rv.pw_shell == 0)
     36     rv.pw_shell = shell;
     37   rv.pw_gecos = getlogin();
     38   rv.pw_passwd = passwd;
     39   return &rv;
     40 }
     41