This source file includes following definitions.
- tep_strerror
1
2 #undef _GNU_SOURCE
3 #include <string.h>
4 #include <stdio.h>
5
6 #include "event-parse.h"
7
8 #undef _PE
9 #define _PE(code, str) str
10 static const char * const tep_error_str[] = {
11 TEP_ERRORS
12 };
13 #undef _PE
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 int tep_strerror(struct tep_handle *tep __maybe_unused,
30 enum tep_errno errnum, char *buf, size_t buflen)
31 {
32 const char *msg;
33 int idx;
34
35 if (!buflen)
36 return 0;
37
38 if (errnum >= 0) {
39 int err = strerror_r(errnum, buf, buflen);
40 buf[buflen - 1] = 0;
41 return err;
42 }
43
44 if (errnum <= __TEP_ERRNO__START ||
45 errnum >= __TEP_ERRNO__END)
46 return -1;
47
48 idx = errnum - __TEP_ERRNO__START - 1;
49 msg = tep_error_str[idx];
50 snprintf(buf, buflen, "%s", msg);
51
52 return 0;
53 }