Changes in conf.c [8961950:eeb85a8]
Legend:
- Unmodified
- Added
- Removed
-
conf.c
r8961950 reeb85a8 36 36 #include "proxy.h" 37 37 38 char *CONF_FILE;39 40 38 static int conf_loadini( conf_t *conf, char *file ); 41 39 … … 43 41 { 44 42 conf_t *conf; 45 int opt, i ;43 int opt, i, config_missing = 0; 46 44 47 45 conf = g_new0( conf_t, 1 ); … … 61 59 conf->pidfile = g_strdup( PIDFILE ); 62 60 conf->motdfile = g_strdup( ETCDIR "/motd.txt" ); 63 conf->welcomefile = g_strdup( ETCDIR "/welcome.txt" );64 61 conf->ping_interval = 180; 65 62 conf->ping_timeout = 300; … … 67 64 proxytype = 0; 68 65 69 i = conf_loadini( conf, CONF_FILE);66 i = conf_loadini( conf, global.conf_file ); 70 67 if( i == 0 ) 71 68 { 72 fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", CONF_FILE);73 return ( NULL );69 fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", global.conf_file ); 70 return NULL; 74 71 } 75 72 else if( i == -1 ) 76 73 { 77 fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", CONF_FILE ); 74 config_missing ++; 75 /* Whine after parsing the options if there was no -c pointing 76 at a *valid* configuration file. */ 78 77 } 79 78 … … 107 106 else if( opt == 'c' ) 108 107 { 109 if( strcmp( CONF_FILE, optarg ) != 0 )110 { 111 g_free( CONF_FILE);112 CONF_FILE= g_strdup( optarg );108 if( strcmp( global.conf_file, optarg ) != 0 ) 109 { 110 g_free( global.conf_file ); 111 global.conf_file = g_strdup( optarg ); 113 112 g_free( conf ); 114 113 /* Re-evaluate arguments. Don't use this option twice, … … 116 115 works with all libcs BTW.. */ 117 116 optind = 1; 118 return ( conf_load( argc, argv ));117 return conf_load( argc, argv ); 119 118 } 120 119 } … … 144 143 " -d Specify alternative user configuration directory\n" 145 144 " -h Show this help page.\n" ); 146 return ( NULL );145 return NULL; 147 146 } 148 147 else if( opt == 'R' ) … … 170 169 } 171 170 172 return( conf ); 171 if( config_missing ) 172 fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", global.conf_file ); 173 174 return conf; 173 175 } 174 176 … … 179 181 180 182 ini = ini_open( file ); 181 if( ini == NULL ) return ( -1 );183 if( ini == NULL ) return -1; 182 184 while( ini_read( ini ) ) 183 185 { … … 242 244 conf->motdfile = g_strdup( ini->value ); 243 245 } 244 else if( g_strcasecmp( ini->key, "welcomefile" ) == 0 )245 {246 g_free( conf->welcomefile );247 conf->welcomefile = g_strdup( ini->value );248 }249 246 else if( g_strcasecmp( ini->key, "account_storage" ) == 0 ) 250 247 { … … 262 259 { 263 260 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 264 return ( 0 );261 return 0; 265 262 } 266 263 conf->ping_interval = i; … … 271 268 { 272 269 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 273 return ( 0 );270 return 0; 274 271 } 275 272 conf->ping_timeout = i; … … 283 280 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 284 281 g_free( url ); 285 return ( 0 );282 return 0; 286 283 } 287 284 … … 307 304 { 308 305 fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key ); 309 return ( 0 );306 return 0; 310 307 /* For now just ignore unknown keys... */ 311 308 } … … 315 312 fprintf( stderr, "Error: Unknown section [%s] in configuration file. " 316 313 "BitlBee configuration must be put in a [settings] section!\n", ini->section ); 317 return ( 0 );314 return 0; 318 315 } 319 316 } 320 317 ini_close( ini ); 321 318 322 return ( 1 );319 return 1; 323 320 } 324 321 … … 327 324 ini_t *ini; 328 325 329 ini = ini_open( CONF_FILE);326 ini = ini_open( global.conf_file ); 330 327 if( ini == NULL ) return; 331 328 while( ini_read( ini ) )
Note: See TracChangeset
for help on using the changeset viewer.