chiark / gitweb /
Initial revision
[ssr] / StraySrc / SDLS / cdll / h / error
1 /*
2  * error.h
3  *
4  * Error messages and handling
5  *
6  * © 1994-1998 Straylight
7  */
8
9 /*----- Licensing note ----------------------------------------------------*
10  *
11  * This file is part of Straylight's Dynamic Linking System (SDLS)
12  *
13  * SDLS is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2, or (at your option)
16  * any later version.
17  *
18  * SDLS is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with SDLS.  If not, write to the Free Software Foundation,
25  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27
28 #ifndef __error_h
29 #define __error_h
30
31 typedef enum
32 {
33   error_INFO,
34   error_WARN,
35   error_ERROR,
36   error_SEVERE,
37   error_FATAL
38 }
39 error_sev;
40
41 /*----- A word to the wise ------------------------------------------------*
42  *
43  * There's some clever preprocessor jiggery-pokery going on here, which
44  * does all the tedious matching up of error names to numbers and severities
45  * and things.  Quite neat, really.
46  *
47  * To actually make the array of error strings *defined*, you should
48  * predefine the macro error__MAKETABLE.
49  */
50
51 #ifdef error__MAKETABLE
52
53   #define __entry(sev,name,msg) sev , msg "\n" ,
54
55   static const struct
56   {
57     error_sev sev;
58     char *msg;
59   }
60   error__table[]={
61
62 #else
63
64   #define __entry(sev,name,msg) name ,
65
66   enum
67   {
68
69 #endif
70
71 /* --- End of preprocessor trickery --- */
72
73   __entry(error_FATAL,  NOMEM,          "Out of memory")
74
75   __entry(error_ERROR,  BADFILE,        "'%s' is not a valid object file "
76                                         "or library -- ignored")
77
78   __entry(error_SEVERE, BADNAME,        "Symbol '%s' not found in specified "
79                                         "object files")
80
81   __entry(error_WARN,   NOSYMS,         "No symbols specified -- reading "
82                                         "from object files")
83   __entry(error_ERROR,  DUPSYM,         "Duplicate symbol '%s' found -- "
84                                         "ignoring")
85
86   __entry(error_WARN,   BADTAG,         "Unknown option tag '%s'")
87   __entry(error_ERROR,  DUPOPT,         "Option '%s' already specified -- "
88                                         "duplicate ignored")
89   __entry(error_WARN,   SILLYOPT,       "Unexpected option '%s' ignored")
90   __entry(error_ERROR,  SORBNOBJ,       "You can't specify -o and -s or -b")
91   __entry(error_ERROR,  APPNOEXT,       "You can't specify -e and -app")
92   __entry(error_ERROR,  NODEF,          "No definition file specified")
93   __entry(error_ERROR,  NOSTUB,         "No stublib file specified")
94   __entry(error_ERROR,  NOBIND,         "No DLL header file specified")
95   __entry(error_INFO,   BADCMDLINE,     "Exiting due to errors in command "
96                                         "line")
97
98   __entry(error_WARN,   LOSTSYM,        "Symbol '%s' not found in specified "
99                                         "object files")
100
101   __entry(error_SEVERE, NOOPENOUT,      "Couldn't open file '%s' for "
102                                         "writing")
103   __entry(error_ERROR,  NOOPENIN,       "Couldn't open file '%s' for "
104                                         "reading")
105
106   __entry(error_ERROR,  JUNKNOITEM,     "Expected section name, found '%s'")
107   __entry(error_ERROR,  JUNKNOBRA,      "Expected '{', found '%s'")
108   __entry(error_ERROR,  BADITEM,        "Invalid item name '%s'")
109   __entry(error_ERROR,  JUNKNOKET,      "Expected name or '}', found '%s'")
110   __entry(error_ERROR,  JUNKNOVER,      "Expected version, found '%s'")
111   __entry(error_ERROR,  JUNKNONAME,     "Expected DLL name, found '%s'")
112   __entry(error_ERROR,  JUNKNOCRIGHT,   "Expected copyright string, found "
113                                         "'%s'")
114   __entry(error_ERROR,  BADVER,         "Bad version number '%s'")
115   __entry(error_ERROR,  QBFEOF,         "Missing %c before <EOF>, inserted")
116   __entry(error_ERROR,  QBFNL,          "Missing %c before <newline>, "
117                                         "inserted")
118
119   __entry(error_WARN,   NOVERSION,      "No version number specified, "
120                                         "assuming version 1.00")
121   __entry(error_SEVERE, NONAME,         "No DLL name specified")
122   __entry(error_WARN,   NOCRIGHT,       "No copyright string specified")
123
124   __entry(error_WARN,   EASY,           "Nothing to do!")
125
126 /* --- Terminate entries --- */
127
128 #ifdef error__MAKETABLE
129
130   };
131
132 #else
133
134     __dummy
135   };
136
137 #endif
138
139 #undef __entry
140
141 /* --- Functions --- */
142
143 void error_setProgName(char *name);
144 char *error_progname(void);
145 void error(int message,...);
146 void error_show(void);
147 int error_returnCode(void);
148
149 #endif