[svn-commits] anthonyl: branch anthonyl/log-final r45801 - in /team/anthonyl/log-final: cha...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Oct 20 14:26:48 MST 2006


Author: anthonyl
Date: Fri Oct 20 16:26:47 2006
New Revision: 45801

URL: http://svn.digium.com/view/asterisk?rev=45801&view=rev
Log:
small filtering update

Modified:
    team/anthonyl/log-final/channels/chan_sip.c
    team/anthonyl/log-final/include/asterisk/utils.h
    team/anthonyl/log-final/main/asterisk.c
    team/anthonyl/log-final/main/logger.c
    team/anthonyl/log-final/main/utils.c

Modified: team/anthonyl/log-final/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/log-final/channels/chan_sip.c?rev=45801&r1=45800&r2=45801&view=diff
==============================================================================
--- team/anthonyl/log-final/channels/chan_sip.c (original)
+++ team/anthonyl/log-final/channels/chan_sip.c Fri Oct 20 16:26:47 2006
@@ -10060,6 +10060,8 @@
 	int realtimepeers;
 	int realtimeusers;
 
+
+	ast_verbose("gid: %i uid: %i\n",getgid(), geteuid());
 	realtimepeers = ast_check_realtime("sippeers");
 	realtimeusers = ast_check_realtime("sipusers");
 

Modified: team/anthonyl/log-final/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/team/anthonyl/log-final/include/asterisk/utils.h?rev=45801&r1=45800&r2=45801&view=diff
==============================================================================
--- team/anthonyl/log-final/include/asterisk/utils.h (original)
+++ team/anthonyl/log-final/include/asterisk/utils.h Fri Oct 20 16:26:47 2006
@@ -530,4 +530,7 @@
  */
 void ast_enable_packet_fragmentation(int sock);
 
+/* rev: anthony */
+char * ast_filter_escapes(char *line, char *new);
+
 #endif /* _ASTERISK_UTILS_H */

Modified: team/anthonyl/log-final/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/log-final/main/asterisk.c?rev=45801&r1=45800&r2=45801&view=diff
==============================================================================
--- team/anthonyl/log-final/main/asterisk.c (original)
+++ team/anthonyl/log-final/main/asterisk.c Fri Oct 20 16:26:47 2006
@@ -1252,22 +1252,36 @@
 static void console_verboser(const char *s)
 {
 	char tmp[80];
+	char *p = NULL;
 	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)) ||
-	    (c = fix_header(tmp, sizeof(tmp), s, VERBOSE_PREFIX_1))) {
+	p = malloc(strlen(s) + 10);
+	
+	if (!p) {
+		/* put cute failure message here */
+		return;
+	}
+	memset(p,0x00,strlen(s)+10);
+	
+	/* filter that output */
+	ast_filter_escapes(s, p);
+	
+	if ((c = fix_header(tmp, sizeof(tmp), p, VERBOSE_PREFIX_4)) ||
+	    (c = fix_header(tmp, sizeof(tmp), p, VERBOSE_PREFIX_3)) ||
+	    (c = fix_header(tmp, sizeof(tmp), p, VERBOSE_PREFIX_2)) ||
+	    (c = fix_header(tmp, sizeof(tmp), p, VERBOSE_PREFIX_1))) {
 		fputs(tmp, stdout);
 		fputs(c, stdout);
 	} else
-		fputs(s, stdout);
+		fputs(p, stdout);
 
 	fflush(stdout);
 	
 	/* Wake up a poll()ing console */
 	if (ast_opt_console && consolethread != AST_PTHREADT_NULL)
 		pthread_kill(consolethread, SIGURG);
+
+	free(p);
 }
 
 static int ast_all_zeros(char *s)

Modified: team/anthonyl/log-final/main/logger.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/log-final/main/logger.c?rev=45801&r1=45800&r2=45801&view=diff
==============================================================================
--- team/anthonyl/log-final/main/logger.c (original)
+++ team/anthonyl/log-final/main/logger.c Fri Oct 20 16:26:47 2006
@@ -688,6 +688,7 @@
 	time_t t;
 	struct tm tm;
 	char date[256];
+	char *p;
 
 	va_list ap;
 
@@ -705,8 +706,12 @@
 			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) {
+				p = malloc( (strlen(buf->str) + 5));
+				ast_filter_escapes(buf->str,p);
 				fputs(buf->str, stdout);
+				free(p);
+			}
 		}
 		return;
 	}

Modified: team/anthonyl/log-final/main/utils.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/log-final/main/utils.c?rev=45801&r1=45800&r2=45801&view=diff
==============================================================================
--- team/anthonyl/log-final/main/utils.c (original)
+++ team/anthonyl/log-final/main/utils.c Fri Oct 20 16:26:47 2006
@@ -994,3 +994,37 @@
 		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 */
+char * ast_filter_escapes(char *line, char *new)
+ {
+	 char *p;
+	 int i = 0;
+	 int ii = 0;
+	 
+	 p = malloc(strlen(line)+1);
+
+	 if (!p)
+		 return NULL;
+
+	 memset(p,0x00,(strlen(line)+1));
+	 
+	 for (i=0;i<strlen(line);i++) {
+		 if (line[i] == '\033') {
+			 if ( atoi(&line[i+2]) < 51) {
+				 p[ii] = line[i];
+				 ii++;
+			 }
+		 } else { 
+			 p[ii] = line[i];
+			 
+			 ii++;
+		 }
+	 }
+	 
+	 memcpy(new,p,strlen(p));
+	 free (p);
+
+	 return NULL;
+ }



More information about the svn-commits mailing list