Changeset 90 for trunk/wifidog/src/conf.c
- Timestamp:
- 04/20/04 20:03:24 (9 years ago)
- Files:
-
- 1 modified
-
trunk/wifidog/src/conf.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/src/conf.c
r82 r90 28 28 29 29 #define DEFAULT_CONFIGFILE "/etc/wifidog.conf" 30 #define DEFAULT_DEBUGLEVEL D_LOG_DEBUG 30 #define DEFAULT_DAEMON 1 31 #define DEFAULT_DEBUGLEVEL LOG_INFO 31 32 #define DEFAULT_HTTPDMAXCONN 10 32 33 #define DEFAULT_GATEWAYID "default" … … 38 39 #define DEFAULT_FWSCRIPTS_PATH "." 39 40 #define DEFAULT_FWTYPE "." 41 #define DEFAULT_LOG_SYSLOG 0 42 #define DEFAULT_SYSLOG_FACILITY LOG_DAEMON 40 43 41 44 s_config config; … … 61 64 oFWType, 62 65 oUserClass, 66 oSyslogFacility, 63 67 } OpCodes; 64 68 … … 84 88 { "fwscriptspath", oFWScriptsPath }, 85 89 { "fwtype", oFWType }, 86 { "userclass", oUserClass }, 90 { "userclass", oUserClass }, 91 { "syslogfacility", oSyslogFacility }, 87 92 { NULL, oBadOption }, 88 93 }; … … 91 96 config_init(void) 92 97 { 93 debug( D_LOG_DEBUG, "Setting default config parameters");98 debug(LOG_DEBUG, "Setting default config parameters"); 94 99 config.configfile = (char *)malloc(255); 95 100 strcpy(config.configfile, DEFAULT_CONFIGFILE); 96 config.daemon = 1;97 101 config.debuglevel = DEFAULT_DEBUGLEVEL; 98 102 config.httpdmaxconn = DEFAULT_HTTPDMAXCONN; … … 112 116 config.userclasses = (char **)malloc(sizeof(char *) * 256); 113 117 memset(config.userclasses, 0, sizeof(char *) * 256); 118 config.syslog_facility = DEFAULT_SYSLOG_FACILITY; 119 config.daemon = -1; 120 config.log_syslog = DEFAULT_LOG_SYSLOG; 121 } 122 123 /** 124 * @brief Initialize the variables we override with the command line 125 * 126 * 127 * Initialize the variables we override with the command line after the config has been read 128 * if they haven't been initialized by the configuration file 129 */ 130 void 131 config_init_override(void) 132 { 133 if (!config.daemon) config.daemon = DEFAULT_DAEMON; 114 134 } 115 135 … … 123 143 return keywords[i].opcode; 124 144 125 debug( D_LOG_ERR, "%s: line %d: Bad configuration option: %s",145 debug(LOG_ERR, "%s: line %d: Bad configuration option: %s", 126 146 filename, linenum, cp); 127 147 return oBadOption; … … 135 155 int linenum = 0, opcode, value; 136 156 137 debug( D_LOG_INFO, "Reading configuration file '%s'", filename);157 debug(LOG_INFO, "Reading configuration file '%s'", filename); 138 158 139 159 if (!(fd = fopen(filename, "r"))) { 140 debug( D_LOG_ERR, "Could not open configuration file '%s', "160 debug(LOG_ERR, "Could not open configuration file '%s', " 141 161 "exiting...", filename); 142 162 exit(1); … … 172 192 173 193 if ((strncmp(s, "#", 1)) != 0) { 174 debug( D_LOG_DEBUG, "Parsing token: %s, "194 debug(LOG_DEBUG, "Parsing token: %s, " 175 195 "value: %s", s, p1); 176 196 opcode = parse_token(s, filename, linenum); … … 182 202 break; 183 203 case oDaemon: 184 if ( ((value = parse_value(p1)) != -1)) {204 if (config.daemon == -1 && ((value = parse_value(p1)) != -1)) { 185 205 config.daemon = value; 186 206 } … … 216 236 break; 217 237 case oBadOption: 238 debug(LOG_ERR, "Exiting..."); 218 239 exit(-1); 219 240 break; … … 229 250 case oFWType: 230 251 config.fwtype = get_string(p1); 252 break; 253 case oSyslogFacility: 254 sscanf(p1, "%d", &config.syslog_facility); 231 255 break; 232 256 } … … 295 319 296 320 if (missing_parms) { 297 debug( D_LOG_ERR, "Configuration is not complete, exiting...");321 debug(LOG_ERR, "Configuration is not complete, exiting..."); 298 322 exit(-1); 299 323 } … … 304 328 { 305 329 if (parm == NULL) { 306 debug( D_LOG_ERR, "%s is not set", parmname);330 debug(LOG_ERR, "%s is not set", parmname); 307 331 missing_parms = 1; 308 332 }
