netsniff-ng: also support stdin/stdout for -i/-o
[netsniff-ng.git] / die.h
blobca9e2276025721a587d0d3ba7f7e3cb299b7bf87
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2009, 2010 Daniel Borkmann.
5 * Subject to the GPL, version 2.
6 */
8 #ifndef DIE_H
9 #define DIE_H
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <stdarg.h>
14 #include <string.h>
15 #include <errno.h>
16 #include <unistd.h>
17 #include <syslog.h>
19 #include "built_in.h"
21 static inline void panic(const char *format, ...) __check_format_printf(1, 2);
22 static inline void syslog_panic(const char *format,
23 ...) __check_format_printf(1, 2);
24 static inline void syslog_maybe(int may, int priority,
25 const char *format, ...) __check_format_printf(3, 4);
27 static inline void die(void)
29 exit(EXIT_FAILURE);
32 static inline void _die(void)
34 _exit(EXIT_FAILURE);
37 static inline void panic(const char *format, ...)
39 va_list vl;
41 va_start(vl, format);
42 vfprintf(stderr, format, vl);
43 va_end(vl);
45 die();
48 static inline void syslog_panic(const char *format, ...)
50 va_list vl;
52 va_start(vl, format);
53 vsyslog(LOG_ERR, format, vl);
54 va_end(vl);
56 die();
59 static inline void syslog_maybe(int maybe, int priority, const char *format, ...)
61 if (!!maybe) {
62 va_list vl;
64 va_start(vl, format);
65 vsyslog(priority, format, vl);
66 va_end(vl);
70 #endif /* DIE_H */