Back to index

glibc  2.9
Classes | Defines | Functions | Variables
files-network.c File Reference
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "files-parse.c"
#include "files-XXX.c"

Go to the source code of this file.

Classes

struct  netent_data

Defines

#define ENTNAME   netent
#define DATABASE   "networks"
#define NEED_H_ERRNO
#define TRAILING_LIST_MEMBER   n_aliases
#define TRAILING_LIST_SEPARATOR_P   isspace

Functions

 LINE_PARSER ("#")

Variables

uint32_t net

Class Documentation

struct netent_data

Definition at line 28 of file files-network.c.


Define Documentation

#define DATABASE   "networks"

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

#define ENTNAME   netent

Definition at line 24 of file files-network.c.

#define NEED_H_ERRNO

Definition at line 26 of file files-network.c.

#define TRAILING_LIST_MEMBER   n_aliases

Definition at line 30 of file files-network.c.

Definition at line 31 of file files-network.c.


Function Documentation

LINE_PARSER ( "#"  )

Definition at line 34 of file files-network.c.

 {
   char *addr;
   char *cp;
   int n = 1;

   STRING_FIELD (result->n_name, isspace, 1);

   STRING_FIELD (addr, isspace, 1);
   /* 'inet_network' does not add zeroes at the end if the network number
      does not four byte values.  We add them outselves if necessary.  */
   cp = strchr (addr, '.');
   if (cp != NULL)
     {
       ++n;
       cp = strchr (cp + 1, '.');
       if (cp != NULL)
        {
          ++n;
          cp = strchr (cp + 1, '.');
          if (cp != NULL)
            ++n;
        }
     }
   if (n < 4)
     {
       char *newp = (char *) alloca (strlen (addr) + (4 - n) * 2 + 1);
       cp = stpcpy (newp, addr);
       do
        {
          *cp++ = '.';
          *cp++ = '0';
        }
       while (++n < 4);
       *cp = '\0';
       addr = newp;
     }
   result->n_net = inet_network (addr);
   result->n_addrtype = AF_INET;

 })

#include "files-XXX.c"

DB_LOOKUP (netbyname, ,,
          LOOKUP_NAME_CASE (n_name, n_aliases),
          const char *name)

DB_LOOKUP (netbyaddr, ,,
          {
            if (result->n_addrtype == type && result->n_net == net)
              /* Bingo!  */
              break;
          }, uint32_t net, int type)

Here is the call graph for this function:


Variable Documentation

Definition at line 87 of file files-network.c.