Back to index

glibc  2.9
Classes | Defines | Functions
hesiod-proto.c File Reference
#include <errno.h>
#include <hesiod.h>
#include <netdb.h>
#include <netinet/in.h>
#include <nss.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nss_hesiod.h"
#include <nss/nss_files/files-parse.c>

Go to the source code of this file.

Classes

struct  protoent_data

Defines

#define ENTNAME   protoent
#define TRAILING_LIST_MEMBER   p_aliases
#define TRAILING_LIST_SEPARATOR_P   isspace

Functions

 LINE_PARSER ("#", STRING_FIELD(result->p_name, isspace, 1);INT_FIELD(result->p_proto, isspace, 1, 10,);)
enum nss_status _nss_hesiod_endprotoent (void)
static enum nss_status lookup (const char *name, const char *type, struct protoent *proto, char *buffer, size_t buflen, int *errnop)
enum nss_status _nss_hesiod_getprotobyname_r (const char *name, struct protoent *proto, char *buffer, size_t buflen, int *errnop)
enum nss_status _nss_hesiod_getprotobynumber_r (const int protocol, struct protoent *proto, char *buffer, size_t buflen, int *errnop)

Class Documentation

struct protoent_data

Definition at line 37 of file hesiod-proto.c.


Define Documentation

#define ENTNAME   protoent

Definition at line 35 of file hesiod-proto.c.

#define TRAILING_LIST_MEMBER   p_aliases

Definition at line 39 of file hesiod-proto.c.

Definition at line 40 of file hesiod-proto.c.


Function Documentation

Definition at line 55 of file hesiod-proto.c.

{
  return NSS_STATUS_SUCCESS;
}
enum nss_status _nss_hesiod_getprotobyname_r ( const char *  name,
struct protoent proto,
char *  buffer,
size_t  buflen,
int errnop 
)

Definition at line 131 of file hesiod-proto.c.

{
  return lookup (name, "protocol", proto, buffer, buflen, errnop);
}

Here is the call graph for this function:

enum nss_status _nss_hesiod_getprotobynumber_r ( const int  protocol,
struct protoent proto,
char *  buffer,
size_t  buflen,
int errnop 
)

Definition at line 138 of file hesiod-proto.c.

{
  char protostr[21];

  snprintf (protostr, sizeof protostr, "%d", protocol);

  return lookup (protostr, "protonum", proto, buffer, buflen, errnop);
}

Here is the call graph for this function:

LINE_PARSER ( "#"  ,
STRING_FIELD(result->p_name, isspace, 1);INT_FIELD(result->p_proto, isspace, 1, 10,);   
)

Definition at line 43 of file hesiod-proto.c.

{
  return NSS_STATUS_SUCCESS;
}
static enum nss_status lookup ( const char *  name,
const char *  type,
struct protoent proto,
char *  buffer,
size_t  buflen,
int errnop 
) [static]

Definition at line 61 of file hesiod-proto.c.

{
  struct parser_data *data = (void *) buffer;
  size_t linebuflen;
  void *context;
  char **list, **item;
  int parse_res;
  int found;
  int olderr = errno;

  context = _nss_hesiod_init ();
  if (context == NULL)
    return NSS_STATUS_UNAVAIL;

  list = hesiod_resolve (context, name, type);
  if (list == NULL)
    {
      int err = errno;
      hesiod_end (context);
      __set_errno (olderr);
      return err == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL;
    }

  linebuflen = buffer + buflen - data->linebuffer;

  item = list;
  found = 0;
  do
    {
      size_t len = strlen (*item) + 1;

      if (linebuflen < len)
       {
         hesiod_free_list (context, list);
         hesiod_end (context);
         *errnop = ERANGE;
         return NSS_STATUS_TRYAGAIN;
       }

      memcpy (data->linebuffer, *item, len);

      parse_res = parse_line (buffer, proto, data, buflen, errnop);
      if (parse_res == -1)
       {
         hesiod_free_list (context, list);
         hesiod_end (context);
         return NSS_STATUS_TRYAGAIN;
       }

      if (parse_res > 0)
       found = 1;

      ++item;
    }
  while (*item != NULL && !found);

  hesiod_free_list (context, list);
  hesiod_end (context);

  if (found == 0)
    {
      __set_errno (olderr);
      return NSS_STATUS_NOTFOUND;
    }

  return NSS_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function: