ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/libltdl/lt_error.c
Revision: 4806
Committed: Thu Oct 30 19:33:19 2014 UTC (11 years, 8 months ago) by michael
Content type: text/x-csrc
File size: 2967 byte(s)
Log Message:
- libtool 2.4.3

File Contents

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

Properties

Name Value
svn:eol-style native