home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / forut062.zip / ForUtil-0.62 / lib / msdospwd.c < prev    next >
C/C++ Source or Header  |  1996-08-28  |  2KB  |  114 lines

  1. #ifndef lint
  2. static char rcsId[]="$Source: /usr/local/rcs/ForUtil/lib/RCS/msdospwd.c,v $";
  3. #endif
  4. /*****
  5. * msdospwd.c : fake passwd routines for msdos
  6. *
  7. * This file Version    $Revision: 1.2 $
  8. *
  9. * Creation date:    Wed Aug  7 15:24:32 GMT+0100 1996
  10. * Last modification:     $Date: 1996/08/27 19:20:49 $
  11. * By:            $Author: koen $
  12. * Current State:    $State: Exp $
  13. *
  14. * Author:        koen
  15. * (C)Copyright 1995-1996 Ripley Software Development
  16. * All Rights Reserved
  17. *****/
  18. /*****
  19. * ChangeLog 
  20. * $Log: msdospwd.c,v $
  21. * Revision 1.2  1996/08/27 19:20:49  koen
  22. * msdos related changes
  23. *
  24. * Revision 1.1  1996/08/07 21:16:52  koen
  25. * Initial Revision
  26. *
  27. *****/ 
  28. /* needed to prevent multiple variable decls under MSDOS in sysdeps.h */
  29. #define LIBRARY_OBJECT
  30.  
  31. /* include this before anything else */
  32. #ifdef HAVE_CONFIG_H
  33. #include "autoconf.h"
  34. #endif
  35.  
  36. #include <stdlib.h>
  37. #include <sys/types.h>
  38.  
  39. #include "forutil.h"
  40. #include "memmacros.h"
  41. #include "msdospwd.h"
  42.  
  43. struct passwd
  44. *getpwuid(uid_t uid)
  45. {
  46.     static struct passwd *pwd;
  47.  
  48.     if(pwd == NULL)
  49.     {
  50.         char *chPtr;
  51.  
  52.         checked_malloc(pwd, 1, struct passwd);
  53.         /* get user identity */
  54.         if((chPtr = getenv("USER")) == NULL)
  55.             if((chPtr = getenv("LOGNAME")) == NULL)
  56.                 if((chPtr = getenv("LOGIN")) == NULL)
  57.                     chPtr = "nobody";
  58.         pwd->pw_name = chPtr;
  59.         pwd->pw_gecos = chPtr;
  60.  
  61.         /* set user and group id */
  62.         pwd->pw_uid = uid;
  63.         pwd->pw_gid = 0;
  64.  
  65.         /* get shell */
  66.         if((chPtr = getenv("COMSPEC")) == NULL)
  67.             chPtr = "COMMAND.COM";
  68.         pwd->pw_shell = chPtr;
  69.         pwd->pw_dir = "C:\\";    /* root directory of c drive */
  70.     }
  71.     return(pwd);
  72. }
  73.  
  74. struct passwd
  75. *getpwnam(char *name)
  76. {
  77.     static struct passwd *pwd;
  78.  
  79.     if(pwd == NULL)
  80.     {
  81.         char *chPtr;
  82.  
  83.         checked_malloc(pwd, 1, struct passwd);
  84.         /* get user identity */
  85.         if((chPtr = getenv("USER")) == NULL)
  86.             if((chPtr = getenv("LOGNAME")) == NULL)
  87.                 if((chPtr = getenv("LOGIN")) == NULL)
  88.                     chPtr = name;
  89.         pwd->pw_name = chPtr;
  90.         pwd->pw_gecos = chPtr;
  91.  
  92.         /* set user and group id */
  93.         pwd->pw_uid = 0;
  94.         pwd->pw_gid = 0;
  95.  
  96.         /* get shell */
  97.         if((chPtr = getenv("COMSPEC")) == NULL)
  98.             chPtr = "COMMAND.COM";
  99.         pwd->pw_shell = chPtr;
  100.         pwd->pw_dir = "C:\\";    /* root directory of c drive */
  101.     }
  102.     return(pwd);
  103. }
  104.  
  105. struct passwd
  106. *getpwent(void)
  107. {
  108.     static struct passwd *pwd;
  109.  
  110.     if(pwd == NULL)
  111.         pwd = getpwuid(0);
  112.     return(pwd);
  113. }
  114.