Back to index

glibc  2.9
Defines | Functions | Variables
nss-default.c File Reference
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
#include <bits/libc-lock.h>
#include <libnsl.h>

Go to the source code of this file.

Defines

#define STRNLEN(s)   s, sizeof (s) - 1
#define nvars   (sizeof (vars) / sizeof (vars[0]))

Functions

 __libc_once_define (static, once)
static void init (void)
int _nsl_default_nss (void)

Variables

static const char default_nss [] = "/etc/default/nss"
static int default_nss_flags
struct {
char name [23]
unsigned int len
int flag
vars []

Define Documentation

#define nvars   (sizeof (vars) / sizeof (vars[0]))

Definition at line 52 of file nss-default.c.

#define STRNLEN (   s)    s, sizeof (s) - 1

Function Documentation

__libc_once_define ( static  ,
once   
)
int _nsl_default_nss ( void  )

Definition at line 121 of file nss-default.c.

{
  /* If we have not yet read the file yet do it now.  */
  __libc_once (once, init);

  return default_nss_flags;
}

Here is the caller graph for this function:

static void init ( void  ) [static]

Definition at line 56 of file nss-default.c.

{
  int saved_errno = errno;
  FILE *fp = fopen (default_nss, "rc");
  if (fp != NULL)
    {
      char *line = NULL;
      size_t linelen = 0;

      __fsetlocking (fp, FSETLOCKING_BYCALLER);

      while (!feof_unlocked (fp))
       {
         ssize_t n = getline (&line, &linelen, fp);
         if (n <= 0)
           break;

         /* Recognize only

              <THE-VARIABLE> = TRUE

            with arbitrary white spaces.  */
         char *cp = line;
         while (isspace (*cp))
           ++cp;

         /* Recognize comment lines.  */
         if (*cp == '#')
           continue;

         int idx;
         for (idx = 0; idx < nvars; ++idx)
           if (strncmp (cp, vars[idx].name, vars[idx].len) == 0)
             break;
         if (idx == nvars)
           continue;

         cp += vars[idx].len;
         while (isspace (*cp))
           ++cp;
         if (*cp++ != '=')
           continue;
         while (isspace (*cp))
           ++cp;

         if (strncmp (cp, "TRUE", 4) != 0)
           continue;
         cp += 4;

         while (isspace (*cp))
           ++cp;

         if (*cp == '\0')
           default_nss_flags |= vars[idx].flag;
       }

      free (line);

      fclose (fp);
    }
  __set_errno (saved_errno);
}

Here is the call graph for this function:


Variable Documentation

const char default_nss[] = "/etc/default/nss" [static]

Definition at line 31 of file nss-default.c.

Definition at line 34 of file nss-default.c.

struct { ... } vars[] [static]