Back to index

glibc  2.9
Defines | Functions
getXXbyYY.c File Reference
#include <assert.h>
#include <errno.h>
#include <bits/libc-lock.h>
#include <stdlib.h>
#include <resolv.h>
#include "nsswitch.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define REENTRANT_NAME   APPEND_R (FUNCTION_NAME)
#define APPEND_R(name)   APPEND_R1 (name)
#define APPEND_R1(name)   name##_r
#define INTERNAL(name)   INTERNAL1 (name)
#define INTERNAL1(name)   __##name
#define H_ERRNO_PARM
#define H_ERRNO_VAR
#define H_ERRNO_VAR_P   NULL
#define AF_VAL   AF_INET

Functions

int INTERNAL() REENTRANT_NAME (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM)
 __libc_lock_define_initialized (static, lock)
 libc_freeres_ptr (static char *buffer)
LOOKUP_TYPEFUNCTION_NAME (ADD_PARAMS)

Define Documentation

#define AF_VAL   AF_INET

Definition at line 72 of file getXXbyYY.c.

#define APPEND_R (   name)    APPEND_R1 (name)

Definition at line 53 of file getXXbyYY.c.

#define APPEND_R1 (   name)    name##_r

Definition at line 54 of file getXXbyYY.c.

#define H_ERRNO_PARM

Definition at line 64 of file getXXbyYY.c.

#define H_ERRNO_VAR

Definition at line 65 of file getXXbyYY.c.

#define H_ERRNO_VAR_P   NULL

Definition at line 66 of file getXXbyYY.c.

#define INTERNAL (   name)    INTERNAL1 (name)

Definition at line 55 of file getXXbyYY.c.

#define INTERNAL1 (   name)    __##name

Definition at line 56 of file getXXbyYY.c.

Definition at line 52 of file getXXbyYY.c.


Function Documentation

__libc_lock_define_initialized ( static  ,
lock   
)

Definition at line 34 of file getnetgrent_r.c.

{
  /* Remember the first service_entry, it's always the same.  */
  static bool startp_initialized;
  static service_user *startp;
  int no_more;

  if (!startp_initialized)
    {
      /* Executing this more than once at the same time must yield the
        same result every time.  So we need no locking.  */
      no_more = __nss_netgroup_lookup (nipp, "setnetgrent", fctp);
      startp = no_more ? (service_user *) -1 : *nipp;
      PTR_MANGLE (startp);
      atomic_write_barrier ();
      startp_initialized = true;
    }
  else
    {
      service_user *nip = startp;
      PTR_DEMANGLE (nip);
      if (nip == (service_user *) -1)
       /* No services at all.  */
       return 1;

      /* Reset to the beginning of the service list.  */
      *nipp = nip;
      /* Look up the first function.  */
      no_more = __nss_lookup (nipp, "setnetgrent", NULL, fctp);
    }
  return no_more;
}

Definition at line 88 of file getXXbyYY.c.

{
  static size_t buffer_size;
  static LOOKUP_TYPE resbuf;
  LOOKUP_TYPE *result;
#ifdef NEED_H_ERRNO
  int h_errno_tmp = 0;
#endif

  /* Get lock.  */
  __libc_lock_lock (lock);

  if (buffer == NULL)
    {
      buffer_size = BUFLEN;
      buffer = (char *) malloc (buffer_size);
    }

#ifdef HANDLE_DIGITS_DOTS
  if (buffer != NULL)
    {
      if (__nss_hostname_digits_dots (name, &resbuf, &buffer,
                                  &buffer_size, 0, &result, NULL, AF_VAL,
                                  H_ERRNO_VAR_P))
       goto done;
    }
#endif

  while (buffer != NULL
        && (INTERNAL (REENTRANT_NAME) (ADD_VARIABLES, &resbuf, buffer,
                                   buffer_size, &result H_ERRNO_VAR)
            == ERANGE)
#ifdef NEED_H_ERRNO
        && h_errno_tmp == NETDB_INTERNAL
#endif
        )
    {
      char *new_buf;
      buffer_size *= 2;
      new_buf = (char *) realloc (buffer, buffer_size);
      if (new_buf == NULL)
       {
         /* We are out of memory.  Free the current buffer so that the
            process gets a chance for a normal termination.  */
         free (buffer);
         __set_errno (ENOMEM);
       }
      buffer = new_buf;
    }

  if (buffer == NULL)
    result = NULL;

#ifdef HANDLE_DIGITS_DOTS
done:
#endif
  /* Release lock.  */
  __libc_lock_unlock (lock);

#ifdef NEED_H_ERRNO
  if (h_errno_tmp != 0)
    __set_h_errno (h_errno_tmp);
#endif

  return result;
}

Here is the call graph for this function:

libc_freeres_ptr ( static char *  buffer)
int INTERNAL() REENTRANT_NAME ( ADD_PARAMS  ,
LOOKUP_TYPE resbuf,
char *  buffer,
size_t  buflen,
LOOKUP_TYPE **result  H_ERRNO_PARM 
)