ReactOS 0.4.16-dev-297-gc569aee
checkerr.c File Reference
#include <schily/mconfig.h>
#include <schily/stdio.h>
#include <schily/standard.h>
#include <schily/patmatch.h>
#include <schily/string.h>
#include <schily/utypes.h>
#include <schily/schily.h>
#include <schily/checkerr.h>
Include dependency graph for checkerr.c:

Go to the source code of this file.

Classes

struct  errconf
 
struct  eflags
 

Typedefs

typedef struct errconf ec_t
 

Functions

EXPORT int errconfig __PR ((char *name))
 
LOCAL char *_endword __PR ((char *p))
 
LOCAL void parse_errctl __PR ((char *line))
 
LOCAL UInt32_t errflags __PR ((char *eflag, BOOL doexit))
 
LOCAL ec_t *_errptr __PR ((int etype, const char *fname))
 
EXPORT BOOL errabort __PR ((int etype, const char *fname, BOOL doexit))
 
EXPORT int errconfig (char *name)
 
LOCAL char_endword (char *p)
 
LOCAL void parse_errctl (char *line)
 
LOCAL UInt32_t errflags (char *eflag, BOOL doexit)
 
LOCAL ec_t_errptr (int etype, const char *fname)
 
EXPORT BOOL errhidden (int etype, const char *fname)
 
EXPORT BOOL errwarnonly (int etype, const char *fname)
 
EXPORT BOOL errabort (int etype, const char *fname, BOOL doexit)
 

Variables

static UConst char sccsid []
 
LOCAL intec_state
 
LOCAL ec_tec_root
 
LOCAL ec_t ** ec_last = &ec_root
 
LOCAL int maxplen
 
LOCAL BOOL _errflag = TRUE
 
LOCAL struct eflags eflags []
 

Typedef Documentation

◆ ec_t

typedef struct errconf ec_t

Function Documentation

◆ __PR() [1/6]

LOCAL UInt32_t errflags __PR ( (char *eflag, BOOL doexit)  )

◆ __PR() [2/6]

