[Freeswitch-svn] [commit] r1158 - in freeswitch/trunk: . conf src src/include src/mod/loggers/mod_syslog

mikej at freeswitch.org mikej at freeswitch.org
Wed Jun 7 14:28:30 EDT 2006


Author: mikej
Date: Fri Apr 14 12:45:31 2006
New Revision: 1158

Added:
   freeswitch/trunk/src/mod/loggers/mod_syslog/
      - copied from r1155, /freeswitch/branches/james/src/mod/loggers/mod_syslog/
   freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c
      - copied unchanged from r1155, /freeswitch/branches/james/src/mod/loggers/mod_syslog/mod_syslog.c
Modified:
   freeswitch/trunk/AUTHORS
   freeswitch/trunk/conf/freeswitch.conf
   freeswitch/trunk/src/include/switch_utils.h
   freeswitch/trunk/src/switch_utils.c

Log:
Addition of mod_syslog for *nix.  Thanks to James Martelletti.

Modified: freeswitch/trunk/AUTHORS
==============================================================================
--- freeswitch/trunk/AUTHORS	(original)
+++ freeswitch/trunk/AUTHORS	Fri Apr 14 12:45:31 2006
@@ -20,6 +20,7 @@
  Brian K. West - For countless hours of work on BSD and Mac support, finding countless bugs, 
   and moral support.
  Michal "cypromis" Bielicki (michal.bielicki  AT halo2.pl) - Solaris porting, and autotools enhancements.
+ James Martelletti <james at nerdc0re.com> - All around cool guy (mod_syslog)
  
 A big THANK YOU goes to:
 

Modified: freeswitch/trunk/conf/freeswitch.conf
==============================================================================
--- freeswitch/trunk/conf/freeswitch.conf	(original)
+++ freeswitch/trunk/conf/freeswitch.conf	Fri Apr 14 12:45:31 2006
@@ -18,6 +18,7 @@
 
 ; Loggers (I'd load these first)
 load => mod_console
+load => mod_syslog
 
 ; Event Handlers
 ;load => mod_event_multicast
@@ -67,6 +68,23 @@
 ; ASR /TTS
 ;load => mod_cepstral
 
+;---- SYSLOG
+;--------------------------------------------------------------------------------
+; emerg   - system is unusable 
+; alert   - action must be taken immediately 
+; crit    - critical conditions 
+; err     - error conditions 
+; warning - warning conditions 
+; notice  - normal, but significant, condition 
+; info    - informational message 
+; debug   - debug-level message
+;
+[+syslog.conf]
+[settings]
+ident    => freeswitch
+facility => user
+format   => ${time} - ${message}
+level    => debug,info,warning-alert
 
 
 ;---- IAX PROTOCOL

Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h	(original)
+++ freeswitch/trunk/src/include/switch_utils.h	Fri Apr 14 12:45:31 2006
@@ -174,6 +174,8 @@
 */
 SWITCH_DECLARE(char *) switch_cut_path(char *in);
 
+SWITCH_DECLARE(char *) switch_string_replace(const char *string, const char *search, const char *replace);
+SWITCH_DECLARE(switch_status) switch_string_match(const char *string, size_t string_len, const char *search, size_t search_len);
 
 #ifdef __cplusplus
 }

Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c	(original)
+++ freeswitch/trunk/src/switch_utils.c	Fri Apr 14 12:45:31 2006
@@ -30,6 +30,9 @@
  *
  */
 #include <switch.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
 
 SWITCH_DECLARE(char *) switch_priority_name(switch_priority_t priority)
 {
@@ -141,6 +144,52 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+SWITCH_DECLARE(switch_status) switch_string_match(const char *string, size_t string_len, const char *search, size_t search_len)
+{
+	size_t i;
+
+	for (i = 0; (i < search_len) && (i < string_len); i++) {
+		if (string[i] != search[i]) {
+			return SWITCH_STATUS_FALSE;
+		}
+	}	
+	
+	if (i == search_len) {
+		return SWITCH_STATUS_SUCCESS;
+	}
+
+	return SWITCH_STATUS_FALSE;
+}
+
+SWITCH_DECLARE(char *) switch_string_replace(const char *string, const char *search, const char *replace)
+{
+	size_t string_len = strlen(string);
+	size_t search_len = strlen(search);
+	size_t replace_len = strlen(replace);
+	size_t i, n;
+	size_t dest_len = 0;
+	char *dest;
+  
+	dest = (char *)malloc(sizeof(char));
+
+	for (i = 0; i < string_len; i++) {
+		if (switch_string_match(string + i, string_len - i, search, search_len) == SWITCH_STATUS_SUCCESS) {
+			for (n = 0; n < replace_len; n++) {
+				dest[dest_len] = replace[n];
+				dest_len++;
+				dest = (char *)realloc(dest, sizeof(char)*(dest_len+1));
+			}
+			i += search_len-1;
+		} else {
+			dest[dest_len] = string[i];
+			dest_len++;
+			dest = (char *)realloc(dest, sizeof(char)*(dest_len+1));
+		}
+	}
+
+	dest[dest_len] = 0;
+	return dest;
+}
 
 SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms)
 {



More information about the Freeswitch-svn mailing list