build: remove elf_core.c from source dependencies
[mit.git] / logging.h
blobc01187b053b91d0af9720f843c0d98d5a232b4a8
1 #ifndef MODINITTOOLS_LOGGING_H
2 #define MODINITTOOLS_LOGGING_H
4 /* Do we use syslog for messages or stderr? */
5 extern int logging;
7 /* Do we want to silently drop all warnings? */
8 extern int quiet;
10 /* Do we want informative messages as well as errors? */
11 extern int verbose;
13 extern void fatal(const char *fmt, ...);
14 extern void error(const char *fmt, ...);
15 extern void warn(const char *fmt, ...);
16 extern void info(const char *fmt, ...);
18 typedef void (*errfn_t)(const char *fmt, ...);
20 static inline void grammar(const char *cmd,
21 const char *filename, unsigned int line)
23 warn("%s line %u: ignoring bad line starting with '%s'\n",
24 filename, line, cmd);
27 #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__, #ptr)
29 #define nofail_asprintf(ptr, ...) \
30 do { if (asprintf((ptr), __VA_ARGS__) < 0) \
31 do_nofail(NULL, __FILE__, __LINE__, #ptr); \
32 } while(0)
34 static inline void *do_nofail(void *ptr, const char *file, int line, const char *expr)
36 if (!ptr) {
37 fatal("Memory allocation failure %s line %d: %s.\n",
38 file, line, expr);
40 return ptr;
43 #endif /* MODINITTOOLS_LOGGING_H */