/[imapfilter]/imapfilter/struct.h
ViewVC logotype

Contents of /imapfilter/struct.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Fri Feb 13 12:17:16 2004 UTC (20 years, 1 month ago) by lefcha
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
File MIME type: text/plain
Stylistic changes.

1 #ifndef STRUCT_H
2 #define STRUCT_H
3
4
5 #include "imapfilter.h"
6 #include "account.h"
7
8
9 /*
10 * Find last node of linked list and append at the end of the list the
11 * supplied node.
12 */
13 #define APPEND_LINKED_LIST(FIRST, NODE, TYPE) \
14 { \
15 struct TYPE *POS; \
16 struct TYPE **APP; \
17 POS = FIRST; \
18 APP = &FIRST; \
19 while (POS) { \
20 APP = &(POS->next); \
21 POS = POS->next; \
22 } \
23 *APP = NODE; \
24 }
25
26 /*
27 * Find, based on the key of the supplied node, the apropriate position for it
28 * in the tree, and then insert it there.
29 */
30 #define INSERT_TREE(ROOT, NODE, TYPE) \
31 { \
32 int CMP; \
33 struct TYPE *POS; \
34 struct TYPE **INS; \
35 INS = &ROOT; \
36 POS = ROOT; \
37 while (POS) { \
38 CMP = strncmp(NODE->key, POS->key, KEY_LEN); \
39 if (CMP < 0) { \
40 INS = &(POS->left); \
41 POS = POS->left; \
42 } else if (CMP > 0) { \
43 INS = &(POS->right); \
44 POS = POS->right; \
45 } else \
46 return ERROR_PARSER; \
47 } \
48 *INS = NODE; \
49 }
50
51 /*
52 * Find, based on the key, the position of a node, and set accordingly the
53 * pointer supplied.
54 */
55 #define FIND_TREE(ROOT, KEY, PTR) \
56 { \
57 int CMP; \
58 PTR = ROOT; \
59 while (PTR) { \
60 CMP = strncmp(KEY, PTR->key, KEY_LEN); \
61 if (CMP < 0) \
62 PTR = PTR->left; \
63 else if (CMP > 0) \
64 PTR = PTR->right; \
65 else \
66 break; \
67 } \
68 }
69
70
71 #endif /* STRUCT_H */

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26