示例#1
0
文件: getpwnam.c 项目: 8l/FUZIX
struct passwd *
getpwnam(const char * name)
{
  int passwd_fd;
  struct passwd * passwd;

  if (name==NULL)
    {
      errno=EINVAL;
      return NULL;
    }

  if ((passwd_fd=open("/etc/passwd", O_RDONLY))<0)
    return NULL;

  while ((passwd=__getpwent(passwd_fd))!=NULL)
    if (!strcmp(passwd->pw_name, name))
      {
	close(passwd_fd);
	return passwd;
      }	  

  close(passwd_fd);
  return NULL;
}
示例#2
0
文件: pwent.c 项目: 8l/FUZIX
struct passwd *
getpwent(void)
{
  if (pw_fd==-1)
    setpwent();
  if (pw_fd!=-1)
    return __getpwent(pw_fd);
  return NULL;  
}
示例#3
0
struct passwd *fgetpwent(FILE * file)
{
	if (file == NULL) {
		errno = EINTR;
		return NULL;
	}

	return __getpwent(fileno(file));
}