This source file includes following definitions.
- errno_to_name
- errno_from_name
- errno_max
#include <errno.h>
#include <string.h>
#include "util.h"
#include "errno-list.h"
static const struct errno_name* lookup_errno(register const char *str,
register unsigned int len);
#include "errno-to-name.h"
#include "errno-from-name.h"
const char *errno_to_name(int id) {
if (id < 0)
id = -id;
if (id >= (int) ELEMENTSOF(errno_names))
return NULL;
return errno_names[id];
}
int errno_from_name(const char *name) {
const struct errno_name *sc;
assert(name);
sc = lookup_errno(name, strlen(name));
if (!sc)
return 0;
return sc->id;
}
int errno_max(void) {
return ELEMENTSOF(errno_names);
}