[Freeswitch-svn] [commit] r5026 - in freeswitch/branches/anthonyl/fs-branch/src: . include mod/applications/mod_playback mod/codecs/mod_g729 mod/loggers/mod_log2file

Freeswitch SVN anthonyl at freeswitch.org
Fri Apr 27 02:31:31 EDT 2007


Author: anthonyl
Date: Fri Apr 27 02:31:30 2007
New Revision: 5026

Modified:
   freeswitch/branches/anthonyl/fs-branch/src/include/switch_am_config.h.in
   freeswitch/branches/anthonyl/fs-branch/src/mod/applications/mod_playback/mod_playback.c
   freeswitch/branches/anthonyl/fs-branch/src/mod/codecs/mod_g729/mod_g729.c
   freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c
   freeswitch/branches/anthonyl/fs-branch/src/switch_console.c

Log:
god knows what i was updating here. im trying to get back to work on this code now that i have freetime


Modified: freeswitch/branches/anthonyl/fs-branch/src/include/switch_am_config.h.in
==============================================================================
--- freeswitch/branches/anthonyl/fs-branch/src/include/switch_am_config.h.in	(original)
+++ freeswitch/branches/anthonyl/fs-branch/src/include/switch_am_config.h.in	Fri Apr 27 02:31:30 2007
@@ -127,5 +127,5 @@
 /* Define to rpl_malloc if the replacement function should be used. */
 #undef malloc
 
-/* Define to `unsigned' if <sys/types.h> does not define. */
+/* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t

Modified: freeswitch/branches/anthonyl/fs-branch/src/mod/applications/mod_playback/mod_playback.c
==============================================================================
--- freeswitch/branches/anthonyl/fs-branch/src/mod/applications/mod_playback/mod_playback.c	(original)
+++ freeswitch/branches/anthonyl/fs-branch/src/mod/applications/mod_playback/mod_playback.c	Fri Apr 27 02:31:30 2007
@@ -116,7 +116,7 @@
     switch_input_args_t args = {0};
 
 	file_name = switch_core_session_strdup(session, data);
-
+    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "param is %s\n", file_name);
 	channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
 

Modified: freeswitch/branches/anthonyl/fs-branch/src/mod/codecs/mod_g729/mod_g729.c
==============================================================================
--- freeswitch/branches/anthonyl/fs-branch/src/mod/codecs/mod_g729/mod_g729.c	(original)
+++ freeswitch/branches/anthonyl/fs-branch/src/mod/codecs/mod_g729/mod_g729.c	Fri Apr 27 02:31:30 2007
@@ -30,6 +30,9 @@
  *
  * mod_g729.c -- G729 Codec Module
  *
+ * with modifactions to use the asterisk codec_g729.so module
+ * (the asterisk 1.4 version api)
+ *
  */  
 
 static const char modname[] = "mod_g729";
@@ -45,6 +48,13 @@
 };
 #endif
 
+
+/* load the asterisk codec_g729a.so module */
+static void load_asterisk_codec(void)
+{
+    return;
+}
+
 static switch_status_t switch_g729_init(switch_codec_t *codec, switch_codec_flag_t flags,
 									  const switch_codec_settings_t *codec_settings) 
 {

Modified: freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c
==============================================================================
--- freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c	(original)
+++ freeswitch/branches/anthonyl/fs-branch/src/mod/loggers/mod_log2file/mod_log2file.c	Fri Apr 27 02:31:30 2007
@@ -35,17 +35,22 @@
 
 #define MAX_LENGTH       1024
 #define DEFAULT_FORMAT   "${data}" /* for the most part this contains all that we need by default */
+#define DEFAULT_LOGFILE  "/var/log/freeswitch"
+#define DEFAULT_LIMIT    0x7FFFFFFF
 
+static const uint8_t STATIC_LEVELS[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
 static const char modname[] = "mod_log2file";
+
 static switch_status_t load_config(void);
+static switch_status_t mod_log2file_check(void);
+
 static struct {
-    int log_fd;
-    int log_size;   /* keep the log size in check for rotation */
-    char *logfile;
-	char *format;
+    unsigned int log_fd;
+    unsigned int log_size;   /* keep the log size in check for rotation */
+    unsigned char *logfile;
+	unsigned char *format;
 } globals;
 
-
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_logfile, globals.logfile)
 SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_format, globals.format)
 
@@ -72,23 +77,45 @@
         return SWITCH_STATUS_FALSE;
     }    
     globals.log_fd = fd;
+    mod_log2file_check();
     return SWITCH_STATUS_SUCCESS;
 }
 
+/* rotate the log file */
 static switch_status_t mod_log2file_rotate(void)
 {
+    int fd;
+    int fd2;
+    unsigned char *p;
+
+    globals.log_size = 0;
+    
     return SWITCH_STATUS_SUCCESS;
 }
 
 /* check the size of the file for rotation */
 static switch_status_t mod_log2file_check(void)
 {
+    off_t off;
+    
+    if((off = ftello(globals.log_fd)) < 0) {
+        return SWITCH_STATUS_FALSE;
+    }
+
+    printf("\n****** OFF is %i\n", off);
+    
+    if (off >= DEFAULT_LIMIT) {
+        return mod_log2file_rotate();
+    }
+    
+    globals.log_size = off;
     return SWITCH_STATUS_SUCCESS;
 }
 
 /* write to the actual logfile */
 static switch_status_t mod_log2file_write(char *fmt, ...) 
 {
+    int ret;
     unsigned int len;
     char log_data[MAX_LENGTH]; /* seems like a waste of stack space no ;), i'll fix this later */   
     va_list args;
@@ -99,7 +126,12 @@
 #else
     vsnprintf((char *)&log_data, sizeof(log_data), fmt, args);
 #endif
-    fprintf(globals.log_fd, "%s" , log_data);
+    if ((ret = fprintf(globals.log_fd, "%s" , log_data))<0) {
+        return SWITCH_STATUS_FALSE;
+    }
+    globals.log_size += ret;
+    /* we may want to hold back on this for preformance reasons */
+    mod_log2file_check();
     return SWITCH_STATUS_SUCCESS;
 }
 
@@ -163,12 +195,15 @@
 		}
 		switch_xml_free(xml);
 	}
+    
+    if (switch_strlen_zero(globals.logfile)) {
+        set_global_logfile(DEFAULT_LOGFILE);
+    }
 
 	if (switch_strlen_zero(globals.format)) {
 		set_global_format(DEFAULT_FORMAT);
 	}
 
-
 	return 0;
 }
 

Modified: freeswitch/branches/anthonyl/fs-branch/src/switch_console.c
==============================================================================
--- freeswitch/branches/anthonyl/fs-branch/src/switch_console.c	(original)
+++ freeswitch/branches/anthonyl/fs-branch/src/switch_console.c	Fri Apr 27 02:31:30 2007
@@ -101,7 +101,7 @@
 	char *arg = NULL;
 	switch_stream_handle_t stream = {0};
 
-	if (!strcmp(cmd, "shutdown") || !strcmp(cmd, "...")) {
+	if (!strcmp(cmd, "shutdown") || !strcmp(cmd, "...") || !strcmp(cmd, "quit")) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Bye!\n");
 		return 0;
 	}



More information about the Freeswitch-svn mailing list