[svn-commits] russell: branch group/security_events r194753 - in /team/group/security_event...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri May 15 13:24:51 CDT 2009


Author: russell
Date: Fri May 15 13:24:46 2009
New Revision: 194753

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=194753
Log:
resolve, reset

Added:
    team/group/security_events/tests/test_logger.c
      - copied unchanged from r194722, trunk/tests/test_logger.c
Removed:
    team/group/security_events/codecs/g722/Makefile
Modified:
    team/group/security_events/   (props changed)
    team/group/security_events/CREDITS
    team/group/security_events/codecs/Makefile
    team/group/security_events/codecs/g722/g722_decode.c
    team/group/security_events/codecs/g722/g722_encode.c
    team/group/security_events/doc/appdocsxml.dtd
    team/group/security_events/include/asterisk/logger.h
    team/group/security_events/main/logger.c
    team/group/security_events/main/xmldoc.c

Propchange: team/group/security_events/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/security_events/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri May 15 13:24:46 2009
@@ -1,1 +1,1 @@
-/trunk:1-194576
+/trunk:1-194751

Modified: team/group/security_events/CREDITS
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/CREDITS?view=diff&rev=194753&r1=194752&r2=194753
==============================================================================
--- team/group/security_events/CREDITS (original)
+++ team/group/security_events/CREDITS Fri May 15 13:24:46 2009
@@ -197,6 +197,9 @@
 Moises Silva (moy) - for writing LibOpenR2, and providing support for it in chan_dahdi
      moises.silva(AT)gmail.com
 
+Eliel C. Sardanons - XML documentation implementation, and various other contributions
+     <eliels at gmail.com>
+
 === OTHER CONTRIBUTIONS ===
 John Todd - Monkey sounds and associated teletorture prompt
 Michael Jerris - bug marshaling

Modified: team/group/security_events/codecs/Makefile
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/codecs/Makefile?view=diff&rev=194753&r1=194752&r2=194753
==============================================================================
--- team/group/security_events/codecs/Makefile (original)
+++ team/group/security_events/codecs/Makefile Fri May 15 13:24:46 2009
@@ -19,7 +19,6 @@
 
 LIBILBC:=ilbc/libilbc.a
 LIBLPC10:=lpc10/liblpc10.a
-LIBG722:=g722/libg722.a
 
 all: _all
 
@@ -34,7 +33,7 @@
 	$(MAKE) -C gsm clean
 	$(MAKE) -C lpc10 clean
 	$(MAKE) -C ilbc clean
-	$(MAKE) -C g722 clean
+	rm -f g722/*.[oa]
 
 gsm/lib/libgsm.a:
 	@mkdir -p gsm/lib
@@ -50,9 +49,4 @@
 
 $(if $(filter codec_ilbc,$(EMBEDDED_MODS)),modules.link,codec_ilbc.so): $(LIBILBC)
 
-FORCE:
-
-$(LIBG722): FORCE
-	@$(MAKE) -C g722 all
-
-$(if $(filter codec_g722,$(EMBEDDED_MODS)),modules.link,codec_g722.so): $(LIBG722)
+$(if $(filter codec_g722,$(EMBEDDED_MODS)),modules.link,codec_g722.so): g722/g722_encode.o g722/g722_decode.o

Modified: team/group/security_events/codecs/g722/g722_decode.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/codecs/g722/g722_decode.c?view=diff&rev=194753&r1=194752&r2=194753
==============================================================================
--- team/group/security_events/codecs/g722/g722_decode.c (original)
+++ team/group/security_events/codecs/g722/g722_decode.c Fri May 15 13:24:46 2009
@@ -370,7 +370,7 @@
         {
             if (s->eight_k)
             {
-                amp[outlen++] = (int16_t) rlow;
+                amp[outlen++] = (int16_t) (rlow << 1);
             }
             else
             {
@@ -387,8 +387,8 @@
                     xout2 += s->x[2*i]*qmf_coeffs[i];
                     xout1 += s->x[2*i + 1]*qmf_coeffs[11 - i];
                 }
-                amp[outlen++] = (int16_t) (xout1 >> 12);
-                amp[outlen++] = (int16_t) (xout2 >> 12);
+                amp[outlen++] = (int16_t) (xout1 >> 11);
+                amp[outlen++] = (int16_t) (xout2 >> 11);
             }
         }
     }

Modified: team/group/security_events/codecs/g722/g722_encode.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/codecs/g722/g722_encode.c?view=diff&rev=194753&r1=194752&r2=194753
==============================================================================
--- team/group/security_events/codecs/g722/g722_encode.c (original)
+++ team/group/security_events/codecs/g722/g722_encode.c Fri May 15 13:24:46 2009
@@ -279,7 +279,7 @@
         {
             if (s->eight_k)
             {
-                xlow = amp[j++];
+                xlow = amp[j++] >> 1;
             }
             else
             {
@@ -298,8 +298,8 @@
                     sumodd += s->x[2*i]*qmf_coeffs[i];
                     sumeven += s->x[2*i + 1]*qmf_coeffs[11 - i];
                 }
-                xlow = (sumeven + sumodd) >> 13;
-                xhigh = (sumeven - sumodd) >> 13;
+                xlow = (sumeven + sumodd) >> 14;
+                xhigh = (sumeven - sumodd) >> 14;
             }
         }
         /* Block 1L, SUBTRA */

