- Timestamp:
- 2008-02-11T12:35:01Z (15 years ago)
- Branches:
- master
- Children:
- 1ba7e8f, 2799ff9
- Parents:
- 3038e47
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
conf.c
r3038e47 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 ); … … 66 64 proxytype = 0; 67 65 68 i = conf_loadini( conf, CONF_FILE);66 i = conf_loadini( conf, global.conf_file ); 69 67 if( i == 0 ) 70 68 { 71 fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", CONF_FILE);72 return ( NULL );69 fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", global.conf_file ); 70 return NULL; 73 71 } 74 72 else if( i == -1 ) 75 73 { 76 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. */ 77 77 } 78 78 … … 106 106 else if( opt == 'c' ) 107 107 { 108 if( strcmp( CONF_FILE, optarg ) != 0 )109 { 110 g_free( CONF_FILE);111 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 ); 112 112 g_free( conf ); 113 113 /* Re-evaluate arguments. Don't use this option twice, … … 115 115 works with all libcs BTW.. */ 116 116 optind = 1; 117 return ( conf_load( argc, argv ));117 return conf_load( argc, argv ); 118 118 } 119 119 } … … 143 143 " -d Specify alternative user configuration directory\n" 144 144 " -h Show this help page.\n" ); 145 return ( NULL );145 return NULL; 146 146 } 147 147 else if( opt == 'R' ) … … 169 169 } 170 170 171 return( conf ); 171 if( config_missing ) 172 fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", global.conf_file ); 173 174 return conf; 172 175 } 173 176 … … 178 181 179 182 ini = ini_open( file ); 180 if( ini == NULL ) return ( -1 );183 if( ini == NULL ) return -1; 181 184 while( ini_read( ini ) ) 182 185 { … … 256 259 { 257 260 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 258 return ( 0 );261 return 0; 259 262 } 260 263 conf->ping_interval = i; … … 265 268 { 266 269 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 267 return ( 0 );270 return 0; 268 271 } 269 272 conf->ping_timeout = i; … … 277 280 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 278 281 g_free( url ); 279 return ( 0 );282 return 0; 280 283 } 281 284 … … 301 304 { 302 305 fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key ); 303 return ( 0 );306 return 0; 304 307 /* For now just ignore unknown keys... */ 305 308 } … … 309 312 fprintf( stderr, "Error: Unknown section [%s] in configuration file. " 310 313 "BitlBee configuration must be put in a [settings] section!\n", ini->section ); 311 return ( 0 );314 return 0; 312 315 } 313 316 } 314 317 ini_close( ini ); 315 318 316 return ( 1 );319 return 1; 317 320 } 318 321 … … 321 324 ini_t *ini; 322 325 323 ini = ini_open( CONF_FILE);326 ini = ini_open( global.conf_file ); 324 327 if( ini == NULL ) return; 325 328 while( ini_read( ini ) )
Note: See TracChangeset
for help on using the changeset viewer.