Changes in conf.c [8961950:cd63d58]
Legend:
- Unmodified
- Added
- Removed
-
conf.c
r8961950 rcd63d58 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 ); 48 46 49 conf->iface = NULL; 47 conf->iface_in = NULL; 48 conf->iface_out = NULL; 50 49 conf->port = g_strdup( "6667" ); 51 50 conf->nofork = 0; … … 61 60 conf->pidfile = g_strdup( PIDFILE ); 62 61 conf->motdfile = g_strdup( ETCDIR "/motd.txt" ); 63 conf->welcomefile = g_strdup( ETCDIR "/welcome.txt" );64 62 conf->ping_interval = 180; 65 63 conf->ping_timeout = 300; … … 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 ); 78 } 79 80 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 ) 75 config_missing ++; 76 /* Whine after parsing the options if there was no -c pointing 77 at a *valid* configuration file. */ 78 } 79 80 while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hu:" ) ) >= 0 ) 81 81 /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ 82 82 { 83 83 if( opt == 'i' ) 84 84 { 85 conf->iface = g_strdup( optarg );85 conf->iface_in = g_strdup( optarg ); 86 86 } 87 87 else if( opt == 'p' ) … … 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 } … … 132 132 "\n" 133 133 " -I Classic/InetD mode. (Default)\n" 134 " -D Daemon mode. ( Still EXPERIMENTAL!)\n"134 " -D Daemon mode. (one process serves all)\n" 135 135 " -F Forking daemon. (one process per client)\n" 136 136 " -u Run daemon as specified user.\n" … … 144 144 " -d Specify alternative user configuration directory\n" 145 145 " -h Show this help page.\n" ); 146 return( NULL ); 147 } 148 else if( opt == 'R' ) 149 { 150 /* We can't load the statefile yet (and should make very sure we do this 151 only once), so set the filename here and load the state information 152 when initializing ForkDaemon. (This option only makes sense in that 153 mode anyway!) */ 154 ipc_master_set_statefile( optarg ); 146 return NULL; 155 147 } 156 148 else if( opt == 'u' ) … … 170 162 } 171 163 172 return( conf ); 164 if( config_missing ) 165 fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", global.conf_file ); 166 167 return conf; 173 168 } 174 169 … … 179 174 180 175 ini = ini_open( file ); 181 if( ini == NULL ) return ( -1 );176 if( ini == NULL ) return -1; 182 177 while( ini_read( ini ) ) 183 178 { … … 200 195 else if( g_strcasecmp( ini->key, "daemoninterface" ) == 0 ) 201 196 { 202 g_free( conf->iface );203 conf->iface = g_strdup( ini->value );197 g_free( conf->iface_in ); 198 conf->iface_in = g_strdup( ini->value ); 204 199 } 205 200 else if( g_strcasecmp( ini->key, "daemonport" ) == 0 ) … … 207 202 g_free( conf->port ); 208 203 conf->port = g_strdup( ini->value ); 204 } 205 else if( g_strcasecmp( ini->key, "clientinterface" ) == 0 ) 206 { 207 g_free( conf->iface_out ); 208 conf->iface_out = g_strdup( ini->value ); 209 209 } 210 210 else if( g_strcasecmp( ini->key, "authmode" ) == 0 ) … … 242 242 conf->motdfile = g_strdup( ini->value ); 243 243 } 244 else if( g_strcasecmp( ini->key, "welcomefile" ) == 0 )245 {246 g_free( conf->welcomefile );247 conf->welcomefile = g_strdup( ini->value );248 }249 244 else if( g_strcasecmp( ini->key, "account_storage" ) == 0 ) 250 245 { … … 255 250 { 256 251 g_strfreev( conf->migrate_storage ); 257 conf->migrate_storage = g_strsplit ( ini->value, " \t,;", -1 );252 conf->migrate_storage = g_strsplit_set( ini->value, " \t,;", -1 ); 258 253 } 259 254 else if( g_strcasecmp( ini->key, "pinginterval" ) == 0 ) … … 262 257 { 263 258 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 264 return ( 0 );259 return 0; 265 260 } 266 261 conf->ping_interval = i; … … 271 266 { 272 267 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 273 return ( 0 );268 return 0; 274 269 } 275 270 conf->ping_timeout = i; … … 283 278 fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); 284 279 g_free( url ); 285 return ( 0 );280 return 0; 286 281 } 287 282 … … 307 302 { 308 303 fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key ); 309 return ( 0 );304 return 0; 310 305 /* For now just ignore unknown keys... */ 311 306 } … … 315 310 fprintf( stderr, "Error: Unknown section [%s] in configuration file. " 316 311 "BitlBee configuration must be put in a [settings] section!\n", ini->section ); 317 return ( 0 );312 return 0; 318 313 } 319 314 } 320 315 ini_close( ini ); 321 316 322 return ( 1 );317 return 1; 323 318 } 324 319 … … 327 322 ini_t *ini; 328 323 329 ini = ini_open( CONF_FILE);324 ini = ini_open( global.conf_file ); 330 325 if( ini == NULL ) return; 331 326 while( ini_read( ini ) )
Note: See TracChangeset
for help on using the changeset viewer.