Source File ca/ca_defs.h

    1    | /***************************************
    2    |   $Revision:
    3    |
    4    |   CA module: definitions header file for the configuration module.
    5    |
    6    |   Status: NOT REVIEWED, NOT TESTED
    7    |
    8    |   Author(s):       Ambrose Magee
    9    |
    10   | ******************/ /******************
    11   | Modification History:
    12   |
    13   | ******************/
    14   |
    15   | /************************************
    16   |   Copyright (c) 2000,2001,2002                    RIPE NCC
    17   |
    18   |   All Rights Reserved
    19   |
    20   |   Permission to use, copy, modify, and distribute this software and its
    21   |   documentation for any purpose and without fee is hereby granted,
    22   |   provided that the above copyright notice appear in all copies and that
    23   |   both that copyright notice and this permission notice appear in
    24   |   supporting documentation, and that the name of the author not be
    25   |   used in advertising or publicity pertaining to distribution of the
    26   |   software without specific, written prior permission.
    27   |
    28   |   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
    29   |   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
    30   |   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
    31   |   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
    32   |   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    33   |   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    34   |  ***************************************/
    35   |
    36   | #ifndef CA_DEFS
    37   | #define CA_DEFS
    38   |
    39   | /************************************************************************
    40   |  * This is the definitions header file for the configuration module.  It
    41   |  * includes the definitions of data structures, external declarations and
    42   |  * definitions, definitions of sybolic constants.
    43   |  *
    44   |  ************************************************************************/
    45   |
    46   | #include <pthread.h>
    47   | #include <glib.h>
    48   |
    49   | #ifdef __cplusplus
    50   | extern "C" {
    51   | #endif
    52   |
    53   | /* Number of configurations variables. */
    54   | #define VARS 123
    55   |
    56   | #define SCOPE_GLOBAL 1
    57   | #define SCOPE_LOCAL 99
    58   |
    59   | /*
    60   |  * Define the length of a string to be 160 to cope with the
    61   |  * copyright statement.
    62   |  *
    63   |  */
    64   | #define STRLENGTH 256
    65   |
    66   | /*
    67   | 	* Define the length of strings to cope with the values of
    68   |  * various types of string variables.
    69   | 	*/
    70   | #define STRLENGTH_XS 40
    71   | #define STRLENGTH_S 80
    72   | #define STRLENGTH_M 160
    73   | #define STRLENGTH_L 320
    74   | #define STRLENGTH_XL 640
    75   | #define STRLENGTH_XXL 2560
    76   |
    77   | /*
    78   |  *  Define the maximum number of sources
    79   |  *
    80   |  */
    81   | #define CA_MAXSOURCES  100
    82   |
    83   |
    84   | /**********************************************
    85   |  * Default values for the SOURCE variables		*
    86   | 	*															*
    87   |  **********************************************/
    88   |
    89   |  #define CA_DEFHOST "rowan"
    90   |  #define CA_DEFPORT "4343"
    91   |  #define CA_DEFUSER "dbase"
    92   |  #define CA_DEFPASSWORD "encrypt1"
    93   |  #define CA_DEFDBNAME	"default-db"
    94   |
    95   |
    96   |
    97   | /**********************************************
    98   |  * Defintion of the dictionary structures.		*
    99   | 	*															*
    100  |  **********************************************/
    101  |
    102  | typedef struct dict_s	{
    103  | 				char varName[STRLENGTH];
    104  | 				char varSym[STRLENGTH];
    105  | 				char varType[STRLENGTH];
    106  | 				int varNum;
    107  | 				int varMandatory;
    108  | 				int varScope;
    109  | } dict_t;
    110  |
    111  | extern dict_t dictionary[];
    112  |
    113  |
    114  |
    115  |
    116  | /**********************************************
    117  |  * Definition of the values structures.			*
    118  |  *															*
    119  | 	**********************************************/
    120  |
    121  | typedef struct values_s	{
    122  | 			   GString *strPtr;	/* Pointer to the GString that contains the value. */
    123  | 				void *valPtr;	/* Pointer to the actual value. */
    124  | } values_t;
    125  |
    126  | /*
    127  |  * "extern" definition of variables that are defined elsewhere.
    128  |  */
    129  |
    130  |
    131  | extern values_t globals[];
    132  | extern values_t locals[];
    133  |
    134  | /*
    135  |  * "extern" definition of configuration variables, defined elsewhere.
    136  |  */
    137  | extern values_t confVars[];
    138  |
    139  | /* Mutex lock; used for synchronising changes. */
    140  | pthread_mutex_t Lock;
    141  |
    142  | /*
    143  | 	* New value of the bindport.
    144  | 	* This must be a global variable.
    145  |  * This variable is no longer needed.
    146  |  * char newPort[16];
    147  | 	*/
    148  |
    149  | /*
    150  |  * The following is needed for the SOURCE variable.  First,
    151  |  * we define the "database" structure.  Then, we define the
    152  |  * structure of an element of the linked list.  Lastly, we
    153  |  * define the linked list itself.
    154  |  */
    155  |
    156  | typedef struct ca_database_s	{
    157  |
    158  | 			char host[64];
    159  | 			int port;
    160  | 			char user[16];
    161  | 			char password[9];
    162  | 			char dbName[16];
    163  | 		} ca_database_t;
    164  |
    165  | typedef struct ca_mirror_s		{
    166  | 			char host[64];
    167  | 			int port;
    168  | 			char log[64];
    169  | 			int delay;
    170  | 			int protocolVer;
    171  | 			char mrName[16];
    172  | 		} ca_mirror_t;
    173  |
    174  | typedef struct ca_ripadmin_s	{
    175  | 			char host[64];
    176  | 			int port;
    177  | 			char user[16];
    178  | 			char password[9];
    179  | 			char tableName[72];
    180  | 		} ca_ripadmin_t;
    181  |
    182  | extern ca_database_t ripe;
    183  | extern ca_database_t arin;
    184  | extern ca_database_t radb;
    185  |
    186  | typedef struct ca_database_list_s		{
    187  | 			char name[16];
    188  | 			ca_database_t db;
    189  | 			int opMode;
    190  | 			ca_mirror_t nrtm;
    191  | 			int updPort;
    192  | 			char canupd[2];
    193  | 			char deflook[2];
    194  | 		} ca_database_list_t;
    195  |
    196  | /*
    197  | 	* Define the type of a source.
    198  |  * This is the name of a source and
    199  |  * the details of the database which
    200  |  * makes this source.
    201  |  */
    202  | typedef struct ca_dbSource_s	{
    203  | 			char name[16];
    204  | 			ca_database_t db;
    205  | 			int opMode;
    206  | 			ca_mirror_t nrtm;
    207  | 			int updPort;
    208  | 			char canupd[2];
    209  | 			char deflook[2];
    210  | 		} ca_dbSource_t;
    211  |
    212  | /*
    213  |  * Define the source handle:
    214  |  * this is a pointer to a source;
    215  |  * i.e. it is of type ca_dbSource_t.
    216  |  */
    217  | typedef ca_dbSource_t ca_SrcHdl_t;
    218  |
    219  |
    220  | /*
    221  |  * Define an updateSource.  This is used by dbupdate.
    222  |  *
    223  |  */
    224  | typedef struct ca_updDbSource_s	{
    225  | 			char name[16];
    226  | 			ca_database_t updDb;
    227  | 			char whoisd_host[32];
    228  | 			int qryPort;
    229  | 			int updPort;
    230  | 		} ca_updDbSource_t;
    231  |
    232  |
    233  |
    234  | extern ca_database_list_t ripeComponent;
    235  | extern ca_database_list_t arinComponent;
    236  | extern ca_database_list_t radbComponent;
    237  |
    238  | /*
    239  |  * typedef struct GSList {
    240  | 	*  	gpointer src;
    241  | 	*  	GSList *next;
    242  | 	* 	} ca_source_t;
    243  |  */
    244  |  /* gpointer src;		This points to a ca_database_list_t varialbe */
    245  |
    246  |
    247  | /*************************************************************
    248  |  * Definition of the default values for the SOURCE variable.	*
    249  |  *																				*
    250  |  *************************************************************/
    251  |
    252  | /*
    253  |  * char ca_defHost[64];
    254  |  * char ca_defPort[16];
    255  |  * char ca_defUser[16];
    256  |  * char ca_defPassword[9];
    257  |  * char ca_defdbName[16];
    258  |  */
    259  |
    260  | /*
    261  |  * extern char ca_defPort[16];
    262  |  * extern char ca_defHost[64];
    263  |  * extern char ca_defUser[16];
    264  |  * extern char ca_defPassword[9];
    265  |  * extern char ca_defdbName[16];
    266  |  */
    267  |
    268  | /*
    269  |  * The linked-list of sources.
    270  |  *
    271  |  */
    272  | extern GSList *sourceList;
    273  |
    274  | /*
    275  | 	* The linked-list of databases and mirrors used by ca_readSources()
    276  |  */
    277  | extern GSList *dbList;
    278  | extern GSList *nrtmList;
    279  |
    280  | /*
    281  |  */
    282  |
    283  | /*
    284  |  * extern ca_source_t *srcList;
    285  |  */
    286  |
    287  | /*
    288  |  * A varialbe of type GSList
    289  |  */
    290  | extern ca_dbSource_t *testSource;
    291  |
    292  |
    293  | /*
    294  |  * 20000609
    295  |  * Experiment:
    296  |  * define the variable mySrcList as type GSList;
    297  |  * use the extern modifier and put the "real" definition
    298  |  * of the variable elsewhere.
    299  |  *
    300  |  * extern GSList *mySrcList;
    301  |  */
    302  |
    303  | /*
    304  | 	* The test configuration file.
    305  |  * This is defined using a constant string, cf. Oualline, p.145.
    306  |  */
    307  | extern const char *testFile;
    308  | extern const char *tempFile;
    309  | extern const char *dictFile;
    310  | extern const char *confFile;
    311  | extern const char *sourcesFile;
    312  |
    313  | /*
    314  |  * Value returned by ca_getStorageLocation if the symbol for
    315  |  * a configuration variable cannot be found.
    316  |  *
    317  | 	* This value is also returned by ca_getType, if it cannot map
    318  |  * the name of a configuration variable to a data type.
    319  |  *
    320  |  */
    321  | #define NOT_FOUND -1
    322  | #define INCOMPLETE -1
    323  |
    324  | /*
    325  |  * Definition of the identifiers used in the sources configuration file.
    326  |  */
    327  | #define DATABASE_KEY	"DATABASE"
    328  | #define NRTM_KEY	"NRTM"
    329  | #define SOURCE_KEY "SOURCE"
    330  |
    331  | /*
    332  |  * Symbolic constants defined to represent data types.
    333  |
    334  |  * #define CA_INT 			11
    335  |  * #define CA_STRING 		12
    336  |  * #define CA_DIRLIST 	13
    337  |  * #define CA_BOOLEAN 	14
    338  |  * #define CA_SOURCETYPE		15
    339  | 	*/
    340  |
    341  | extern ca_dbSource_t *theSrc;
    342  |
    343  | /*
    344  | 	* Macros and const char * definitions for warning and error
    345  |  * messages.
    346  |  */
    347  |
    348  | extern const char *configWarningStr;
    349  | extern const char *configError_1Str;
    350  | extern const char *configError_2Str;
    351  | extern const char *configVarChk_OK_Str;
    352  |
    353  |
    354  | #ifdef __cplusplus
    355  | }
    356  | #endif
    357  |
    358  |
    359  | #endif /* CA_DEFS */