home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / uucp / getpwinfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1979-01-10  |  884 b   |  59 lines

  1. #include "uucp.h"
  2. #include <pwd.h>
  3.  
  4.  
  5. /*******
  6.  *    guinfo(uid, name, path)    get passwd file info for uid
  7.  *    int uid;
  8.  *    char *path, *name;
  9.  *
  10.  *    return codes:  0  |  FAIL
  11.  */
  12.  
  13. guinfo(uid, name, path)
  14. int uid;
  15. char *path, *name;
  16. {
  17.     struct passwd *pwd;
  18.     struct passwd *getpwuid();
  19.  
  20.     if ((pwd = getpwuid(uid)) == NULL) {
  21.         /* can not find uid in passwd file */
  22.         *path = '\0';
  23.         return(FAIL);
  24.     }
  25.  
  26.     strcpy(path, pwd->pw_dir);
  27.     strcpy(name, pwd->pw_name);
  28.     return(0);
  29. }
  30.  
  31.  
  32. /***
  33.  *    gninfo(name, uid, path)    get passwd file info for name
  34.  *    char *path, *name;
  35.  *    int *uid;
  36.  *
  37.  *    return codes:  0  |  FAIL
  38.  */
  39.  
  40. gninfo(name, uid, path)
  41. char *path, *name;
  42. int *uid;
  43. {
  44.     struct passwd *pwd;
  45.     struct passwd *getpwnam();
  46.  
  47.     if ((pwd = getpwnam(name)) == NULL) {
  48.         /* can not find name in passwd file */
  49.         *path = '\0';
  50.         return(FAIL);
  51.     }
  52.  
  53.     strcpy(path, pwd->pw_dir);
  54.     *uid = pwd->pw_uid;
  55.     return(0);
  56. }
  57.  
  58.  
  59.