LOCAL void parse_errctl __PR ( (char *line )

◆ __PR() [3/6]

EXPORT int errconfig __PR ( (char *name )

◆ __PR() [4/6]

LOCAL char *_endword __PR ( (char *p )

◆ __PR() [5/6]

LOCAL ec_t *_errptr __PR ( (int etype, const char *fname)  )

◆ __PR() [6/6]

EXPORT BOOL errabort __PR ( (int etype, const char *fname, BOOL doexit)  )

◆ _endword()

LOCAL char * _endword ( char p)

Definition at line 93 of file checkerr.c.

95{
96 /*
97 * Find end of word.
98 */
99 for (; *p != '\0' &&
100 *p != '\t' &&
101 *p != ' ';
102 p++) {
103 ;
104 /* LINTED */
105 }
106 return (p);
107}
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by errflags(), and parse_errctl().

◆ _errptr()

LOCAL ec_t * _errptr ( int  etype,
const char fname 
)

Definition at line 229 of file checkerr.c.

232{
233 ec_t *ep = ec_root;
234 char *ret;
235 const Uchar *name = (const Uchar *)fname;
236 int nlen;
237
238 if (fname == NULL) {
240 "Implementation botch for errhidden(0x%X, NULL)\n",
241 etype);
242 errmsgno(EX_BAD, "Please report this bug!\n");
243 errmsgno(EX_BAD, "Error cannot be ignored.\n");
244 return ((ec_t *)NULL);
245 }
246 nlen = strlen(fname);
247 while (ep) {
248 if ((ep->ec_flags & etype) != 0) {
249 ret = (char *)patmatch(ep->ec_pat, ep->ec_aux,
250 name, 0,
251 nlen, ep->ec_alt, ec_state);
252 if (ret != NULL && *ret == '\0')
253 return (ep);
254 }
255 ep = ep->ec_next;
256 }
257 return ((ec_t *)NULL);
258}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LOCAL int * ec_state
Definition: checkerr.c:48
LOCAL ec_t * ec_root
Definition: checkerr.c:49
EXPORT int errmsgno(int err, char *msg, va_alist)
Definition: comerr.c:219
#define NULL
Definition: types.h:112
EXPORT CHAR * patmatch(PCHAR *pat, const int *aux, const CHAR *str, int soff, int slen, int alt, state) const
Definition: match.c:230
#define EX_BAD
Definition: standard.h:62
UInt32_t ec_flags
Definition: checkerr.c:45
const Uchar * ec_pat
Definition: checkerr.c:41
struct errconf * ec_next
Definition: checkerr.c:40
int * ec_aux
Definition: checkerr.c:42
int ec_alt
Definition: checkerr.c:43
Definition: name.c:39
unsigned char Uchar
Definition: utypes.h:45
int ret

Referenced by errabort(), errhidden(), and errwarnonly().

◆ errabort()

EXPORT BOOL errabort ( int  etype,
const char fname,
BOOL  doexit 
)

Definition at line 300 of file checkerr.c.

304{
305 ec_t *ep;
306
307 if ((ep = _errptr(etype, fname)) == NULL) {
308 if (!_errflag)
309 return (FALSE);
310 } else if ((ep->ec_flags & E_ABORT) == 0)
311 return (FALSE);
312
313 if (doexit) {
314 errmsgno(EX_BAD, "Error is considered fatal, aborting.\n");
315#ifdef CALL_OTHER_FUNCTION
316 if (other_func != NULL)
317 (*other_func)();
318 else
319#endif
320 comexit(-3);
321 }
322 return (TRUE);
323}
LOCAL BOOL _errflag
Definition: checkerr.c:52
LOCAL ec_t * _errptr(int etype, const char *fname)
Definition: checkerr.c:229
EXPORT void comexit(int err)
Definition: comerr.c:331
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define E_ABORT
Definition: winerror.h:2366

Referenced by write_one_file().

◆ errconfig()

EXPORT int errconfig ( char name)

Definition at line 67 of file checkerr.c.

69{
70 char line[8192];
71 FILE *f;
72 int omaxplen = maxplen;
73
74 if ((f = fileopen(name, "r")) == NULL) {
75 if (errflags(name, FALSE) != 0)
77 else
78 comerr("Cannot open '%s'.\n", name);
79 } else {
80 while (fgetline(f, line, sizeof (line)) >= 0) {
82 }
83 fclose(f);
84 }
85 if (maxplen > omaxplen) {
86 ec_state = ___realloc(ec_state, (maxplen+1)*sizeof (int),
87 "pattern state");
88 }
89 return (1);
90}
LOCAL int maxplen
Definition: checkerr.c:51
LOCAL UInt32_t errflags(char *eflag, BOOL doexit)
Definition: checkerr.c:192
LOCAL void parse_errctl(char *line)
Definition: checkerr.c:110
EXPORT void comerr(char *msg, va_alist)
Definition: comerr.c:84
EXPORT FILE * fileopen(char *name, const char *mode) const
Definition: fileopen.c:20
GLfloat f
Definition: glext.h:7540
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define f
Definition: ke_i.h:83
#define ___realloc
Definition: schily.h:631
#define fgetline
Definition: schily.h:569
Definition: parser.c:49

Referenced by main().

◆ errflags()

LOCAL UInt32_t errflags ( char eflag,
BOOL  doexit 
)

Definition at line 192 of file checkerr.c.

195{
196 register char *p = eflag;
197 char *ef = _endword(eflag);
198 register struct eflags *ep;
199 register int slen;
200 register UInt32_t nflags = 0;
201
202 do {
203 for (ep = eflags; ep->fname; ep++) {
204 slen = strlen(ep->fname);
205 if ((strncmp(ep->fname, p, slen) == 0) &&
206 (p[slen] == '|' || p[slen] == ' ' ||
207 p[slen] == '\0')) {
208 nflags |= ep->fval;
209 break;
210 }
211 }
212 if (ep->fname == NULL) {
213 if (doexit)
214 comerrno(EX_BAD, "Bad flag '%s'\n", p);
215 return (0);
216 }
217 p = strchr(p, '|');
218 } while (p < ef && p && *p++ == '|');
219
220 if ((nflags & ~(UInt32_t)(E_ABORT|E_WARN)) == 0) {
221 if (doexit)
222 comerrno(EX_BAD, "Bad error condition '%s'.\n", eflag);
223 return (0);
224 }
225 return (nflags);
226}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
char * strchr(const char *String, int ch)
Definition: utclib.c:501
LOCAL char * _endword(char *p)
Definition: checkerr.c:93
#define E_WARN
Definition: checkerr.h:79
EXPORT void comerrno(int err, char *msg, va_alist)
Definition: comerr.c:137
char * fname
Definition: checkerr.c:152
UInt32_t fval
Definition: checkerr.c:153

Referenced by errconfig(), and parse_errctl().

◆ errhidden()

EXPORT BOOL errhidden ( int  etype,
const char fname 
)

Definition at line 264 of file checkerr.c.

267{
268 ec_t *ep;
269
270 if ((ep = _errptr(etype, fname)) != NULL) {
271 if ((ep->ec_flags & (E_ABORT|E_WARN)) != 0)
272 return (FALSE);
273 return (TRUE);
274 }
275 return (FALSE);
276}

Referenced by write_one_file().

◆ errwarnonly()

EXPORT BOOL errwarnonly ( int  etype,
const char fname 
)

Definition at line 282 of file checkerr.c.

285{
286 ec_t *ep;
287
288 if ((ep = _errptr(etype, fname)) != NULL) {
289 if ((ep->ec_flags & E_WARN) != 0)
290 return (TRUE);
291 return (FALSE);
292 }
293 return (FALSE);
294}

Referenced by write_one_file().

◆ parse_errctl()

LOCAL void parse_errctl ( char line)

Definition at line 110 of file checkerr.c.

112{
113 int plen;
114 char *pattern;
115 ec_t *ep;
116
117 /*
118 * Find end of word.
119 */
121
122 if (pattern == line || *pattern == '\0') {
124 "Bad error configuration line '%s'.\n", line);
125 }
126 /*
127 * Find end of white space after word.
128 */
129 for (pattern++; *pattern != '\0' &&
130 (*pattern == '\t' || *pattern == ' ');
131 pattern++) {
132 ;
133 /* LINTED */
134 }
135 ep = ___malloc(sizeof (ec_t), "errcheck node");
136 ep->ec_flags = errflags(line, TRUE);
137 ep->ec_plen = plen = strlen(pattern);
138 if (ep->ec_plen > maxplen)
139 maxplen = ep->ec_plen;
140 ep->ec_pat = (const Uchar *)___savestr(pattern);
141 ep->ec_aux = ___malloc(plen*sizeof (int), "compiled pattern");
142 if ((ep->ec_alt = patcompile((const Uchar *)pattern,
143 plen, ep->ec_aux)) == 0)
144 comerrno(EX_BAD, "Bad errctl pattern: '%s'.\n", pattern);
145
146 ep->ec_next = NULL;
147 *ec_last = ep;
148 ec_last = &ep->ec_next;
149}
LOCAL ec_t ** ec_last
Definition: checkerr.c:50
GLubyte * pattern
Definition: glext.h:7787
EXPORT int patcompile(PCHAR *pat, int len, int *aux) const
Definition: match.c:584
#define ___malloc
Definition: schily.h:630
#define ___savestr
Definition: schily.h:632
int ec_plen
Definition: checkerr.c:44

Referenced by errconfig().

Variable Documentation

◆ _errflag

LOCAL BOOL _errflag = TRUE

Definition at line 52 of file checkerr.c.

Referenced by errabort().

◆ ec_last

LOCAL ec_t** ec_last = &ec_root

Definition at line 50 of file checkerr.c.

Referenced by parse_errctl().

◆ ec_root

LOCAL ec_t* ec_root

Definition at line 49 of file checkerr.c.

Referenced by _errptr().

◆ ec_state

LOCAL int* ec_state

Definition at line 48 of file checkerr.c.

Referenced by _errptr(), and errconfig().

◆ eflags

◆ maxplen

LOCAL int maxplen

Definition at line 51 of file checkerr.c.

Referenced by errconfig(), and parse_errctl().

◆ sccsid

UConst char sccsid[]
static
Initial value:
=
"@(#)checkerr.c 1.24 09/07/08 Copyright 2003-2009 J. Schilling"

Definition at line 4 of file checkerr.c.