[5ebff60] | 1 | /********************************************************************\ |
---|
[b7d3cc34] | 2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
| 3 | * * |
---|
[c92e6801] | 4 | * Copyright 2002-2005 Wilmer van der Gaast and others * |
---|
[b7d3cc34] | 5 | \********************************************************************/ |
---|
| 6 | |
---|
| 7 | /* Configuration reading code */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | This program is free software; you can redistribute it and/or modify |
---|
| 11 | it under the terms of the GNU General Public License as published by |
---|
| 12 | the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | (at your option) any later version. |
---|
| 14 | |
---|
| 15 | This program is distributed in the hope that it will be useful, |
---|
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | GNU General Public License for more details. |
---|
| 19 | |
---|
| 20 | You should have received a copy of the GNU General Public License with |
---|
| 21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
[6f10697] | 22 | if not, write to the Free Software Foundation, Inc., 51 Franklin St., |
---|
| 23 | Fifth Floor, Boston, MA 02110-1301 USA |
---|
[b7d3cc34] | 24 | */ |
---|
| 25 | |
---|
| 26 | #include "bitlbee.h" |
---|
| 27 | |
---|
| 28 | #include <stdio.h> |
---|
| 29 | #include <string.h> |
---|
| 30 | #include <stdlib.h> |
---|
| 31 | #include "conf.h" |
---|
| 32 | #include "ini.h" |
---|
| 33 | #include "url.h" |
---|
[54879ab] | 34 | #include "ipc.h" |
---|
[b7d3cc34] | 35 | |
---|
[df1694b] | 36 | #include "proxy.h" |
---|
[b7d3cc34] | 37 | |
---|
[5ebff60] | 38 | static int conf_loadini(conf_t *conf, char *file); |
---|
[49f1105] | 39 | static void conf_free(conf_t *conf); |
---|
[b7d3cc34] | 40 | |
---|
[5ebff60] | 41 | conf_t *conf_load(int argc, char *argv[]) |
---|
[b7d3cc34] | 42 | { |
---|
| 43 | conf_t *conf; |
---|
[eeb85a8] | 44 | int opt, i, config_missing = 0; |
---|
[2e5f594] | 45 | int version_happened = 0; |
---|
[5ebff60] | 46 | |
---|
| 47 | conf = g_new0(conf_t, 1); |
---|
| 48 | |
---|
[aefaac3a] | 49 | conf->iface_in = NULL; |
---|
| 50 | conf->iface_out = NULL; |
---|
[5ebff60] | 51 | conf->port = g_strdup("6667"); |
---|
[b7d3cc34] | 52 | conf->nofork = 0; |
---|
| 53 | conf->verbose = 0; |
---|
[5ebff60] | 54 | conf->primary_storage = g_strdup("xml"); |
---|
| 55 | conf->migrate_storage = g_strsplit("text", ",", -1); |
---|
[b7d3cc34] | 56 | conf->runmode = RUNMODE_INETD; |
---|
| 57 | conf->authmode = AUTHMODE_OPEN; |
---|
[8e6ecfe] | 58 | conf->auth_backend = NULL; |
---|
[d25f6fc] | 59 | conf->auth_pass = NULL; |
---|
| 60 | conf->oper_pass = NULL; |
---|
[446a23e] | 61 | conf->allow_account_add = 1; |
---|
[5ebff60] | 62 | conf->configdir = g_strdup(CONFIG); |
---|
| 63 | conf->plugindir = g_strdup(PLUGINDIR); |
---|
| 64 | conf->pidfile = g_strdup(PIDFILE); |
---|
| 65 | conf->motdfile = g_strdup(ETCDIR "/motd.txt"); |
---|
[b7d3cc34] | 66 | conf->ping_interval = 180; |
---|
| 67 | conf->ping_timeout = 300; |
---|
[aaf92a9] | 68 | conf->user = NULL; |
---|
[a02f34f] | 69 | conf->ft_max_size = SIZE_MAX; |
---|
| 70 | conf->ft_max_kbps = G_MAXUINT; |
---|
| 71 | conf->ft_listen = NULL; |
---|
[90cd6c4] | 72 | conf->protocols = NULL; |
---|
[486ddb5] | 73 | conf->cafile = NULL; |
---|
[f4a5940] | 74 | proxytype = 0; |
---|
[5ebff60] | 75 | |
---|
| 76 | i = conf_loadini(conf, global.conf_file); |
---|
| 77 | if (i == 0) { |
---|
| 78 | fprintf(stderr, "Error: Syntax error in configuration file `%s'.\n", global.conf_file); |
---|
[c2969f9] | 79 | conf_free(conf); |
---|
[eeb85a8] | 80 | return NULL; |
---|
[5ebff60] | 81 | } else if (i == -1) { |
---|
| 82 | config_missing++; |
---|
[eeb85a8] | 83 | /* Whine after parsing the options if there was no -c pointing |
---|
| 84 | at a *valid* configuration file. */ |
---|
[b7d3cc34] | 85 | } |
---|
[5ebff60] | 86 | |
---|
| 87 | while (argc > 0 && (opt = getopt(argc, argv, "i:p:P:nvIDFc:d:hu:V")) >= 0) { |
---|
| 88 | /* ^^^^ Just to make sure we skip this step from the REHASH handler. */ |
---|
| 89 | if (opt == 'i') { |
---|
| 90 | conf->iface_in = g_strdup(optarg); |
---|
| 91 | } else if (opt == 'p') { |
---|
| 92 | g_free(conf->port); |
---|
| 93 | conf->port = g_strdup(optarg); |
---|
| 94 | } else if (opt == 'P') { |
---|
| 95 | g_free(conf->pidfile); |
---|
| 96 | conf->pidfile = g_strdup(optarg); |
---|
| 97 | } else if (opt == 'n') { |
---|
[74c119d] | 98 | conf->nofork = 1; |
---|
[5ebff60] | 99 | } else if (opt == 'v') { |
---|
[74c119d] | 100 | conf->verbose = 1; |
---|
[5ebff60] | 101 | } else if (opt == 'I') { |
---|
[74c119d] | 102 | conf->runmode = RUNMODE_INETD; |
---|
[5ebff60] | 103 | } else if (opt == 'D') { |
---|
[74c119d] | 104 | conf->runmode = RUNMODE_DAEMON; |
---|
[5ebff60] | 105 | } else if (opt == 'F') { |
---|
[74c119d] | 106 | conf->runmode = RUNMODE_FORKDAEMON; |
---|
[5ebff60] | 107 | } else if (opt == 'c') { |
---|
| 108 | if (strcmp(global.conf_file, optarg) != 0) { |
---|
| 109 | g_free(global.conf_file); |
---|
| 110 | global.conf_file = g_strdup(optarg); |
---|
[49f1105] | 111 | conf_free(conf); |
---|
[5ebff60] | 112 | /* Re-evaluate arguments. Don't use this option twice, |
---|
[f4a5940] | 113 | you'll end up in an infinite loop! Hope this trick |
---|
| 114 | works with all libcs BTW.. */ |
---|
[74c119d] | 115 | optind = 1; |
---|
[5ebff60] | 116 | return conf_load(argc, argv); |
---|
[b7d3cc34] | 117 | } |
---|
[5ebff60] | 118 | } else if (opt == 'd') { |
---|
| 119 | g_free(conf->configdir); |
---|
| 120 | conf->configdir = g_strdup(optarg); |
---|
| 121 | } else if (opt == 'h') { |
---|
| 122 | printf("Usage: bitlbee [-D/-F [-i <interface>] [-p <port>] [-n] [-v]] [-I]\n" |
---|
| 123 | " [-c <file>] [-d <dir>] [-x] [-h]\n" |
---|
| 124 | "\n" |
---|
| 125 | "An IRC-to-other-chat-networks gateway\n" |
---|
| 126 | "\n" |
---|
| 127 | " -I Classic/InetD mode. (Default)\n" |
---|
| 128 | " -D Daemon mode. (one process serves all)\n" |
---|
| 129 | " -F Forking daemon. (one process per client)\n" |
---|
| 130 | " -u Run daemon as specified user.\n" |
---|
| 131 | " -P Specify PID-file (not for inetd mode)\n" |
---|
| 132 | " -i Specify the interface (by IP address) to listen on.\n" |
---|
| 133 | " (Default: 0.0.0.0 (any interface))\n" |
---|
| 134 | " -p Port number to listen on. (Default: 6667)\n" |
---|
| 135 | " -n Don't fork.\n" |
---|
| 136 | " -v Be verbose (only works in combination with -n)\n" |
---|
| 137 | " -c Load alternative configuration file\n" |
---|
| 138 | " -d Specify alternative user configuration directory\n" |
---|
| 139 | " -x Command-line interface to password encryption/hashing\n" |
---|
| 140 | " -h Show this help page.\n" |
---|
| 141 | " -V Show version info.\n"); |
---|
[c2969f9] | 142 | conf_free(conf); |
---|
[3d1481f] | 143 | return NULL; |
---|
[5ebff60] | 144 | } else if (opt == 'V') { |
---|
[2e5f594] | 145 | printf("BitlBee %s\n", BITLBEE_VERSION); |
---|
| 146 | /* the rest of the version string is displayed below, for ld -vvv compatibility*/ |
---|
| 147 | version_happened = TRUE; |
---|
[5ebff60] | 148 | } else if (opt == 'u') { |
---|
| 149 | g_free(conf->user); |
---|
| 150 | conf->user = g_strdup(optarg); |
---|
[aaf92a9] | 151 | } |
---|
[b7d3cc34] | 152 | } |
---|
[5ebff60] | 153 | |
---|
[2e5f594] | 154 | if (version_happened) { |
---|
| 155 | printf("API version %06x\nConfigure args: %s\n", |
---|
| 156 | BITLBEE_VERSION_CODE, BITLBEE_CONFIGURE_ARGS); |
---|
| 157 | conf_free(conf); |
---|
| 158 | return NULL; |
---|
| 159 | } |
---|
| 160 | |
---|
[5ebff60] | 161 | if (conf->configdir[strlen(conf->configdir) - 1] != '/') { |
---|
| 162 | char *s = g_new(char, strlen(conf->configdir) + 2); |
---|
| 163 | |
---|
| 164 | sprintf(s, "%s/", conf->configdir); |
---|
| 165 | g_free(conf->configdir); |
---|
[b7d3cc34] | 166 | conf->configdir = s; |
---|
| 167 | } |
---|
[5ebff60] | 168 | |
---|
| 169 | if (config_missing) { |
---|
| 170 | fprintf(stderr, "Warning: Unable to read configuration file `%s'.\n", global.conf_file); |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | if (conf->cafile && access(conf->cafile, R_OK) != 0) { |
---|
[af5764e] | 174 | /* Let's treat this as a serious problem so people won't think |
---|
| 175 | they're secure when in fact they're not. */ |
---|
[5ebff60] | 176 | fprintf(stderr, "Error: Could not read CA file %s: %s\n", conf->cafile, strerror(errno)); |
---|
[c2969f9] | 177 | conf_free(conf); |
---|
[af5764e] | 178 | return NULL; |
---|
| 179 | } |
---|
[5ebff60] | 180 | |
---|
[eeb85a8] | 181 | return conf; |
---|
[b7d3cc34] | 182 | } |
---|
| 183 | |
---|
[49f1105] | 184 | static void conf_free(conf_t *conf) |
---|
| 185 | { |
---|
| 186 | /* Free software means users have the four essential freedoms: |
---|
| 187 | 0. to run the program, |
---|
| 188 | 2. to study and change the program in source code form, |
---|
| 189 | 2. to redistribute exact copies, and |
---|
| 190 | 3. to distribute modified versions |
---|
| 191 | */ |
---|
| 192 | g_free(conf->auth_pass); |
---|
| 193 | g_free(conf->cafile); |
---|
| 194 | g_free(conf->configdir); |
---|
| 195 | g_free(conf->ft_listen); |
---|
| 196 | g_free(conf->hostname); |
---|
| 197 | g_free(conf->iface_in); |
---|
| 198 | g_free(conf->iface_out); |
---|
| 199 | g_free(conf->motdfile); |
---|
| 200 | g_free(conf->oper_pass); |
---|
| 201 | g_free(conf->pidfile); |
---|
| 202 | g_free(conf->plugindir); |
---|
| 203 | g_free(conf->port); |
---|
| 204 | g_free(conf->primary_storage); |
---|
| 205 | g_free(conf->user); |
---|
| 206 | g_strfreev(conf->migrate_storage); |
---|
| 207 | g_strfreev(conf->protocols); |
---|
| 208 | g_free(conf); |
---|
| 209 | |
---|
| 210 | } |
---|
| 211 | |
---|
[5ebff60] | 212 | static int conf_loadini(conf_t *conf, char *file) |
---|
[b7d3cc34] | 213 | { |
---|
| 214 | ini_t *ini; |
---|
| 215 | int i; |
---|
[5ebff60] | 216 | |
---|
| 217 | ini = ini_open(file); |
---|
| 218 | if (ini == NULL) { |
---|
| 219 | return -1; |
---|
| 220 | } |
---|
| 221 | while (ini_read(ini)) { |
---|
| 222 | if (g_strcasecmp(ini->section, "settings") == 0) { |
---|
| 223 | if (g_strcasecmp(ini->key, "runmode") == 0) { |
---|
| 224 | if (g_strcasecmp(ini->value, "daemon") == 0) { |
---|
[b7d3cc34] | 225 | conf->runmode = RUNMODE_DAEMON; |
---|
[5ebff60] | 226 | } else if (g_strcasecmp(ini->value, "forkdaemon") == 0) { |
---|
[d25f6fc] | 227 | conf->runmode = RUNMODE_FORKDAEMON; |
---|
[5ebff60] | 228 | } else { |
---|
[b7d3cc34] | 229 | conf->runmode = RUNMODE_INETD; |
---|
[5ebff60] | 230 | } |
---|
| 231 | } else if (g_strcasecmp(ini->key, "pidfile") == 0) { |
---|
| 232 | g_free(conf->pidfile); |
---|
| 233 | conf->pidfile = g_strdup(ini->value); |
---|
| 234 | } else if (g_strcasecmp(ini->key, "daemoninterface") == 0) { |
---|
| 235 | g_free(conf->iface_in); |
---|
| 236 | conf->iface_in = g_strdup(ini->value); |
---|
| 237 | } else if (g_strcasecmp(ini->key, "daemonport") == 0) { |
---|
| 238 | g_free(conf->port); |
---|
| 239 | conf->port = g_strdup(ini->value); |
---|
| 240 | } else if (g_strcasecmp(ini->key, "clientinterface") == 0) { |
---|
| 241 | g_free(conf->iface_out); |
---|
| 242 | conf->iface_out = g_strdup(ini->value); |
---|
| 243 | } else if (g_strcasecmp(ini->key, "authmode") == 0) { |
---|
| 244 | if (g_strcasecmp(ini->value, "registered") == 0) { |
---|
[b7d3cc34] | 245 | conf->authmode = AUTHMODE_REGISTERED; |
---|
[5ebff60] | 246 | } else if (g_strcasecmp(ini->value, "closed") == 0) { |
---|
[b7d3cc34] | 247 | conf->authmode = AUTHMODE_CLOSED; |
---|
[5ebff60] | 248 | } else { |
---|
[b7d3cc34] | 249 | conf->authmode = AUTHMODE_OPEN; |
---|
[5ebff60] | 250 | } |
---|
[8e6ecfe] | 251 | } else if (g_strcasecmp(ini->key, "authbackend") == 0) { |
---|
| 252 | if (g_strcasecmp(ini->value, "storage") == 0) { |
---|
| 253 | conf->auth_backend = NULL; |
---|
[50bb490] | 254 | } else if (g_strcasecmp(ini->value, "pam") == 0 || |
---|
| 255 | g_strcasecmp(ini->value, "ldap") == 0) { |
---|
[a6005da] | 256 | g_free(conf->auth_backend); |
---|
| 257 | conf->auth_backend = g_strdup(ini->value); |
---|
[8e6ecfe] | 258 | } else { |
---|
| 259 | fprintf(stderr, "Invalid %s value: %s\n", ini->key, ini->value); |
---|
| 260 | return 0; |
---|
| 261 | } |
---|
[5ebff60] | 262 | } else if (g_strcasecmp(ini->key, "authpassword") == 0) { |
---|
| 263 | g_free(conf->auth_pass); |
---|
| 264 | conf->auth_pass = g_strdup(ini->value); |
---|
| 265 | } else if (g_strcasecmp(ini->key, "operpassword") == 0) { |
---|
| 266 | g_free(conf->oper_pass); |
---|
| 267 | conf->oper_pass = g_strdup(ini->value); |
---|
[446a23e] | 268 | } else if (g_strcasecmp(ini->key, "allowaccountadd") == 0) { |
---|
| 269 | if (!is_bool(ini->value)) { |
---|
| 270 | fprintf(stderr, "Invalid %s value: %s\n", ini->key, ini->value); |
---|
| 271 | return 0; |
---|
| 272 | } |
---|
| 273 | conf->allow_account_add = bool2int(ini->value); |
---|
[5ebff60] | 274 | } else if (g_strcasecmp(ini->key, "hostname") == 0) { |
---|
| 275 | g_free(conf->hostname); |
---|
| 276 | conf->hostname = g_strdup(ini->value); |
---|
| 277 | } else if (g_strcasecmp(ini->key, "configdir") == 0) { |
---|
| 278 | g_free(conf->configdir); |
---|
| 279 | conf->configdir = g_strdup(ini->value); |
---|
[34d16d5] | 280 | } else if (g_strcasecmp(ini->key, "plugindir") == 0) { |
---|
| 281 | g_free(conf->plugindir); |
---|
| 282 | conf->plugindir = g_strdup(ini->value); |
---|
[5ebff60] | 283 | } else if (g_strcasecmp(ini->key, "motdfile") == 0) { |
---|
| 284 | g_free(conf->motdfile); |
---|
| 285 | conf->motdfile = g_strdup(ini->value); |
---|
[365dd59] | 286 | } else if (g_strcasecmp(ini->key, "accountstorage") == 0 || |
---|
| 287 | g_strcasecmp(ini->key, "account_storage") == 0) { |
---|
[5ebff60] | 288 | g_free(conf->primary_storage); |
---|
| 289 | conf->primary_storage = g_strdup(ini->value); |
---|
[365dd59] | 290 | } else if (g_strcasecmp(ini->key, "accountstoragemigrate") == 0 || |
---|
| 291 | g_strcasecmp(ini->key, "account_storage_migrate") == 0) { |
---|
[5ebff60] | 292 | g_strfreev(conf->migrate_storage); |
---|
| 293 | conf->migrate_storage = g_strsplit_set(ini->value, " \t,;", -1); |
---|
| 294 | } else if (g_strcasecmp(ini->key, "pinginterval") == 0) { |
---|
| 295 | if (sscanf(ini->value, "%d", &i) != 1) { |
---|
| 296 | fprintf(stderr, "Invalid %s value: %s\n", ini->key, ini->value); |
---|
[eeb85a8] | 297 | return 0; |
---|
[b7d3cc34] | 298 | } |
---|
| 299 | conf->ping_interval = i; |
---|
[5ebff60] | 300 | } else if (g_strcasecmp(ini->key, "pingtimeout") == 0) { |
---|
| 301 | if (sscanf(ini->value, "%d", &i) != 1) { |
---|
| 302 | fprintf(stderr, "Invalid %s value: %s\n", ini->key, ini->value); |
---|
[eeb85a8] | 303 | return 0; |
---|
[b7d3cc34] | 304 | } |
---|
| 305 | conf->ping_timeout = i; |
---|
[5ebff60] | 306 | } else if (g_strcasecmp(ini->key, "proxy") == 0) { |
---|
| 307 | url_t *url = g_new0(url_t, 1); |
---|
| 308 | |
---|
| 309 | if (!url_set(url, ini->value)) { |
---|
| 310 | fprintf(stderr, "Invalid %s value: %s\n", ini->key, ini->value); |
---|
| 311 | g_free(url); |
---|
[eeb85a8] | 312 | return 0; |
---|
[b7d3cc34] | 313 | } |
---|
[5ebff60] | 314 | |
---|
| 315 | strncpy(proxyhost, url->host, sizeof(proxyhost)); |
---|
| 316 | strncpy(proxyuser, url->user, sizeof(proxyuser)); |
---|
| 317 | strncpy(proxypass, url->pass, sizeof(proxypass)); |
---|
[b7d3cc34] | 318 | proxyport = url->port; |
---|
[5ebff60] | 319 | if (url->proto == PROTO_HTTP) { |
---|
[b7d3cc34] | 320 | proxytype = PROXY_HTTP; |
---|
[5ebff60] | 321 | } else if (url->proto == PROTO_SOCKS4) { |
---|
[b7d3cc34] | 322 | proxytype = PROXY_SOCKS4; |
---|
[5ebff60] | 323 | } else if (url->proto == PROTO_SOCKS5) { |
---|
[b7d3cc34] | 324 | proxytype = PROXY_SOCKS5; |
---|
[12f041d] | 325 | } else if (url->proto == PROTO_SOCKS4A) { |
---|
| 326 | proxytype = PROXY_SOCKS4A; |
---|
[5ebff60] | 327 | } |
---|
| 328 | |
---|
| 329 | g_free(url); |
---|
| 330 | } else if (g_strcasecmp(ini->key, "user") == 0) { |
---|
| 331 | g_free(conf->user); |
---|
| 332 | conf->user = g_strdup(ini->value); |
---|
| 333 | } else if (g_strcasecmp(ini->key, "ft_max_size") == 0) { |
---|
[a02f34f] | 334 | size_t ft_max_size; |
---|
[5ebff60] | 335 | if (sscanf(ini->value, "%zu", &ft_max_size) != 1) { |
---|
| 336 | fprintf(stderr, "Invalid %s value: %s\n", ini->key, ini->value); |
---|
[a02f34f] | 337 | return 0; |
---|
| 338 | } |
---|
| 339 | conf->ft_max_size = ft_max_size; |
---|
[5ebff60] | 340 | } else if (g_strcasecmp(ini->key, "ft_max_kbps") == 0) { |
---|
| 341 | if (sscanf(ini->value, "%d", &i) != 1) { |
---|
| 342 | fprintf(stderr, "Invalid %s value: %s\n", ini->key, ini->value); |
---|
[a02f34f] | 343 | return 0; |
---|
| 344 | } |
---|
| 345 | conf->ft_max_kbps = i; |
---|
[5ebff60] | 346 | } else if (g_strcasecmp(ini->key, "ft_listen") == 0) { |
---|
| 347 | g_free(conf->ft_listen); |
---|
| 348 | conf->ft_listen = g_strdup(ini->value); |
---|
| 349 | } else if (g_strcasecmp(ini->key, "protocols") == 0) { |
---|
| 350 | g_strfreev(conf->protocols); |
---|
| 351 | conf->protocols = g_strsplit_set(ini->value, " \t,;", -1); |
---|
| 352 | } else if (g_strcasecmp(ini->key, "cafile") == 0) { |
---|
| 353 | g_free(conf->cafile); |
---|
| 354 | conf->cafile = g_strdup(ini->value); |
---|
| 355 | } else { |
---|
| 356 | fprintf(stderr, "Error: Unknown setting `%s` in configuration file (line %d).\n", |
---|
| 357 | ini->key, ini->line); |
---|
[eeb85a8] | 358 | return 0; |
---|
[b7d3cc34] | 359 | /* For now just ignore unknown keys... */ |
---|
| 360 | } |
---|
[5ebff60] | 361 | } else if (g_strcasecmp(ini->section, "defaults") != 0) { |
---|
| 362 | fprintf(stderr, "Error: Unknown section [%s] in configuration file (line %d). " |
---|
| 363 | "BitlBee configuration must be put in a [settings] section!\n", ini->section, |
---|
| 364 | ini->line); |
---|
[eeb85a8] | 365 | return 0; |
---|
[b7d3cc34] | 366 | } |
---|
| 367 | } |
---|
[5ebff60] | 368 | ini_close(ini); |
---|
| 369 | |
---|
[eeb85a8] | 370 | return 1; |
---|
[b7d3cc34] | 371 | } |
---|
| 372 | |
---|
[5ebff60] | 373 | void conf_loaddefaults(irc_t *irc) |
---|
[b7d3cc34] | 374 | { |
---|
| 375 | ini_t *ini; |
---|
[5ebff60] | 376 | |
---|
| 377 | ini = ini_open(global.conf_file); |
---|
| 378 | if (ini == NULL) { |
---|
| 379 | return; |
---|
| 380 | } |
---|
| 381 | while (ini_read(ini)) { |
---|
| 382 | if (g_strcasecmp(ini->section, "defaults") == 0) { |
---|
| 383 | set_t *s = set_find(&irc->b->set, ini->key); |
---|
| 384 | |
---|
| 385 | if (s) { |
---|
| 386 | if (s->def) { |
---|
| 387 | g_free(s->def); |
---|
| 388 | } |
---|
| 389 | s->def = g_strdup(ini->value); |
---|
[b7d3cc34] | 390 | } |
---|
| 391 | } |
---|
| 392 | } |
---|
[5ebff60] | 393 | ini_close(ini); |
---|
[b7d3cc34] | 394 | } |
---|