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