hash api: Remove HASH_MASK and HASH_BUCKETS macros
[nagios-reports-module.git] / logutils.h
bloba411587376575d2508dfbfb4fd856f5e76128863
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>
15 #define prefixcmp(s1, s2) strncmp(s1, s2, strlen(s2))
17 /* for the string code structs */
18 #define add_code(n, s, c) { n, s, sizeof(s) - 1, c, }
19 #define add_ignored(s) add_code(0, s, IGNORE_LINE)
20 #define add_cdef(__nvecs, __define) add_code(__nvecs, #__define, __define)
21 #define get_event_type(str, len) get_string_code(event_codes, str, len)
22 #define get_command_type(str, len) get_string_code(command_codes, str, len)
25 #define IGNORE_LINE 0
26 #define CONCERNS_HOST 50
27 #define CONCERNS_SERVICE 60
29 #define DEL_HOST_DOWNTIME 1
30 #define DEL_SVC_DOWNTIME 2
31 #define SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME 3
32 #define SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME 4
33 #define SCHEDULE_HOSTGROUP_HOST_DOWNTIME 5
34 #define SCHEDULE_HOSTGROUP_SVC_DOWNTIME 6
35 #define SCHEDULE_HOST_DOWNTIME 7
36 #define SCHEDULE_HOST_SVC_DOWNTIME 8
37 #define SCHEDULE_SERVICEGROUP_HOST_DOWNTIME 9
38 #define SCHEDULE_SERVICEGROUP_SVC_DOWNTIME 10
39 #define SCHEDULE_SVC_DOWNTIME 11
40 #define ACKNOWLEDGE_HOST_PROBLEM 12
41 #define ACKNOWLEDGE_SVC_PROBLEM 13
42 #define RESTART_PROGRAM 14
44 /* for some reason these aren't defined inside Nagios' headers */
45 #define SERVICE_OK 0
46 #define SERVICE_WARNING 1
47 #define SERVICE_CRITICAL 2
48 #define SERVICE_UNKNOWN 3
50 typedef unsigned int uint;
52 struct naglog_file {
53 time_t first;
54 char *path;
55 uint size;
56 uint cmp;
59 struct string_code {
60 int nvecs;
61 const char *str;
62 uint len;
63 int code;
66 extern int debug_level;
67 extern int num_nfile;
68 extern struct naglog_file *cur_file; /* the file we're currently importing */
69 extern uint line_no;
70 extern uint num_unhandled;
71 extern char **strv;
73 extern int vectorize_string(char *str, int nvecs);
74 extern void handle_unknown_event(const char *line);
75 extern void print_unhandled_events();
77 extern int is_interesting(const char *ptr);
78 extern int is_start_event(const char *ptr);
79 extern int is_stop_event(const char *ptr);
81 extern struct string_code *get_string_code(struct string_code *codes,
82 const char *str, uint len);
84 extern uint warnings;
85 extern void crash(const char *fmt, ...)
86 __attribute__((__format__(__printf__, 1, 2), __noreturn__));
87 extern void pdebug(int lvl, const char *fmt, ...)
88 __attribute__((__format__(__printf__, 2, 3)));
89 #define debug(...) pdebug(1, __VA_ARGS__)
90 extern void warn(const char *fmt, ...);
92 int strtotimet(const char *str, time_t *val);
95 extern uint path_cmp_number(char *path);
96 extern void first_log_time(struct naglog_file *nf);
97 extern int nfile_cmp(const void *p1, const void *p2);
99 #endif