Skip to content
Snippets Groups Projects
Commit 1d016d21 authored by Russell Bryant's avatar Russell Bryant
Browse files

simplify some code, tweak formatting, and reduce indentation

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@101746 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 574b5e2a
No related branches found
No related tags found
No related merge requests found
...@@ -147,27 +147,33 @@ static int auth_exec(struct ast_channel *chan, void *data) ...@@ -147,27 +147,33 @@ static int auth_exec(struct ast_channel *chan, void *data)
continue; continue;
} }
while (!feof(f)) { for (;;) {
fgets(buf, sizeof(buf), f); fgets(buf, sizeof(buf), f);
if (!feof(f) && !ast_strlen_zero(buf)) {
buf[strlen(buf) - 1] = '\0'; if (feof(f))
if (ast_test_flag(&flags,OPT_MULTIPLE)) { break;
md5secret = strchr(buf, ':');
if (!md5secret) if (ast_strlen_zero(buf))
continue; continue;
*md5secret++ = '\0';
ast_md5_hash(md5passwd, passwd); buf[strlen(buf) - 1] = '\0';
if (!strcmp(md5passwd, md5secret)) {
if (ast_test_flag(&flags,OPT_ACCOUNT)) if (ast_test_flag(&flags, OPT_MULTIPLE)) {
ast_cdr_setaccount(chan, buf); md5secret = buf;
break; strsep(&md5secret, ":");
} if (!md5secret)
} else { continue;
if (!strcmp(passwd, buf)) { ast_md5_hash(md5passwd, passwd);
if (ast_test_flag(&flags,OPT_ACCOUNT)) if (!strcmp(md5passwd, md5secret)) {
ast_cdr_setaccount(chan, buf); if (ast_test_flag(&flags,OPT_ACCOUNT))
break; ast_cdr_setaccount(chan, buf);
} break;
}
} else {
if (!strcmp(passwd, buf)) {
if (ast_test_flag(&flags, OPT_ACCOUNT))
ast_cdr_setaccount(chan, buf);
break;
} }
} }
} }
...@@ -175,7 +181,7 @@ static int auth_exec(struct ast_channel *chan, void *data) ...@@ -175,7 +181,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
fclose(f); fclose(f);
if (!ast_strlen_zero(buf)) { if (!ast_strlen_zero(buf)) {
if (ast_test_flag(&flags,OPT_MULTIPLE)) { if (ast_test_flag(&flags, OPT_MULTIPLE)) {
if (md5secret && !strcmp(md5passwd, md5secret)) if (md5secret && !strcmp(md5passwd, md5secret))
break; break;
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment