chiark / gitweb /
tree-wide: remove Lennart's copyright lines
[elogind.git] / src / basic / errno-list.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include <errno.h>
4 #include <string.h>
5
6 #include "errno-list.h"
7 #include "macro.h"
8
9 static const struct errno_name* lookup_errno(register const char *str,
10                                              register GPERF_LEN_TYPE len);
11
12 #include "errno-from-name.h"
13 #include "errno-to-name.h"
14
15 const char *errno_to_name(int id) {
16
17         if (id < 0)
18                 id = -id;
19
20         if (id >= (int) ELEMENTSOF(errno_names))
21                 return NULL;
22
23         return errno_names[id];
24 }
25
26 int errno_from_name(const char *name) {
27         const struct errno_name *sc;
28
29         assert(name);
30
31         sc = lookup_errno(name, strlen(name));
32         if (!sc)
33                 return -EINVAL;
34
35         assert(sc->id > 0);
36         return sc->id;
37 }
38 #if 0 /// UNNEEDED by elogind
39 #endif // 0