xref: /dflybsd-src/lib/libevtr/internal.h (revision c9e3d8f96688a159959b1af2d4fef14b744173e3)
1 #ifndef _EVTR_INTERNAL_H_
2 #define _EVTR_INTERNAL_H_
3 
4 #include <sys/queue.h>
5 #include "evtr.h"
6 
7 extern unsigned evtr_debug;
8 
9 #define DEFINE_DEBUG_FLAG(nam, chr)		\
10 	nam = 1 << (chr - 'a')
11 
12 enum debug_flags {
13 	DEFINE_DEBUG_FLAG(IO, 'i'),
14 	DEFINE_DEBUG_FLAG(DS, 't'),	/* data structures */
15 	DEFINE_DEBUG_FLAG(LEX, 'l'),
16 	DEFINE_DEBUG_FLAG(PARSE, 'p'),
17 	DEFINE_DEBUG_FLAG(MISC, 'm'),
18 };
19 
20 #define printd(subsys, ...)				\
21 	do {						\
22 		if (evtr_debug & (subsys)) {	\
23 			fprintf(stderr, "%s:", #subsys);	\
24 			fprintf(stderr, __VA_ARGS__);	\
25 		}					\
26 	} while (0)
27 
28 #define printw(...)				\
29 	do {					\
30 	fprintf(stderr, "Warning: ");		\
31 	fprintf(stderr, __VA_ARGS__);		\
32 	} while(0)
33 
34 
35 TAILQ_HEAD(evtr_value_list, evtr_variable_value);
36 typedef struct evtr_value_list *evtr_value_list_t;
37 
38 struct evtr_variable * symtab_find(const struct symtab *, const char *);
39 int symtab_insert(struct symtab *, const char *, struct evtr_variable *);
40 
41 int parse_string(evtr_event_t, struct symtab *, const char *);
42 int parse_var(const char *, struct symtab *, struct evtr_variable **);
43 
44 struct hashtab;
45 struct hashentry;
46 struct hashtab * hash_new(void);
47 int hash_find(const struct hashtab *, uintptr_t, uintptr_t *);
48 struct hashentry * hash_insert(struct hashtab *, uintptr_t, uintptr_t);
49 
50 void evtr_variable_value_list_destroy(evtr_value_list_t);
51 
52 
53 #endif /* _EVTR_INTERNAL_H_ */
54