home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source: /unixb/home/unixlib/source/unixlib37/src/pwd/c/RCS/getpwnam,v $
- * $Date: 1996/10/30 22:04:51 $
- * $Revision: 1.1 $
- * $State: Rel $
- * $Author: unixlib $
- *
- * $Log: getpwnam,v $
- * Revision 1.1 1996/10/30 22:04:51 unixlib
- * Initial revision
- *
- ***************************************************************************/
-
- static const char rcs_id[] = "$Id: getpwnam,v 1.1 1996/10/30 22:04:51 unixlib Rel $";
-
- /* pwd.c.getpwnam. Search for an entry with a matching username.
-
- This is a POSIX.1 function written by Nick Burrett, 13 October 1996. */
-
- #include <stddef.h>
- #include <stdio.h>
- #include <string.h>
- #include <pwd.h>
-
- /* Search for an entry with a matching name. */
- struct passwd *
- getpwnam (const char *name)
- {
- FILE *stream;
- struct passwd *p;
-
- stream = fopen ("/etc/passwd", "r");
- if (stream == NULL)
- return NULL;
-
- while ((p = fgetpwent (stream)) != NULL)
- if (!strcmp(p->pw_name, name))
- break;
-
- fclose (stream);
- return p;
- }
-