Release bumped to "gts4".
[tac_plus.git] / utils.h
1 #ifndef UTILS_H
2 #define UTILS_H 1
3
4 #include "tac_plus.h"
5
6 #include <sys/types.h>          /* for u_* */
7
8
9 /* Configurable:
10  */
11 #define TAC_LIST_PARANOIA 1
12
13
14 /* Bidirectional lists */
15
16 #ifdef TAC_LIST_PARANOIA
17 #define TAC_LIST_MAGIC      (0xBEF78147U)
18 #define TAC_LIST_NODE_MAGIC (0x297DA735U)
19 #endif
20
21 struct tac_list {
22 #ifdef TAC_LIST_PARANOIA
23     unsigned _magic;
24 #endif
25     struct tac_list_node *_head, *_tail;
26 };
27
28 struct tac_list_node {
29 #ifdef TAC_LIST_PARANOIA
30     unsigned _magic;
31 #endif
32     struct tac_list_node *_next, *_prev;
33     struct tac_list *_list;
34 };
35
36
37 extern void *tac_malloc TAC_ARGS((int size));
38 extern void *tac_realloc TAC_ARGS((void *ptr, int size));
39 extern void tac_exit TAC_ARGS((int status)) G_GNUC_NORETURN;
40 extern char *tac_strdup TAC_ARGS((const char *p));
41 extern char *tac_make_string TAC_ARGS((u_char *p, int len));
42 extern const char *tac_find_substring TAC_ARGS((const char *substring, const char *string));
43 extern int tac_lockfd TAC_ARGS((char *filename, int lockfd));
44
45 /* Bidirectional lists: */
46
47 extern void tac_list_init TAC_ARGS((struct tac_list *list));
48 extern void tac_list_node_init TAC_ARGS((struct tac_list_node *node));
49 extern struct tac_list *tac_list_node_get_list TAC_ARGS((struct tac_list_node *node));
50 struct tac_list_node *tac_list_first_node TAC_ARGS((struct tac_list *list));
51 struct tac_list_node *tac_list_last_node TAC_ARGS((struct tac_list *list));
52 extern void tac_list_addhead TAC_ARGS((struct tac_list *list, struct tac_list_node *node));
53 extern void tac_list_addtail TAC_ARGS((struct tac_list *list, struct tac_list_node *node));
54 extern struct tac_list_node *tac_list_node_next TAC_ARGS((struct tac_list_node *node));
55 extern struct tac_list_node *tac_list_node_prev TAC_ARGS((struct tac_list_node *node));
56 extern void tac_list_node_remove TAC_ARGS((struct tac_list_node *node));
57
58
59 #endif /* UTILS_H */