1 | /************************************************************************ 2 | * This is the definitions header file for the configuration module. It 3 | * includes the definitions of data structures, external declarations and 4 | * definitions, defitinitions of sybolic constants. 5 | * 6 | ************************************************************************/ 7 | 8 | #include <pthread.h> 9 | #include <glib.h> 10 | 11 | /* Number of configurations variables. */ 12 | #define VARS 86 13 | 14 | #define SCOPE_GLOBAL 1 15 | #define SCOPE_LOCAL 99 16 | 17 | /* 18 | * Define the length of a string to be 160 to cope with the 19 | * copyright statement. 20 | * 21 | */ 22 | #define STRLENGTH 160 23 | 24 | /********************************************** 25 | * Default values for the SOURCE variables * 26 | * * 27 | **********************************************/ 28 | 29 | #define CA_DEFHOST "rowan" 30 | #define CA_DEFPORT "4343" 31 | #define CA_DEFUSER "dbase" 32 | #define CA_DEFPASSWORD "encrypt1" 33 | #define CA_DEFDBNAME "default-db" 34 | 35 | 36 | 37 | /********************************************** 38 | * Defintion of the dictionary structures. * 39 | * * 40 | **********************************************/ 41 | 42 | typedef struct dict_s { 43 | char varName[STRLENGTH]; 44 | char varSym[STRLENGTH]; 45 | char varType[STRLENGTH]; 46 | int varScope; 47 | int varNum; 48 | } dict_t; 49 | 50 | 51 | extern dict_t dictionary[]; 52 | 53 | 54 | /********************************************** 55 | * Definition of the values structures. * 56 | * * 57 | **********************************************/ 58 | 59 | typedef struct values_s { 60 | char *strPtr; /* Pointer to the string that contains the value. */ 61 | void *valPtr; /* Pointer to the actual value. */ 62 | } values_t; 63 | 64 | /* 65 | * "extern" definition of variables that are defined elsewhere. 66 | */ 67 | 68 | 69 | extern values_t globals[]; 70 | extern values_t locals[]; 71 | 72 | /* 73 | * "extern" definition of configuration variables, defined elsewhere. 74 | */ 75 | extern values_t confVars[]; 76 | 77 | /* Mutex lock; used for synchronising changes. */ 78 | pthread_mutex_t Lock; 79 | 80 | /* 81 | * New value of the bindport. 82 | * This must be a global variable. 83 | */ 84 | 85 | char newPort[16]; 86 | 87 | /* 88 | * The following is needed for the SOURCE variable. First, 89 | * we define the "database" structure. Then, we define the 90 | * structure of an element of the linked list. Lastly, we 91 | * define the linked list itself. 92 | */ 93 | 94 | typedef struct ca_database_s { 95 | 96 | char host[64]; 97 | char port[16]; 98 | char user[16]; 99 | char password[9]; 100 | char dbName[16]; 101 | } ca_database_t; 102 | 103 | extern ca_database_t ripe; 104 | extern ca_database_t arin; 105 | extern ca_database_t radb; 106 | 107 | typedef struct ca_database_list_s { 108 | char name[16]; 109 | ca_database_t db; 110 | } ca_database_list_t; 111 | 112 | extern ca_database_list_t ripeComponent; 113 | extern ca_database_list_t arinComponent; 114 | extern ca_database_list_t radbComponent; 115 | 116 | typedef struct GSList { 117 | gpointer src; /* This points to a ca_database_list_t varialbe */ 118 | GSList *next; 119 | } ca_source_t; 120 | 121 | 122 | /************************************************************* 123 | * Definition of the default values for the SOURCE variable. * 124 | * * 125 | *************************************************************/ 126 | 127 | /* 128 | * char ca_defHost[64]; 129 | * char ca_defPort[16]; 130 | * char ca_defUser[16]; 131 | * char ca_defPassword[9]; 132 | * char ca_defdbName[16]; 133 | */ 134 | 135 | /* 136 | * extern char ca_defPort[16]; 137 | * extern char ca_defHost[64]; 138 | * extern char ca_defUser[16]; 139 | * extern char ca_defPassword[9]; 140 | * extern char ca_defdbName[16]; 141 | */ 142 | 143 | /* 144 | * The linked-list of sources. 145 | * 146 | */ 147 | extern GSList *sourceList; 148 | extern ca_source_t *srcList; 149 | 150 | /* 151 | * The test configuration file. 152 | * This is defined using a constant string, cf. Oualline, p.145. 153 | */ 154 | extern const char *testFile; 155 | extern const char *tempFile; 156 | extern const char *dictFile; 157 | extern const char *confFile; 158 | 159 | /* 160 | * Value returned by ca_getStorageLocation if the symbol for 161 | * a configuration variable cannot be found. 162 | * 163 | * This value is also returned by ca_getType, if it cannot map 164 | * the name of a configuration variable to a data type. 165 | * 166 | */ 167 | #define NOT_FOUND -1 168 | 169 | /* 170 | * Symbolic constants defined to represent data types. 171 | 172 | * #define CA_INT 11 173 | * #define CA_STRING 12 174 | * #define CA_DIRLIST 13 175 | * #define CA_BOOLEAN 14 176 | * #define CA_SOURCETYPE 15 177 | */ 178 | 179 |