Changeset 3fbce97 for conf.c


Ignore:
Timestamp:
2016-09-24T20:14:34Z (8 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Children:
ba52ac5
Parents:
63cad66 (diff), 82cb190 (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.
Message:

Merge branch 'master' into parson

File:
1 edited

Legend:

Unmodified
Added
Removed
  • conf.c

    r63cad66 r3fbce97  
    3737
    3838static int conf_loadini(conf_t *conf, char *file);
     39static void conf_free(conf_t *conf);
    3940
    4041conf_t *conf_load(int argc, char *argv[])
     
    7374        if (i == 0) {
    7475                fprintf(stderr, "Error: Syntax error in configuration file `%s'.\n", global.conf_file);
     76                conf_free(conf);
    7577                return NULL;
    7678        } else if (i == -1) {
     
    104106                                g_free(global.conf_file);
    105107                                global.conf_file = g_strdup(optarg);
    106                                 g_free(conf);
     108                                conf_free(conf);
    107109                                /* Re-evaluate arguments. Don't use this option twice,
    108110                                   you'll end up in an infinite loop! Hope this trick
     
    135137                               "  -h  Show this help page.\n"
    136138                               "  -V  Show version info.\n");
     139                        conf_free(conf);
    137140                        return NULL;
    138141                } else if (opt == 'V') {
    139                         printf("BitlBee %s\nAPI version %06x\n",
    140                                BITLBEE_VERSION, BITLBEE_VERSION_CODE);
     142                        printf("BitlBee %s\nAPI version %06x\nConfigure args: %s\n",
     143                               BITLBEE_VERSION, BITLBEE_VERSION_CODE, BITLBEE_CONFIGURE_ARGS);
     144                        conf_free(conf);
    141145                        return NULL;
    142146                } else if (opt == 'u') {
     
    162166                   they're secure when in fact they're not. */
    163167                fprintf(stderr, "Error: Could not read CA file %s: %s\n", conf->cafile, strerror(errno));
     168                conf_free(conf);
    164169                return NULL;
    165170        }
    166171
    167172        return conf;
     173}
     174
     175static void conf_free(conf_t *conf)
     176{
     177        /* Free software means users have the four essential freedoms:
     178           0. to run the program,
     179           2. to study and change the program in source code form,
     180           2. to redistribute exact copies, and
     181           3. to distribute modified versions
     182        */
     183        g_free(conf->auth_pass);
     184        g_free(conf->cafile);
     185        g_free(conf->configdir);
     186        g_free(conf->ft_listen);
     187        g_free(conf->hostname);
     188        g_free(conf->iface_in);
     189        g_free(conf->iface_out);
     190        g_free(conf->motdfile);
     191        g_free(conf->oper_pass);
     192        g_free(conf->pidfile);
     193        g_free(conf->plugindir);
     194        g_free(conf->port);
     195        g_free(conf->primary_storage);
     196        g_free(conf->user);
     197        g_strfreev(conf->migrate_storage);
     198        g_strfreev(conf->protocols);
     199        g_free(conf);
     200
    168201}
    169202
     
    219252                                g_free(conf->configdir);
    220253                                conf->configdir = g_strdup(ini->value);
     254                        } else if (g_strcasecmp(ini->key, "plugindir") == 0) {
     255                                g_free(conf->plugindir);
     256                                conf->plugindir = g_strdup(ini->value);
    221257                        } else if (g_strcasecmp(ini->key, "motdfile") == 0) {
    222258                                g_free(conf->motdfile);
     
    259295                                } else if (url->proto == PROTO_SOCKS5) {
    260296                                        proxytype = PROXY_SOCKS5;
     297                                } else if (url->proto == PROTO_SOCKS4A) {
     298                                        proxytype = PROXY_SOCKS4A;
    261299                                }
    262300
Note: See TracChangeset for help on using the changeset viewer.