Nagios  4.4.6
Dev docs for Nagios core and neb-module hackers
t-utils.h
1 #ifndef NAGIOS_T_UTILS_H_INCLUDED
2 #define NAGIOS_T_UTILS_H_INCLUDED
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <string.h>
6 #include <stdio.h>
7 #include <stdarg.h>
8 
9 #ifndef ARRAY_SIZE
10 # define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
11 #endif
12 
13 #define TEST_PASS 1
14 #define TEST_FAIL 0
15 
16 #define CLR_RESET "\033[m"
17 #define CLR_BOLD "\033[1m"
18 #define CLR_RED "\033[31m"
19 #define CLR_GREEN "\033[32m"
20 #define CLR_BROWN "\033[33m"
21 #define CLR_YELLOW "\033[33m\033[1m"
22 #define CLR_BLUE "\033[34m"
23 #define CLR_MAGENTA "\033[35m"
24 #define CLR_CYAN "\033[36m"
25 #define CLR_BG_RED "\033[41m"
26 #define CLR_BRIGHT_RED "\033[31m\033[1m"
27 #define CLR_BRIGHT_GREEN "\033[32m\033[1m"
28 #define CLR_BRIGHT_BLUE "\033[34m\033[1m"
29 #define CLR_BRIGHT_MAGENTA "\033[35m\033[1m"
30 #define CLR_BRIGHT_CYAN "\033[36m\033[1m"
31 
32 extern const char *red, *green, *yellow, *cyan, *reset;
33 extern unsigned int passed, failed, t_verbose;
34 
35 #define CHECKPOINT() \
36  do { \
37  fprintf(stderr, "ALIVE @ %s:%s:%d\n", __FILE__, __func__, __LINE__); \
38  } while(0)
39 
40 #define t_assert(expr) \
41 
42 extern void t_set_colors(int force);
43 extern void t_start(const char *fmt, ...)
44  __attribute__((__format__(__printf__, 1, 2)));
45 extern void t_pass(const char *fmt, ...)
46  __attribute__((__format__(__printf__, 1, 2)));
47 extern void t_fail(const char *fmt, ...)
48  __attribute__((__format__(__printf__, 1, 2)));
49 extern void t_diag(const char *fmt, ...)
50  __attribute__((__format__(__printf__, 1, 2)));
51 extern int t_ok(int success, const char *fmt, ...)
52  __attribute__((__format__(__printf__, 2, 3)));
53 #define test t_ok
54 #define t_req(expr) \
55  if (!(expr)) \
56  crash("No further testing is possible: " #expr " @%s:%d", __FILE__, __LINE__)
57 extern int ok_int(int a, int b, const char *name);
58 extern int ok_uint(unsigned int a, unsigned int b, const char *name);
59 extern int ok_str(const char *a, const char *b, const char *name);
60 extern int t_end(void);
61 extern void t_reset(void);
62 extern void crash(const char *fmt, ...)
63  __attribute__((__format__(__printf__, 1, 2), __noreturn__));
64 #endif