-
Notifications
You must be signed in to change notification settings - Fork 0
/
die.c
48 lines (38 loc) · 806 Bytes
/
die.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
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "die.h"
void die(const char *fmt, ...)
{
va_list ap;
if( fmt != NULL ) {
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
printf("\n");
}
exit(EXIT_FAILURE);
}
void die_status(int status, const char *fmt, ...)
{
va_list ap;
if( fmt != NULL ) {
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
printf("\n");
}
exit(status);
}
void die_full(const char *file, long line, const char *func, int status, const char *fmt, ...)
{
va_list ap;
if( fmt != NULL ) {
printf("%s:%ld:%s: ", file, line, func);
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
printf("\n");
}
exit(status);
}