tests/ca/test_ca.c
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- main
1 /* A test program to test the get and set functions. */
2
3 #include <stdio.h>
4 #include <glib.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include <stubs.h>
8 #include "../../modules/ca/ca_configFns.h"
9 #include "../../modules/ca/ca_dictionary.h"
10 #include "../../modules/ca/ca_macros.h"
11 #include "../../modules/ca/ca_srcAttribs.h"
12
13 /*
14 * #include "../../modules/ca/ca_adminAttribs.h"
15 */
16
17 /* #define DEBUG */ /* Debug this file. */
18
19 int main ()
/* [<][>][^][v][top][bottom][index][help] */
20 {
21 /* Initialise the linked list of sources. */
22
23 ca_dbSource_t *testSourceHdl;
24 ca_dbSource_t *testSourceHdl2;
25 ca_updDbSource_t *UpdSourceHdl;
26 char ainm[80];
27 char *testString;
28 char *testString2;
29 char *testString3;
30 int testInt;
31 int srcPosition;
32
33 ca_init("./andrei.test.config");
34
35 puts("Finding the TestMode ..... ");
36 testInt = ca_get_testmode;
37 printf("\nThe TestMode is %d\n", testInt);
38
39 if (testInt != 1)
40 {
41 puts("Testing the testmode");
42 testInt = ca_get_testmode;
43 printf("\nThe TestMode is %d\n", testInt);
44 }
45 /*
46 * testString = ca_get_replybanner;
47 * printf("The Replybanner is: %s\n", testString);
48 * free(testString);
49 */
50
51 testString = ca_get_mailtxt;
52 printf("The Mailtext is: %s\n", testString);
53 free(testString);
54
55 testString = ca_get_autodbmhelp;
56 printf("The AUTO-HELP is: %s\n", testString);
57 free(testString);
58
59 testString = ca_get_notitxt;
60 printf("The Notify-Text is: %s\n", testString);
61 free(testString);
62
63 /*
64 * testInt = ca_get_bindport;
65 * printf("The Bindport is: %d\n", testInt);
66 */
67 puts("Enter name >>> ");
68 gets(ainm);
69
70
71
72
73 testSourceHdl = ca_get_SourceHandleByName(ainm);
74 if(testSourceHdl == NULL)
75 {
76 puts("We fell off the end of the list !!!");
77 }
78 else
79 {
80 printf("\nThe testSourceHdl is: %s\n", testSourceHdl->name);
81 }
82
83
84
85 testString = ca_get_srcname(testSourceHdl);
86 printf("The name of Source %s is %s\n", testSourceHdl->name, testString);
87 free(testString);
88
89 testString = ca_get_srccanupd(testSourceHdl);
90 printf("CANUPD of Source %s is %s\n", testSourceHdl->name, testString);
91 free(testString);
92
93 testString = ca_get_srcdeflook(testSourceHdl);
94 printf("DEFLOOK of Source %s is %s\n", testSourceHdl->name, testString);
95 free(testString);
96
97 testString = ca_get_srcdbmachine(testSourceHdl);
98 printf("DBMachine of Source %s is %s\n", testSourceHdl->name, testString);
99 free(testString);
100
101 testString = ca_get_srcdbuser(testSourceHdl);
102 printf("DBUSER of Source %s is %s\n", testSourceHdl->name, testString);
103 free(testString);
104
105 testString = ca_get_srcdbpassword(testSourceHdl);
106 printf("DBPASSWORD of Source %s is %s\n", testSourceHdl->name, testString);
107 free(testString);
108
109 testString = ca_get_srcdbname(testSourceHdl);
110 printf("DBNAME of Source %s is %s\n", testSourceHdl->name, testString);
111 free(testString);
112
113 testInt = ca_get_srcdbport(testSourceHdl);
114 printf("DBPORT of Source %s is %d\n", testSourceHdl->name, testInt);
115
116
117 testString = ca_get_srcnrtmhost(testSourceHdl);
118 printf("NRTMHOST of Source %s is %s\n", testSourceHdl->name, testString);
119 free(testString);
120
121 /*
122 * The 'log' component of NRTM is no longer needed.
123 * testString = ca_get_srcnrtmlog(testSourceHdl);
124 * printf("NRTMLOG of Source %s is %s\n", testSourceHdl->name, testString);
125 * free(testString);
126 */
127
128 testInt = ca_get_srcmode(testSourceHdl);
129 printf("SRCMODE of Source %s is %d\n", testSourceHdl->name, testInt);
130
131 testInt = ca_get_srcnrtmport(testSourceHdl);
132 printf("NRTMPORT of Source %s is %d\n", testSourceHdl->name, testInt);
133
134 testInt = ca_get_srcnrtmdelay(testSourceHdl);
135 printf("NRTMDELAY of Source %s is %d\n", testSourceHdl->name, testInt);
136
137 testInt = ca_get_srcnrtmprotocolvers(testSourceHdl);
138 printf("NRTMPROTOCOLVERS of Source %s is %d\n", testSourceHdl->name, testInt);
139
140 testInt = ca_get_srcupdateport(testSourceHdl);
141 printf("\nSourceName: %s has SRCUPDPORT: %d\n", testSourceHdl->name, testInt);
142
143 fflush(stdin);
144 puts("Enter position of the source in the list >>>");
145 scanf("%d", &srcPosition);
146
147 testSourceHdl2 = ca_get_SourceHandleByPosition(srcPosition);
148
149 testString2 = ca_get_srcname(testSourceHdl2);
150 printf("The name of this source is %s\n", testString2);
151 free(testString2);
152
153
154 testString = ca_get_notiflog;
155 printf("The Notify Log is at: %s\n", testString);
156 free(testString);
157
158 testString = ca_get_forwlog;
159 printf("The Forward Log is: %s\n", testString);
160 free(testString);
161
162 testString = ca_get_crosslog;
163 printf("The Cross-Notification Log is: %s\n", testString);
164 free(testString);
165
166 testString = ca_get_adminStrElement(CA_RIPADMIN, CA_ADMINTABLE);
167 printf("The Admin table is: %s\n", testString);
168 free(testString);
169
170 testString = ca_get_adminStrElement(CA_RIPADMIN, CA_ADMINUSER);
171 printf("The Admin User is: %s\n", testString);
172 free(testString);
173
174 testInt = ca_get_adminIntElement(CA_RIPADMIN, CA_ADMINPORT);
175 printf("The Admin Port is: %d\n", testInt);
176
177 testString = ca_get_ripadminpassword;
178 printf("The Admin Password is: %s\n", testString);
179 free(testString);
180
181 testString = ca_get_ripadminhost;
182 printf("The Admin Machine is:%s\n", testString);
183 free(testString);
184
185 testInt = ca_get_ripadminport;
186 printf("The Admin Port again is :%d\n", testInt);
187
188 testInt = ca_get_testmode;
189 printf("\nThe TestMode is %d\n", testInt);
190
191
192 UpdSourceHdl = ca_get_UpdSourceHandle(CA_UPDSOURCE);
193
194 if(UpdSourceHdl == NULL)
195 {
196 puts("There is no Update Source !!!\n");
197 }
198 else
199 {
200 printf("\nThe UpdSourceHdl is: %s\n", UpdSourceHdl->name);
201 }
202
203 /*
204 * testString = ca_UpdSrcHandle2StrElement(UpdSourceHdl, CA_SRCNAME);
205 */
206 testString = ca_get_updsrcname(UpdSourceHdl);
207 printf("Update Source >> DB-Name ==> %s\n", testString);
208 free(testString);
209
210 /*
211 * testString = ca_UpdSrcHandle2StrElement(UpdSourceHdl, CA_DBMACHINE);
212 */
213 testString = ca_get_updsrcdbmachine(UpdSourceHdl);
214 printf("Update Source >> DB-Details >> Machine ? ==> %s\n", testString);
215 free(testString);
216
217 /*
218 * testString = ca_UpdSrcHandle2StrElement(UpdSourceHdl, CA_DBUSER);
219 */
220 testString = ca_get_updsrcdbuser(UpdSourceHdl);
221 printf("Update Source >> DB-Details >> User ==> %s\n", testString);
222 free(testString);
223 /*
224 * testString = ca_UpdSrcHandle2StrElement(UpdSourceHdl, CA_DBPASSWORD);
225 */
226 testString = ca_get_updsrcdbpassword(UpdSourceHdl);
227 printf("Update Source >> DB-Details >> Password ==> %s\n", testString);
228 free(testString);
229
230 /*
231 * testString = ca_UpdSrcHandle2StrElement(UpdSourceHdl, CA_DBNAME);
232 */
233 testString = ca_get_updsrcdbname(UpdSourceHdl);
234 printf("Update Source >> DB-Details >> Database ==> %s\n", testString);
235 free(testString);
236
237 /*
238 * testString = ca_UpdSrcHandle2StrElement(UpdSourceHdl, CA_UPDSRCWHOISHOST);
239 */
240 testString = ca_get_updsrcwhoishost(UpdSourceHdl);
241 printf("Update Source >> Whois Machine ==> %s\n", testString);
242 free(testString);
243
244 /*
245 * testInt = ca_UpdSrcHandle2IntElement(UpdSourceHdl, CA_DBPORT);
246 */
247 testInt = ca_get_updsrcdbport(UpdSourceHdl);
248 printf("Update Source >> DB-Details >> Port ==> %d\n", testInt);
249
250 /*
251 * testInt = ca_UpdSrcHandle2IntElement(UpdSourceHdl, CA_UPDSRCQRYPORT);
252 */
253 testInt = ca_get_updqryport(UpdSourceHdl);
254 printf("Update Source >> QRY Port ==> %d\n", testInt);
255
256 /*
257 * testInt = ca_UpdSrcHandle2IntElement(UpdSourceHdl, CA_UPDSRCUPDPORT);
258 */
259 testInt = ca_get_updupdport(UpdSourceHdl);
260 printf("Update Source >> UPD Port ==> %d\n", testInt);
261
262 g_strstrip(ca_get_tmpdir);
263
264 /*
265 * ca_readSources(sourcesFile, confVars);
266 */
267 ca_getAllDatabases(dbList);
268 ca_getAllMirrors(nrtmList);
269
270 /****************************************************
271 * Now test the new syntax of the SOURCE variable. *
272 * *
273 ****************************************************/
274
275 /* First, flush the input stream. */
276
277 fflush(stdin);
278 puts("Enter SOURCE name or \"Finish\" to finish >>> ");
279 gets(ainm);
280
281 while (strcasecmp(ainm, "Finish") != 0)
282 {
283 testSourceHdl = ca_get_SourceHandleByName(ainm);
284 if(testSourceHdl == NULL)
285 {
286 puts("We fell off the end of the list !!!");
287 }
288 else
289 {
290 printf("\nThe testSourceHdl is: %s\n", testSourceHdl->name);
291 }
292
293
294 testString = ca_get_srcname(testSourceHdl);
295 printf("The name of Source %s is %s\n", testSourceHdl->name, testString);
296 free(testString);
297
298
299 testString = ca_get_srcname(testSourceHdl);
300 printf("The name of Source %s is %s\n", testSourceHdl->name, testString);
301 free(testString);
302
303 testString = ca_get_srccanupd(testSourceHdl);
304 printf("CANUPD of Source %s is %s\n", testSourceHdl->name, testString);
305 free(testString);
306
307 testString = ca_get_srcdeflook(testSourceHdl);
308 printf("DEFLOOK of Source %s is %s\n", testSourceHdl->name, testString);
309 free(testString);
310
311 testString = ca_get_srcdbmachine(testSourceHdl);
312 printf("DBMachine of Source %s is %s\n", testSourceHdl->name, testString);
313 free(testString);
314
315 testString = ca_get_srcdbuser(testSourceHdl);
316 printf("DBUSER of Source %s is %s\n", testSourceHdl->name, testString);
317 free(testString);
318
319 testString = ca_get_srcdbpassword(testSourceHdl);
320 printf("DBPASSWORD of Source %s is %s\n", testSourceHdl->name, testString);
321 free(testString);
322
323 testString = ca_get_srcdbname(testSourceHdl);
324 printf("DBNAME of Source %s is %s\n", testSourceHdl->name, testString);
325 free(testString);
326
327 testInt = ca_get_srcdbport(testSourceHdl);
328 printf("DBPORT of Source %s is %d\n", testSourceHdl->name, testInt);
329
330
331 testString = ca_get_srcnrtmhost(testSourceHdl);
332 printf("NRTMHOST of Source %s is %s\n", testSourceHdl->name, testString);
333 free(testString);
334 /*
335 * The log component of NRMT is no longer needed.
336 * testString = ca_get_srcnrtmlog(testSourceHdl);
337 * printf("NRTMLOG of Source %s is %s\n", testSourceHdl->name, testString);
338 * free(testString);
339 */
340
341 testInt = ca_get_srcmode(testSourceHdl);
342 printf("SRCMODE of Source %s is %d\n", testSourceHdl->name, testInt);
343
344 testInt = ca_get_srcnrtmport(testSourceHdl);
345 printf("NRTMPORT of Source %s is %d\n", testSourceHdl->name, testInt);
346
347 testInt = ca_get_srcnrtmdelay(testSourceHdl);
348 printf("NRTMDELAY of Source %s is %d\n", testSourceHdl->name, testInt);
349
350 testInt = ca_get_srcnrtmprotocolvers(testSourceHdl);
351 printf("NRTMPROTOCOLVERS of Source %s is %d\n", testSourceHdl->name, testInt);
352
353 testInt = ca_get_srcupdateport(testSourceHdl);
354 printf("\nSourceName: %s has SRCUPDPORT: %d\n", testSourceHdl->name, testInt);
355
356 fflush(stdin);
357 puts("Enter SOURCE name or \"Finish\" to finish >>> ");
358 gets(ainm);
359 }
360
361 testInt = ca_get_svwhois_port;
362 printf("The SV.whois_port is: %d\n", testInt);
363
364 testInt = ca_get_svconfig_port;
365 printf("The SV.config_port is: %d\n", testInt);
366
367 testInt = ca_get_svmirror_port;
368 printf("The SV.mirror_port is: %d\n", testInt);
369
370 testString = ca_get_sourcefile;
371 printf("The SOURCEFILE is: %s\n", testString);
372 free(testString);
373
374 testInt = ca_get_ac_decay_interval;
375 printf("The AC Decay Interval is: %d\n", testInt);
376
377 testInt = ca_get_ac_decay_halflife;
378 printf("The AC Decay Half-Life is: %d\n", testInt);
379
380 testString = ca_get_pw_limit_reached;
381 printf("The PW Limit Reached text is:\n");
382 printf("%s", testString);
383 free(testString);
384
385 testString = ca_get_pw_help_file;
386 printf("The PW Help File is %s\n", testString);
387 free(testString);
388
389 testString = ca_get_pw_banner;
390 printf("The PW Banner is:\n");
391 printf("%s", testString);
392 free(testString);
393
394 testString = ca_get_er_ud_def;
395 printf("The ER_UD_DEF is:\n");
396 if (testString == NULL)
397 {
398 puts("Undefined");
399 }
400 else
401 {
402 printf("%s", testString);
403 }
404 free(testString);
405
406 testString = ca_get_er_macro;
407 printf("The ER_MACRO is:\n");
408 if (testString == NULL)
409 {
410 puts("Undefined");
411 }
412 else
413 {
414 printf("%s", testString);
415 }
416 free(testString);
417
418 testString = ca_get_qi_reftrailer;
419 printf("The QI_REFTRAILER is:");
420 if (testString == NULL)
421 {
422 puts("Undefined");
423 }
424 else
425 {
426 printf("%s\n", testString);
427 }
428 free(testString);
429
430 testString = ca_get_gpgcmd;
431 printf("The GPGCMD is:");
432 if (testString == NULL)
433 {
434 puts("Undefined");
435 }
436 else
437 {
438 printf("%s\n", testString);
439 }
440 free(testString);
441
442
443 /*
444 * puts("Running sanity check; wait .....");
445 * ca_sanityCheck(confVars);
446 *
447 */
448
449 puts("Running sanity check wrapper; please wait .....");
450 ca_conifigCheck();
451
452
453 /*
454 * puts("Printing the strings of the configuration variables .....");
455 * sleep(5);
456 * ca_getConfig(confVars, VARS);
457 */
458
459 return (0);
460 }
461