Back to index

glibc  2.9
Defines | Functions
putpwent.c File Reference
#include <errno.h>
#include <stdio.h>
#include <pwd.h>

Go to the source code of this file.

Defines

#define _S(x)   x ?: ""

Functions

int putpwent (struct passwd *p, FILE *stream) const

Define Documentation

#define _S (   x)    x ?: ""

Definition at line 23 of file putpwent.c.


Function Documentation

int putpwent ( struct passwd p,
FILE stream 
) const

Definition at line 28 of file putpwent.c.

{
  if (p == NULL || stream == NULL)
    {
      __set_errno (EINVAL);
      return -1;
    }

  if (p->pw_name[0] == '+' || p->pw_name[0] == '-')
    {
      if (fprintf (stream, "%s:%s:::%s:%s:%s\n",
                 p->pw_name, _S (p->pw_passwd),
                 _S (p->pw_gecos), _S (p->pw_dir), _S (p->pw_shell)) < 0)
       return -1;
    }
  else
    {
      if (fprintf (stream, "%s:%s:%lu:%lu:%s:%s:%s\n",
                 p->pw_name, _S (p->pw_passwd),
                 (unsigned long int) p->pw_uid,
                 (unsigned long int) p->pw_gid,
                 _S (p->pw_gecos), _S (p->pw_dir), _S (p->pw_shell)) < 0)
       return -1;
    }
  return 0;
}

Here is the call graph for this function: