-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy patherr.c
54 lines (40 loc) · 861 Bytes
/
err.c
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
54
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "err.h"
void my_err(const char *format, ...) {
int i;
va_list args;
va_start(args, format);
fprintf(stderr, "ERROR: ");
vfprintf(stderr, format, args);
i = strlen(format);
if(i < 1 || format[i-1] != '\n') {
/* add new line */
fprintf(stderr, "\n");
}
va_end(args);
exit(2);
}
void my_warn(const char *format, ...) {
int i;
va_list args;
va_start(args, format);
fprintf(stderr, "WARNING: ");
vfprintf(stderr, format, args);
i = strlen(format);
if(i < 1 || format[i-1] != '\n') {
/* add new line */
fprintf(stderr, "\n");
}
va_end(args);
}
void my_verbose(const char *format, ...) {
#ifdef VERBOSE
va_list args;
va_start(args, format);
vafprintf(stderr, format, args)
va_end(args);
#endif
}