Nagios 4.4.2
Dev docs for Nagios core and neb-module hackers

t-utils.h

00001 #ifndef NAGIOS_T_UTILS_H_INCLUDED
00002 #define NAGIOS_T_UTILS_H_INCLUDED
00003 #include <stdlib.h>
00004 #include <unistd.h>
00005 #include <string.h>
00006 #include <stdio.h>
00007 #include <stdarg.h>
00008 
00009 #ifndef ARRAY_SIZE
00010 # define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
00011 #endif
00012 
00013 #define TEST_PASS 1
00014 #define TEST_FAIL 0
00015 
00016 #define CLR_RESET          "\033[m"
00017 #define CLR_BOLD           "\033[1m"
00018 #define CLR_RED            "\033[31m"
00019 #define CLR_GREEN          "\033[32m"
00020 #define CLR_BROWN          "\033[33m"
00021 #define CLR_YELLOW         "\033[33m\033[1m"
00022 #define CLR_BLUE           "\033[34m"
00023 #define CLR_MAGENTA        "\033[35m"
00024 #define CLR_CYAN           "\033[36m"
00025 #define CLR_BG_RED         "\033[41m"
00026 #define CLR_BRIGHT_RED     "\033[31m\033[1m"
00027 #define CLR_BRIGHT_GREEN   "\033[32m\033[1m"
00028 #define CLR_BRIGHT_BLUE    "\033[34m\033[1m"
00029 #define CLR_BRIGHT_MAGENTA "\033[35m\033[1m"
00030 #define CLR_BRIGHT_CYAN    "\033[36m\033[1m"
00031 
00032 extern const char *red, *green, *yellow, *cyan, *reset;
00033 extern unsigned int passed, failed, t_verbose;
00034 
00035 #define CHECKPOINT() \
00036     do { \
00037         fprintf(stderr, "ALIVE @ %s:%s:%d\n", __FILE__, __func__, __LINE__); \
00038     } while(0)
00039 
00040 #define t_assert(expr) \
00041 
00042 extern void t_set_colors(int force);
00043 extern void t_start(const char *fmt, ...)
00044     __attribute__((__format__(__printf__, 1, 2)));
00045 extern void t_pass(const char *fmt, ...)
00046     __attribute__((__format__(__printf__, 1, 2)));
00047 extern void t_fail(const char *fmt, ...)
00048     __attribute__((__format__(__printf__, 1, 2)));
00049 extern void t_diag(const char *fmt, ...)
00050     __attribute__((__format__(__printf__, 1, 2)));
00051 extern int t_ok(int success, const char *fmt, ...)
00052     __attribute__((__format__(__printf__, 2, 3)));
00053 #define test t_ok
00054 #define t_req(expr) \
00055     if (!(expr)) \
00056         crash("No further testing is possible: " #expr " @%s:%d", __FILE__, __LINE__)
00057 extern int ok_int(int a, int b, const char *name);
00058 extern int ok_uint(unsigned int a, unsigned int b, const char *name);
00059 extern int ok_str(const char *a, const char *b, const char *name);
00060 extern int t_end(void);
00061 extern void t_reset(void);
00062 extern void crash(const char *fmt, ...)
00063     __attribute__((__format__(__printf__, 1, 2), __noreturn__));
00064 #endif
 All Data Structures Files Functions Variables Typedefs Defines