home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume14 / libpw / part01 / sortuser.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-15  |  377 b   |  27 lines

  1. /*
  2.  * sortuser(uname) - look for uname in /etc/passwd.  TRUE=1, FALSE=0
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <pwd.h>
  7.  
  8. struct passwd *tmp;
  9.  
  10. sortuser(uname)
  11. char    uname[10];
  12. {
  13.     lockpwfile();
  14.     setpwent();
  15.  
  16.     while ((tmp = getpwent()) != NULL) {
  17.         if (strcmp(tmp->pw_name, uname) == 0) {
  18.             endpwent();
  19.             unlockpwfile();
  20.             return(1);
  21.         }
  22.     }
  23.     unlockpwfile();
  24.     endpwent();
  25.     return(0);
  26. }
  27.