Back to index

glibc  2.9
Classes | Defines | Functions
fgetspent_r.c File Reference
#include <ctype.h>
#include <errno.h>
#include <shadow.h>
#include <stdio.h>
#include <nss/nss_files/files-parse.c>

Go to the source code of this file.

Classes

struct  spent_data

Defines

#define STRUCTURE   spwd
#define ENTNAME   spent
#define EXTERN_PARSER   1

Functions

int __fgetspent_r (FILE *stream, struct spwd *resbuf, char *buffer, size_t buflen, struct spwd **result)

Class Documentation

struct spent_data

Definition at line 25 of file files-spwd.c.


Define Documentation

#define ENTNAME   spent

Definition at line 33 of file fgetspent_r.c.

#define EXTERN_PARSER   1

Definition at line 34 of file fgetspent_r.c.

#define STRUCTURE   spwd

Definition at line 32 of file fgetspent_r.c.


Function Documentation

int __fgetspent_r ( FILE stream,
struct spwd resbuf,
char *  buffer,
size_t  buflen,
struct spwd **  result 
)

Definition at line 42 of file fgetspent_r.c.

{
  char *p;

  flockfile (stream);
  do
    {
      buffer[buflen - 1] = '\xff';
      p = fgets_unlocked (buffer, buflen, stream);
      if (p == NULL && feof_unlocked (stream))
       {
         funlockfile (stream);
         *result = NULL;
         __set_errno (ENOENT);
         return errno;
       }
      if (p == NULL || buffer[buflen - 1] != '\xff')
       {
         funlockfile (stream);
         *result = NULL;
         __set_errno (ERANGE);
         return errno;
       }

      /* Skip leading blanks.  */
      while (isspace (*p))
       ++p;
    } while (*p == '\0' || *p == '#' ||   /* Ignore empty and comment lines.  */
            /* Parse the line.  If it is invalid, loop to
              get the next line of the file to parse.  */
            ! parse_line (buffer, (void *) resbuf, NULL, 0, &errno));

  funlockfile (stream);

  *result = resbuf;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: