auth lib: Add missing exclamation mark in auth_parse_permission()
[nagios-reports-module.git] / logutils.h
blob3966fdbc36ce4662a50f585231c861913307d538
1 #ifndef logutils_h__
2 #define logutils_h__
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <sys/stat.h>
7 #include <unistd.h>
8 #include <string.h>
9 #include <stdarg.h>
10 #include <fcntl.h>
11 #include <errno.h>
12 #include <nagios/broker.h>
13 #include <nagios/nebcallbacks.h>
14 #include "hash.h"
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"
32 #define prefixcmp(s1, s2) strncmp(s1, s2, strlen(s2))
34 /* for the string code structs */
35 #define add_code(n, s, c) { n, s, sizeof(s) - 1, c, }
36 #define add_ignored(s) add_code(0, s, IGNORE_LINE)
37 #define add_cdef(__nvecs, __define) add_code(__nvecs, #__define, __define)
38 #define get_event_type(str, len) get_string_code(event_codes, str, len)
39 #define get_command_type(str, len) get_string_code(command_codes, str, len)
42 #define IGNORE_LINE 0
43 #define CONCERNS_HOST 50
44 #define CONCERNS_SERVICE 60
46 #define DEL_HOST_DOWNTIME 1
47 #define DEL_SVC_DOWNTIME 2
48 #define SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME 3
49 #define SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME 4
50 #define SCHEDULE_HOSTGROUP_HOST_DOWNTIME 5
51 #define SCHEDULE_HOSTGROUP_SVC_DOWNTIME 6
52 #define SCHEDULE_HOST_DOWNTIME 7
53 #define SCHEDULE_HOST_SVC_DOWNTIME 8
54 #define SCHEDULE_SERVICEGROUP_HOST_DOWNTIME 9
55 #define SCHEDULE_SERVICEGROUP_SVC_DOWNTIME 10
56 #define SCHEDULE_SVC_DOWNTIME 11
57 #define ACKNOWLEDGE_HOST_PROBLEM 12
58 #define ACKNOWLEDGE_SVC_PROBLEM 13
59 #define RESTART_PROGRAM 14
61 /* for some reason these aren't defined inside Nagios' headers */
62 #define SERVICE_OK 0
63 #define SERVICE_WARNING 1
64 #define SERVICE_CRITICAL 2
65 #define SERVICE_UNKNOWN 3
67 typedef unsigned int uint;
69 struct naglog_file {
70 time_t first;
71 char *path;
72 uint size;
73 uint cmp;
75 extern struct naglog_file *nfile;
77 struct string_code {
78 int nvecs;
79 const char *str;
80 uint len;
81 int code;
84 extern int debug_level;
85 extern int num_nfile;
86 extern struct naglog_file *cur_file; /* the file we're currently importing */
87 extern uint line_no;
88 extern uint num_unhandled;
89 extern char **strv;
91 extern int vectorize_string(char *str, int nvecs);
92 extern void handle_unknown_event(const char *line);
93 extern void print_unhandled_events(void);
95 extern int parse_service_state(const char *str);
96 extern int parse_host_state(const char *str);
97 extern int soft_hard(const char *str);
99 extern void print_interesting_objects(void);
100 extern int add_interesting_object(const char *orig_str);
101 extern int is_interesting_host(const char *host);
102 extern int is_interesting_service(const char *host, const char *service);
103 extern int is_interesting(const char *ptr);
104 extern int is_start_event(const char *ptr);
105 extern int is_stop_event(const char *ptr);
106 extern int add_naglog_path(char *path);
109 extern struct string_code *get_string_code(struct string_code *codes,
110 const char *str, uint len);
112 extern uint warnings;
113 extern void crash(const char *fmt, ...)
114 __attribute__((__format__(__printf__, 1, 2), __noreturn__));
115 extern void pdebug(int lvl, const char *fmt, ...)
116 __attribute__((__format__(__printf__, 2, 3)));
117 #define debug(...) pdebug(1, __VA_ARGS__)
118 extern void warn(const char *fmt, ...);
120 int strtotimet(const char *str, time_t *val);
123 extern uint path_cmp_number(char *path);
124 extern void first_log_time(struct naglog_file *nf);
125 extern int nfile_cmp(const void *p1, const void *p2);
126 extern int nfile_rev_cmp(const void *p1, const void *p2);
128 #endif