- Timestamp:
- 2008-02-16T17:15:31Z (17 years ago)
- Branches:
- master
- Children:
- fd9fa52
- Parents:
- 8961950 (diff), ca60550 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
conf.c
r8961950 r4eb4c0f 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 ); … … 67 65 proxytype = 0; 68 66 69 i = conf_loadini( conf, CONF_FILE);67 i = conf_loadini( conf, global.conf_file ); 70 68 if( i == 0 ) 71 69 { 72 fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", CONF_FILE);73 return ( NULL );70 fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", global.conf_file ); 71 return NULL; 74 72 } 75 73 else if( i == -1 ) 76 74 { 77 fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", CONF_FILE ); 75 config_missing ++; 76 /* Whine after parsing the options if there was no -c pointing 77 at a *valid* configuration file. */ 78 78 } 79 79 … … 107 107 else if( opt == 'c' ) 108 108 { 109 if( strcmp( CONF_FILE, optarg ) != 0 )110 { 111 g_free( CONF_FILE);112 CONF_FILE= g_strdup( optarg );109 if( strcmp( global.conf_file, optarg ) != 0 ) 110 { 111 g_free( global.conf_file ); 112 global.conf_file = g_strdup( optarg ); 113 113 g_free( conf ); 114 114 /* Re-evaluate arguments. Don't use this option twice, … … 116 116 works with all libcs BTW.. */ 117 117 optind = 1; 118 return ( conf_load( argc, argv ));118 return conf_load( argc, argv ); 119 119 } 120 120 } … … 144 144 " -d Specify alternative user configuration directory\n" 145 145 " -h Show this help page.\n" ); 146 return ( NULL );146 return NULL; 147 147 } 148 148 else if( opt == 'R' ) … … 170 170 } 171 171 172 return( conf ); 172 if( config_missing ) 173 fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", global.conf_file ); 174 175 return conf; 173 176 } 174 177 … … 179 182 180 183 ini = ini_open( file ); 181 if( ini == NULL ) return ( -1 );184 if( ini == NULL ) return -1; 182 185 while( ini_read( ini ) ) 183 186 { … … 262 265 { 263 266 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 264 return ( 0 );267 return 0; 265 268 } 266 269 conf->ping_interval = i; … … 271 274 { 272 275 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 273 return ( 0 );276 return 0; 274 277 } 275 278 conf->ping_timeout = i; … … 283 286 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 284 287 g_free( url ); 285 return ( 0 );288 return 0; 286 289 } 287 290 … … 307 310 { 308 311 fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key ); 309 return ( 0 );312 return 0; 310 313 /* For now just ignore unknown keys... */ 311 314 } … … 315 318 fprintf( stderr, "Error: Unknown section [%s] in configuration file. " 316 319 "BitlBee configuration must be put in a [settings] section!\n", ini->section ); 317 return ( 0 );320 return 0; 318 321 } 319 322 } 320 323 ini_close( ini ); 321 324 322 return ( 1 );325 return 1; 323 326 } 324 327 … … 327 330 ini_t *ini; 328 331 329 ini = ini_open( CONF_FILE);332 ini = ini_open( global.conf_file ); 330 333 if( ini == NULL ) return; 331 334 while( ini_read( ini ) )
Note: See TracChangeset
for help on using the changeset viewer.