1 /* $Cambridge: hermes/src/prayer/lib/template_structs.h,v 1.1 2010/07/07 08:52:14 dpc22 Exp $ */
2 
3 /************************************************
4  *    Prayer - a Webmail Interface              *
5  ************************************************/
6 
7 /* Copyright (c) University of Cambridge 2000 - 2008 */
8 /* See the file NOTICE for conditions of use and distribution. */
9 
10 typedef enum {
11     TEMPLATE_ITEM_LINES,
12     TEMPLATE_ITEM_IFDEF,
13     TEMPLATE_ITEM_IFEQ,
14     TEMPLATE_ITEM_FOREACH,
15     TEMPLATE_ITEM_LOOP,
16     TEMPLATE_ITEM_CALL,
17 } TEMPLATE_ITEM_TYPE;
18 
19 /* Any changes to the following must be mirrored in template_compile */
20 
21 struct template_map_index {
22     char *name;
23     struct template_map *template_map;
24     unsigned long *count;
25 };
26 
27 struct template_map {
28     char *name;
29     struct template *template;
30 };
31 
32 struct template {
33     char *name;
34     struct template_item *head;
35     struct template_item *tail;
36     unsigned long count;
37     struct template_item *tree;
38     struct str *error;
39 };
40 
41 struct template_item {
42     unsigned long number;
43     struct template_item *list_next;
44     struct template_item *tree_next;
45     TEMPLATE_ITEM_TYPE type;
46     /* ... */
47 };
48 
49 struct template_lines {
50     unsigned long number;
51     struct template_item *list_next;
52     struct template_item *tree_next;
53     TEMPLATE_ITEM_TYPE type;
54     char **first;
55     int count;
56 };
57 
58 struct template_ifdef {
59     unsigned long number;
60     struct template_item *list_next;
61     struct template_item *tree_next;
62     TEMPLATE_ITEM_TYPE type;
63     BOOL positive;
64     char *expr;
65     struct template_item *true_block;
66     struct template_item *false_block;
67 };
68 
69 struct template_ifeq {
70     unsigned long number;
71     struct template_item *list_next;
72     struct template_item *tree_next;
73     TEMPLATE_ITEM_TYPE type;
74     BOOL positive;
75     char *name;
76     char *value;
77     struct template_item *true_block;
78     struct template_item *false_block;
79 };
80 
81 struct template_foreach {
82     unsigned long number;
83     struct template_item *list_next;
84     struct template_item *tree_next;
85     TEMPLATE_ITEM_TYPE type;
86     char *name;
87     char *array;
88     struct template_item *block;
89 };
90 
91 struct template_loop {
92     unsigned long number;
93     struct template_item *list_next;
94     struct template_item *tree_next;
95     TEMPLATE_ITEM_TYPE type;
96     char *var;
97     struct template_item *block;
98 };
99 
100 struct template_call {
101     unsigned long number;
102     struct template_item *list_next;
103     struct template_item *tree_next;
104     TEMPLATE_ITEM_TYPE type;
105     char *name;
106     char *params;
107 };
108 
109