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 #include "lt__private.h"
32 #include "lt_error.h"
33
34 static const char *last_error = 0;
35 static const char error_strings[LT_ERROR_MAX][LT_ERROR_LEN_MAX + 1] =
36 {
37 #define LT_ERROR(name, diagnostic) diagnostic,
38 lt_dlerror_table
39 #undef LT_ERROR
40 };
41
42 static const char **user_error_strings = 0;
43 static int errorcount = LT_ERROR_MAX;
44
45 int
46 lt_dladderror (const char *diagnostic)
47 {
48 int errindex = 0;
49 int result = -1;
50 const char **temp = (const char **) 0;
51
52 assert (diagnostic);
53
54 errindex = errorcount - LT_ERROR_MAX;
55 temp = REALLOC (const char *, user_error_strings, 1 + errindex);
56 if (temp)
57 {
58 user_error_strings = temp;
59 user_error_strings[errindex] = diagnostic;
60 result = errorcount++;
61 }
62
63 return result;
64 }
65
66 int
67 lt_dlseterror (int errindex)
68 {
69 int errors = 0;
70
71 if (errindex >= errorcount || errindex < 0)
72 {
73
74 LT__SETERROR (INVALID_ERRORCODE);
75 ++errors;
76 }
77 else if (errindex < LT_ERROR_MAX)
78 {
79
80 LT__SETERRORSTR (error_strings[errindex]);
81 }
82 else
83 {
84
85 LT__SETERRORSTR (user_error_strings[errindex - LT_ERROR_MAX]);
86 }
87
88 return errors;
89 }
90
91 const char *
92 lt__error_string (int errorcode)
93 {
94 assert (errorcode >= 0);
95 assert (errorcode < LT_ERROR_MAX);
96
97 return error_strings[errorcode];
98 }
99
100 const char *
101 lt__get_last_error (void)
102 {
103 return last_error;
104 }
105
106 const char *
107 lt__set_last_error (const char *errormsg)
108 {
109 return last_error = errormsg;
110 }