Back to index

glibc  2.9
Classes | Defines | Functions
sgetspent_r.c File Reference
#include <ctype.h>
#include <errno.h>
#include <shadow.h>
#include <stdio.h>
#include <string.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 FALSEP(arg)   0

Functions

 LINE_PARSER ()

Class Documentation

struct spent_data

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


Define Documentation

#define ENTNAME   spent

Definition at line 29 of file sgetspent_r.c.

#define FALSEP (   arg)    0

Definition at line 33 of file sgetspent_r.c.

#define STRUCTURE   spwd

Definition at line 28 of file sgetspent_r.c.


Function Documentation

Definition at line 38 of file sgetspent_r.c.

   {
     result->sp_pwdp = NULL;
     result->sp_lstchg = 0;
     result->sp_min = 0;
     result->sp_max = 0;
     result->sp_warn = -1l;
     result->sp_inact = -1l;
     result->sp_expire = -1l;
     result->sp_flag = ~0ul;
   }
 else
   {
     STRING_FIELD (result->sp_pwdp, ISCOLON, 0);
     INT_FIELD_MAYBE_NULL (result->sp_lstchg, ISCOLON, 0, 10, (long int),
                        (long int) -1);
     INT_FIELD_MAYBE_NULL (result->sp_min, ISCOLON, 0, 10, (long int),
                        (long int) -1);
     INT_FIELD_MAYBE_NULL (result->sp_max, ISCOLON, 0, 10, (long int),
                        (long int) -1);
     while (isspace (*line))
       ++line;
     if (*line == '\0')
       {
        /* The old form.  */
        result->sp_warn = -1l;
        result->sp_inact = -1l;
        result->sp_expire = -1l;
        result->sp_flag = ~0ul;
       }
     else
       {
        INT_FIELD_MAYBE_NULL (result->sp_warn, ISCOLON, 0, 10, (long int),
                            (long int) -1);
        INT_FIELD_MAYBE_NULL (result->sp_inact, ISCOLON, 0, 10, (long int),
                            (long int) -1);
        INT_FIELD_MAYBE_NULL (result->sp_expire, ISCOLON, 0, 10, (long int),
                            (long int) -1);
        if (*line != '\0')
          INT_FIELD_MAYBE_NULL (result->sp_flag, FALSEP, 0, 10,
                             (unsigned long int), ~0ul)
        else
          result->sp_flag = ~0ul;
       }
   }
 )


/* Read one shadow entry from the given stream.  */
int
__sgetspent_r (const char *string, struct spwd *resbuf, char *buffer,
              size_t buflen, struct spwd **result)
{
  int parse_result = parse_line (strncpy (buffer, string, buflen),
                             resbuf, NULL, 0, &errno);
  *result = parse_result > 0 ? resbuf : NULL;

  return *result == NULL ? errno : 0;
}