- Timestamp:
- 2008-02-15T17:38:57Z (16 years ago)
- Branches:
- master
- Children:
- 506e61b
- Parents:
- 0fbd3a6d (diff), eeb85a8 (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
r0fbd3a6d r1ba7e8f 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 { … … 257 260 { 258 261 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 259 return ( 0 );262 return 0; 260 263 } 261 264 conf->ping_interval = i; … … 266 269 { 267 270 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 268 return ( 0 );271 return 0; 269 272 } 270 273 conf->ping_timeout = i; … … 278 281 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 279 282 g_free( url ); 280 return ( 0 );283 return 0; 281 284 } 282 285 … … 302 305 { 303 306 fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key ); 304 return ( 0 );307 return 0; 305 308 /* For now just ignore unknown keys... */ 306 309 } … … 310 313 fprintf( stderr, "Error: Unknown section [%s] in configuration file. " 311 314 "BitlBee configuration must be put in a [settings] section!\n", ini->section ); 312 return ( 0 );315 return 0; 313 316 } 314 317 } 315 318 ini_close( ini ); 316 319 317 return ( 1 );320 return 1; 318 321 } 319 322 … … 322 325 ini_t *ini; 323 326 324 ini = ini_open( CONF_FILE);327 ini = ini_open( global.conf_file ); 325 328 if( ini == NULL ) return; 326 329 while( ini_read( ini ) )
Note: See TracChangeset
for help on using the changeset viewer.