[svn-commits] russell: branch group/newcdr r201981 - /team/group/newcdr/main/cel.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 19 13:28:29 CDT 2009


Author: russell
Date: Fri Jun 19 13:28:25 2009
New Revision: 201981

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201981
Log:
Reduce indentation in do_reload()

Modified:
    team/group/newcdr/main/cel.c

Modified: team/group/newcdr/main/cel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/main/cel.c?view=diff&rev=201981&r1=201980&r2=201981
==============================================================================
--- team/group/newcdr/main/cel.c (original)
+++ team/group/newcdr/main/cel.c Fri Jun 19 13:28:25 2009
@@ -151,6 +151,7 @@
 	int res = 0;
 	enum ast_cel_eventtype et;
 	struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED };
+	const char *s;
 
 	was_enabled = cel_enabled;
 	cel_enabled = 1;
@@ -167,151 +168,151 @@
 		appset = 0;
 	}
 
-	if ((config = ast_config_load2("cel.conf", "cel", config_flags))) {
-		if (config == CONFIG_STATUS_FILEUNCHANGED) {
-			return 0;
-		}
-		if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) {
-			cel_enabled = ast_true(enabled_value);
-		}
-		if (cel_enabled) {
-			const char *s;
-
-			/* get the date format for logging */
-			if ((s = ast_variable_retrieve(config, "general", "dateformat"))) {
-				ast_copy_string(cel_dateformat, s, sizeof(cel_dateformat));
+	config = ast_config_load2("cel.conf", "cel", config_flags);
+
+	if (!config || config == CONFIG_STATUS_FILEUNCHANGED) {
+		return 0;
+	}
+
+	if ((enabled_value = ast_variable_retrieve(config, "general", "enable"))) {
+		cel_enabled = ast_true(enabled_value);
+	}
+
+	if (!cel_enabled) {
+		goto return_cleanup;
+	}
+
+	/* get the date format for logging */
+	if ((s = ast_variable_retrieve(config, "general", "dateformat"))) {
+		ast_copy_string(cel_dateformat, s, sizeof(cel_dateformat));
+	}
+
+	if ((eventlist = ast_variable_retrieve(config, "general", "events"))) {
+		char *t1, *t2, *t3, *myeventlist = ast_strdup(eventlist);
+		t1 = myeventlist;
+		if (!t1 || !(*t1)) {
+			ast_log(LOG_ERROR, "no events line? Turning off CEL capability!\n");
+			cel_enabled = 0;
+		} else {
+			while (t1 && *t1) {
+				t2 = strchr(t1,',');
+				if (!t2) {
+					t2 = t1 + strlen(t1) - 1;
+				} else {
+					*t2 = 0;
+				}
+				/*push t1 to the first non-blank char */
+				while (t1 && *t1 && isspace(*t1)) {
+					t1++;
+				}
+				if (t2 == t1) {
+					ast_log(LOG_ERROR, "A comma with no preceeding event name? --Ignored\n");
+					t1 = t2+1;
+					continue;
+				}
+				if (!(*t1)) {
+					ast_log(LOG_ERROR, "no events to log? Turning off CEL capability!\n");
+					cel_enabled = 0;
+					break;
+				}
+				/* pull t3 (a copy of t2) to last non-blank char */
+				t3 = t2;
+				if (!(*t2)) {
+					t3 = t2-1;
+				}
+				while (t3 && *t3 && isspace(*t3)) {
+					t3--;
+				}
+				*(t3+1) = 0;
+				/* t1 now points to null-terminated entry */
+				et = ast_cel_str2eventtype(t1);
+				if ((int)et == 0) { /* all events */
+					eventset = -1; /* turn on all the bits */
+				} else if ((int)et == -1) {  /* unmatched event */
+					ast_log(LOG_ERROR, "Unrecognized event name %s!\n", t1);
+				} else {
+					eventset |=  (1 << (int)et);
+				}
+				t1 = t2+1;
 			}
-
-			if ((eventlist = ast_variable_retrieve(config, "general", "events"))) {
-				char *t1, *t2, *t3, *myeventlist = ast_strdup(eventlist);
-				t1 = myeventlist;
-				if (!t1 || !(*t1)) {
-					ast_log(LOG_ERROR, "no events line? Turning off CEL capability!\n");
+		}
+		if (myeventlist) {
+			free(myeventlist);
+		}
+	}
+
+	if ((applist = ast_variable_retrieve(config, "general", "apps"))) {
+		char *t1, *t2, *t3, *myapplist = ast_strdup(applist);
+		if (!ast_cel_track_event(CEL_APP_START) && !ast_cel_track_event(CEL_APP_END)) {
+			ast_log(LOG_ERROR, "An apps= config line, but not tracking APP events!\n");
+		} else {
+			int commacount = 0;
+			t1 = myapplist;
+			t2 = t1;
+			while (t2) {
+				t2 = strchr(t2,',');
+				if (t2) {
+					t2++;
+					commacount++;
+				}
+			}
+			/* form a hash table */
+			appset = ast_hashtab_create(commacount+1, ast_hashtab_compare_strings_nocase,
+										ast_hashtab_resize_none,
+										ast_hashtab_newsize_none,
+										ast_hashtab_hash_string_nocase,1);
+			while (t1 && *t1) {
+				t2 = strchr(t1,',');
+				if (!t2) {
+					t2 = t1 + strlen(t1) - 1;
+				} else {
+					*t2 = 0;
+				}
+
+				/*push t1 to the first non-blank char */
+				while (t1 && *t1 && isspace(*t1)) {
+					t1++;
+				}
+				if (t2 == t1) {
+					ast_log(LOG_ERROR, "A comma with no preceeding event name? --Ignored\n");
+					t1 = t2+1;
+					continue;
+				}
+				if (!(*t1)) {
+					ast_log(LOG_ERROR, "no events to log? Turning off CEL capability!\n");
 					cel_enabled = 0;
-				} else {
-					while (t1 && *t1) {
-						t2 = strchr(t1,',');
-						if (!t2) {
-							t2 = t1 + strlen(t1) - 1;
-						} else {
-							*t2 = 0;
-						}
-						/*push t1 to the first non-blank char */
-						while (t1 && *t1 && isspace(*t1)) {
-							t1++;
-						}
-						if (t2 == t1) {
-							ast_log(LOG_ERROR, "A comma with no preceeding event name? --Ignored\n");
-							t1 = t2+1;
-							continue;
-						}
-						if (!(*t1)) {
-							ast_log(LOG_ERROR, "no events to log? Turning off CEL capability!\n");
-							cel_enabled = 0;
-							break;
-						}
-						/* pull t3 (a copy of t2) to last non-blank char */
-						t3 = t2;
-						if (!(*t2)) {
-							t3 = t2-1;
-						}
-						while (t3 && *t3 && isspace(*t3)) {
-							t3--;
-						}
-						*(t3+1) = 0;
-						/* t1 now points to null-terminated entry */
-						et = ast_cel_str2eventtype(t1);
-						if ((int)et == 0) { /* all events */
-							eventset = -1; /* turn on all the bits */
-						} else if ((int)et == -1) {  /* unmatched event */
-							ast_log(LOG_ERROR, "Unrecognized event name %s!\n", t1);
-						} else {
-							eventset |=  (1 << (int)et);
-						}
-						t1 = t2+1;
-					}
-				}
-				if (myeventlist) {
-					free(myeventlist);
-				}
+					break;
+				}
+				/* pull t3 (a copy of t2) to last non-blank char */
+				t3 = t2;
+				if (!(*t2)) {
+					t3 = t2-1;
+				}
+				while (t3 && *t3 && isspace(*t3)) {
+					t3--;
+				}
+				*(t3+1) = 0;
+				/* t1 now points to null-terminated entry */
+				/* while just a few apps would be OK to put in a linked list,
+				   If there are dozens, a linked list search would be really
+				   horribly slow and therefore bad.
+				   So, let's put these in a hash table
+				*/
+				t3 = strdup(t1);
+				if (!ast_hashtab_insert_safe(appset, t3)) {
+					ast_log(LOG_ERROR, "The %s app in the apps= line is repeated!\n", t3);
+					free(t3);
+				}
+				t1 = t2+1;
 			}
-			if ((applist = ast_variable_retrieve(config, "general", "apps"))) {
-				char *t1, *t2, *t3, *myapplist = ast_strdup(applist);
-				if (!ast_cel_track_event(CEL_APP_START) && !ast_cel_track_event(CEL_APP_END)) {
-					ast_log(LOG_ERROR, "An apps= config line, but not tracking APP events!\n");
-				} else {
-					int commacount = 0;
-					t1 = myapplist;
-					t2 = t1;
-					while (t2) {
-						t2 = strchr(t2,',');
-						if (t2) {
-							t2++;
-							commacount++;
-						}
-					}
-					/* form a hash table */
-					appset = ast_hashtab_create(commacount+1, ast_hashtab_compare_strings_nocase,
-												ast_hashtab_resize_none,
-												ast_hashtab_newsize_none,
-												ast_hashtab_hash_string_nocase,1);
-					while (t1 && *t1) {
-						t2 = strchr(t1,',');
-						if (!t2) {
-							t2 = t1 + strlen(t1) - 1;
-						} else {
-							*t2 = 0;
-						}
-
-						/*push t1 to the first non-blank char */
-						while (t1 && *t1 && isspace(*t1)) {
-							t1++;
-						}
-						if (t2 == t1) {
-							ast_log(LOG_ERROR, "A comma with no preceeding event name? --Ignored\n");
-							t1 = t2+1;
-							continue;
-						}
-						if (!(*t1)) {
-							ast_log(LOG_ERROR, "no events to log? Turning off CEL capability!\n");
-							cel_enabled = 0;
-							break;
-						}
-						/* pull t3 (a copy of t2) to last non-blank char */
-						t3 = t2;
-						if (!(*t2)) {
-							t3 = t2-1;
-						}
-						while (t3 && *t3 && isspace(*t3)) {
-							t3--;
-						}
-						*(t3+1) = 0;
-						/* t1 now points to null-terminated entry */
-						/* while just a few apps would be OK to put in a linked list,
-						   If there are dozens, a linked list search would be really
-						   horribly slow and therefore bad.
-						   So, let's put these in a hash table
-						*/
-						t3 = strdup(t1);
-						if (!ast_hashtab_insert_safe(appset, t3)) {
-							ast_log(LOG_ERROR, "The %s app in the apps= line is repeated!\n", t3);
-							free(t3);
-						}
-						t1 = t2+1;
-					}
-				}
-				if (myapplist) {
-					free(myapplist);
-				}
-			}
-		}
-	}
-
-	if (cel_enabled) {
-		ast_log(LOG_NOTICE, "CEL logging enabled.\n");
-	} else {
-		ast_log(LOG_NOTICE, "CEL logging disabled.\n");
-	}
+		}
+		if (myapplist) {
+			free(myapplist);
+		}
+	}
+
+return_cleanup:
+	ast_verb(3, "CEL logging %sabled.\n", cel_enabled ? "en" : "dis");
 
 	ast_config_destroy(config);
 




More information about the svn-commits mailing list