Back to index

glibc  2.9
Functions
nis_domain_of_r.c File Reference
#include <errno.h>
#include <string.h>
#include <rpcsvc/nis.h>

Go to the source code of this file.

Functions

nis_name nis_domain_of_r (const_nis_name name, char *buffer, size_t buflen)

Function Documentation

nis_name nis_domain_of_r ( const_nis_name  name,
char *  buffer,
size_t  buflen 
)

Definition at line 25 of file nis_domain_of_r.c.

{
  char *cptr;
  size_t cptr_len;

  if (buffer == NULL)
    {
    erange:
      __set_errno (ERANGE);
      return NULL;
    }

  buffer[0] = '\0';

  cptr = strchr (name, '.');

  if (cptr == NULL)
    return buffer;

  ++cptr;
  cptr_len = strlen (cptr);

  if (cptr_len == 0)
    {
      if (buflen < 2)
       goto erange;
      return strcpy (buffer, ".");
    }

  if (__builtin_expect (cptr_len >= buflen, 0))
    {
      __set_errno (ERANGE);
      return NULL;
    }

  return memcpy (buffer, cptr, cptr_len + 1);
}

Here is the call graph for this function:

Here is the caller graph for this function: