diff options
Diffstat (limited to 'src/sms_config.c')
-rw-r--r-- | src/sms_config.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/sms_config.c b/src/sms_config.c index 9386ff7..2d44e18 100644 --- a/src/sms_config.c +++ b/src/sms_config.c @@ -40,7 +40,19 @@ static int boolean_value(const char *str) return !strcmp(str, "true") ? true : false; } -static int config_open(struct config_info *config, char *filename) +static int config_close(struct config_info *config) +{ + yaml_parser_delete(&config->parser); + fclose(config->file); + free(config->filename); + free(config->section); + free(config->key); + free(config->value); + + return 0; +} + +static int config_open(struct config_info *config, const char *filename) { int err; @@ -71,18 +83,6 @@ static int config_open(struct config_info *config, char *filename) return 0; } -static int config_close(struct config_info *config) -{ - yaml_parser_delete(&config->parser); - fclose(config->file); - free(config->filename); - free(config->section); - free(config->key); - free(config->value); - - return 0; -} - static int config_next_event(struct config_info *config) { int err; @@ -117,18 +117,25 @@ static int config_set_core_value(const char *key, const char *value) } else if (!strcmp("read-timeout", key)) { Global.core.read_timeout = atoi(value); } else if (!strcmp("device", key)) { + free(Global.core.device); Global.core.device = strdup(value); } else if (!strcmp("msg-store-read", key)) { + free(Global.core.msg_store_read); Global.core.msg_store_read = strdup(value); } else if (!strcmp("msg-store-send", key)) { + free(Global.core.msg_store_send); Global.core.msg_store_send = strdup(value); } else if (!strcmp("msg-store-new", key)) { + free(Global.core.msg_store_new); Global.core.msg_store_new = strdup(value); } else if (!strcmp("pb-store", key)) { + free(Global.core.pb_store); Global.core.pb_store = strdup(value); } else if (!strcmp("editor", key)) { + free(Global.core.editor); Global.core.editor = strdup(value); } else if (!strcmp("edit-file", key)) { + free(Global.core.edit_file); Global.core.edit_file = strdup(value); } @@ -140,14 +147,18 @@ static int config_set_smtp_value(const char *key, const char *value) log_debug("try setting smtp.%s to '%s'", key, value); if (!strcmp("server", key)) { + free(Global.smtp.server); Global.smtp.server = strdup(value); } else if (!strcmp("port", key)) { Global.smtp.port = atoi(value); } else if (!strcmp("user", key)) { + free(Global.smtp.user); Global.smtp.user = strdup(value); } else if (!strcmp("passwd", key)) { + free(Global.smtp.passwd); Global.smtp.passwd = strdup(value); } else if (!strcmp("encryption", key)) { + free(Global.smtp.encryption); Global.smtp.encryption = strdup(value); } @@ -159,6 +170,7 @@ static int config_set_send_email_value(const char *key, const char *value) log_debug("try setting send-email.%s to %s", key, value); if (!strcmp("domain", key)) { + free(Global.send_email.domain); Global.send_email.domain = strdup(value); } @@ -170,8 +182,10 @@ static int config_set_user_value(const char *key, const char *value) log_debug("try setting user.%s to %s", key, value); if (!strcmp("name", key)) { + free(Global.user.name); Global.user.name = strdup(value); } else if (!strcmp("email", key)) { + free(Global.user.email); Global.user.email = strdup(value); } |