Modified: team/group/security_events/doc/appdocsxml.dtd
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/doc/appdocsxml.dtd?view=diff&rev=194753&r1=194752&r2=194753
==============================================================================
--- team/group/security_events/doc/appdocsxml.dtd (original)
+++ team/group/security_events/doc/appdocsxml.dtd Fri May 15 13:24:46 2009
@@ -41,7 +41,7 @@
   <!ATTLIST option hasparams CDATA "">
 
   <!ELEMENT enumlist (enum+)>
-  <!ELEMENT enum (para|note|warning|parameter)*>
+  <!ELEMENT enum (para|note|warning|parameter|enumlist)*>
   <!ATTLIST enum name CDATA "">
 
   <!ELEMENT argument (para|note|warning|variablelist|argument)*>

Modified: team/group/security_events/include/asterisk/logger.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/include/asterisk/logger.h?view=diff&rev=194753&r1=194752&r2=194753
==============================================================================
--- team/group/security_events/include/asterisk/logger.h (original)
+++ team/group/security_events/include/asterisk/logger.h Fri May 15 13:24:46 2009
@@ -193,6 +193,37 @@
  * \return the debug level
  */
 unsigned int ast_verbose_get_by_file(const char *file);
+
+/*!
+ * \brief Register a new logger level
+ * \param name The name of the level to be registered
+ * \retval -1 if an error occurs
+ * \retval non-zero level to be used with ast_log for sending messages to this level
+ * \since 1.6.3
+ */
+int ast_logger_register_level(const char *name);
+
+/*!
+ * \brief Unregister a previously registered logger level
+ * \param name The name of the level to be unregistered
+ * \return nothing
+ * \since 1.6.3
+ */
+void ast_logger_unregister_level(const char *name);
+
+/*!
+ * \brief Send a log message to a dynamically registered log level
+ * \param level The log level to send the message to
+ *
+ * Like ast_log, the log message may include printf-style formats, and
+ * the data for these must be provided as additional parameters after
+ * the log message.
+ *
+ * \return nothing
+ * \since 1.6.3
+ */
+
+#define ast_log_dynamic_level(level, ...) ast_log(level, __FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
 
 /*!
  * \brief Log a DEBUG message

Modified: team/group/security_events/main/logger.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/main/logger.c?view=diff&rev=194753&r1=194752&r2=194753
==============================================================================
--- team/group/security_events/main/logger.c (original)
+++ team/group/security_events/main/logger.c Fri May 15 13:24:46 2009
@@ -54,7 +54,7 @@
 		        from <syslog.h> which is included by logger.h */
 #include <syslog.h>
 
