Amaury Denoyelle | 5a6926d | 2021-03-30 17:34:24 +0200 | [diff] [blame^] | 1 | #include <stdarg.h> |
| 2 | #include <stdlib.h> |
| 3 | |
| 4 | #include <haproxy/cfgdiag.h> |
| 5 | #include <haproxy/log.h> |
| 6 | |
| 7 | /* Use this fonction to emit diagnostic. |
| 8 | * This can be used as a shortcut to set value pointed by <ret> to 1 at the |
| 9 | * same time. |
| 10 | */ |
| 11 | static inline void diag_warning(int *ret, char *fmt, ...) |
| 12 | { |
| 13 | va_list argp; |
| 14 | |
| 15 | va_start(argp, fmt); |
| 16 | *ret = 1; |
| 17 | _ha_vdiag_warning(fmt, argp); |
| 18 | va_end(argp); |
| 19 | } |
| 20 | |
| 21 | /* Use this for dynamic allocation in diagnostics. |
| 22 | * In case of allocation failure, this will immediately terminates haproxy. |
| 23 | */ |
| 24 | static inline void *diag_alloc(size_t size) |
| 25 | { |
| 26 | void *out = NULL; |
| 27 | |
| 28 | if (!(out = malloc(size))) { |
| 29 | fprintf(stderr, "out of memory\n"); |
| 30 | exit(1); |
| 31 | } |
| 32 | |
| 33 | return out; |
| 34 | } |
| 35 | |
| 36 | /* Placeholder to execute various diagnostic checks after the configuration file |
| 37 | * has been fully parsed. It will output a warning for each diagnostic found. |
| 38 | * |
| 39 | * Returns 0 if no diagnostic message has been found else 1. |
| 40 | */ |
| 41 | int cfg_run_diagnostics() |
| 42 | { |
| 43 | int ret = 0; |
| 44 | return ret; |
| 45 | } |