Commit | Line | Data |
---|---|---|
cf310881 FF |
1 | #include <stdarg.h> |
2 | #include <stdio.h> | |
3 | #include <stdlib.h> | |
4 | ||
5 | /* program_invocation_short_name GNU extension - http://linux.die.net/man/3/program_invocation_short_name */ | |
6 | extern char* __progname; | |
7 | #define program_invocation_short_name __progname | |
8 | ||
9 | /* error(3) GNU extension - http://man7.org/linux/man-pages/man3/error.3.html */ | |
10 | unsigned int error_message_count; | |
11 | static inline void error(int status, int errnum, const char* format, ...) { | |
12 | error_message_count++; | |
13 | va_list myargs; | |
14 | va_start(myargs, format); | |
15 | vfprintf(stderr, format, myargs); | |
16 | va_end(myargs); | |
17 | exit(status); | |
18 | } | |
19 | ||
20 | /* strchrnul(3) GNU extension - http://man7.org/linux/man-pages/man3/strchr.3.html */ | |
21 | static inline char* strchrnul(char const* s, int c) | |
22 | { | |
23 | char* result = strchr(s, c); | |
24 | return (result == NULL) ? (char*)(s + strlen(s)) : result; | |
25 | } |