[Freeswitch-svn] [commit] r4241 - in freeswitch/trunk/src: . include

Freeswitch SVN mikej at freeswitch.org
Tue Feb 13 16:03:06 EST 2007


Author: mikej
Date: Tue Feb 13 16:03:06 2007
New Revision: 4241

Modified:
   freeswitch/trunk/src/include/switch_console.h
   freeswitch/trunk/src/include/switch_utils.h
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_console.c
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_log.c
   freeswitch/trunk/src/switch_utils.c

Log:
constify some arguments to switch_console_printf and switch_cut_path and remove improper casts for the consumers of those functions.

Modified: freeswitch/trunk/src/include/switch_console.h
==============================================================================
--- freeswitch/trunk/src/include/switch_console.h	(original)
+++ freeswitch/trunk/src/include/switch_console.h	Tue Feb 13 16:03:06 2007
@@ -62,7 +62,7 @@
 /*!
   \brief A method akin to printf that allows you to redirect output to a specific console "channel"
 */
-SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, ...) PRINTF_FUNCTION(5,6);
+SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt, ...) PRINTF_FUNCTION(5,6);
 
 /*!
   \brief A method akin to printf for dealing with api streams

Modified: freeswitch/trunk/src/include/switch_utils.h
==============================================================================
--- freeswitch/trunk/src/include/switch_utils.h	(original)
+++ freeswitch/trunk/src/include/switch_utils.h	Tue Feb 13 16:03:06 2007
@@ -274,7 +274,7 @@
   \brief Create a pointer to the file name in a given file path eliminating the directory name
   \return the pointer to the next character after the final / or \\ characters
 */
-SWITCH_DECLARE(char *) switch_cut_path(char *in);
+SWITCH_DECLARE(const char *) switch_cut_path(const char *in);
 
 #define switch_clean_re(re)	if (re) {\
 				pcre_free(re);\

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Tue Feb 13 16:03:06 2007
@@ -612,7 +612,7 @@
 		if (state > CS_RING) {
 			switch_channel_presence(channel, "unknown", (char*)state_names[state]);
 		}
-		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", 
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", 
 						  channel->name,
 						  state_names[last_state], 
 						  state_names[state]);
@@ -645,7 +645,7 @@
 		}
 		
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n", 
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n", 
 						  channel->name,
 						  state_names[last_state],
 						  state_names[state]);
@@ -958,7 +958,7 @@
 		switch_channel_state_t last_state = channel->state;
 		channel->state = CS_HANGUP;
 		channel->hangup_cause = hangup_cause;
-		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", 
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", 
 						  channel->name,
 						  state_names[last_state], switch_channel_cause2str(channel->hangup_cause));
 		if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP) == SWITCH_STATUS_SUCCESS) {
@@ -985,7 +985,7 @@
 																	   int line)
 {
 	if (!switch_channel_test_flag(channel, CF_RING_READY)) {
-        switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name);
+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name);
 		switch_channel_set_flag(channel, CF_RING_READY);
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -1008,7 +1008,7 @@
         char *uuid;
         switch_core_session_t *other_session;
 
-        switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name);
+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name);
         switch_channel_set_flag(channel, CF_EARLY_MEDIA);
         switch_channel_set_variable(channel, "endpoint_disposition", "EARLY MEDIA");
         if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PROGRESS) == SWITCH_STATUS_SUCCESS) {
@@ -1091,7 +1091,7 @@
 	status = switch_core_session_message_send(uuid, &msg);
 
 	if (status == SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
+		switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
 	}
 
 	return status;
@@ -1138,7 +1138,7 @@
     }
 
     switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
-    switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name);
+    switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name);
     
     return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/trunk/src/switch_console.c
==============================================================================
--- freeswitch/trunk/src/switch_console.c	(original)
+++ freeswitch/trunk/src/switch_console.c	Tue Feb 13 16:03:06 2007
@@ -132,14 +132,14 @@
 	return 1;
 }
 
-SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line,
-										   char *fmt, ...)
+SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line,
+										   const char *fmt, ...)
 {
 	char *data = NULL;
 	int ret = 0;
 	va_list ap;
 	FILE *handle;
-	char *filep = switch_cut_path(file);
+	const char *filep = switch_cut_path(file);
 
 	va_start(ap, fmt);
 

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Tue Feb 13 16:03:06 2007
@@ -589,13 +589,13 @@
         if (switch_test_flag(session, SSF_DESTROYED)) {
             status = SWITCH_STATUS_FALSE;
 #ifdef SWITCH_DEBUG_RWLOCKS
-            switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s Read lock FAIL\n", 
+            switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s Read lock FAIL\n", 
                               switch_channel_get_name(session->channel));
 #endif
         } else {
             status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock);
 #ifdef SWITCH_DEBUG_RWLOCKS
-            switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s Read lock AQUIRED\n", 
+            switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s Read lock AQUIRED\n", 
                               switch_channel_get_name(session->channel));
 #endif
         }	
@@ -611,7 +611,7 @@
                                                             int line)
 {
 
-    switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s Write lock AQUIRED\n", 
+    switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s Write lock AQUIRED\n", 
                       switch_channel_get_name(session->channel));
 #else
 SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *session)
@@ -626,7 +626,7 @@
                                                   const char *func,
                                                   int line)
 {
-    switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s Read/Write lock CLEARED\n", 
+    switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s Read/Write lock CLEARED\n", 
                       switch_channel_get_name(session->channel));
 #else
 SWITCH_DECLARE(void) switch_core_session_rwunlock(switch_core_session_t *session)
@@ -2495,7 +2495,7 @@
 	switch_io_event_hook_kill_channel_t *ptr;
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	
-	switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_INFO, "Kill %s [%d]\n", switch_channel_get_name(session->channel), sig);
+	switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_INFO, "Kill %s [%d]\n", switch_channel_get_name(session->channel), sig);
 
 	if (session->endpoint_interface->io_routines->kill_channel) {
 		if ((status = session->endpoint_interface->io_routines->kill_channel(session, sig)) == SWITCH_STATUS_SUCCESS) {

Modified: freeswitch/trunk/src/switch_log.c
==============================================================================
--- freeswitch/trunk/src/switch_log.c	(original)
+++ freeswitch/trunk/src/switch_log.c	Tue Feb 13 16:03:06 2007
@@ -169,7 +169,7 @@
 	int ret = 0;
 	va_list ap;
 	FILE *handle;
-	const char *filep = (file ? (const char *)switch_cut_path((char *)file): "");
+	const char *filep = (file ? switch_cut_path(file): "");
 	const char *funcp = (func ? func : "");
 	char *content = NULL;
 	switch_time_t now = switch_time_now();

Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c	(original)
+++ freeswitch/trunk/src/switch_utils.c	Tue Feb 13 16:03:06 2007
@@ -496,11 +496,11 @@
 	return argc;
 }
 
-SWITCH_DECLARE(char *) switch_cut_path(char *in)
+SWITCH_DECLARE(const char *) switch_cut_path(const char *in)
 {
-	char *p, *ret = in;
-	char delims[] = "/\\";
-	char *i;
+	const char *p, *ret = in;
+	const char delims[] = "/\\";
+	const char *i;
 
 	if (in) {
 		for (i = delims; *i; i++) {



More information about the Freeswitch-svn mailing list