home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3343 / entry.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-17  |  1.9 KB  |  87 lines

  1. /*
  2.  * Copyright 1989, 1990, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Permission is granted to copy and create derivative works for any
  6.  * non-commercial purpose, provided this copyright notice is preserved
  7.  * in all copies of source code, or included in human readable form
  8.  * and conspicuously displayed on all copies of object code or
  9.  * distribution media.
  10.  */
  11.  
  12. #include "pwd.h"
  13. #ifndef    BSD
  14. #include <string.h>
  15. #else
  16. #include <strings.h>
  17. #define    strchr    index
  18. #define    strrchr    rindex
  19. #endif
  20. #include "config.h"
  21. #ifdef    SHADOWPWD
  22. #include "shadow.h"
  23. #endif
  24.  
  25. #ifndef    lint
  26. static    char    sccsid[] = "@(#)entry.c    3.2    12:30:39    12/12/90";
  27. #endif
  28.  
  29. struct    passwd    *fgetpwent ();
  30.  
  31. void    entry (name, pwent)
  32. char    *name;
  33. struct    passwd    *pwent;
  34. {
  35.     struct    passwd    *passwd;
  36. #ifdef    SHADOWPWD
  37.     struct    spwd    *spwd;
  38.     char    *l64a ();
  39. #endif
  40.     char    *cp;
  41.  
  42.     if (! (passwd = getpwnam (name))) {
  43.         pwent->pw_name = (char *) 0;
  44.         return;
  45.     } else  {
  46.         pwent->pw_name = strdup (passwd->pw_name);
  47.         pwent->pw_uid = passwd->pw_uid;
  48.         pwent->pw_gid = passwd->pw_gid;
  49. #ifdef    ATT_COMMENT
  50.         pwent->pw_comment = strdup (passwd->pw_comment);
  51. #endif
  52.         pwent->pw_gecos = strdup (passwd->pw_gecos);
  53.         pwent->pw_dir = strdup (passwd->pw_dir);
  54.         pwent->pw_shell = strdup (passwd->pw_shell);
  55. #if defined(SHADOWPWD) && !defined(AUTOSHADOW)
  56.         setspent ();
  57.         if (spwd = getspnam (name)) {
  58.             pwent->pw_passwd = strdup (spwd->sp_pwdp);
  59. #ifdef    ATT_AGE
  60.             pwent->pw_age = malloc (5);
  61.  
  62.             if (spwd->sp_max > (63*7))
  63.                 spwd->sp_max = (63*7);
  64.             if (spwd->sp_min > (63*7))
  65.                 spwd->sp_min = (63*7);
  66.  
  67.             pwent->pw_age[0] = i64c (spwd->sp_max / 7);
  68.             pwent->pw_age[1] = i64c (spwd->sp_min / 7);
  69.  
  70.             cp = l64a (spwd->sp_lstchg / 7);
  71.             pwent->pw_age[2] = cp[0];
  72.             pwent->pw_age[3] = cp[1];
  73.  
  74.             pwent->pw_age[4] = '\0';
  75. #endif
  76.             endspent ();
  77.             return;
  78.         }
  79.         endspent ();
  80. #endif
  81.         pwent->pw_passwd = strdup (passwd->pw_passwd);
  82. #ifdef    ATT_AGE
  83.         pwent->pw_age = strdup (passwd->pw_age);
  84. #endif
  85.     }
  86. }
  87.