[asterisk-commits] anthonyl: branch anthonyl/8509-manager-httcallback r48355 - /team/anthonyl/85...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Dec 7 10:20:09 MST 2006


Author: anthonyl
Date: Thu Dec  7 11:20:09 2006
New Revision: 48355

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48355
Log:
indentation update

Modified:
    team/anthonyl/8509-manager-httcallback/main/manager.c

Modified: team/anthonyl/8509-manager-httcallback/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/8509-manager-httcallback/main/manager.c?view=diff&rev=48355&r1=48354&r2=48355
==============================================================================
--- team/anthonyl/8509-manager-httcallback/main/manager.c (original)
+++ team/anthonyl/8509-manager-httcallback/main/manager.c Thu Dec  7 11:20:09 2006
@@ -1935,64 +1935,66 @@
 		snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
 	}
 	
-	if (!s->authenticated) {
-		if (!strcasecmp(action, "Challenge")) {
-			char *authtype;
-			authtype = astman_get_header(m, "AuthType");
-			if (!strcasecmp(authtype, "MD5")) {
-				if (ast_strlen_zero(s->challenge))
-					snprintf(s->challenge, sizeof(s->challenge), "%ld", ast_random());
-				ast_mutex_lock(&s->__lock);
-				astman_append(s, "Response: Success\r\n"
-						"%s"
-						"Challenge: %s\r\n\r\n",
-						idText, s->challenge);
-				ast_mutex_unlock(&s->__lock);
-				return 0;
+	if (!strcasecmp(action, "Challenge")) {
+		char *authtype;
+		authtype = astman_get_header(m, "AuthType");
+		if (!strcasecmp(authtype, "MD5")) {
+			if (ast_strlen_zero(s->challenge))
+				snprintf(s->challenge, sizeof(s->challenge), "%ld", ast_random());
+			ast_mutex_lock(&s->__lock);
+			astman_append(s, "Response: Success\r\n"
+					"%s"
+					"Challenge: %s\r\n\r\n",
+					idText, s->challenge);
+			ast_mutex_unlock(&s->__lock);
+			return 0;
+		} else {
+			astman_send_error(s, m, "Must specify AuthType");
+			return 0;
+		}
+	} else if (!strcasecmp(action, "Login")) {
+		
+		/* in case of re-authencation of an existing session (it happens) remove write/read perms */
+		s->readperm = 0;   
+	        s->writeperm = 0;
+		 
+		if (authenticate(s, m)) {
+			sleep(1);
+			astman_send_error(s, m, "Authentication failed");
+			return -1;
+		} else {
+			s->authenticated = 1;
+			if (option_verbose > 1) {
+				if (displayconnects) {
+					ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
+				}
+			}
+			ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
+			astman_send_ack(s, m, "Authentication accepted");
+		}
+	} else if (!strcasecmp(action, "Logoff")) {
+		astman_send_ack(s, m, "See ya");
+		return -1;
+	} else {
+		astman_send_error(s, m, "Authentication Required");
+		return -1;
+	}
+
+	while (tmp) { 	
+		if (!strcasecmp(action, tmp->action)) {
+			if ((s->writeperm & tmp->authority) == tmp->authority) {
+				if (tmp->func(s, m))
+					ret = -1;
 			} else {
-				astman_send_error(s, m, "Must specify AuthType");
-				return 0;
+				astman_send_error(s, m, "Permission denied");
 			}
-		} else if (!strcasecmp(action, "Login")) {
-			
-			/* in case of re-authencation of an existing session (it happens) remove write/read perms */
-			s->readperm = 0;   
-		        s->writeperm = 0;
-			 
-			if (authenticate(s, m)) {
-				sleep(1);
-				astman_send_error(s, m, "Authentication failed");
-				return -1;
-			} else {
-				s->authenticated = 1;
-				if (option_verbose > 1) {
-					if (displayconnects) {
-						ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
-					}
-				}
-				ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
-				astman_send_ack(s, m, "Authentication accepted");
-			}
-		} else if (!strcasecmp(action, "Logoff")) {
-			astman_send_ack(s, m, "See ya");
-			return -1;
-		} else
-			astman_send_error(s, m, "Authentication Required");
-		while (tmp) { 	
-			if (!strcasecmp(action, tmp->action)) {
-				if ((s->writeperm & tmp->authority) == tmp->authority) {
-					if (tmp->func(s, m))
-						ret = -1;
-				} else {
-					astman_send_error(s, m, "Permission denied");
-				}
-				break;
-			}
-			tmp = tmp->next;
-		}
-		if (!tmp)
-			astman_send_error(s, m, "Invalid/unknown command");
-	
+			break;
+		}
+		tmp = tmp->next;
+	}
+	if (!tmp)
+		astman_send_error(s, m, "Invalid/unknown command");
+
 	return process_events(s);
 }
 



More information about the asterisk-commits mailing list