]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FreeSWITCH: Add WIN32 strerror_s() variant to custom switch_strerror_r() helper funct...
authorStefan Knoblich <stkn@openisdn.net>
Tue, 14 Aug 2012 12:54:06 +0000 (14:54 +0200)
committerStefan Knoblich <stkn@openisdn.net>
Tue, 14 Aug 2012 12:54:06 +0000 (14:54 +0200)
Convert mod_xml_cdr, mod_json_cdr and mod_conference to the new function.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
src/mod/applications/mod_conference/mod_conference.c
src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c
src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
src/switch_utils.c

index fccdefd46e2d1efcd7acdc6fdfa3a2cb67e8dc08..bc600919641230cf667f7faacf60c52af7274d90 100644 (file)
@@ -1029,12 +1029,8 @@ static void conference_cdr_render(conference_obj_t *conference)
                fd = -1;
        } else {
                char ebuf[512] = { 0 };
-#ifdef WIN32
-               strerror_s(ebuf, sizeof(ebuf), errno);
-#else
-               strerror_r(errno, ebuf, sizeof(ebuf));
-#endif
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n",
+                               path, switch_strerror_r(errno, ebuf, sizeof(ebuf)));
        }
 
        
index e07871b88dfe69922a1a0f23682127583c280125..7b1cf2a6a90ad71cf76c8640874b98e812f042ef 100644 (file)
@@ -253,12 +253,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
                                }
                        } else {
                                char ebuf[512] = { 0 };
-#ifdef WIN32
-                               strerror_s(ebuf, sizeof(ebuf), errno);
-#else
-                               strerror_r(errno, ebuf, sizeof(ebuf));
-#endif
-                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf);
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n",
+                                               path, switch_strerror_r(errno, ebuf, sizeof(ebuf)));
                        }
                        switch_safe_free(path);
                }
@@ -412,12 +408,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
                                        break;
                                } else {
                                        char ebuf[512] = { 0 };
-#ifdef WIN32
-                                       strerror_s(ebuf, sizeof(ebuf), errno);
-#else
-                                       strerror_r(errno, ebuf, sizeof(ebuf));
-#endif
-                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s! [%s]\n", path, ebuf);
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s! [%s]\n",
+                                                       path, switch_strerror_r(errno, ebuf, sizeof(ebuf)));
 
                                }
 
index 44379444e3f00ec501cd2e594d926201509373db..28f4ae2e44ca13cf1c69b3a4b9439ff8136ee746 100644 (file)
@@ -244,12 +244,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
                                fd = -1;
                        } else {
                                char ebuf[512] = { 0 };
-#ifdef WIN32
-                               strerror_s(ebuf, sizeof(ebuf), errno);
-#else
-                               strerror_r(errno, ebuf, sizeof(ebuf));
-#endif
-                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf);
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n",
+                                               path, switch_strerror_r(errno, ebuf, sizeof(ebuf)));
                        }
                        switch_safe_free(path);
                }
@@ -400,12 +396,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
                                fd = -1;
                        } else {
                                char ebuf[512] = { 0 };
-#ifdef WIN32
-                               strerror_s(ebuf, sizeof(ebuf), errno);
-#else
-                               strerror_r(errno, ebuf, sizeof(ebuf));
-#endif
-                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error![%s]\n", ebuf);
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error![%s]\n",
+                                               switch_strerror_r(errno, ebuf, sizeof(ebuf)));
                        }
                }
        }
index b0c4e1a287226b9f4036e4689bb52ddd926d6474..d877061e398ec1c04428207b36d90ad7ff52aaec 100644 (file)
@@ -2985,6 +2985,12 @@ SWITCH_DECLARE(char *) switch_strerror_r(int errnum, char *buf, switch_size_t bu
        }
        return buf;
 #endif /* STRERROR_R_CHAR_P */
+#elif defined(WIN32)
+       /* WIN32 variant */
+       if (strerror_s(buf, buflen, errnum)) {
+               switch_snprintf(buf, buflen, "Unknown error %d", errnum);
+       }
+       return buf;
 #else
        /* Fallback, copy string into private buffer */
        switch_copy_string(buf, strerror(errnum), buflen);