-static int syslog_level_map[] = {
+static const int syslog_level_map[] = {
 	LOG_DEBUG,
 	LOG_INFO,    /* arbitrary equivalent of LOG_EVENT */
 	LOG_NOTICE,
@@ -89,14 +89,13 @@
 #else
 #define GETTID() getpid()
 #endif
-
 static char dateformat[256] = "%b %e %T";		/* Original Asterisk Format */
 
 static char queue_log_name[256] = QUEUELOG;
 static char exec_after_rotate[256] = "";
 
 static int filesize_reload_needed;
-static int global_logmask = -1;
+static unsigned int global_logmask = 0xFFFF;
 
 enum rotatestrategy {
 	SEQUENTIAL = 1 << 0,     /* Original method - create a new file, in order */
@@ -117,13 +116,24 @@
 };
 
 struct logchannel {
-	int logmask;			/* What to log to this channel */
-	int disabled;			/* If this channel is disabled or not */
-	int facility; 			/* syslog facility */
-	enum logtypes type;		/* Type of log channel */
-	FILE *fileptr;			/* logfile logging file pointer */
-	char filename[256];		/* Filename */
+	/*! What to log to this channel */
+	unsigned int logmask;
+	/*! If this channel is disabled or not */
+	int disabled;
+	/*! syslog facility */
+	int facility;
+	/*! Type of log channel */
+	enum logtypes type;
+	/*! logfile logging file pointer */
+	FILE *fileptr;
+	/*! Filename */
+	char filename[PATH_MAX];
+	/*! field for linking to list */
 	AST_LIST_ENTRY(logchannel) list;
+	/*! Line number from configuration file */
+	int lineno;
+	/*! Components (levels) from last config load */
+	char components[0];
 };
 
 static AST_RWLIST_HEAD_STATIC(logchannels, logchannel);
@@ -135,14 +145,17 @@
 
 struct logmsg {
 	enum logmsgtypes type;
-	char date[256];
 	int level;
-	char file[80];
 	int line;
-	char function[80];
 	long process_id;
+	AST_DECLARE_STRING_FIELDS(
+		AST_STRING_FIELD(date);
+		AST_STRING_FIELD(file);
+		AST_STRING_FIELD(function);
+		AST_STRING_FIELD(message);
+		AST_STRING_FIELD(level_name);
+	);
 	AST_LIST_ENTRY(logmsg) list;
-	char str[0];
 };
 
 static AST_LIST_HEAD_STATIC(logmsgs, logmsg);
@@ -152,26 +165,61 @@
 
 static FILE *qlog;
 
-/*! \brief Logging channels used in the Asterisk logging system */
-static char *levels[] = {
+/*! \brief Logging channels used in the Asterisk logging system
+ *
+ * The first 16 levels are reserved for system usage, and the remaining
+ * levels are reserved for usage by dynamic levels registered via
+ * ast_logger_register_level.
+ */
+
+/* Modifications to this array are protected by the rwlock in the
+ * logchannels list.
+ */
+
+static char *levels[32] = {
 	"DEBUG",
 	"---EVENT---",		/* no longer used */
 	"NOTICE",
 	"WARNING",
 	"ERROR",
 	"VERBOSE",
-	"DTMF"
+	"DTMF",
 };
 
 /*! \brief Colors used in the console for logging */
-static int colors[] = {
+static const int colors[32] = {
 	COLOR_BRGREEN,
-	COLOR_BRBLUE,
+	COLOR_BRBLUE,		/* no longer used */
 	COLOR_YELLOW,
 	COLOR_BRRED,
 	COLOR_RED,
 	COLOR_GREEN,
-	COLOR_BRGREEN
+	COLOR_BRGREEN,
+	0,
+	0,
+	0,
+	0,
+	0,
+	0,
+	0,
+	0,
+	0,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
+	COLOR_BRBLUE,
 };
 
 AST_THREADSTORAGE(verbose_buf);
@@ -180,28 +228,24 @@
 AST_THREADSTORAGE(log_buf);
 #define LOG_BUF_INIT_SIZE       256
 
-static int make_components(const char *s, int lineno)
+static unsigned int make_components(const char *s, int lineno)
 {
 	char *w;
-	int res = 0;
+	unsigned int res = 0;
 	char *stringp = ast_strdupa(s);
+	unsigned int x;
 
 	while ((w = strsep(&stringp, ","))) {
+		int found = 0;
+
 		w = ast_skip_blanks(w);
-		if (!strcasecmp(w, "error")) 
-			res |= (1 << __LOG_ERROR);
-		else if (!strcasecmp(w, "warning"))
-			res |= (1 << __LOG_WARNING);
-		else if (!strcasecmp(w, "notice"))
-			res |= (1 << __LOG_NOTICE);
-		else if (!strcasecmp(w, "debug"))
-			res |= (1 << __LOG_DEBUG);
-		else if (!strcasecmp(w, "verbose"))
-			res |= (1 << __LOG_VERBOSE);
-		else if (!strcasecmp(w, "dtmf"))
-			res |= (1 << __LOG_DTMF);
-		else {
-			fprintf(stderr, "Logfile Warning: Unknown keyword '%s' at line %d of logger.conf\n", w, lineno);
+
+		for (x = 0; x < ARRAY_LEN(levels); x++) {
+			if (levels[x] && !strcasecmp(w, levels[x])) {
+				res |= (1 << x);
+				found = 1;
+				break;
+			}
 		}
 	}
 
@@ -216,8 +260,11 @@
 	CODE *cptr;
 #endif
 
-	if (ast_strlen_zero(channel) || !(chan = ast_calloc(1, sizeof(*chan))))
+	if (ast_strlen_zero(channel) || !(chan = ast_calloc(1, sizeof(*chan) + strlen(components) + 1)))
 		return NULL;
+
+	strcpy(chan->components, components);
+	chan->lineno = lineno;
 
 	if (!strcasecmp(channel, "console")) {
 		chan->type = LOGTYPE_CONSOLE;
@@ -292,7 +339,7 @@
 		}
 
 		chan->type = LOGTYPE_SYSLOG;
-		snprintf(chan->filename, sizeof(chan->filename), "%s", channel);
+		ast_copy_string(chan->filename, channel, sizeof(chan->filename));
 		openlog("asterisk", LOG_PID, chan->facility);
 	} else {
 		if (!ast_strlen_zero(hostname)) {
@@ -302,14 +349,14 @@
 			snprintf(chan->filename, sizeof(chan->filename), "%s/%s",
 				 channel[0] != '/' ? ast_config_AST_LOG_DIR : "", channel);
 		}
-		chan->fileptr = fopen(chan->filename, "a");
-		if (!chan->fileptr) {
+		if (!(chan->fileptr = fopen(chan->filename, "a"))) {
 			/* Can't log here, since we're called with a lock */
 			fprintf(stderr, "Logger Warning: Unable to open log file '%s': %s\n", chan->filename, strerror(errno));
 		} 
 		chan->type = LOGTYPE_FILE;
 	}
-	chan->logmask = make_components(components, lineno);
+	chan->logmask = make_components(chan->components, lineno);
+
 	return chan;
 }
 
@@ -329,10 +376,10 @@
 		AST_RWLIST_WRLOCK(&logchannels);
 	while ((chan = AST_RWLIST_REMOVE_HEAD(&logchannels, list)))
 		ast_free(chan);
+	global_logmask = 0;
 	if (!locked)
 		AST_RWLIST_UNLOCK(&logchannels);
 	
-	global_logmask = 0;
 	errno = 0;
 	/* close syslog */
 	closelog();
@@ -346,13 +393,13 @@
 		if (!(chan = ast_calloc(1, sizeof(*chan))))
 			return;
 		chan->type = LOGTYPE_CONSOLE;
-		chan->logmask = 28; /*warning,notice,error */
+		chan->logmask = __LOG_WARNING | __LOG_NOTICE | __LOG_ERROR;
 		if (!locked)
 			AST_RWLIST_WRLOCK(&logchannels);
 		AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);
+		global_logmask |= chan->logmask;
 		if (!locked)
 			AST_RWLIST_UNLOCK(&logchannels);
-		global_logmask |= chan->logmask;
 		return;
 	}
 	
@@ -711,12 +758,16 @@
 	if (a->argc < 5)
 		return CLI_SHOWUSAGE;
 
-	for (x = 0; x <= NUMLOGLEVELS; x++) {
-		if (!strcasecmp(a->argv[3], levels[x])) {
+	AST_RWLIST_WRLOCK(&logchannels);
+
+	for (x = 0; x < ARRAY_LEN(levels); x++) {
+		if (levels[x] && !strcasecmp(a->argv[3], levels[x])) {
 			level = x;
 			break;
 		}
 	}
+
+	AST_RWLIST_UNLOCK(&logchannels);
 
 	state = ast_true(a->argv[4]) ? 1 : 0;
 
@@ -750,21 +801,16 @@
 	ast_cli(a->fd, "-------------\n");
 	AST_RWLIST_RDLOCK(&logchannels);
 	AST_RWLIST_TRAVERSE(&logchannels, chan, list) {
+		unsigned int level;
+
 		ast_cli(a->fd, FORMATL, chan->filename, chan->type == LOGTYPE_CONSOLE ? "Console" : (chan->type == LOGTYPE_SYSLOG ? "Syslog" : "File"),
 			chan->disabled ? "Disabled" : "Enabled");
 		ast_cli(a->fd, " - ");
-		if (chan->logmask & (1 << __LOG_DEBUG)) 
-			ast_cli(a->fd, "Debug ");
-		if (chan->logmask & (1 << __LOG_DTMF)) 
-			ast_cli(a->fd, "DTMF ");
-		if (chan->logmask & (1 << __LOG_VERBOSE)) 
-			ast_cli(a->fd, "Verbose ");
-		if (chan->logmask & (1 << __LOG_WARNING)) 
-			ast_cli(a->fd, "Warning ");
-		if (chan->logmask & (1 << __LOG_NOTICE)) 
-			ast_cli(a->fd, "Notice ");
-		if (chan->logmask & (1 << __LOG_ERROR)) 
-			ast_cli(a->fd, "Error ");
+		for (level = 0; level < ARRAY_LEN(levels); level++) {
+			if (chan->logmask & (1 << level)) {
+				ast_cli(a->fd, "%s ", levels[level]);
+			}
+		}
 		ast_cli(a->fd, "\n");
 	}
 	AST_RWLIST_UNLOCK(&logchannels);
@@ -794,7 +840,7 @@
 	return 0;
 }
 
-static void ast_log_vsyslog(int level, const char *file, int line, const char *function, char *str, long pid)
+static void ast_log_vsyslog(int level, const char *file, int line, const char *function, const char *str, long pid)
 {
 	char buf[BUFSIZ];
 
@@ -834,7 +880,7 @@
 				continue;
 			/* Check syslog channels */
 			if (chan->type == LOGTYPE_SYSLOG && (chan->logmask & (1 << logmsg->level))) {
-				ast_log_vsyslog(logmsg->level, logmsg->file, logmsg->line, logmsg->function, logmsg->str, logmsg->process_id);
+				ast_log_vsyslog(logmsg->level, logmsg->file, logmsg->line, logmsg->function, logmsg->message, logmsg->process_id);
 			/* Console channels */
 			} else if (chan->type == LOGTYPE_CONSOLE && (chan->logmask & (1 << logmsg->level))) {
 				char linestr[128];
@@ -849,12 +895,12 @@
 				/* Build string to print out */
 				snprintf(buf, sizeof(buf), "[%s] %s[%ld]: %s:%s %s: %s",
 					 logmsg->date,
-					 term_color(tmp1, levels[logmsg->level], colors[logmsg->level], 0, sizeof(tmp1)),
+					 term_color(tmp1, logmsg->level_name, colors[logmsg->level], 0, sizeof(tmp1)),
 					 logmsg->process_id,
 					 term_color(tmp2, logmsg->file, COLOR_BRWHITE, 0, sizeof(tmp2)),
 					 term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
 					 term_color(tmp4, logmsg->function, COLOR_BRWHITE, 0, sizeof(tmp4)),
-					 logmsg->str);
+					 logmsg->message);
 				/* Print out */
 				ast_console_puts_mutable(buf, logmsg->level);
 			/* File channels */
@@ -867,8 +913,8 @@
 				
 				/* Print out to the file */
 				res = fprintf(chan->fileptr, "[%s] %s[%ld] %s: %s",
-					      logmsg->date, levels[logmsg->level], logmsg->process_id, logmsg->file, logmsg->str);
-				if (res <= 0 && !ast_strlen_zero(logmsg->str)) {
+					      logmsg->date, logmsg->level_name, logmsg->process_id, logmsg->file, logmsg->message);
+				if (res <= 0 && !ast_strlen_zero(logmsg->message)) {
 					fprintf(stderr, "**** Asterisk Logging Error: ***********\n");
 					if (errno == ENOMEM || errno == ENOSPC)
 						fprintf(stderr, "Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->filename);
@@ -882,7 +928,7 @@
 			}
 		}
 	} else if (logmsg->level != __LOG_VERBOSE) {
-		fputs(logmsg->str, stdout);
+		fputs(logmsg->message, stdout);
 	}
 
 	AST_RWLIST_UNLOCK(&logchannels);
@@ -904,7 +950,7 @@
 	/* Iterate through the list of verbosers and pass them the log message string */
 	AST_RWLIST_RDLOCK(&verbosers);
 	AST_RWLIST_TRAVERSE(&verbosers, v, list)
-		v->verboser(logmsg->str);
+		v->verboser(logmsg->message);
 	AST_RWLIST_UNLOCK(&verbosers);
 
 	return;
@@ -941,6 +987,7 @@
 				logger_print_verbose(msg);
 
 			/* Free the data since we are done */
+			ast_string_field_free_memory(msg);
 			ast_free(msg);
 		}
 
@@ -1028,6 +1075,7 @@
 	struct timeval now = ast_tvnow();
 	int res = 0;
 	va_list ap;
+	char datestring[256];
 
 	if (!(buf = ast_str_thread_get(&log_buf, LOG_BUF_INIT_SIZE)))
 		return;
@@ -1073,24 +1121,26 @@
 		return;
 
 	/* Create a new logging message */
-	if (!(logmsg = ast_calloc(1, sizeof(*logmsg) + res + 1)))
+	if (!(logmsg = ast_calloc_with_stringfields(1, struct logmsg, res + 128)))
 		return;
 
 	/* Copy string over */
-	strcpy(logmsg->str, ast_str_buffer(buf));
+	ast_string_field_set(logmsg, message, ast_str_buffer(buf));
 
 	/* Set type to be normal */
 	logmsg->type = LOGMSG_NORMAL;
 
 	/* Create our date/time */
 	ast_localtime(&now, &tm, NULL);
-	ast_strftime(logmsg->date, sizeof(logmsg->date), dateformat, &tm);
+	ast_strftime(datestring, sizeof(datestring), dateformat, &tm);
+	ast_string_field_set(logmsg, date, datestring);
 
 	/* Copy over data */
 	logmsg->level = level;
 	logmsg->line = line;
-	ast_copy_string(logmsg->file, file, sizeof(logmsg->file));
-	ast_copy_string(logmsg->function, function, sizeof(logmsg->function));
+	ast_string_field_set(logmsg, level_name, levels[level]);
+	ast_string_field_set(logmsg, file, file);
+	ast_string_field_set(logmsg, function, function);
 	logmsg->process_id = (long) GETTID();
 
 	/* If the logger thread is active, append it to the tail end of the list - otherwise skip that step */
@@ -1206,12 +1256,12 @@
 	if (res == AST_DYNSTR_BUILD_FAILED)
 		return;
 
-	if (!(logmsg = ast_calloc(1, sizeof(*logmsg) + res + 1)))
-		return;
-
-	strcpy(logmsg->str, ast_str_buffer(buf));
-
-	ast_log(__LOG_VERBOSE, file, line, func, "%s", logmsg->str + 1);
+	if (!(logmsg = ast_calloc_with_stringfields(1, struct logmsg, res + 128)))
+		return;
+
+	ast_string_field_set(logmsg, message, ast_str_buffer(buf));
+
+	ast_log(__LOG_VERBOSE, file, line, func, "%s", logmsg->message + 1);
 
 	/* Set type */
 	logmsg->type = LOGMSG_VERBOSE;
@@ -1231,6 +1281,7 @@
 void __ast_verbose(const char *file, int line, const char *func, const char *fmt, ...)
 {
 	va_list ap;
+
 	va_start(ap, fmt);
 	__ast_verbose_ap(file, line, func, fmt, ap);
 	va_end(ap);
@@ -1242,6 +1293,7 @@
 void ast_verbose(const char *fmt, ...)
 {
 	va_list ap;
+
 	va_start(ap, fmt);
 	__ast_verbose_ap("", 0, "", fmt, ap);
 	va_end(ap);
@@ -1280,3 +1332,102 @@
 	
 	return cur ? 0 : -1;
 }
+
+static void update_logchannels(void)
+{
+	struct logchannel *cur;
+
+	AST_RWLIST_WRLOCK(&logchannels);
+
+	global_logmask = 0;
+
+	AST_RWLIST_TRAVERSE(&logchannels, cur, list) {
+		cur->logmask = make_components(cur->components, cur->lineno);
+		global_logmask |= cur->logmask;
+	}
+
+	AST_RWLIST_UNLOCK(&logchannels);
+}
+
+int ast_logger_register_level(const char *name)
+{
+	unsigned int level;
+	unsigned int available = 0;
+
+	AST_RWLIST_WRLOCK(&logchannels);
+
+	for (level = 0; level < ARRAY_LEN(levels); level++) {
+		if ((level >= 16) && !available && !levels[level]) {
+			available = level;
+			continue;
+		}
+
+		if (levels[level] && !strcasecmp(levels[level], name)) {
+			ast_log(LOG_WARNING,
+				"Unable to register dynamic logger level '%s': a standard logger level uses that name.\n",
+				name);
+			AST_RWLIST_UNLOCK(&logchannels);
+
+			return -1;
+		}
+	}
+
+	if (!available) {
+		ast_log(LOG_WARNING,
+			"Unable to register dynamic logger level '%s'; maximum number of levels registered.\n",
+			name);
+		AST_RWLIST_UNLOCK(&logchannels);
+
+		return -1;
+	}
+
+	levels[available] = ast_strdup(name);
+
+	AST_RWLIST_UNLOCK(&logchannels);
+
+	ast_debug(1, "Registered dynamic logger level '%s' with index %d.\n", name, available);
+
+	update_logchannels();
+
+	return available;
+}
+
+void ast_logger_unregister_level(const char *name)
+{
+	unsigned int found = 0;
+	unsigned int x;
+
+	AST_RWLIST_WRLOCK(&logchannels);
+
+	for (x = 16; x < ARRAY_LEN(levels); x++) {
+		if (!levels[x]) {
+			continue;
+		}
+
+		if (strcasecmp(levels[x], name)) {
+			continue;
+		}
+
+		found = 1;
+		break;
+	}
+
+	if (found) {
+		/* take this level out of the global_logmask, to ensure that no new log messages
+		 * will be queued for it
+		 */
+
+		global_logmask &= ~(1 << x);
+
+		free(levels[x]);
+		levels[x] = NULL;
+		AST_RWLIST_UNLOCK(&logchannels);
+
+		ast_debug(1, "Unregistered dynamic logger level '%s' with index %d.\n", name, x);
+
+		update_logchannels();
+	} else {
+		AST_RWLIST_UNLOCK(&logchannels);
+	}
+}
+

Modified: team/group/security_events/main/xmldoc.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/security_events/main/xmldoc.c?view=diff&rev=194753&r1=194752&r2=194753
==============================================================================
--- team/group/security_events/main/xmldoc.c (original)
+++ team/group/security_events/main/xmldoc.c Fri May 15 13:24:46 2009
@@ -60,6 +60,7 @@
 };
 
 static char *xmldoc_get_syntax_cmd(struct ast_xml_node *fixnode, const char *name, int printname);
+static int xmldoc_parse_enumlist(struct ast_xml_node *fixnode, const char *tabs, struct ast_str **buffer);
 
 /*!
  * \brief Container of documentation trees
@@ -1400,6 +1401,9 @@
 {
 	struct ast_xml_node *node = fixnode;
 	int ret = 0;
+	char *optiontabs;
+
+	ast_asprintf(&optiontabs, "%s    ", tabs);
 
 	for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) {
 		if ((xmldoc_parse_para(node, (ret ? tabs : " - "), "\n", buffer))) {
@@ -1407,7 +1411,12 @@
 		} else if ((xmldoc_parse_specialtags(node, (ret ? tabs : " - "), "\n", buffer))) {
 			ret = 1;
 		}
-	}
+
+		xmldoc_parse_enumlist(node, optiontabs, buffer);
+	}
+
+	ast_free(optiontabs);
+
 	return ret;
 }
 




More information about the svn-commits mailing list