[asterisk-commits] anthonyl: branch anthonyl/escape-filter2 r47292 - in /team/anthonyl/escape-fi...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Nov 7 15:23:52 MST 2006


Author: anthonyl
Date: Tue Nov  7 16:23:51 2006
New Revision: 47292

URL: http://svn.digium.com/view/asterisk?rev=47292&view=rev
Log:
small design change

Modified:
    team/anthonyl/escape-filter2/include/asterisk/utils.h
    team/anthonyl/escape-filter2/main/asterisk.c
    team/anthonyl/escape-filter2/main/logger.c
    team/anthonyl/escape-filter2/main/utils.c

Modified: team/anthonyl/escape-filter2/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/team/anthonyl/escape-filter2/include/asterisk/utils.h?rev=47292&r1=47291&r2=47292&view=diff
==============================================================================
--- team/anthonyl/escape-filter2/include/asterisk/utils.h (original)
+++ team/anthonyl/escape-filter2/include/asterisk/utils.h Tue Nov  7 16:23:51 2006
@@ -529,5 +529,5 @@
   to ensure that the DF bit will not be set.
  */
 void ast_enable_packet_fragmentation(int sock);
-
+void ast_filter_escapes(const char *line, char *p);
 #endif /* _ASTERISK_UTILS_H */

Modified: team/anthonyl/escape-filter2/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/escape-filter2/main/asterisk.c?rev=47292&r1=47291&r2=47292&view=diff
==============================================================================
--- team/anthonyl/escape-filter2/main/asterisk.c (original)
+++ team/anthonyl/escape-filter2/main/asterisk.c Tue Nov  7 16:23:51 2006
@@ -1253,7 +1253,7 @@
 {
 	char tmp[80];
 	const char *c = NULL;
-
+      
 	if ((c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_4)) ||
 	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_3)) ||
 	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_2)) ||

Modified: team/anthonyl/escape-filter2/main/logger.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/escape-filter2/main/logger.c?rev=47292&r1=47291&r2=47292&view=diff
==============================================================================
--- team/anthonyl/escape-filter2/main/logger.c (original)
+++ team/anthonyl/escape-filter2/main/logger.c Tue Nov  7 16:23:51 2006
@@ -680,10 +680,11 @@
 {
 	struct logchannel *chan;
 	struct ast_dynamic_str *buf;
-	time_t t;
+       	time_t t;
 	struct tm tm;
 	char date[256];
-
+	char *p = NULL;
+	
 	va_list ap;
 
 	if (!(buf = ast_dynamic_str_thread_get(&log_buf, LOG_BUF_INIT_SIZE)))
@@ -700,8 +701,10 @@
 			va_start(ap, fmt);
 			res = ast_dynamic_str_thread_set_va(&buf, BUFSIZ, &log_buf, fmt, ap);
 			va_end(ap);
-			if (res != AST_DYNSTR_BUILD_FAILED)
+			if (res != AST_DYNSTR_BUILD_FAILED) {
+				printf("--------------------\n"); /* filter point 1 */
 				fputs(buf->str, stdout);
+			}
 		}
 		return;
 	}
@@ -848,8 +851,9 @@
 	struct verb *v;
 	struct ast_dynamic_str *buf;
 	int res;
+	char *p = NULL;
 	va_list ap;
-
+	
 	if (ast_opt_timestamp) {
 		time_t t;
 		struct tm tm;
@@ -873,13 +877,22 @@
 
 	if (res == AST_DYNSTR_BUILD_FAILED)
 		return;
-
+	p = ast_calloc(1,strlen(buf->str));
+	
+	if (!p)
+		return;
+	memset(p,'\0',strlen(buf->str));
+	ast_filter_escapes(buf->str,p);
+	
 	AST_LIST_LOCK(&verbosers);
 	AST_LIST_TRAVERSE(&verbosers, v, list)
-		v->verboser(buf->str);
+		v->verboser(p);
 	AST_LIST_UNLOCK(&verbosers);
 
-	ast_log(LOG_VERBOSE, "%s", buf->str);
+  
+	ast_log(LOG_VERBOSE, "%s", p);
+
+	free(p);
 }
 
 int ast_register_verbose(void (*v)(const char *string)) 

Modified: team/anthonyl/escape-filter2/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/escape-filter2/main/utils.c?rev=47292&r1=47291&r2=47292&view=diff
==============================================================================
--- team/anthonyl/escape-filter2/main/utils.c (original)
+++ team/anthonyl/escape-filter2/main/utils.c Tue Nov  7 16:23:51 2006
@@ -995,3 +995,34 @@
 		ast_log(LOG_WARNING, "Unable to disable PMTU discovery. Large UDP packets may fail to be delivered when sent from this socket.\n");
 #endif /* HAVE_IP_MTU_DISCOVER */
 }
+
+
+/* make output a tad more sane */
+void ast_filter_escapes(const char *line, char *p)
+ {
+	 int i  = 0;
+	 int ii = 0;
+	 int tamper = 0;
+	 
+	 for (i=0;i<strlen(line);i++) {
+		 if (line[i] == '\x1B') {					 
+			 if ( line[i+1] == '\x5b') {
+				 if (line[i+2] != 30 || line[i+2] != 33) {
+					 tamper = 1;
+				 }
+				 
+			 } else 
+				 tamper = 1;
+			 
+		 }
+		 p[ii] = line[i];
+		 ii++;
+	 }
+
+	 tamper = 1;
+
+	 if (tamper == 1) 
+		 snprintf(p,strlen(line),"\0");
+	 
+	 return;
+ }



More information about the asterisk-commits mailing list