Back to index

glibc  2.9
Defines | Functions
xpg-strerror.c File Reference
#include <errno.h>
#include <libintl.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include <stdio-common/_itoa.h>
#include <locale.h>

Go to the source code of this file.

Defines

#define dgettext(domainname, msgid)   dcgettext (domainname, msgid, LC_MESSAGES)

Functions

int __xpg_strerror_r (int errnum, char *buf, size_t buflen)

Define Documentation

#define dgettext (   domainname,
  msgid 
)    dcgettext (domainname, msgid, LC_MESSAGES)

Definition at line 33 of file xpg-strerror.c.


Function Documentation

int __xpg_strerror_r ( int  errnum,
char *  buf,
size_t  buflen 
)

Definition at line 38 of file xpg-strerror.c.

{
  if (errnum < 0 || errnum >= _sys_nerr_internal
      || _sys_errlist_internal[errnum] == NULL)
    {
      __set_errno (EINVAL);
      return -1;
    }
  const char *estr = (const char *) _(_sys_errlist_internal[errnum]);
  size_t estrlen = strlen (estr) + 1;

  if (buflen < estrlen)
    {
      __set_errno (ERANGE);
      return -1;
    }

  memcpy (buf, estr, estrlen);
  return 0;
}

Here is the call graph for this function: