This source file includes following definitions.
- lt_dladderror
- lt_dlseterror
- lt__error_string
- lt__get_last_error
- lt__set_last_error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #include "lt__private.h"
33 #include "lt_error.h"
34
35 static const char *last_error = 0;
36 static const char error_strings[LT_ERROR_MAX][LT_ERROR_LEN_MAX + 1] =
37 {
38 #define LT_ERROR(name, diagnostic) diagnostic,
39 lt_dlerror_table
40 #undef LT_ERROR
41 };
42
43 static const char **user_error_strings = 0;
44 static int errorcount = LT_ERROR_MAX;
45
46 int
47 lt_dladderror (const char *diagnostic)
48 {
49 int errindex = 0;
50 int result = -1;
51 const char **temp = (const char **) 0;
52
53 assert (diagnostic);
54
55 errindex = errorcount - LT_ERROR_MAX;
56 temp = REALLOC (const char *, user_error_strings, 1 + errindex);
57 if (temp)
58 {
59 user_error_strings = temp;
60 user_error_strings[errindex] = diagnostic;
61 result = errorcount++;
62 }
63
64 return result;
65 }
66
67 int
68 lt_dlseterror (int errindex)
69 {
70 int errors = 0;
71
72 if (errindex >= errorcount || errindex < 0)
73 {
74
75 LT__SETERROR (INVALID_ERRORCODE);
76 ++errors;
77 }
78 else if (errindex < LT_ERROR_MAX)
79 {
80
81 LT__SETERRORSTR (error_strings[errindex]);
82 }
83 else
84 {
85
86 LT__SETERRORSTR (user_error_strings[errindex - LT_ERROR_MAX]);
87 }
88
89 return errors;
90 }
91
92 const char *
93 lt__error_string (int errorcode)
94 {
95 assert (errorcode >= 0);
96 assert (errorcode < LT_ERROR_MAX);
97
98 return error_strings[errorcode];
99 }
100
101 const char *
102 lt__get_last_error (void)
103 {
104 return last_error;
105 }
106
107 const char *
108 lt__set_last_error (const char *errormsg)
109 {
110 return last_error = errormsg;
111 }