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 <mach/error.h>
#include <errorlib.h>
#include <sys/param.h>
#include <stdio-common/_itoa.h>
#include <locale.h>

Go to the source code of this file.


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


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

Define Documentation

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

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

Function Documentation

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

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

  int system;
  int sub;
  int code;
  const struct error_system *es;
  extern void __mach_error_map_compat (int *);
  const char *estr;

  __mach_error_map_compat (&errnum);

  system = err_get_system (errnum);
  sub = err_get_sub (errnum);
  code = err_get_code (errnum);

  if (system > err_max_system || ! __mach_error_systems[system].bad_sub)
      __set_errno (EINVAL);
      return -1;

  es = &__mach_error_systems[system];

  if (sub >= es->max_sub)
    estr = (const char *) es->bad_sub;
  else if (code >= es->subsystem[sub].max_code)
      __set_errno (EINVAL);
      return -1;
    estr = (const char *) _(es->subsystem[sub].codes[code]);

  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: