-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.h
53 lines (45 loc) · 1.01 KB
/
error.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef __ERROR_H__
#define __ERROR_H__
#include <stdio.h>
#include <stdlib.h>
#define ENORI 126
#define ENOEXIST 127
#define INFO (1)
#define FATAL (2)
#define FATAL_RESTART (3)
#define WARNING (4)
#define NOTE (5)
#define CONT (6)
static inline void
errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
{
fprintf(stderr, "%s: ", "kread");
if (fmt != NULL) {
va_list argp;
va_start(argp, fmt);
vfprintf(stderr, fmt, argp);
va_end(argp);
if (adderr)
fprintf(stderr, ": ");
}
if (adderr)
fprintf(stderr, "%m");
fprintf(stderr, "\n");
if (doexit)
exit(excode);
}
#ifndef HAVE_ERR
# define err(E, FMT...) errmsg(1, E, 1, FMT)
#endif
static void error (int line, const char *errmsg)
{
fprintf (stderr, "error: %d: %s\n", line, errmsg);
//++error_count;
}
static void warn (int line, const char *msg)
{
fprintf (stdout, "warn: %d: %s\n", line, msg);
}
#define ERROR(ERRMSG) error (__LINE__, ERRMSG)
#define WARN(MSG) warn (__LINE__, MSG)
#endif