1    | #ifndef CA_DEFS
2    | #define CA_DEFS
3    | 
4    | /************************************************************************
5    |  * This is the definitions header file for the configuration module.  It
6    |  * includes the definitions of data structures, external declarations and
7    |  * definitions, definitions of sybolic constants.
8    |  *
9    |  ************************************************************************/
10   | 
11   | #include <pthread.h>
12   | #include <glib.h>
13   | 
14   | #ifdef __cplusplus
15   | extern "C" {
16   | #endif
17   | 
18   | /* Number of configurations variables. */
19   | #define VARS 90
20   | 
21   | #define SCOPE_GLOBAL 1
22   | #define SCOPE_LOCAL 99
23   | 
24   | /* 
25   |  * Define the length of a string to be 160 to cope with the 
26   |  * copyright statement.
27   |  *
28   |  */
29   | #define STRLENGTH 160
30   | 
31   | /*
32   | 	* Define the length of strings to cope with the values of 
33   |  * various types of string variables.
34   | 	*/
35   | #define STRLENGTH_S 40
36   | #define STRLENGTH_M 80
37   | #define STRLENGTH_L 160
38   | #define STRLENGTH_XL 320
39   | #define STRLENGTH_XXL 640
40   | 
41   | 
42   | /**********************************************
43   |  * Default values for the SOURCE variables		*
44   | 	*															*
45   |  **********************************************/
46   | 
47   |  #define CA_DEFHOST "rowan"						
48   |  #define CA_DEFPORT "4343"
49   |  #define CA_DEFUSER "dbase"						
50   |  #define CA_DEFPASSWORD "encrypt1"				
51   |  #define CA_DEFDBNAME	"default-db"			
52   | 															
53   | 
54   | 
55   | /**********************************************
56   |  * Defintion of the dictionary structures.		*
57   | 	*															*
58   |  **********************************************/
59   | 
60   | typedef struct dict_s	{
61   | 				char varName[STRLENGTH];
62   | 				char varSym[STRLENGTH];
63   | 				char varType[STRLENGTH];
64   | 				int varScope;
65   | 				int varNum;
66   | } dict_t;
67   | 
68   | extern dict_t dictionary[];
69   | 
70   | 
71   | 
72   | 
73   | /**********************************************
74   |  * Definition of the values structures.			*
75   |  *															*
76   | 	**********************************************/
77   | 
78   | typedef struct values_s	{
79   | 				char *strPtr;	/* Pointer to the string that contains the value. */
80   | 				void *valPtr;	/* Pointer to the actual value. */
81   | } values_t;									
82   | 
83   | /*
84   |  * "extern" definition of variables that are defined elsewhere.
85   |  */
86   | 
87   | 
88   | extern values_t globals[];
89   | extern values_t locals[];
90   | 
91   | /*
92   |  * "extern" definition of configuration variables, defined elsewhere.
93   |  */
94   | extern values_t confVars[];
95   | 
96   | /* Mutex lock; used for synchronising changes. */
97   | pthread_mutex_t Lock;
98   | 
99   | /* 
100  | 	* New value of the bindport.
101  | 	* This must be a global variable.
102  | 	*/
103  | 
104  | char newPort[16];
105  | 
106  | /*
107  |  * The following is needed for the SOURCE variable.  First,
108  |  * we define the "database" structure.  Then, we define the
109  |  * structure of an element of the linked list.  Lastly, we 
110  |  * define the linked list itself.
111  |  */
112  | 
113  | typedef struct ca_database_s	{
114  | 
115  | 			char host[64];
116  | 			int port;
117  | 			char user[16];
118  | 			char password[9];
119  | 			char dbName[16];
120  | 		} ca_database_t;
121  | 
122  | typedef struct ca_mirror_s		{
123  | 			char host[64];
124  | 			int port;
125  | 			char log[64];
126  | 			int delay;
127  | 			int protocolVer;
128  | 		} ca_mirror_t;
129  | 
130  | typedef struct ca_ripadmin_s	{
131  | 			char host[64];
132  | 			int port;
133  | 			char user[16];
134  | 			char password[9];
135  | 			char tableName[16];
136  | 		} ca_ripadmin_t;
137  | 
138  | extern ca_database_t ripe;
139  | extern ca_database_t arin;
140  | extern ca_database_t radb;
141  | 
142  | typedef struct ca_database_list_s		{
143  | 			char name[16];	
144  | 			ca_database_t db;
145  | 			int opMode;
146  | 			ca_mirror_t nrtm;
147  | 			int updPort;
148  | 			char canupd[2];
149  | 			char deflook[2];
150  | 		} ca_database_list_t;
151  | 
152  | /*
153  | 	* Define the type of a source.
154  |  * This is the name of a source and
155  |  * the details of the database which 
156  |  * makes this source.
157  |  */
158  | typedef struct ca_dbSource_s	{
159  | 			char name[16];
160  | 			ca_database_t db;
161  | 			int opMode;
162  | 			ca_mirror_t nrtm;
163  | 			int updPort;
164  | 			char canupd[2];
165  | 			char deflook[2];
166  | 		} ca_dbSource_t;
167  | 
168  | /*
169  |  * Define the source handle:
170  |  * this is a pointer to a source;
171  |  * i.e. it is of type ca_dbSource_t.
172  |  */
173  | typedef ca_dbSource_t ca_SrcHdl_t;
174  | 
175  | extern ca_database_list_t ripeComponent;
176  | extern ca_database_list_t arinComponent;
177  | extern ca_database_list_t radbComponent;
178  | 
179  | /*
180  |  * typedef struct GSList {
181  | 	*  	gpointer src;		
182  | 	*  	GSList *next;
183  | 	* 	} ca_source_t;
184  |  */
185  |  /* gpointer src;		This points to a ca_database_list_t varialbe */
186  | 
187  | 
188  | /*************************************************************
189  |  * Definition of the default values for the SOURCE variable.	*
190  |  *																				*
191  |  *************************************************************/
192  | 
193  | /*
194  |  * char ca_defHost[64];
195  |  * char ca_defPort[16];
196  |  * char ca_defUser[16];
197  |  * char ca_defPassword[9];
198  |  * char ca_defdbName[16];
199  |  */
200  | 
201  | /*
202  |  * extern char ca_defPort[16];
203  |  * extern char ca_defHost[64];
204  |  * extern char ca_defUser[16];
205  |  * extern char ca_defPassword[9];
206  |  * extern char ca_defdbName[16];
207  |  */
208  | 
209  | /*
210  |  * The linked-list of sources.
211  |  *
212  |  */
213  | extern GSList *sourceList;
214  | 
215  | /*
216  |  * extern ca_source_t *srcList;
217  |  */
218  | 
219  | /*
220  |  * A varialbe of type GSList
221  |  */
222  | extern ca_dbSource_t *testSource;
223  | 
224  | 
225  | /*
226  |  * 20000609
227  |  * Experiment:
228  |  * define the variable mySrcList as type GSList;
229  |  * use the extern modifier and put the "real" definition
230  |  * of the variable elsewhere.
231  |  *
232  |  * extern GSList *mySrcList;
233  |  */
234  | 
235  | /*
236  | 	* The test configuration file.
237  |  * This is defined using a constant string, cf. Oualline, p.145.
238  |  */
239  | extern const char *testFile;
240  | extern const char *tempFile;
241  | extern const char *dictFile;
242  | extern const char *confFile;
243  | 
244  | /* 
245  |  * Value returned by ca_getStorageLocation if the symbol for
246  |  * a configuration variable cannot be found.
247  |  *
248  | 	* This value is also returned by ca_getType, if it cannot map 
249  |  * the name of a configuration variable to a data type.
250  |  *
251  |  */
252  | #define NOT_FOUND -1 	
253  | 
254  | /*
255  |  * Symbolic constants defined to represent data types.
256  | 
257  |  * #define CA_INT 			11
258  |  * #define CA_STRING 		12
259  |  * #define CA_DIRLIST 	13
260  |  * #define CA_BOOLEAN 	14
261  |  * #define CA_SOURCETYPE		15
262  | 	*/
263  | 
264  | extern ca_dbSource_t *theSrc;
265  | 
266  | #ifdef __cplusplus
267  | }
268  | #endif
269  | 
270  | 
271  | #endif /* CA_DEFS */