build: announcement: also add v prefix to checkout command
[netsniff-ng.git] / die.h
blob919f3aea122f3ad937ce01e78875d350d88e16f9
1 #ifndef DIE_H
2 #define DIE_H
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <stdarg.h>
7 #include <stdbool.h>
8 #include <string.h>
9 #include <errno.h>
10 #include <unistd.h>
11 #include <syslog.h>
13 #include "built_in.h"
15 static inline void panic(const char *format, ...) __check_format_printf(1, 2);
16 static inline void syslog_panic(const char *format,
17 ...) __check_format_printf(1, 2);
18 static inline void syslog_maybe(bool cond, int priority,
19 const char *format, ...) __check_format_printf(3, 4);
21 static inline void __noreturn __die_hard(void)
23 exit(EXIT_FAILURE);
26 static inline void __noreturn __die_harder(void)
28 _exit(EXIT_FAILURE);
31 static inline void __noreturn die(void)
33 __die_hard();
36 static inline void __noreturn _die(void)
38 __die_harder();
41 static inline void __noreturn panic(const char *format, ...)
43 va_list vl;
45 va_start(vl, format);
46 vfprintf(stderr, format, vl);
47 va_end(vl);
49 die();
52 static inline void __noreturn syslog_panic(const char *format, ...)
54 va_list vl;
56 va_start(vl, format);
57 vsyslog(LOG_ERR, format, vl);
58 va_end(vl);
60 die();
63 static inline void syslog_maybe(bool cond, int priority,
64 const char *format, ...)
66 if (cond) {
67 va_list vl;
69 va_start(vl, format);
70 vsyslog(priority, format, vl);
71 va_end(vl);
75 #endif /* DIE_H */