-
Notifications
You must be signed in to change notification settings - Fork 4
/
messages.c
53 lines (45 loc) · 893 Bytes
/
messages.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
#include <stdio.h>
#include <stdarg.h>
#include "messages.h"
__attribute__ ((format (printf, 1, 2)))
void error(const char *fmt, ...)
{
va_list args;
fputs("ERROR: ", stderr);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fputc('\n', stderr);
}
__attribute__ ((format (printf, 1, 2)))
void warning(const char *fmt, ...)
{
va_list args;
fputs("WARNING: ", stderr);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fputc('\n', stderr);
}
__attribute__ ((format (printf, 1, 2)))
void info(const char *fmt, ...)
{
va_list args;
fputs("INFO: ", stdout);
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
putchar('\n');
}
__attribute__ ((format (printf, 1, 2)))
void debug(const char *fmt, ...)
{
#ifdef DEBUG
va_list args;
fputs("DEBUG: ", stdout);
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
putchar('\n');
#endif
}