Changeset eeb85a8


Ignore:
Timestamp:
2008-02-11T12:35:01Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
1ba7e8f, 2799ff9
Parents:
3038e47
Message:

Got rid of some noise at startup: complaining when the default configuration
file couldn't be found while the user specified an alternative location with
the -c option, and double complaints about /var/lib/bitlbee/ permissions.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.h

    r3038e47 reeb85a8  
    122122#define CONF_FILE_DEF ETCDIR "bitlbee.conf"
    123123
    124 extern char *CONF_FILE;
    125 
    126124#include "irc.h"
    127125#include "storage.h"
     
    145143        gint listen_watch_source_id;
    146144        help_t *help;
     145        char *conf_file;
    147146        conf_t *conf;
    148147        GList *storage; /* The first backend in the list will be used for saving */
  • conf.c

    r3038e47 reeb85a8  
    3636#include "proxy.h"
    3737
    38 char *CONF_FILE;
    39 
    4038static int conf_loadini( conf_t *conf, char *file );
    4139
     
    4341{
    4442        conf_t *conf;
    45         int opt, i;
     43        int opt, i, config_missing = 0;
    4644       
    4745        conf = g_new0( conf_t, 1 );
     
    6664        proxytype = 0;
    6765       
    68         i = conf_loadini( conf, CONF_FILE );
     66        i = conf_loadini( conf, global.conf_file );
    6967        if( i == 0 )
    7068        {
    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;
    7371        }
    7472        else if( i == -1 )
    7573        {
    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. */
    7777        }
    7878       
     
    106106                else if( opt == 'c' )
    107107                {
    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 );
    112112                                g_free( conf );
    113113                                /* Re-evaluate arguments. Don't use this option twice,
     
    115115                                   works with all libcs BTW.. */
    116116                                optind = 1;
    117                                 return( conf_load( argc, argv ) );
     117                                return conf_load( argc, argv );
    118118                        }
    119119                }
     
    143143                                "  -d  Specify alternative user configuration directory\n"
    144144                                "  -h  Show this help page.\n" );
    145                         return( NULL );
     145                        return NULL;
    146146                }
    147147                else if( opt == 'R' )
     
    169169        }
    170170       
    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;
    172175}
    173176
     
    178181       
    179182        ini = ini_open( file );
    180         if( ini == NULL ) return( -1 );
     183        if( ini == NULL ) return -1;
    181184        while( ini_read( ini ) )
    182185        {
     
    256259                                {
    257260                                        fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value );
    258                                         return( 0 );
     261                                        return 0;
    259262                                }
    260263                                conf->ping_interval = i;
     
    265268                                {
    266269                                        fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value );
    267                                         return( 0 );
     270                                        return 0;
    268271                                }
    269272                                conf->ping_timeout = i;
     
    277280                                        fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value );
    278281                                        g_free( url );
    279                                         return( 0 );
     282                                        return 0;
    280283                                }
    281284                               
     
    301304                        {
    302305                                fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key );
    303                                 return( 0 );
     306                                return 0;
    304307                                /* For now just ignore unknown keys... */
    305308                        }
     
    309312                        fprintf( stderr, "Error: Unknown section [%s] in configuration file. "
    310313                                         "BitlBee configuration must be put in a [settings] section!\n", ini->section );
    311                         return( 0 );
     314                        return 0;
    312315                }
    313316        }
    314317        ini_close( ini );
    315318       
    316         return( 1 );
     319        return 1;
    317320}
    318321
     
    321324        ini_t *ini;
    322325       
    323         ini = ini_open( CONF_FILE );
     326        ini = ini_open( global.conf_file );
    324327        if( ini == NULL ) return;
    325328        while( ini_read( ini ) )
  • irc_commands.c

    r3038e47 reeb85a8  
    571571                ipc_to_master( cmd );
    572572       
    573         irc_reply( irc, 382, "%s :Rehashing", CONF_FILE );
     573        irc_reply( irc, 382, "%s :Rehashing", global.conf_file );
    574574}
    575575
  • storage_text.c

    r3038e47 reeb85a8  
    3030static void text_init (void)
    3131{
    32         if( access( global.conf->configdir, F_OK ) != 0 )
    33                 log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", global.conf->configdir );
    34         else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 )
    35                 log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir );
     32        /* Don't complain about the configuration directory anymore, leave it
     33           up to the XML storage module, which uses the same directory for it
     34           anyway. Nobody should be using just the text plugin anymore since
     35           it's read only! */
    3636}
    3737
  • storage_xml.c

    r3038e47 reeb85a8  
    263263{
    264264        if( access( global.conf->configdir, F_OK ) != 0 )
    265                 log_message( LOGLVL_WARNING, "The configuration directory %s does not exist. Configuration won't be saved.", global.conf->configdir );
     265                log_message( LOGLVL_WARNING, "The configuration directory `%s' does not exist. Configuration won't be saved.", global.conf->configdir );
    266266        else if( access( global.conf->configdir, R_OK ) != 0 || access( global.conf->configdir, W_OK ) != 0 )
    267                 log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to %s.", global.conf->configdir );
     267                log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to `%s'.", global.conf->configdir );
    268268}
    269269
  • unix.c

    r3038e47 reeb85a8  
    4747       
    4848        log_init();
    49         CONF_FILE = g_strdup( CONF_FILE_DEF );
     49        global.conf_file = g_strdup( CONF_FILE_DEF );
    5050        global.conf = conf_load( argc, argv );
    5151        if( global.conf == NULL )
Note: See TracChangeset for help on using the changeset viewer.