[asterisk-commits] pabelanger: trunk r306292 - /trunk/utils/extconf.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 4 12:16:19 CST 2011


Author: pabelanger
Date: Fri Feb  4 12:16:16 2011
New Revision: 306292

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=306292
Log:
Revert changes to extconf.c

It seems extconf.c already defines some local ast_debug() functions.  Theses
should be removed and replaced with logger.h.  A patch will be added to
reviewboard shortly.

Modified:
    trunk/utils/extconf.c

Modified: trunk/utils/extconf.c
URL: http://svnview.digium.com/svn/asterisk/trunk/utils/extconf.c?view=diff&rev=306292&r1=306291&r2=306292
==============================================================================
--- trunk/utils/extconf.c (original)
+++ trunk/utils/extconf.c Fri Feb  4 12:16:16 2011
@@ -3761,29 +3761,31 @@
 			fflush(stdout);
 		}
 		if (!(f = fopen(fn, "r"))) {
-			ast_debug(1, "No file to parse: %s\n", fn);
+			if (option_debug)
+				ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
 			if (option_verbose > 1)
 				ast_verbose( "Not found (%s)\n", strerror(errno));
 			continue;
 		}
 		count++;
-		ast_debug(1, "Parsing %s\n", fn);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Parsing %s\n", fn);
 		if (option_verbose > 1)
 			ast_verbose("Found\n");
 		while(!feof(f)) {
 			lineno++;
 			if (fgets(buf, sizeof(buf), f)) {
-				if ( withcomments ) {
+				if ( withcomments ) {    
 					CB_ADD(lline_buffer);       /* add the current lline buffer to the comment buffer */
 					lline_buffer[0] = 0;        /* erase the lline buffer */
 				}
-
+				
 				new_buf = buf;
-				if (comment)
+				if (comment) 
 					process_buf = NULL;
 				else
 					process_buf = buf;
-
+				
 				while ((comment_p = strchr(new_buf, COMMENT_META))) {
 					if ((comment_p > new_buf) && (*(comment_p-1) == '\\')) {
 						/* Yuck, gotta memmove */
@@ -4139,22 +4141,24 @@
 						}
 					}
 				}
-
+                
 				for (cmt = var->precomments; cmt; cmt=cmt->next) {
 					if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')
 						fprintf(f,"%s", cmt->cmt);
 				}
-				if (var->sameline)
+				if (var->sameline) 
 					fprintf(f, "%s %s %s  %s", var->name, (var->object ? "=>" : "="), var->value, var->sameline->cmt);
-				else
+				else	
 					fprintf(f, "%s %s %s\n", var->name, (var->object ? "=>" : "="), var->value);
 				if (var->blanklines) {
 					blanklines = var->blanklines;
 					while (blanklines--)
 						fprintf(f, "\n");
 				}
-
+				
 				fclose(f);
+                
+				
 				var = var->next;
 			}
 			cat = cat->next;
@@ -4162,7 +4166,8 @@
 		if ((option_verbose > 1) && !option_debug)
 			ast_verbose("Saved\n");
 	} else {
-		ast_debug(1, "Unable to open for writing: %s\n", fn);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Unable to open for writing: %s\n", fn);
 		if (option_verbose > 1)
 			ast_verbose(VERBOSE_PREFIX_2 "Unable to write (%s)", strerror(errno));
 		return -1;
@@ -4170,7 +4175,7 @@
 
 	/* Now, for files with trailing #include/#exec statements,
 	   we have to make sure every entry is output */
-
+	
 	for (incl=cfg->includes; incl; incl = incl->next) {
 		if (!incl->output) {
 			/* open the respective file */
@@ -4181,7 +4186,7 @@
 				ast_verbose(VERBOSE_PREFIX_2 "Unable to write %s (%s)", fn, strerror(errno));
 				return -1;
 			}
-
+            
 			/* output the respective include */
 			if (incl->exec)
 				fprintf(f,"#exec \"%s\"\n", incl->exec_file);
@@ -4272,12 +4277,14 @@
 	/* Search if hint exists, do nothing */
 	AST_RWLIST_TRAVERSE(&hints, hint, list) {
 		if (hint->exten == e) {
-			ast_debug(2, "HINTS: Not re-adding existing hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
+			if (option_debug > 1)
+				ast_log(LOG_DEBUG, "HINTS: Not re-adding existing hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
 			return -1;
 		}
 	}
 
-	ast_debug(2, "HINTS: Adding hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
+	if (option_debug > 1)
+		ast_log(LOG_DEBUG, "HINTS: Adding hint %s: %s\n", ast_get_extension_name(e), ast_get_extension_app(e));
 
 	if (!(hint = ast_calloc(1, sizeof(*hint)))) {
 		return -1;
@@ -5316,7 +5323,8 @@
 		tmp->includes = NULL;
 		tmp->ignorepats = NULL;
 		*loc_contexts = tmp;
-		ast_debug(1, "Registered context '%s'\n", tmp->name);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Registered context '%s'\n", tmp->name);
 		if (option_verbose > 2)
 			ast_verbose( VERBOSE_PREFIX_3 "Registered extension context '%s'\n", tmp->name);
 	}
@@ -5449,10 +5457,10 @@
 	}
 	if (option_debug) {
 		if (tmp->matchcid) {
-			ast_debug(1, "Added extension '%s' priority %d (CID match '%s') to %s\n",
+			ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s\n",
 				tmp->exten, tmp->priority, tmp->cidmatch, con->name);
 		} else {
-			ast_debug(1, "Added extension '%s' priority %d to %s\n",
+			ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n",
 				tmp->exten, tmp->priority, con->name);
 		}
 	}
@@ -5543,7 +5551,8 @@
 				ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
 			break;
 		default:
-			ast_debug(1, "Shouldn't happen!\n");
+			if (option_debug)
+				ast_log(LOG_DEBUG, "Shouldn't happen!\n");
 		}
 
 		return (matching_action) ? 0 : -1;
@@ -5825,7 +5834,8 @@
 			if (isfunction) {
 				/* Evaluate function */
 				cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
-				ast_debug(1, "Function result is '%s'\n", cp4 ? cp4 : "(null)");
+				if (option_debug)
+					ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)");
 			} else {
 				/* Retrieve variable value */
 				pbx_retrieve_variable(c, vars, &cp4, workspace, VAR_BUF_SIZE, headp);
@@ -5893,7 +5903,8 @@
 			length = ast_expr(vars, cp2, count, NULL);
 
 			if (length) {
-				ast_debug(1, "Expression result is '%s'\n", cp2);
+				if (option_debug)
+					ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2);
 				count -= length;
 				cp2 += length;
 				*cp2 = 0;
@@ -6087,7 +6098,8 @@
 	for (tmp = contexts; tmp; ) {
 		struct ast_context *next;	/* next starting point */
 		for (; tmp; tmpl = tmp, tmp = tmp->next) {
-			ast_debug(1, "check ctx %s %s\n", tmp->name, tmp->registrar);
+			if (option_debug)
+				ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar);
 			if ( (!registrar || !strcasecmp(registrar, tmp->registrar)) &&
 			     (!con || !strcasecmp(tmp->name, con->name)) )
 				break;	/* found it */
@@ -6095,7 +6107,8 @@
 		if (!tmp)	/* not found, we are done */
 			break;
 		ast_wrlock_context(tmp);
-		ast_debug(1, "delete ctx %s %s\n", tmp->name, tmp->registrar);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar);
 		next = tmp->next;
 		if (tmpl)
 			tmpl->next = next;
@@ -6160,7 +6173,8 @@
 	tmp = *extcontexts;
 	if (registrar) {
 		/* XXX remove previous contexts from same registrar */
-		ast_debug(1, "must remove any reg %s\n", registrar);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar);
 		__ast_context_destroy(NULL,registrar);
 		while (tmp) {
 			lasttmp = tmp;




More information about the asterisk-commits mailing list