From b445a32bfff282734144340ad5ace7327ea37f9f Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Tue, 22 Oct 2013 11:48:27 +0200 Subject: More synchronized error/debug methods * plugin/icedteanp/IcedTeaNPPlugin.cc: all occurrences of PLUGIN_ERROR_TWO and PLUGIN_ERROR_THREE replaced by PLUGIN_ERROR. PLUGIN_ERROR itself moved to * plugin/icedteanp/IcedTeaPluginUtils.h: (PLUGIN_ERROR) new fuction, now uses ... arguments and printf with __VA_ARGS__ instead of g_printerr (PLUGIN_DEBUG) now prints to stdout, instead of stderr which is used by (PLUGIN_ERROR). --- plugin/icedteanp/IcedTeaNPPlugin.cc | 43 ++++++++++++----------------------- plugin/icedteanp/IcedTeaPluginUtils.h | 25 +++++++++++++------- 2 files changed, 32 insertions(+), 36 deletions(-) (limited to 'plugin') diff --git a/plugin/icedteanp/IcedTeaNPPlugin.cc b/plugin/icedteanp/IcedTeaNPPlugin.cc index bfce1ae..789ff78 100644 --- a/plugin/icedteanp/IcedTeaNPPlugin.cc +++ b/plugin/icedteanp/IcedTeaNPPlugin.cc @@ -57,19 +57,6 @@ exception statement from your version. */ #include "IcedTeaNPPlugin.h" -// Error reporting macros. -#define PLUGIN_ERROR(message) \ - g_printerr ("%s:%d: thread %p: Error: %s\n", __FILE__, __LINE__, \ - g_thread_self (), message) - -#define PLUGIN_ERROR_TWO(first, second) \ - g_printerr ("%s:%d: thread %p: Error: %s: %s\n", __FILE__, __LINE__, \ - g_thread_self (), first, second) - -#define PLUGIN_ERROR_THREE(first, second, third) \ - g_printerr ("%s:%d: thread %p: Error: %s: %s: %s\n", __FILE__, \ - __LINE__, g_thread_self (), first, second, third) - // Plugin information passed to about:plugins. #define PLUGIN_FULL_NAME PLUGIN_NAME " (using " PLUGIN_VERSION ")" #define PLUGIN_DESC "The " PLUGIN_NAME " executes Java applets." @@ -460,7 +447,7 @@ void start_jvm_if_needed() PLUGIN_DEBUG ("ITNP_New: creating input fifo: %s\n", in_pipe_name); if (mkfifo (in_pipe_name, 0600) == -1 && errno != EEXIST) { - PLUGIN_ERROR_TWO ("Failed to create input pipe", strerror (errno)); + PLUGIN_ERROR ("Failed to create input pipe", strerror (errno)); np_error = NPERR_GENERIC_ERROR; goto cleanup_in_pipe_name; } @@ -486,7 +473,7 @@ void start_jvm_if_needed() PLUGIN_DEBUG ("ITNP_New: creating output fifo: %s\n", out_pipe_name); if (mkfifo (out_pipe_name, 0600) == -1 && errno != EEXIST) { - PLUGIN_ERROR_TWO ("Failed to create output pipe", strerror (errno)); + PLUGIN_ERROR ("Failed to create output pipe", strerror (errno)); np_error = NPERR_GENERIC_ERROR; goto cleanup_out_pipe_name; } @@ -508,7 +495,7 @@ void start_jvm_if_needed() { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to create output channel", + PLUGIN_ERROR ("Failed to create output channel", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -535,7 +522,7 @@ void start_jvm_if_needed() { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to create input channel", + PLUGIN_ERROR ("Failed to create input channel", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -998,7 +985,7 @@ plugin_in_pipe_callback (GIOChannel* source, { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to read line from input channel", + PLUGIN_ERROR ("Failed to read line from input channel", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -1337,7 +1324,7 @@ plugin_test_appletviewer () { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to spawn applet viewer", + PLUGIN_ERROR ("Failed to spawn applet viewer", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -1417,7 +1404,7 @@ plugin_start_appletviewer (ITNPPluginData* data) { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to spawn applet viewer", + PLUGIN_ERROR ("Failed to spawn applet viewer", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -1548,7 +1535,7 @@ plugin_send_message_to_appletviewer (gchar const* message) { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to write bytes to output channel", + PLUGIN_ERROR ("Failed to write bytes to output channel", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -1562,7 +1549,7 @@ plugin_send_message_to_appletviewer (gchar const* message) { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to flush bytes to output channel", + PLUGIN_ERROR ("Failed to flush bytes to output channel", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -1629,7 +1616,7 @@ plugin_stop_appletviewer () { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to write shutdown message to" + PLUGIN_ERROR ("Failed to write shutdown message to" " appletviewer", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -1643,7 +1630,7 @@ plugin_stop_appletviewer () { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to write shutdown message to" + PLUGIN_ERROR ("Failed to write shutdown message to" " appletviewer", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -1658,7 +1645,7 @@ plugin_stop_appletviewer () { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to shut down appletviewer" + PLUGIN_ERROR ("Failed to shut down appletviewer" " output channel", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -1676,7 +1663,7 @@ plugin_stop_appletviewer () { if (channel_error) { - PLUGIN_ERROR_TWO ("Failed to shut down appletviewer" + PLUGIN_ERROR ("Failed to shut down appletviewer" " input channel", channel_error->message); g_error_free (channel_error); channel_error = NULL; @@ -1820,7 +1807,7 @@ initialize_data_directory() file_error = g_mkdir (data_directory.c_str(), 0700); if (file_error != 0) { - PLUGIN_ERROR_THREE ("Failed to create data directory", + PLUGIN_ERROR ("Failed to create data directory", data_directory.c_str(), strerror (errno)); return NPERR_GENERIC_ERROR; @@ -1832,7 +1819,7 @@ initialize_data_directory() if (!g_file_test (data_directory.c_str(), (GFileTest) (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { - PLUGIN_ERROR_THREE ("Temp directory does not exist: ", + PLUGIN_ERROR ("Temp directory does not exist: ", data_directory.c_str(), strerror (errno)); return NPERR_GENERIC_ERROR; diff --git a/plugin/icedteanp/IcedTeaPluginUtils.h b/plugin/icedteanp/IcedTeaPluginUtils.h index 29cc3ae..02b14e6 100644 --- a/plugin/icedteanp/IcedTeaPluginUtils.h +++ b/plugin/icedteanp/IcedTeaPluginUtils.h @@ -59,15 +59,24 @@ exception statement from your version. */ #include #include -#define PLUGIN_DEBUG(...) \ - do \ - { \ - if (plugin_debug) \ - { \ - fprintf (stderr, "ITNPP Thread# %ld: ", pthread_self()); \ - fprintf (stderr, __VA_ARGS__); \ - } \ +#define PLUGIN_DEBUG(...) \ + do \ + { \ + if (plugin_debug) \ + { \ + fprintf (stdout, "ITNPP Thread# %ld: ", pthread_self()); \ + fprintf (stdout, __VA_ARGS__); \ + } \ } while (0) + + // Error reporting macros. +#define PLUGIN_ERROR(...) \ +do \ + { \ + fprintf (stderr, "%s:%d: thread %p: Error: %s\n", \ + __FILE__, __LINE__, \ + g_thread_self (), __VA_ARGS__); \ + } while (0) #define CHECK_JAVA_RESULT(result_data) \ { \ -- cgit v1.2.3