Source File ca/ca_sanityCheck.c

    1    | /************************************
    2    | Copyright (c) 2001,2002                         RIPE NCC
    3    |
    4    | All Rights Reserved
    5    |
    6    | Permission to use, copy, modify, and distribute this software and its
    7    | documentation for any purpose and without fee is hereby granted,
    8    | provided that the above copyright notice appear in all copies and that
    9    | both that copyright notice and this permission notice appear in
    10   | supporting documentation, and that the name of the author not be
    11   | used in advertising or publicity pertaining to distribution of the
    12   | software without specific, written prior permission.
    13   |
    14   | THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
    15   | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
    16   | AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
    17   | DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
    18   | AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    19   | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    20   | ***************************************/
    21   |
    22   |
    23   | #include "rip.h"
    24   |
    25   | #include <stdio.h>
    26   | #include <stdlib.h>
    27   |
    28   |
    29   | int ca_sanityCheck(values_t confVars[])
    30   | /*
    31   | 	- does a simple sanity check
    32   |  - Parameters
    33   | 		- confVars - the array of configuration variables
    34   |  - Returns
    35   | 		- an integer: -1 or 0
    36   |  */
    37   | {
    38   | int symbol;	/* A counting variable */
    39   | int status = 0;	/* Assume that the Configuration File is complete. */
    40   | int undefVars = 0; /* Number of undefined variables. */
    41   | const char *configWarningStr = "Warning: undefined configuration variable:";
    42   | const char *configError_1Str = "Error: Incomplete configuration file.  Please check if this was intended.\n";
    43   | const char *configError_2Str = " configuration variables undefined.\n";
    44   |
    45   | /*
    46   | 	* We use CA_NUMBEROFSYMBOLS instead of VARS .....
    47   |  */
    48   |
    49   | for(symbol = 0; symbol < CA_NUMBEROFSYMBOLS; symbol++)
    50   | 	{
    51   | 	if (!confVars[symbol].strPtr)
    52   | 		{
    53   | 		++undefVars;
    54   | 		fprintf(stderr, "%s %s\n", configWarningStr, dictionary[symbol].varName);
    55   | 		}
    56   | 	}
    57   |
    58   | if (undefVars)
    59   | 	{
    60   | 	status = INCOMPLETE;
    61   | 	}
    62   |
    63   | 	fprintf(stderr, "\n%s\n", configError_1Str);
    64   |  fprintf(stderr, "%d%s\n", undefVars, configError_2Str);
    65   |  return(status);
    66   | }
    67   |
    68   | int ca_conifigCheck(void)
    69   | /*
    70   | 	* A wrapper for the ca_sanityCheck() function.A
    71   |  *
    72   |  * Parameters
    73   | 	*	- none
    74   |  *
    75   |  * Returns
    76   | 	* -nothing
    77   |  */
    78   | {
    79   | return(ca_sanityCheck(confVars));
    80   | }