forked from droundy/fac
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.h
More file actions
41 lines (35 loc) · 1.13 KB
/
errors.h
File metadata and controls
41 lines (35 loc) · 1.13 KB
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
#ifndef ERRORS_H
#define ERRORS_H
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
extern int verbose; /* true if user requests verbose output */
static inline void verbose_printf(const char *format, ...) {
va_list args;
va_start(args, format);
if (verbose) vfprintf(stdout, format, args);
va_end(args);
}
static inline void error_at_line(int retval, int my_errno, const char *fname,
int linenum, const char *format, ...) {
va_list args;
va_start(args, format);
fprintf(stderr, " \rerror: %s:%d: ",
fname, linenum);
vfprintf(stderr, format, args);
if (my_errno) fprintf(stderr, "\n %s\n", strerror(my_errno));
va_end(args);
exit(retval);
}
static inline void error(int retval, int my_errno, const char *format, ...) {
va_list args;
va_start(args, format);
fprintf(stderr, " \rerror: ");
vfprintf(stderr, format, args);
if (my_errno) fprintf(stderr, "\n %s\n", strerror(my_errno));
va_end(args);
exit(retval);
}
#endif