diff options
author | James Maki <jmaki@multitech.com> | 2010-05-07 10:52:16 -0500 |
---|---|---|
committer | James Maki <jmaki@multitech.com> | 2010-05-07 10:52:16 -0500 |
commit | 408d03be285010d852fa4234ea03f80e7ee5403a (patch) | |
tree | e08b848fc0662813de77b867f7d6eaf80bab1cb6 /src/sms_main.c | |
parent | cce54aff649a226b987a13638f8dfcc56179d64a (diff) | |
download | sms-utils-408d03be285010d852fa4234ea03f80e7ee5403a.tar.gz sms-utils-408d03be285010d852fa4234ea03f80e7ee5403a.tar.bz2 sms-utils-408d03be285010d852fa4234ea03f80e7ee5403a.zip |
clean up some memory
Diffstat (limited to 'src/sms_main.c')
-rw-r--r-- | src/sms_main.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/src/sms_main.c b/src/sms_main.c index d1155b8..4a955b8 100644 --- a/src/sms_main.c +++ b/src/sms_main.c @@ -42,6 +42,37 @@ #include "atcmd.h" #include "sms_config.h" +static int global_init(void) +{ + memset(&Global, 0, sizeof(Global)); + + Global.user.name = NULL; + Global.user.email = NULL; + + Global.core.verbose = false; + Global.core.interactive = true; + Global.core.sms_init = true; + Global.core.baud_rate = B115200; + Global.core.read_timeout = 5000; + Global.core.device = strdup(DEFAULT_DEVICE); + Global.core.msg_store_read = strdup("MT"); + Global.core.msg_store_send = strdup("MT"); + Global.core.msg_store_new = strdup("MT"); + Global.core.pb_store = strdup("ME"); + Global.core.editor = strdup("vi"); + Global.core.edit_file = strdup("${HOME}/.smsmsg"); + + Global.smtp.server = NULL; + Global.smtp.port = 25; + Global.smtp.user = NULL; + Global.smtp.passwd = NULL; + Global.smtp.encryption = NULL; + + Global.send_email.domain = NULL; + + return 0; +} + struct sms_cmd { const char *object; int (*call)(int argc, char **argv); @@ -213,6 +244,8 @@ int main(int argc, char *argv[]) xprintf_init(); + global_init(); + err = sms_config_load(); if (err < 0) { log_error("sms config load error"); @@ -237,7 +270,8 @@ int main(int argc, char *argv[]) break; case CMD_OPT_DEVICE: - Global.core.device = optarg; + free(Global.core.device); + Global.core.device = strdup(optarg); break; case CMD_OPT_BAUD_RATE: @@ -254,19 +288,23 @@ int main(int argc, char *argv[]) break; case CMD_OPT_MSG_STORE_READ: - Global.core.msg_store_read = optarg; + free(Global.core.msg_store_read); + Global.core.msg_store_read = strdup(optarg); break; case CMD_OPT_MSG_STORE_SEND: - Global.core.msg_store_send = optarg; + free(Global.core.msg_store_send); + Global.core.msg_store_send = strdup(optarg); break; case CMD_OPT_MSG_STORE_NEW: - Global.core.msg_store_new = optarg; + free(Global.core.msg_store_new); + Global.core.msg_store_new = strdup(optarg); break; case CMD_OPT_PHONEBOOK_STORE: - Global.core.pb_store = optarg; + free(Global.core.pb_store); + Global.core.pb_store = strdup(optarg); break; case CMD_OPT_VERSION: |