/[svn]/ircd-hybrid-7.2/libltdl/lt_error.c
ViewVC logotype

Contents of /ircd-hybrid-7.2/libltdl/lt_error.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 945 - (show annotations)
Mon Jul 20 15:48:27 2009 UTC (10 years, 1 month ago) by michael
File MIME type: text/x-chdr
File size: 2961 byte(s)
- fixed some configure mess and imported latest libtool sources

1 /* lt_error.c -- error propogation interface
2
3 Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007 Free Software Foundation, Inc.
4 Written by Thomas Tanner, 1999
5
6 NOTE: The canonical source of this file is maintained with the
7 GNU Libtool package. Report bugs to bug-libtool@gnu.org.
8
9 GNU Libltdl is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
13
14 As a special exception to the GNU Lesser General Public License,
15 if you distribute this file as part of a program or library that
16 is built using GNU Libtool, you may include this file under the
17 same distribution terms that you use for the rest of that program.
18
19 GNU Libltdl is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU Lesser General Public License for more details.
23
24 You should have received a copy of the GNU Lesser General Public
25 License along with GNU Libltdl; see the file COPYING.LIB. If not, a
26 copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
27 or obtained by writing to the Free Software Foundation, Inc.,
28 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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 /* Ack! Error setting the error message! */
74 LT__SETERROR (INVALID_ERRORCODE);
75 ++errors;
76 }
77 else if (errindex < LT_ERROR_MAX)
78 {
79 /* No error setting the error message! */
80 LT__SETERRORSTR (error_strings[errindex]);
81 }
82 else
83 {
84 /* No error setting the error message! */
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 }

Properties

Name Value
svn:eol-style native

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26