modules/ca/ca_sanityCheck.c
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- ca_sanityCheck
- ca_conifigCheck
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "ca_defs.h"
4 #include "ca_configFns.h"
5 #include "ca_dictionary.h"
6
7
8 int ca_sanityCheck(values_t confVars[])
/* [<][>][^][v][top][bottom][index][help] */
9 /*
10 - does a simple sanity check
11 - Parameters
12 - confVars - the array of configuration variables
13 - Returns
14 - an integer: -1 or 0
15 */
16 {
17 int symbol; /* A counting variable */
18 int status = 0; /* Assume that the Configuration File is complete. */
19 int undefVars = 0; /* Number of undefined variables. */
20 const char *configWarningStr = "Warning: undefined configuration variable:";
21 const char *configError_1Str = "Error: Incomplete configuration file. Please check if this was intended.\n";
22 const char *configError_2Str = " configuration variables undefined.\n";
23
24 /*
25 * We use CA_NUMBEROFSYMBOLS instead of VARS .....
26 */
27
28 for(symbol = 0; symbol < CA_NUMBEROFSYMBOLS; symbol++)
29 {
30 if (!confVars[symbol].strPtr)
31 {
32 ++undefVars;
33 fprintf(stderr, "%s %s\n", configWarningStr, dictionary[symbol].varName);
34 }
35 }
36
37 if (undefVars)
38 {
39 status = INCOMPLETE;
40 }
41
42 fprintf(stderr, "\n%s\n", configError_1Str);
43 fprintf(stderr, "%d%s\n", undefVars, configError_2Str);
44 return(status);
45 }
46
47 int ca_conifigCheck(void)
/* [<][>][^][v][top][bottom][index][help] */
48 /*
49 * A wrapper for the ca_sanityCheck() function.A
50 *
51 * Parameters
52 * - none
53 *
54 * Returns
55 * -nothing
56 */
57 {
58 return(ca_sanityCheck(confVars));
59 }