]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
constify some arguments to switch_console_printf and switch_cut_path and remove impro...
authorMichael Jerris <mike@jerris.com>
Tue, 13 Feb 2007 21:03:06 +0000 (21:03 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 13 Feb 2007 21:03:06 +0000 (21:03 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4241 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_console.h
src/include/switch_utils.h
src/switch_channel.c
src/switch_console.c
src/switch_core.c
src/switch_log.c
src/switch_utils.c

index f49a5677f7869625cf8318875c92d5504112ce04..e7a2d271e72796df8bf57c2d0eb4554a39e73499 100644 (file)
@@ -62,7 +62,7 @@ SWITCH_DECLARE(void) switch_console_loop(void);
 /*!
   \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
index 0a4fa622773be92efe0155d2c1a789c3e7499777..f45c75e895ac7272588835816255fddd085b0962 100644 (file)
@@ -274,7 +274,7 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms);
   \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);\
index 414580a1259d4a24b2190658e72a5ad262474537..0ea00fa30f18360c744300661749cc109513736e 100644 (file)
@@ -612,7 +612,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                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 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
                }
                
        } 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_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan
                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 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch
                                                                                                                                           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 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_
         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 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel
        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_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
     }
 
     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;
 }
index 1752b24a86c437eb0866a13f5948eaad5ae0791c..f1d30ea218316bcb4706847e974053029605f3e2 100644 (file)
@@ -132,14 +132,14 @@ static int switch_console_process(char *cmd)
        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);
 
index a43d52fe91e10f156eefe6783f2cf2246d52fb54..4d73b4acce614527b0226ead19e8e7058f613921 100644 (file)
@@ -589,13 +589,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio
         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 @@ SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_
                                                             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 @@ SWITCH_DECLARE(void) switch_core_session_perform_rwunlock(switch_core_session_t
                                                   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_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_
        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) {
index 0cbdb293f5acdb644a03de76e9738783c9e1fddd..1928bea15b84ac684f672074657e0e093a878de8 100644 (file)
@@ -169,7 +169,7 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char
        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();
index 3f02c135bd54ea85c7f9d3f22d3ffe177f875b88..b59db7e2162e11f29988a38ed34c9a30bb879042 100644 (file)
@@ -496,11 +496,11 @@ SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char
        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++) {