[svn-commits] russell: trunk r101746 - /trunk/apps/app_authenticate.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Feb 1 00:27:41 CST 2008


Author: russell
Date: Fri Feb  1 00:27:41 2008
New Revision: 101746

URL: http://svn.digium.com/view/asterisk?view=rev&rev=101746
Log:
simplify some code, tweak formatting, and reduce indentation

Modified:
    trunk/apps/app_authenticate.c

Modified: trunk/apps/app_authenticate.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_authenticate.c?view=diff&rev=101746&r1=101745&r2=101746
==============================================================================
--- trunk/apps/app_authenticate.c (original)
+++ trunk/apps/app_authenticate.c Fri Feb  1 00:27:41 2008
@@ -147,27 +147,33 @@
 				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 @@
 			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 {




More information about the svn-commits mailing list