diff options
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/config.c b/src/config.c index 02d76ec..bc1d2cb 100644 --- a/src/config.c +++ b/src/config.c @@ -9,6 +9,7 @@ void *add_server(char *srvspec) { int ccount = 0; struct ast_server *srv; char *s; + char usessl[10]; /* malloc ourselves a server credentials structure */ srv = malloc(sizeof(struct ast_server)); @@ -17,6 +18,7 @@ void *add_server(char *srvspec) { exit(1); } memset(srv, 0, sizeof (struct ast_server) ); + memset(usessl, 0, sizeof (usessl) ); s = srvspec; do { @@ -42,20 +44,22 @@ void *add_server(char *srvspec) { strncat(srv->ast_events, s, 1); break; case 5: - srv->use_ssl = strcmp(s,"yes") ? 0 : 1; + strncat(usessl, s, 1); break; } } while (*(s++)); - if (!srv->ast_host || !srv->ast_port || !srv->ast_user || !srv->ast_pass || !srv->ast_events || !srv->use_ssl) { - fprintf(stderr, "Aborting! Server spec incomplete: %s!\n", srvspec); + + if (!*srv->ast_host || !*srv->ast_port || !*srv->ast_user || !*srv->ast_pass || !*srv->ast_events || !*usessl) { + fprintf(stderr, "Aborting: server spec incomplete: %s\n", srvspec); free(srv); exit(1); - } else { - srv->next = pc.serverlist; - pc.serverlist = srv; } + srv->use_ssl = (!strcmp(usessl,"on")); + srv->next = pc.serverlist; + pc.serverlist = srv; + return 0; /* TODO: make sure server credentials are freed at leave */ } |