-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherr.cpp
52 lines (39 loc) · 905 Bytes
/
err.cpp
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
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "err.h"
void syserr(const char* fmt, ...)
{
va_list fmt_args;
int org_errno = errno;
fprintf(stderr, "\tERROR: ");
va_start(fmt_args, fmt);
vfprintf(stderr, fmt, fmt_args);
va_end(fmt_args);
fprintf(stderr, " (%d; %s)\n", org_errno, strerror(org_errno));
fflush(stderr);
exit(1);
}
void fatal(const char* fmt, ...)
{
va_list fmt_args;
fprintf(stderr, "\tERROR: ");
va_start(fmt_args, fmt);
vfprintf(stderr, fmt, fmt_args);
va_end(fmt_args);
fprintf(stderr, "\n");
fflush(stderr);
exit(1);
}
void err(const char* fmt, ...)
{
va_list fmt_args;
fprintf(stderr, "\tERROR: ");
va_start(fmt_args, fmt);
vfprintf(stderr, fmt, fmt_args);
va_end(fmt_args);
fprintf(stderr, "\n");
fflush(stderr);
}