aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_authenticate.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-01 06:27:41 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-02-01 06:27:41 +0000
commit627780bc287b3dd92c4a343e10957cbf0a62210d (patch)
tree6a5e73905759897f50a7e8eb09b22b433f28b25c /apps/app_authenticate.c
parent2969477f123c55586a5a1c121cbaa6460b4ddfc7 (diff)
simplify some code, tweak formatting, and reduce indentation
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@101746 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_authenticate.c')
-rw-r--r--apps/app_authenticate.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c
index 87335d236..30ddc4127 100644
--- a/apps/app_authenticate.c
+++ b/apps/app_authenticate.c
@@ -147,27 +147,33 @@ static int auth_exec(struct ast_channel *chan, void *data)
continue;
}
- while (!feof(f)) {
+ for (;;) {
fgets(buf, sizeof(buf), f);
- if (!feof(f) && !ast_strlen_zero(buf)) {
- buf[strlen(buf) - 1] = '\0';
- if (ast_test_flag(&flags,OPT_MULTIPLE)) {
- md5secret = strchr(buf, ':');
- if (!md5secret)
- continue;
- *md5secret++ = '\0';
- ast_md5_hash(md5passwd, passwd);
- if (!strcmp(md5passwd, md5secret)) {
- if (ast_test_flag(&flags,OPT_ACCOUNT))
- ast_cdr_setaccount(chan, buf);
- break;
- }
- } else {
- if (!strcmp(passwd, buf)) {
- if (ast_test_flag(&flags,OPT_ACCOUNT))
- ast_cdr_setaccount(chan, buf);
- break;
- }
+
+ if (feof(f))
+ break;
+
+ if (ast_strlen_zero(buf))
+ continue;
+
+ buf[strlen(buf) - 1] = '\0';
+
+ if (ast_test_flag(&flags, OPT_MULTIPLE)) {
+ md5secret = buf;
+ strsep(&md5secret, ":");
+ if (!md5secret)
+ continue;
+ ast_md5_hash(md5passwd, passwd);
+ if (!strcmp(md5passwd, md5secret)) {
+ if (ast_test_flag(&flags,OPT_ACCOUNT))
+ 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)
fclose(f);
if (!ast_strlen_zero(buf)) {
- if (ast_test_flag(&flags,OPT_MULTIPLE)) {
+ if (ast_test_flag(&flags, OPT_MULTIPLE)) {
if (md5secret && !strcmp(md5passwd, md5secret))
break;
} else {