From dba356d81507cf473234fdcfc97e60a714ea483d Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 16 May 2002 17:41:38 +0000 Subject: [PATCH] libgimpbase/gimpprotocol.[ch] pass "gpointer user_data" to all functions, 2002-05-16 Michael Natterer * libgimpbase/gimpprotocol.[ch] * libgimpbase/gimpwire.[ch]: pass "gpointer user_data" to all functions, which in gets turn passed to the registered reader, writer, and flusher funcs. * libgimp/gimp.c * libgimp/gimptile.c: pass NULL as user_data. We have only one pipe on the plug-in side. * app/plug-in/plug-in.c: pass the PlugIn as user_data. As a consequence, got rid of more global variables. The global "current_plug_in" and the plug_in_push()/pop() madness are still there. Will reeplace them by some less ugly hack later... 2002-05-16 Michael Natterer * libgimpbase/tmpl/gimpprotocol.sgml * libgimpbase/tmpl/gimpwire.sgml: regenerated after API change. --- ChangeLog | 16 + app/plug-in/gimpplugin-message.c | 96 +-- app/plug-in/gimpplugin.c | 96 +-- app/plug-in/gimppluginmanager-call.c | 96 +-- app/plug-in/gimppluginmanager-run.c | 96 +-- app/plug-in/gimppluginshm.c | 96 +-- app/plug-in/plug-in-message.c | 96 +-- app/plug-in/plug-in-run.c | 96 +-- app/plug-in/plug-in-shm.c | 96 +-- app/plug-in/plug-in.c | 96 +-- devel-docs/ChangeLog | 5 + devel-docs/libgimpbase/tmpl/gimpprotocol.sgml | 13 + devel-docs/libgimpbase/tmpl/gimpwire.sgml | 19 + libgimp/gimp.c | 46 +- libgimp/gimptile.c | 28 +- libgimpbase/gimpprotocol.c | 709 +++++++++++------- libgimpbase/gimpprotocol.h | 39 +- libgimpbase/gimpwire.c | 83 +- libgimpbase/gimpwire.h | 57 +- 19 files changed, 1102 insertions(+), 777 deletions(-) diff --git a/ChangeLog b/ChangeLog index eebe7b15af..388292dc1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2002-05-16 Michael Natterer + + * libgimpbase/gimpprotocol.[ch] + * libgimpbase/gimpwire.[ch]: pass "gpointer user_data" to all + functions, which in gets turn passed to the registered reader, + writer, and flusher funcs. + + * libgimp/gimp.c + * libgimp/gimptile.c: pass NULL as user_data. We have only one + pipe on the plug-in side. + + * app/plug-in/plug-in.c: pass the PlugIn as user_data. As a + consequence, got rid of more global variables. The global + "current_plug_in" and the plug_in_push()/pop() madness are still + there. Will reeplace them by some less ugly hack later... + 2002-05-16 Sven Neumann * app/gui/splash.c: don't allow to close the splash screen. Fixes diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index 77700e2749..1531ff6232 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -131,8 +131,10 @@ struct _PlugInHelpPathDef static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean plug_in_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean plug_in_flush (GIOChannel *channel, + gpointer user_data); static void plug_in_push (PlugIn *plug_in); static void plug_in_pop (void); static gboolean plug_in_recv_message (GIOChannel *channel, @@ -169,8 +171,6 @@ static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static gint current_write_buffer_index = 0; -static gchar *current_write_buffer = NULL; static Argument *current_return_vals = NULL; static gint current_return_nvals = 0; @@ -327,7 +327,7 @@ plug_in_call_query (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -365,7 +365,7 @@ plug_in_call_init (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -676,7 +676,7 @@ plug_in_close (PlugIn *plug_in, if (kill_it && plug_in->pid) { plug_in_push (plug_in); - gp_quit_write (plug_in->my_write); + gp_quit_write (plug_in->my_write, plug_in); plug_in_pop (); /* give the plug-in some time (10 ms) */ @@ -872,9 +872,9 @@ plug_in_run (Gimp *gimp, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_config_write (plug_in->my_write, &config) || - ! gp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_config_write (plug_in->my_write, &config, plug_in) || + ! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; @@ -965,7 +965,7 @@ plug_in_recv_message (GIOChannel *channel, memset (&msg, 0, sizeof (WireMessage)); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -1085,14 +1085,14 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.data = NULL; - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); return; } - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1140,7 +1140,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, TRUE); wire_destroy (&msg); - if (! gp_tile_ack_write (plug_in->my_write)) + if (! gp_tile_ack_write (plug_in->my_write, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1186,7 +1186,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, else tile_data.data = tile_data_pointer (tile, 0, 0); - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1195,7 +1195,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, FALSE); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1255,7 +1255,7 @@ plug_in_handle_proc_run (PlugIn *plug_in, proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); } - if (! gp_proc_return_write (plug_in->my_write, &proc_return)) + if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { g_warning ("plug_in_handle_proc_run: ERROR"); plug_in_close (plug_in, TRUE); @@ -1284,7 +1284,7 @@ plug_in_handle_proc_return (PlugIn *plug_in, PlugInBlocked *blocked; GSList *tmp; - if (current_plug_in->recurse) + if (plug_in->recurse) { current_return_vals = plug_in_params_to_args (proc_return->params, proc_return->nparams, @@ -1305,7 +1305,8 @@ plug_in_handle_proc_return (PlugIn *plug_in, plug_in_push (blocked->plug_in); if (! gp_proc_return_write (blocked->plug_in->my_write, - proc_return)) + proc_return, + blocked->plug_in)) { g_message ("plug_in_handle_proc_run: ERROR"); plug_in_close (blocked->plug_in, TRUE); @@ -1658,25 +1659,31 @@ plug_in_handle_has_init (PlugIn *plug_in) static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { - gulong bytes; + PlugIn *plug_in; + gulong bytes; + + plug_in = (PlugIn *) user_data; while (count > 0) { - if ((current_write_buffer_index + count) >= WRITE_BUFFER_SIZE) + if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE) { - bytes = WRITE_BUFFER_SIZE - current_write_buffer_index; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; - if (! wire_flush (channel)) + bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; + if (! wire_flush (channel, plug_in)) return FALSE; } else { bytes = count; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; } buf += bytes; @@ -1687,24 +1694,28 @@ plug_in_write (GIOChannel *channel, } static gboolean -plug_in_flush (GIOChannel *channel) +plug_in_flush (GIOChannel *channel, + gpointer user_data) { + PlugIn *plug_in; GIOStatus status; GError *error = NULL; gint count; guint bytes; - if (current_write_buffer_index > 0) + plug_in = (PlugIn *) user_data; + + if (plug_in->write_buffer_index > 0) { count = 0; - while (count != current_write_buffer_index) + while (count != plug_in->write_buffer_index) { do { bytes = 0; status = g_io_channel_write_chars (channel, - ¤t_write_buffer[count], - (current_write_buffer_index - count), + &plug_in->write_buffer[count], + (plug_in->write_buffer_index - count), &bytes, &error); } @@ -1730,7 +1741,7 @@ plug_in_flush (GIOChannel *channel) count += bytes; } - current_write_buffer_index = 0; + plug_in->write_buffer_index = 0; } return TRUE; @@ -1744,9 +1755,6 @@ plug_in_push (PlugIn *plug_in) current_plug_in = plug_in; plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); - - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; } static void @@ -1756,8 +1764,6 @@ plug_in_pop (void) if (current_plug_in) { - current_plug_in->write_buffer_index = current_write_buffer_index; - tmp = plug_in_stack; plug_in_stack = plug_in_stack->next; tmp->next = NULL; @@ -1766,15 +1772,11 @@ plug_in_pop (void) if (plug_in_stack) { - current_plug_in = plug_in_stack->data; - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; + current_plug_in = plug_in_stack->data; } else { - current_plug_in = NULL; - current_write_buffer_index = 0; - current_write_buffer = NULL; + current_plug_in = NULL; } } @@ -1807,8 +1809,8 @@ plug_in_temp_run (ProcRecord *proc_rec, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index 77700e2749..1531ff6232 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -131,8 +131,10 @@ struct _PlugInHelpPathDef static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean plug_in_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean plug_in_flush (GIOChannel *channel, + gpointer user_data); static void plug_in_push (PlugIn *plug_in); static void plug_in_pop (void); static gboolean plug_in_recv_message (GIOChannel *channel, @@ -169,8 +171,6 @@ static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static gint current_write_buffer_index = 0; -static gchar *current_write_buffer = NULL; static Argument *current_return_vals = NULL; static gint current_return_nvals = 0; @@ -327,7 +327,7 @@ plug_in_call_query (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -365,7 +365,7 @@ plug_in_call_init (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -676,7 +676,7 @@ plug_in_close (PlugIn *plug_in, if (kill_it && plug_in->pid) { plug_in_push (plug_in); - gp_quit_write (plug_in->my_write); + gp_quit_write (plug_in->my_write, plug_in); plug_in_pop (); /* give the plug-in some time (10 ms) */ @@ -872,9 +872,9 @@ plug_in_run (Gimp *gimp, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_config_write (plug_in->my_write, &config) || - ! gp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_config_write (plug_in->my_write, &config, plug_in) || + ! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; @@ -965,7 +965,7 @@ plug_in_recv_message (GIOChannel *channel, memset (&msg, 0, sizeof (WireMessage)); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -1085,14 +1085,14 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.data = NULL; - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); return; } - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1140,7 +1140,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, TRUE); wire_destroy (&msg); - if (! gp_tile_ack_write (plug_in->my_write)) + if (! gp_tile_ack_write (plug_in->my_write, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1186,7 +1186,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, else tile_data.data = tile_data_pointer (tile, 0, 0); - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1195,7 +1195,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, FALSE); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1255,7 +1255,7 @@ plug_in_handle_proc_run (PlugIn *plug_in, proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); } - if (! gp_proc_return_write (plug_in->my_write, &proc_return)) + if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { g_warning ("plug_in_handle_proc_run: ERROR"); plug_in_close (plug_in, TRUE); @@ -1284,7 +1284,7 @@ plug_in_handle_proc_return (PlugIn *plug_in, PlugInBlocked *blocked; GSList *tmp; - if (current_plug_in->recurse) + if (plug_in->recurse) { current_return_vals = plug_in_params_to_args (proc_return->params, proc_return->nparams, @@ -1305,7 +1305,8 @@ plug_in_handle_proc_return (PlugIn *plug_in, plug_in_push (blocked->plug_in); if (! gp_proc_return_write (blocked->plug_in->my_write, - proc_return)) + proc_return, + blocked->plug_in)) { g_message ("plug_in_handle_proc_run: ERROR"); plug_in_close (blocked->plug_in, TRUE); @@ -1658,25 +1659,31 @@ plug_in_handle_has_init (PlugIn *plug_in) static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { - gulong bytes; + PlugIn *plug_in; + gulong bytes; + + plug_in = (PlugIn *) user_data; while (count > 0) { - if ((current_write_buffer_index + count) >= WRITE_BUFFER_SIZE) + if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE) { - bytes = WRITE_BUFFER_SIZE - current_write_buffer_index; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; - if (! wire_flush (channel)) + bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; + if (! wire_flush (channel, plug_in)) return FALSE; } else { bytes = count; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; } buf += bytes; @@ -1687,24 +1694,28 @@ plug_in_write (GIOChannel *channel, } static gboolean -plug_in_flush (GIOChannel *channel) +plug_in_flush (GIOChannel *channel, + gpointer user_data) { + PlugIn *plug_in; GIOStatus status; GError *error = NULL; gint count; guint bytes; - if (current_write_buffer_index > 0) + plug_in = (PlugIn *) user_data; + + if (plug_in->write_buffer_index > 0) { count = 0; - while (count != current_write_buffer_index) + while (count != plug_in->write_buffer_index) { do { bytes = 0; status = g_io_channel_write_chars (channel, - ¤t_write_buffer[count], - (current_write_buffer_index - count), + &plug_in->write_buffer[count], + (plug_in->write_buffer_index - count), &bytes, &error); } @@ -1730,7 +1741,7 @@ plug_in_flush (GIOChannel *channel) count += bytes; } - current_write_buffer_index = 0; + plug_in->write_buffer_index = 0; } return TRUE; @@ -1744,9 +1755,6 @@ plug_in_push (PlugIn *plug_in) current_plug_in = plug_in; plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); - - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; } static void @@ -1756,8 +1764,6 @@ plug_in_pop (void) if (current_plug_in) { - current_plug_in->write_buffer_index = current_write_buffer_index; - tmp = plug_in_stack; plug_in_stack = plug_in_stack->next; tmp->next = NULL; @@ -1766,15 +1772,11 @@ plug_in_pop (void) if (plug_in_stack) { - current_plug_in = plug_in_stack->data; - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; + current_plug_in = plug_in_stack->data; } else { - current_plug_in = NULL; - current_write_buffer_index = 0; - current_write_buffer = NULL; + current_plug_in = NULL; } } @@ -1807,8 +1809,8 @@ plug_in_temp_run (ProcRecord *proc_rec, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index 77700e2749..1531ff6232 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -131,8 +131,10 @@ struct _PlugInHelpPathDef static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean plug_in_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean plug_in_flush (GIOChannel *channel, + gpointer user_data); static void plug_in_push (PlugIn *plug_in); static void plug_in_pop (void); static gboolean plug_in_recv_message (GIOChannel *channel, @@ -169,8 +171,6 @@ static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static gint current_write_buffer_index = 0; -static gchar *current_write_buffer = NULL; static Argument *current_return_vals = NULL; static gint current_return_nvals = 0; @@ -327,7 +327,7 @@ plug_in_call_query (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -365,7 +365,7 @@ plug_in_call_init (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -676,7 +676,7 @@ plug_in_close (PlugIn *plug_in, if (kill_it && plug_in->pid) { plug_in_push (plug_in); - gp_quit_write (plug_in->my_write); + gp_quit_write (plug_in->my_write, plug_in); plug_in_pop (); /* give the plug-in some time (10 ms) */ @@ -872,9 +872,9 @@ plug_in_run (Gimp *gimp, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_config_write (plug_in->my_write, &config) || - ! gp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_config_write (plug_in->my_write, &config, plug_in) || + ! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; @@ -965,7 +965,7 @@ plug_in_recv_message (GIOChannel *channel, memset (&msg, 0, sizeof (WireMessage)); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -1085,14 +1085,14 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.data = NULL; - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); return; } - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1140,7 +1140,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, TRUE); wire_destroy (&msg); - if (! gp_tile_ack_write (plug_in->my_write)) + if (! gp_tile_ack_write (plug_in->my_write, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1186,7 +1186,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, else tile_data.data = tile_data_pointer (tile, 0, 0); - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1195,7 +1195,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, FALSE); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1255,7 +1255,7 @@ plug_in_handle_proc_run (PlugIn *plug_in, proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); } - if (! gp_proc_return_write (plug_in->my_write, &proc_return)) + if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { g_warning ("plug_in_handle_proc_run: ERROR"); plug_in_close (plug_in, TRUE); @@ -1284,7 +1284,7 @@ plug_in_handle_proc_return (PlugIn *plug_in, PlugInBlocked *blocked; GSList *tmp; - if (current_plug_in->recurse) + if (plug_in->recurse) { current_return_vals = plug_in_params_to_args (proc_return->params, proc_return->nparams, @@ -1305,7 +1305,8 @@ plug_in_handle_proc_return (PlugIn *plug_in, plug_in_push (blocked->plug_in); if (! gp_proc_return_write (blocked->plug_in->my_write, - proc_return)) + proc_return, + blocked->plug_in)) { g_message ("plug_in_handle_proc_run: ERROR"); plug_in_close (blocked->plug_in, TRUE); @@ -1658,25 +1659,31 @@ plug_in_handle_has_init (PlugIn *plug_in) static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { - gulong bytes; + PlugIn *plug_in; + gulong bytes; + + plug_in = (PlugIn *) user_data; while (count > 0) { - if ((current_write_buffer_index + count) >= WRITE_BUFFER_SIZE) + if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE) { - bytes = WRITE_BUFFER_SIZE - current_write_buffer_index; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; - if (! wire_flush (channel)) + bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; + if (! wire_flush (channel, plug_in)) return FALSE; } else { bytes = count; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; } buf += bytes; @@ -1687,24 +1694,28 @@ plug_in_write (GIOChannel *channel, } static gboolean -plug_in_flush (GIOChannel *channel) +plug_in_flush (GIOChannel *channel, + gpointer user_data) { + PlugIn *plug_in; GIOStatus status; GError *error = NULL; gint count; guint bytes; - if (current_write_buffer_index > 0) + plug_in = (PlugIn *) user_data; + + if (plug_in->write_buffer_index > 0) { count = 0; - while (count != current_write_buffer_index) + while (count != plug_in->write_buffer_index) { do { bytes = 0; status = g_io_channel_write_chars (channel, - ¤t_write_buffer[count], - (current_write_buffer_index - count), + &plug_in->write_buffer[count], + (plug_in->write_buffer_index - count), &bytes, &error); } @@ -1730,7 +1741,7 @@ plug_in_flush (GIOChannel *channel) count += bytes; } - current_write_buffer_index = 0; + plug_in->write_buffer_index = 0; } return TRUE; @@ -1744,9 +1755,6 @@ plug_in_push (PlugIn *plug_in) current_plug_in = plug_in; plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); - - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; } static void @@ -1756,8 +1764,6 @@ plug_in_pop (void) if (current_plug_in) { - current_plug_in->write_buffer_index = current_write_buffer_index; - tmp = plug_in_stack; plug_in_stack = plug_in_stack->next; tmp->next = NULL; @@ -1766,15 +1772,11 @@ plug_in_pop (void) if (plug_in_stack) { - current_plug_in = plug_in_stack->data; - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; + current_plug_in = plug_in_stack->data; } else { - current_plug_in = NULL; - current_write_buffer_index = 0; - current_write_buffer = NULL; + current_plug_in = NULL; } } @@ -1807,8 +1809,8 @@ plug_in_temp_run (ProcRecord *proc_rec, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; diff --git a/app/plug-in/gimppluginmanager-run.c b/app/plug-in/gimppluginmanager-run.c index 77700e2749..1531ff6232 100644 --- a/app/plug-in/gimppluginmanager-run.c +++ b/app/plug-in/gimppluginmanager-run.c @@ -131,8 +131,10 @@ struct _PlugInHelpPathDef static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean plug_in_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean plug_in_flush (GIOChannel *channel, + gpointer user_data); static void plug_in_push (PlugIn *plug_in); static void plug_in_pop (void); static gboolean plug_in_recv_message (GIOChannel *channel, @@ -169,8 +171,6 @@ static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static gint current_write_buffer_index = 0; -static gchar *current_write_buffer = NULL; static Argument *current_return_vals = NULL; static gint current_return_nvals = 0; @@ -327,7 +327,7 @@ plug_in_call_query (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -365,7 +365,7 @@ plug_in_call_init (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -676,7 +676,7 @@ plug_in_close (PlugIn *plug_in, if (kill_it && plug_in->pid) { plug_in_push (plug_in); - gp_quit_write (plug_in->my_write); + gp_quit_write (plug_in->my_write, plug_in); plug_in_pop (); /* give the plug-in some time (10 ms) */ @@ -872,9 +872,9 @@ plug_in_run (Gimp *gimp, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_config_write (plug_in->my_write, &config) || - ! gp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_config_write (plug_in->my_write, &config, plug_in) || + ! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; @@ -965,7 +965,7 @@ plug_in_recv_message (GIOChannel *channel, memset (&msg, 0, sizeof (WireMessage)); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -1085,14 +1085,14 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.data = NULL; - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); return; } - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1140,7 +1140,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, TRUE); wire_destroy (&msg); - if (! gp_tile_ack_write (plug_in->my_write)) + if (! gp_tile_ack_write (plug_in->my_write, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1186,7 +1186,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, else tile_data.data = tile_data_pointer (tile, 0, 0); - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1195,7 +1195,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, FALSE); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1255,7 +1255,7 @@ plug_in_handle_proc_run (PlugIn *plug_in, proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); } - if (! gp_proc_return_write (plug_in->my_write, &proc_return)) + if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { g_warning ("plug_in_handle_proc_run: ERROR"); plug_in_close (plug_in, TRUE); @@ -1284,7 +1284,7 @@ plug_in_handle_proc_return (PlugIn *plug_in, PlugInBlocked *blocked; GSList *tmp; - if (current_plug_in->recurse) + if (plug_in->recurse) { current_return_vals = plug_in_params_to_args (proc_return->params, proc_return->nparams, @@ -1305,7 +1305,8 @@ plug_in_handle_proc_return (PlugIn *plug_in, plug_in_push (blocked->plug_in); if (! gp_proc_return_write (blocked->plug_in->my_write, - proc_return)) + proc_return, + blocked->plug_in)) { g_message ("plug_in_handle_proc_run: ERROR"); plug_in_close (blocked->plug_in, TRUE); @@ -1658,25 +1659,31 @@ plug_in_handle_has_init (PlugIn *plug_in) static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { - gulong bytes; + PlugIn *plug_in; + gulong bytes; + + plug_in = (PlugIn *) user_data; while (count > 0) { - if ((current_write_buffer_index + count) >= WRITE_BUFFER_SIZE) + if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE) { - bytes = WRITE_BUFFER_SIZE - current_write_buffer_index; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; - if (! wire_flush (channel)) + bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; + if (! wire_flush (channel, plug_in)) return FALSE; } else { bytes = count; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; } buf += bytes; @@ -1687,24 +1694,28 @@ plug_in_write (GIOChannel *channel, } static gboolean -plug_in_flush (GIOChannel *channel) +plug_in_flush (GIOChannel *channel, + gpointer user_data) { + PlugIn *plug_in; GIOStatus status; GError *error = NULL; gint count; guint bytes; - if (current_write_buffer_index > 0) + plug_in = (PlugIn *) user_data; + + if (plug_in->write_buffer_index > 0) { count = 0; - while (count != current_write_buffer_index) + while (count != plug_in->write_buffer_index) { do { bytes = 0; status = g_io_channel_write_chars (channel, - ¤t_write_buffer[count], - (current_write_buffer_index - count), + &plug_in->write_buffer[count], + (plug_in->write_buffer_index - count), &bytes, &error); } @@ -1730,7 +1741,7 @@ plug_in_flush (GIOChannel *channel) count += bytes; } - current_write_buffer_index = 0; + plug_in->write_buffer_index = 0; } return TRUE; @@ -1744,9 +1755,6 @@ plug_in_push (PlugIn *plug_in) current_plug_in = plug_in; plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); - - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; } static void @@ -1756,8 +1764,6 @@ plug_in_pop (void) if (current_plug_in) { - current_plug_in->write_buffer_index = current_write_buffer_index; - tmp = plug_in_stack; plug_in_stack = plug_in_stack->next; tmp->next = NULL; @@ -1766,15 +1772,11 @@ plug_in_pop (void) if (plug_in_stack) { - current_plug_in = plug_in_stack->data; - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; + current_plug_in = plug_in_stack->data; } else { - current_plug_in = NULL; - current_write_buffer_index = 0; - current_write_buffer = NULL; + current_plug_in = NULL; } } @@ -1807,8 +1809,8 @@ plug_in_temp_run (ProcRecord *proc_rec, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; diff --git a/app/plug-in/gimppluginshm.c b/app/plug-in/gimppluginshm.c index 77700e2749..1531ff6232 100644 --- a/app/plug-in/gimppluginshm.c +++ b/app/plug-in/gimppluginshm.c @@ -131,8 +131,10 @@ struct _PlugInHelpPathDef static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean plug_in_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean plug_in_flush (GIOChannel *channel, + gpointer user_data); static void plug_in_push (PlugIn *plug_in); static void plug_in_pop (void); static gboolean plug_in_recv_message (GIOChannel *channel, @@ -169,8 +171,6 @@ static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static gint current_write_buffer_index = 0; -static gchar *current_write_buffer = NULL; static Argument *current_return_vals = NULL; static gint current_return_nvals = 0; @@ -327,7 +327,7 @@ plug_in_call_query (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -365,7 +365,7 @@ plug_in_call_init (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -676,7 +676,7 @@ plug_in_close (PlugIn *plug_in, if (kill_it && plug_in->pid) { plug_in_push (plug_in); - gp_quit_write (plug_in->my_write); + gp_quit_write (plug_in->my_write, plug_in); plug_in_pop (); /* give the plug-in some time (10 ms) */ @@ -872,9 +872,9 @@ plug_in_run (Gimp *gimp, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_config_write (plug_in->my_write, &config) || - ! gp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_config_write (plug_in->my_write, &config, plug_in) || + ! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; @@ -965,7 +965,7 @@ plug_in_recv_message (GIOChannel *channel, memset (&msg, 0, sizeof (WireMessage)); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -1085,14 +1085,14 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.data = NULL; - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); return; } - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1140,7 +1140,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, TRUE); wire_destroy (&msg); - if (! gp_tile_ack_write (plug_in->my_write)) + if (! gp_tile_ack_write (plug_in->my_write, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1186,7 +1186,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, else tile_data.data = tile_data_pointer (tile, 0, 0); - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1195,7 +1195,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, FALSE); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1255,7 +1255,7 @@ plug_in_handle_proc_run (PlugIn *plug_in, proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); } - if (! gp_proc_return_write (plug_in->my_write, &proc_return)) + if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { g_warning ("plug_in_handle_proc_run: ERROR"); plug_in_close (plug_in, TRUE); @@ -1284,7 +1284,7 @@ plug_in_handle_proc_return (PlugIn *plug_in, PlugInBlocked *blocked; GSList *tmp; - if (current_plug_in->recurse) + if (plug_in->recurse) { current_return_vals = plug_in_params_to_args (proc_return->params, proc_return->nparams, @@ -1305,7 +1305,8 @@ plug_in_handle_proc_return (PlugIn *plug_in, plug_in_push (blocked->plug_in); if (! gp_proc_return_write (blocked->plug_in->my_write, - proc_return)) + proc_return, + blocked->plug_in)) { g_message ("plug_in_handle_proc_run: ERROR"); plug_in_close (blocked->plug_in, TRUE); @@ -1658,25 +1659,31 @@ plug_in_handle_has_init (PlugIn *plug_in) static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { - gulong bytes; + PlugIn *plug_in; + gulong bytes; + + plug_in = (PlugIn *) user_data; while (count > 0) { - if ((current_write_buffer_index + count) >= WRITE_BUFFER_SIZE) + if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE) { - bytes = WRITE_BUFFER_SIZE - current_write_buffer_index; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; - if (! wire_flush (channel)) + bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; + if (! wire_flush (channel, plug_in)) return FALSE; } else { bytes = count; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; } buf += bytes; @@ -1687,24 +1694,28 @@ plug_in_write (GIOChannel *channel, } static gboolean -plug_in_flush (GIOChannel *channel) +plug_in_flush (GIOChannel *channel, + gpointer user_data) { + PlugIn *plug_in; GIOStatus status; GError *error = NULL; gint count; guint bytes; - if (current_write_buffer_index > 0) + plug_in = (PlugIn *) user_data; + + if (plug_in->write_buffer_index > 0) { count = 0; - while (count != current_write_buffer_index) + while (count != plug_in->write_buffer_index) { do { bytes = 0; status = g_io_channel_write_chars (channel, - ¤t_write_buffer[count], - (current_write_buffer_index - count), + &plug_in->write_buffer[count], + (plug_in->write_buffer_index - count), &bytes, &error); } @@ -1730,7 +1741,7 @@ plug_in_flush (GIOChannel *channel) count += bytes; } - current_write_buffer_index = 0; + plug_in->write_buffer_index = 0; } return TRUE; @@ -1744,9 +1755,6 @@ plug_in_push (PlugIn *plug_in) current_plug_in = plug_in; plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); - - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; } static void @@ -1756,8 +1764,6 @@ plug_in_pop (void) if (current_plug_in) { - current_plug_in->write_buffer_index = current_write_buffer_index; - tmp = plug_in_stack; plug_in_stack = plug_in_stack->next; tmp->next = NULL; @@ -1766,15 +1772,11 @@ plug_in_pop (void) if (plug_in_stack) { - current_plug_in = plug_in_stack->data; - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; + current_plug_in = plug_in_stack->data; } else { - current_plug_in = NULL; - current_write_buffer_index = 0; - current_write_buffer = NULL; + current_plug_in = NULL; } } @@ -1807,8 +1809,8 @@ plug_in_temp_run (ProcRecord *proc_rec, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; diff --git a/app/plug-in/plug-in-message.c b/app/plug-in/plug-in-message.c index 77700e2749..1531ff6232 100644 --- a/app/plug-in/plug-in-message.c +++ b/app/plug-in/plug-in-message.c @@ -131,8 +131,10 @@ struct _PlugInHelpPathDef static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean plug_in_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean plug_in_flush (GIOChannel *channel, + gpointer user_data); static void plug_in_push (PlugIn *plug_in); static void plug_in_pop (void); static gboolean plug_in_recv_message (GIOChannel *channel, @@ -169,8 +171,6 @@ static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static gint current_write_buffer_index = 0; -static gchar *current_write_buffer = NULL; static Argument *current_return_vals = NULL; static gint current_return_nvals = 0; @@ -327,7 +327,7 @@ plug_in_call_query (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -365,7 +365,7 @@ plug_in_call_init (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -676,7 +676,7 @@ plug_in_close (PlugIn *plug_in, if (kill_it && plug_in->pid) { plug_in_push (plug_in); - gp_quit_write (plug_in->my_write); + gp_quit_write (plug_in->my_write, plug_in); plug_in_pop (); /* give the plug-in some time (10 ms) */ @@ -872,9 +872,9 @@ plug_in_run (Gimp *gimp, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_config_write (plug_in->my_write, &config) || - ! gp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_config_write (plug_in->my_write, &config, plug_in) || + ! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; @@ -965,7 +965,7 @@ plug_in_recv_message (GIOChannel *channel, memset (&msg, 0, sizeof (WireMessage)); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -1085,14 +1085,14 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.data = NULL; - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); return; } - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1140,7 +1140,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, TRUE); wire_destroy (&msg); - if (! gp_tile_ack_write (plug_in->my_write)) + if (! gp_tile_ack_write (plug_in->my_write, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1186,7 +1186,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, else tile_data.data = tile_data_pointer (tile, 0, 0); - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1195,7 +1195,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, FALSE); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1255,7 +1255,7 @@ plug_in_handle_proc_run (PlugIn *plug_in, proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); } - if (! gp_proc_return_write (plug_in->my_write, &proc_return)) + if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { g_warning ("plug_in_handle_proc_run: ERROR"); plug_in_close (plug_in, TRUE); @@ -1284,7 +1284,7 @@ plug_in_handle_proc_return (PlugIn *plug_in, PlugInBlocked *blocked; GSList *tmp; - if (current_plug_in->recurse) + if (plug_in->recurse) { current_return_vals = plug_in_params_to_args (proc_return->params, proc_return->nparams, @@ -1305,7 +1305,8 @@ plug_in_handle_proc_return (PlugIn *plug_in, plug_in_push (blocked->plug_in); if (! gp_proc_return_write (blocked->plug_in->my_write, - proc_return)) + proc_return, + blocked->plug_in)) { g_message ("plug_in_handle_proc_run: ERROR"); plug_in_close (blocked->plug_in, TRUE); @@ -1658,25 +1659,31 @@ plug_in_handle_has_init (PlugIn *plug_in) static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { - gulong bytes; + PlugIn *plug_in; + gulong bytes; + + plug_in = (PlugIn *) user_data; while (count > 0) { - if ((current_write_buffer_index + count) >= WRITE_BUFFER_SIZE) + if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE) { - bytes = WRITE_BUFFER_SIZE - current_write_buffer_index; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; - if (! wire_flush (channel)) + bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; + if (! wire_flush (channel, plug_in)) return FALSE; } else { bytes = count; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; } buf += bytes; @@ -1687,24 +1694,28 @@ plug_in_write (GIOChannel *channel, } static gboolean -plug_in_flush (GIOChannel *channel) +plug_in_flush (GIOChannel *channel, + gpointer user_data) { + PlugIn *plug_in; GIOStatus status; GError *error = NULL; gint count; guint bytes; - if (current_write_buffer_index > 0) + plug_in = (PlugIn *) user_data; + + if (plug_in->write_buffer_index > 0) { count = 0; - while (count != current_write_buffer_index) + while (count != plug_in->write_buffer_index) { do { bytes = 0; status = g_io_channel_write_chars (channel, - ¤t_write_buffer[count], - (current_write_buffer_index - count), + &plug_in->write_buffer[count], + (plug_in->write_buffer_index - count), &bytes, &error); } @@ -1730,7 +1741,7 @@ plug_in_flush (GIOChannel *channel) count += bytes; } - current_write_buffer_index = 0; + plug_in->write_buffer_index = 0; } return TRUE; @@ -1744,9 +1755,6 @@ plug_in_push (PlugIn *plug_in) current_plug_in = plug_in; plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); - - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; } static void @@ -1756,8 +1764,6 @@ plug_in_pop (void) if (current_plug_in) { - current_plug_in->write_buffer_index = current_write_buffer_index; - tmp = plug_in_stack; plug_in_stack = plug_in_stack->next; tmp->next = NULL; @@ -1766,15 +1772,11 @@ plug_in_pop (void) if (plug_in_stack) { - current_plug_in = plug_in_stack->data; - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; + current_plug_in = plug_in_stack->data; } else { - current_plug_in = NULL; - current_write_buffer_index = 0; - current_write_buffer = NULL; + current_plug_in = NULL; } } @@ -1807,8 +1809,8 @@ plug_in_temp_run (ProcRecord *proc_rec, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; diff --git a/app/plug-in/plug-in-run.c b/app/plug-in/plug-in-run.c index 77700e2749..1531ff6232 100644 --- a/app/plug-in/plug-in-run.c +++ b/app/plug-in/plug-in-run.c @@ -131,8 +131,10 @@ struct _PlugInHelpPathDef static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean plug_in_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean plug_in_flush (GIOChannel *channel, + gpointer user_data); static void plug_in_push (PlugIn *plug_in); static void plug_in_pop (void); static gboolean plug_in_recv_message (GIOChannel *channel, @@ -169,8 +171,6 @@ static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static gint current_write_buffer_index = 0; -static gchar *current_write_buffer = NULL; static Argument *current_return_vals = NULL; static gint current_return_nvals = 0; @@ -327,7 +327,7 @@ plug_in_call_query (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -365,7 +365,7 @@ plug_in_call_init (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -676,7 +676,7 @@ plug_in_close (PlugIn *plug_in, if (kill_it && plug_in->pid) { plug_in_push (plug_in); - gp_quit_write (plug_in->my_write); + gp_quit_write (plug_in->my_write, plug_in); plug_in_pop (); /* give the plug-in some time (10 ms) */ @@ -872,9 +872,9 @@ plug_in_run (Gimp *gimp, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_config_write (plug_in->my_write, &config) || - ! gp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_config_write (plug_in->my_write, &config, plug_in) || + ! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; @@ -965,7 +965,7 @@ plug_in_recv_message (GIOChannel *channel, memset (&msg, 0, sizeof (WireMessage)); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -1085,14 +1085,14 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.data = NULL; - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); return; } - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1140,7 +1140,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, TRUE); wire_destroy (&msg); - if (! gp_tile_ack_write (plug_in->my_write)) + if (! gp_tile_ack_write (plug_in->my_write, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1186,7 +1186,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, else tile_data.data = tile_data_pointer (tile, 0, 0); - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1195,7 +1195,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, FALSE); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1255,7 +1255,7 @@ plug_in_handle_proc_run (PlugIn *plug_in, proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); } - if (! gp_proc_return_write (plug_in->my_write, &proc_return)) + if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { g_warning ("plug_in_handle_proc_run: ERROR"); plug_in_close (plug_in, TRUE); @@ -1284,7 +1284,7 @@ plug_in_handle_proc_return (PlugIn *plug_in, PlugInBlocked *blocked; GSList *tmp; - if (current_plug_in->recurse) + if (plug_in->recurse) { current_return_vals = plug_in_params_to_args (proc_return->params, proc_return->nparams, @@ -1305,7 +1305,8 @@ plug_in_handle_proc_return (PlugIn *plug_in, plug_in_push (blocked->plug_in); if (! gp_proc_return_write (blocked->plug_in->my_write, - proc_return)) + proc_return, + blocked->plug_in)) { g_message ("plug_in_handle_proc_run: ERROR"); plug_in_close (blocked->plug_in, TRUE); @@ -1658,25 +1659,31 @@ plug_in_handle_has_init (PlugIn *plug_in) static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { - gulong bytes; + PlugIn *plug_in; + gulong bytes; + + plug_in = (PlugIn *) user_data; while (count > 0) { - if ((current_write_buffer_index + count) >= WRITE_BUFFER_SIZE) + if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE) { - bytes = WRITE_BUFFER_SIZE - current_write_buffer_index; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; - if (! wire_flush (channel)) + bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; + if (! wire_flush (channel, plug_in)) return FALSE; } else { bytes = count; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; } buf += bytes; @@ -1687,24 +1694,28 @@ plug_in_write (GIOChannel *channel, } static gboolean -plug_in_flush (GIOChannel *channel) +plug_in_flush (GIOChannel *channel, + gpointer user_data) { + PlugIn *plug_in; GIOStatus status; GError *error = NULL; gint count; guint bytes; - if (current_write_buffer_index > 0) + plug_in = (PlugIn *) user_data; + + if (plug_in->write_buffer_index > 0) { count = 0; - while (count != current_write_buffer_index) + while (count != plug_in->write_buffer_index) { do { bytes = 0; status = g_io_channel_write_chars (channel, - ¤t_write_buffer[count], - (current_write_buffer_index - count), + &plug_in->write_buffer[count], + (plug_in->write_buffer_index - count), &bytes, &error); } @@ -1730,7 +1741,7 @@ plug_in_flush (GIOChannel *channel) count += bytes; } - current_write_buffer_index = 0; + plug_in->write_buffer_index = 0; } return TRUE; @@ -1744,9 +1755,6 @@ plug_in_push (PlugIn *plug_in) current_plug_in = plug_in; plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); - - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; } static void @@ -1756,8 +1764,6 @@ plug_in_pop (void) if (current_plug_in) { - current_plug_in->write_buffer_index = current_write_buffer_index; - tmp = plug_in_stack; plug_in_stack = plug_in_stack->next; tmp->next = NULL; @@ -1766,15 +1772,11 @@ plug_in_pop (void) if (plug_in_stack) { - current_plug_in = plug_in_stack->data; - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; + current_plug_in = plug_in_stack->data; } else { - current_plug_in = NULL; - current_write_buffer_index = 0; - current_write_buffer = NULL; + current_plug_in = NULL; } } @@ -1807,8 +1809,8 @@ plug_in_temp_run (ProcRecord *proc_rec, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; diff --git a/app/plug-in/plug-in-shm.c b/app/plug-in/plug-in-shm.c index 77700e2749..1531ff6232 100644 --- a/app/plug-in/plug-in-shm.c +++ b/app/plug-in/plug-in-shm.c @@ -131,8 +131,10 @@ struct _PlugInHelpPathDef static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean plug_in_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean plug_in_flush (GIOChannel *channel, + gpointer user_data); static void plug_in_push (PlugIn *plug_in); static void plug_in_pop (void); static gboolean plug_in_recv_message (GIOChannel *channel, @@ -169,8 +171,6 @@ static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static gint current_write_buffer_index = 0; -static gchar *current_write_buffer = NULL; static Argument *current_return_vals = NULL; static gint current_return_nvals = 0; @@ -327,7 +327,7 @@ plug_in_call_query (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -365,7 +365,7 @@ plug_in_call_init (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -676,7 +676,7 @@ plug_in_close (PlugIn *plug_in, if (kill_it && plug_in->pid) { plug_in_push (plug_in); - gp_quit_write (plug_in->my_write); + gp_quit_write (plug_in->my_write, plug_in); plug_in_pop (); /* give the plug-in some time (10 ms) */ @@ -872,9 +872,9 @@ plug_in_run (Gimp *gimp, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_config_write (plug_in->my_write, &config) || - ! gp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_config_write (plug_in->my_write, &config, plug_in) || + ! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; @@ -965,7 +965,7 @@ plug_in_recv_message (GIOChannel *channel, memset (&msg, 0, sizeof (WireMessage)); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -1085,14 +1085,14 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.data = NULL; - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); return; } - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1140,7 +1140,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, TRUE); wire_destroy (&msg); - if (! gp_tile_ack_write (plug_in->my_write)) + if (! gp_tile_ack_write (plug_in->my_write, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1186,7 +1186,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, else tile_data.data = tile_data_pointer (tile, 0, 0); - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1195,7 +1195,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, FALSE); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1255,7 +1255,7 @@ plug_in_handle_proc_run (PlugIn *plug_in, proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); } - if (! gp_proc_return_write (plug_in->my_write, &proc_return)) + if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { g_warning ("plug_in_handle_proc_run: ERROR"); plug_in_close (plug_in, TRUE); @@ -1284,7 +1284,7 @@ plug_in_handle_proc_return (PlugIn *plug_in, PlugInBlocked *blocked; GSList *tmp; - if (current_plug_in->recurse) + if (plug_in->recurse) { current_return_vals = plug_in_params_to_args (proc_return->params, proc_return->nparams, @@ -1305,7 +1305,8 @@ plug_in_handle_proc_return (PlugIn *plug_in, plug_in_push (blocked->plug_in); if (! gp_proc_return_write (blocked->plug_in->my_write, - proc_return)) + proc_return, + blocked->plug_in)) { g_message ("plug_in_handle_proc_run: ERROR"); plug_in_close (blocked->plug_in, TRUE); @@ -1658,25 +1659,31 @@ plug_in_handle_has_init (PlugIn *plug_in) static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { - gulong bytes; + PlugIn *plug_in; + gulong bytes; + + plug_in = (PlugIn *) user_data; while (count > 0) { - if ((current_write_buffer_index + count) >= WRITE_BUFFER_SIZE) + if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE) { - bytes = WRITE_BUFFER_SIZE - current_write_buffer_index; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; - if (! wire_flush (channel)) + bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; + if (! wire_flush (channel, plug_in)) return FALSE; } else { bytes = count; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; } buf += bytes; @@ -1687,24 +1694,28 @@ plug_in_write (GIOChannel *channel, } static gboolean -plug_in_flush (GIOChannel *channel) +plug_in_flush (GIOChannel *channel, + gpointer user_data) { + PlugIn *plug_in; GIOStatus status; GError *error = NULL; gint count; guint bytes; - if (current_write_buffer_index > 0) + plug_in = (PlugIn *) user_data; + + if (plug_in->write_buffer_index > 0) { count = 0; - while (count != current_write_buffer_index) + while (count != plug_in->write_buffer_index) { do { bytes = 0; status = g_io_channel_write_chars (channel, - ¤t_write_buffer[count], - (current_write_buffer_index - count), + &plug_in->write_buffer[count], + (plug_in->write_buffer_index - count), &bytes, &error); } @@ -1730,7 +1741,7 @@ plug_in_flush (GIOChannel *channel) count += bytes; } - current_write_buffer_index = 0; + plug_in->write_buffer_index = 0; } return TRUE; @@ -1744,9 +1755,6 @@ plug_in_push (PlugIn *plug_in) current_plug_in = plug_in; plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); - - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; } static void @@ -1756,8 +1764,6 @@ plug_in_pop (void) if (current_plug_in) { - current_plug_in->write_buffer_index = current_write_buffer_index; - tmp = plug_in_stack; plug_in_stack = plug_in_stack->next; tmp->next = NULL; @@ -1766,15 +1772,11 @@ plug_in_pop (void) if (plug_in_stack) { - current_plug_in = plug_in_stack->data; - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; + current_plug_in = plug_in_stack->data; } else { - current_plug_in = NULL; - current_write_buffer_index = 0; - current_write_buffer = NULL; + current_plug_in = NULL; } } @@ -1807,8 +1809,8 @@ plug_in_temp_run (ProcRecord *proc_rec, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index 77700e2749..1531ff6232 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -131,8 +131,10 @@ struct _PlugInHelpPathDef static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean plug_in_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean plug_in_flush (GIOChannel *channel, + gpointer user_data); static void plug_in_push (PlugIn *plug_in); static void plug_in_pop (void); static gboolean plug_in_recv_message (GIOChannel *channel, @@ -169,8 +171,6 @@ static GSList *open_plug_ins = NULL; static GSList *blocked_plug_ins = NULL; static GSList *plug_in_stack = NULL; -static gint current_write_buffer_index = 0; -static gchar *current_write_buffer = NULL; static Argument *current_return_vals = NULL; static gint current_return_nvals = 0; @@ -327,7 +327,7 @@ plug_in_call_query (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -365,7 +365,7 @@ plug_in_call_init (Gimp *gimp, while (plug_in->open) { - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -676,7 +676,7 @@ plug_in_close (PlugIn *plug_in, if (kill_it && plug_in->pid) { plug_in_push (plug_in); - gp_quit_write (plug_in->my_write); + gp_quit_write (plug_in->my_write, plug_in); plug_in_pop (); /* give the plug-in some time (10 ms) */ @@ -872,9 +872,9 @@ plug_in_run (Gimp *gimp, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_config_write (plug_in->my_write, &config) || - ! gp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_config_write (plug_in->my_write, &config, plug_in) || + ! gp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; @@ -965,7 +965,7 @@ plug_in_recv_message (GIOChannel *channel, memset (&msg, 0, sizeof (WireMessage)); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { plug_in_close (plug_in, TRUE); } @@ -1085,14 +1085,14 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_data.use_shm = (shm_ID == -1) ? FALSE : TRUE; tile_data.data = NULL; - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); return; } - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1140,7 +1140,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, TRUE); wire_destroy (&msg); - if (! gp_tile_ack_write (plug_in->my_write)) + if (! gp_tile_ack_write (plug_in->my_write, plug_in)) { g_warning ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1186,7 +1186,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, else tile_data.data = tile_data_pointer (tile, 0, 0); - if (! gp_tile_data_write (plug_in->my_write, &tile_data)) + if (! gp_tile_data_write (plug_in->my_write, &tile_data, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1195,7 +1195,7 @@ plug_in_handle_tile_req (PlugIn *plug_in, tile_release (tile, FALSE); - if (! wire_read_msg (plug_in->my_read, &msg)) + if (! wire_read_msg (plug_in->my_read, &msg, plug_in)) { g_message ("plug_in_handle_tile_req: ERROR"); plug_in_close (plug_in, TRUE); @@ -1255,7 +1255,7 @@ plug_in_handle_proc_run (PlugIn *plug_in, proc_return.params = plug_in_args_to_params (return_vals, 1, FALSE); } - if (! gp_proc_return_write (plug_in->my_write, &proc_return)) + if (! gp_proc_return_write (plug_in->my_write, &proc_return, plug_in)) { g_warning ("plug_in_handle_proc_run: ERROR"); plug_in_close (plug_in, TRUE); @@ -1284,7 +1284,7 @@ plug_in_handle_proc_return (PlugIn *plug_in, PlugInBlocked *blocked; GSList *tmp; - if (current_plug_in->recurse) + if (plug_in->recurse) { current_return_vals = plug_in_params_to_args (proc_return->params, proc_return->nparams, @@ -1305,7 +1305,8 @@ plug_in_handle_proc_return (PlugIn *plug_in, plug_in_push (blocked->plug_in); if (! gp_proc_return_write (blocked->plug_in->my_write, - proc_return)) + proc_return, + blocked->plug_in)) { g_message ("plug_in_handle_proc_run: ERROR"); plug_in_close (blocked->plug_in, TRUE); @@ -1658,25 +1659,31 @@ plug_in_handle_has_init (PlugIn *plug_in) static gboolean plug_in_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { - gulong bytes; + PlugIn *plug_in; + gulong bytes; + + plug_in = (PlugIn *) user_data; while (count > 0) { - if ((current_write_buffer_index + count) >= WRITE_BUFFER_SIZE) + if ((plug_in->write_buffer_index + count) >= WRITE_BUFFER_SIZE) { - bytes = WRITE_BUFFER_SIZE - current_write_buffer_index; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; - if (! wire_flush (channel)) + bytes = WRITE_BUFFER_SIZE - plug_in->write_buffer_index; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; + if (! wire_flush (channel, plug_in)) return FALSE; } else { bytes = count; - memcpy (¤t_write_buffer[current_write_buffer_index], buf, bytes); - current_write_buffer_index += bytes; + memcpy (&plug_in->write_buffer[plug_in->write_buffer_index], + buf, bytes); + plug_in->write_buffer_index += bytes; } buf += bytes; @@ -1687,24 +1694,28 @@ plug_in_write (GIOChannel *channel, } static gboolean -plug_in_flush (GIOChannel *channel) +plug_in_flush (GIOChannel *channel, + gpointer user_data) { + PlugIn *plug_in; GIOStatus status; GError *error = NULL; gint count; guint bytes; - if (current_write_buffer_index > 0) + plug_in = (PlugIn *) user_data; + + if (plug_in->write_buffer_index > 0) { count = 0; - while (count != current_write_buffer_index) + while (count != plug_in->write_buffer_index) { do { bytes = 0; status = g_io_channel_write_chars (channel, - ¤t_write_buffer[count], - (current_write_buffer_index - count), + &plug_in->write_buffer[count], + (plug_in->write_buffer_index - count), &bytes, &error); } @@ -1730,7 +1741,7 @@ plug_in_flush (GIOChannel *channel) count += bytes; } - current_write_buffer_index = 0; + plug_in->write_buffer_index = 0; } return TRUE; @@ -1744,9 +1755,6 @@ plug_in_push (PlugIn *plug_in) current_plug_in = plug_in; plug_in_stack = g_slist_prepend (plug_in_stack, current_plug_in); - - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; } static void @@ -1756,8 +1764,6 @@ plug_in_pop (void) if (current_plug_in) { - current_plug_in->write_buffer_index = current_write_buffer_index; - tmp = plug_in_stack; plug_in_stack = plug_in_stack->next; tmp->next = NULL; @@ -1766,15 +1772,11 @@ plug_in_pop (void) if (plug_in_stack) { - current_plug_in = plug_in_stack->data; - current_write_buffer_index = current_plug_in->write_buffer_index; - current_write_buffer = current_plug_in->write_buffer; + current_plug_in = plug_in_stack->data; } else { - current_plug_in = NULL; - current_write_buffer_index = 0; - current_write_buffer = NULL; + current_plug_in = NULL; } } @@ -1807,8 +1809,8 @@ plug_in_temp_run (ProcRecord *proc_rec, proc_run.nparams = argc; proc_run.params = plug_in_args_to_params (args, argc, FALSE); - if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run) || - ! wire_flush (plug_in->my_write)) + if (! gp_temp_proc_run_write (plug_in->my_write, &proc_run, plug_in) || + ! wire_flush (plug_in->my_write, plug_in)) { return_vals = procedural_db_return_args (proc_rec, FALSE); goto done; diff --git a/devel-docs/ChangeLog b/devel-docs/ChangeLog index 7781b55e32..5a422179b5 100644 --- a/devel-docs/ChangeLog +++ b/devel-docs/ChangeLog @@ -1,3 +1,8 @@ +2002-05-16 Michael Natterer + + * libgimpbase/tmpl/gimpprotocol.sgml + * libgimpbase/tmpl/gimpwire.sgml: regenerated after API change. + 2002-05-14 Sven Neumann * libgimpmath/libgimpmath-sections.txt diff --git a/devel-docs/libgimpbase/tmpl/gimpprotocol.sgml b/devel-docs/libgimpbase/tmpl/gimpprotocol.sgml index ef1125f00c..71a0473d76 100644 --- a/devel-docs/libgimpbase/tmpl/gimpprotocol.sgml +++ b/devel-docs/libgimpbase/tmpl/gimpprotocol.sgml @@ -148,6 +148,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: +@user_data: @Returns: @@ -157,6 +158,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: +@user_data: @Returns: @@ -167,6 +169,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: @config: +@user_data: @Returns: @@ -177,6 +180,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: @tile_req: +@user_data: @Returns: @@ -186,6 +190,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: +@user_data: @Returns: @@ -196,6 +201,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: @tile_data: +@user_data: @Returns: @@ -206,6 +212,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: @proc_run: +@user_data: @Returns: @@ -216,6 +223,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: @proc_return: +@user_data: @Returns: @@ -226,6 +234,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: @proc_run: +@user_data: @Returns: @@ -236,6 +245,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: @proc_return: +@user_data: @Returns: @@ -246,6 +256,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: @proc_install: +@user_data: @Returns: @@ -256,6 +267,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: @proc_uninstall: +@user_data: @Returns: @@ -265,6 +277,7 @@ The communication protocol between GIMP and it's plug-ins. @channel: +@user_data: @Returns: diff --git a/devel-docs/libgimpbase/tmpl/gimpwire.sgml b/devel-docs/libgimpbase/tmpl/gimpwire.sgml index 340547ebc3..f9aabbd030 100644 --- a/devel-docs/libgimpbase/tmpl/gimpwire.sgml +++ b/devel-docs/libgimpbase/tmpl/gimpwire.sgml @@ -32,6 +32,7 @@ it's plug-ins. @channel: @msg: +@user_data: @@ -41,6 +42,7 @@ it's plug-ins. @channel: @msg: +@user_data: @@ -59,6 +61,7 @@ it's plug-ins. @channel: @buf: @count: +@user_data: @Returns: @@ -68,6 +71,7 @@ it's plug-ins. @channel: +@user_data: @Returns: @@ -114,6 +118,7 @@ it's plug-ins. @channel: @buf: @count: +@user_data: @Returns: @@ -125,6 +130,7 @@ it's plug-ins. @channel: @buf: @count: +@user_data: @Returns: @@ -134,6 +140,7 @@ it's plug-ins. @channel: +@user_data: @Returns: @@ -159,6 +166,7 @@ it's plug-ins. @channel: @msg: +@user_data: @Returns: @@ -169,6 +177,7 @@ it's plug-ins. @channel: @msg: +@user_data: @Returns: @@ -188,6 +197,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: @@ -199,6 +209,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: @@ -210,6 +221,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: @@ -221,6 +233,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: @@ -232,6 +245,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: @@ -243,6 +257,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: @@ -254,6 +269,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: @@ -265,6 +281,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: @@ -276,6 +293,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: @@ -287,6 +305,7 @@ it's plug-ins. @channel: @data: @count: +@user_data: @Returns: diff --git a/libgimp/gimp.c b/libgimp/gimp.c index 016f996e05..5be6684d6b 100644 --- a/libgimp/gimp.c +++ b/libgimp/gimp.c @@ -103,8 +103,10 @@ static gboolean gimp_plugin_io_error_handler (GIOChannel *channel, static gboolean gimp_write (GIOChannel *channel, guint8 *buf, - gulong count); -static gboolean gimp_flush (GIOChannel *channel); + gulong count, + gpointer user_data); +static gboolean gimp_flush (GIOChannel *channel, + gpointer user_data); static void gimp_loop (void); static void gimp_config (GPConfig *config); static void gimp_proc_run (GPProcRun *proc_run); @@ -283,7 +285,7 @@ gimp_main (int argc, if (strcmp (argv[4], "-query") == 0) { if (PLUG_IN_INFO.init_proc) - gp_has_init_write(_writechannel); + gp_has_init_write (_writechannel, NULL); if (PLUG_IN_INFO.query_proc) (* PLUG_IN_INFO.query_proc) (); @@ -327,7 +329,7 @@ gimp_close (void) #endif #endif - gp_quit_write (_writechannel); + gp_quit_write (_writechannel, NULL); } void @@ -384,7 +386,7 @@ gimp_install_procedure (gchar *name, proc_install.params = (GPParamDef *) params; proc_install.return_vals = (GPParamDef *) return_vals; - if (!gp_proc_install_write (_writechannel, &proc_install)) + if (! gp_proc_install_write (_writechannel, &proc_install, NULL)) gimp_quit (); } @@ -425,7 +427,7 @@ gimp_uninstall_temp_proc (gchar *name) gboolean found; proc_uninstall.name = name; - if (!gp_proc_uninstall_write (_writechannel, &proc_uninstall)) + if (! gp_proc_uninstall_write (_writechannel, &proc_uninstall, NULL)) gimp_quit (); found = g_hash_table_lookup_extended (temp_proc_ht, name, &hash_name, NULL); @@ -612,7 +614,7 @@ gimp_run_procedure (gchar *name, va_end (args); - if (!gp_proc_run_write (_writechannel, &proc_run)) + if (! gp_proc_run_write (_writechannel, &proc_run, NULL)) gimp_quit (); gimp_read_expect_msg (&msg, GP_PROC_RETURN); @@ -646,7 +648,7 @@ gimp_read_expect_msg (WireMessage *msg, { while (TRUE) { - if (!wire_read_msg (_readchannel, msg)) + if (! wire_read_msg (_readchannel, msg, NULL)) gimp_quit (); if (msg->type != type) @@ -680,10 +682,10 @@ gimp_run_procedure2 (gchar *name, proc_run.nparams = nparams; proc_run.params = (GPParam *) params; - if (!gp_proc_run_write (_writechannel, &proc_run)) + if (! gp_proc_run_write (_writechannel, &proc_run, NULL)) gimp_quit (); - gimp_read_expect_msg(&msg,GP_PROC_RETURN); + gimp_read_expect_msg (&msg, GP_PROC_RETURN); proc_return = msg.data; *nreturn_vals = proc_return->nparams; @@ -790,7 +792,7 @@ gimp_single_message (void) WireMessage msg; /* Run a temp function */ - if (!wire_read_msg (_readchannel, &msg)) + if (! wire_read_msg (_readchannel, &msg, NULL)) gimp_quit (); gimp_process_message (&msg); @@ -849,7 +851,7 @@ void gimp_extension_ack (void) { /* Send an extension initialization acknowledgement */ - if (! gp_extension_ack_write (_writechannel)) + if (! gp_extension_ack_write (_writechannel, NULL)) gimp_quit (); } @@ -945,7 +947,8 @@ gimp_plugin_io_error_handler (GIOChannel *channel, static gboolean gimp_write (GIOChannel *channel, guint8 *buf, - gulong count) + gulong count, + gpointer user_data) { gulong bytes; @@ -956,7 +959,7 @@ gimp_write (GIOChannel *channel, bytes = WRITE_BUFFER_SIZE - write_buffer_index; memcpy (&write_buffer[write_buffer_index], buf, bytes); write_buffer_index += bytes; - if (!wire_flush (channel)) + if (! wire_flush (channel, NULL)) return FALSE; } else @@ -974,7 +977,8 @@ gimp_write (GIOChannel *channel, } static gboolean -gimp_flush (GIOChannel *channel) +gimp_flush (GIOChannel *channel, + gpointer user_data) { GIOStatus status; GError *error = NULL; @@ -1030,7 +1034,7 @@ gimp_loop (void) while (TRUE) { - if (!wire_read_msg (_readchannel, &msg)) + if (! wire_read_msg (_readchannel, &msg, NULL)) { gimp_close (); return; @@ -1154,9 +1158,9 @@ gimp_config (GPConfig *config) static void gimp_proc_run (GPProcRun *proc_run) { - GPProcReturn proc_return; - GimpParam *return_vals; - gint nreturn_vals; + GPProcReturn proc_return; + GimpParam *return_vals; + gint nreturn_vals; if (PLUG_IN_INFO.run_proc) { @@ -1170,7 +1174,7 @@ gimp_proc_run (GPProcRun *proc_run) proc_return.nparams = nreturn_vals; proc_return.params = (GPParam*) return_vals; - if (!gp_proc_return_write (_writechannel, &proc_return)) + if (! gp_proc_return_write (_writechannel, &proc_return, NULL)) gimp_quit (); } } @@ -1198,7 +1202,7 @@ gimp_temp_proc_run (GPProcRun *proc_run) /* proc_return.nparams = nreturn_vals; */ /* proc_return.params = (GPParam*) return_vals; */ -/* if (!gp_temp_proc_return_write (_writechannel, &proc_return)) */ +/* if (! gp_temp_proc_return_write (_writechannel, &proc_return, NULL)) */ /* gimp_quit (); */ } } diff --git a/libgimp/gimptile.c b/libgimp/gimptile.c index cc0af9feda..5e90ff8929 100644 --- a/libgimp/gimptile.c +++ b/libgimp/gimptile.c @@ -160,10 +160,10 @@ gimp_tile_get (GimpTile *tile) tile_req.drawable_ID = tile->drawable->drawable_id; tile_req.tile_num = tile->tile_num; tile_req.shadow = tile->shadow; - if (!gp_tile_req_write (_writechannel, &tile_req)) + if (! gp_tile_req_write (_writechannel, &tile_req, NULL)) gimp_quit (); - gimp_read_expect_msg(&msg,GP_TILE_DATA); + gimp_read_expect_msg (&msg, GP_TILE_DATA); tile_data = msg.data; if ((tile_data->drawable_ID != tile->drawable->drawable_id) || @@ -188,7 +188,7 @@ gimp_tile_get (GimpTile *tile) tile_data->data = NULL; } - if (!gp_tile_ack_write (_writechannel)) + if (! gp_tile_ack_write (_writechannel, NULL)) gimp_quit (); wire_destroy (&msg); @@ -208,31 +208,31 @@ gimp_tile_put (GimpTile *tile) tile_req.drawable_ID = -1; tile_req.tile_num = 0; tile_req.shadow = 0; - if (!gp_tile_req_write (_writechannel, &tile_req)) + if (! gp_tile_req_write (_writechannel, &tile_req, NULL)) gimp_quit (); - gimp_read_expect_msg(&msg,GP_TILE_DATA); + gimp_read_expect_msg (&msg, GP_TILE_DATA); tile_info = msg.data; tile_data.drawable_ID = tile->drawable->drawable_id; - tile_data.tile_num = tile->tile_num; - tile_data.shadow = tile->shadow; - tile_data.bpp = tile->bpp; - tile_data.width = tile->ewidth; - tile_data.height = tile->eheight; - tile_data.use_shm = tile_info->use_shm; - tile_data.data = NULL; + tile_data.tile_num = tile->tile_num; + tile_data.shadow = tile->shadow; + tile_data.bpp = tile->bpp; + tile_data.width = tile->ewidth; + tile_data.height = tile->eheight; + tile_data.use_shm = tile_info->use_shm; + tile_data.data = NULL; if (tile_info->use_shm) memcpy (_shm_addr, tile->data, tile->ewidth * tile->eheight * tile->bpp); else tile_data.data = tile->data; - if (!gp_tile_data_write (_writechannel, &tile_data)) + if (! gp_tile_data_write (_writechannel, &tile_data, NULL)) gimp_quit (); - gimp_read_expect_msg(&msg,GP_TILE_ACK); + gimp_read_expect_msg (&msg, GP_TILE_ACK); wire_destroy (&msg); } diff --git a/libgimpbase/gimpprotocol.c b/libgimpbase/gimpprotocol.c index 189ae50ce5..8ffe4f68f7 100644 --- a/libgimpbase/gimpprotocol.c +++ b/libgimpbase/gimpprotocol.c @@ -29,91 +29,120 @@ static void _gp_quit_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_quit_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_quit_destroy (WireMessage *msg); static void _gp_config_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_config_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_config_destroy (WireMessage *msg); static void _gp_tile_req_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_tile_req_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_tile_req_destroy (WireMessage *msg); static void _gp_tile_ack_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_tile_ack_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_tile_ack_destroy (WireMessage *msg); static void _gp_tile_data_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_tile_data_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_tile_data_destroy (WireMessage *msg); static void _gp_proc_run_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_proc_run_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_proc_run_destroy (WireMessage *msg); static void _gp_proc_return_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_proc_return_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_proc_return_destroy (WireMessage *msg); static void _gp_temp_proc_run_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_temp_proc_run_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_temp_proc_run_destroy (WireMessage *msg); static void _gp_temp_proc_return_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_temp_proc_return_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_temp_proc_return_destroy (WireMessage *msg); static void _gp_proc_install_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_proc_install_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_proc_install_destroy (WireMessage *msg); static void _gp_proc_uninstall_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_proc_uninstall_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_proc_uninstall_destroy (WireMessage *msg); static void _gp_extension_ack_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_extension_ack_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_extension_ack_destroy (WireMessage *msg); static void _gp_params_read (GIOChannel *channel, GPParam **params, - guint *nparams); + guint *nparams, + gpointer user_data); static void _gp_params_write (GIOChannel *channel, GPParam *params, - gint nparams); + gint nparams, + gpointer user_data); /* used by gimp.c:gimp_destroy_params() */ void _gp_params_destroy (GPParam *params, gint nparams); + static void _gp_has_init_read (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_has_init_write (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); static void _gp_has_init_destroy (WireMessage *msg); @@ -176,205 +205,218 @@ gp_init (void) } gboolean -gp_quit_write (GIOChannel *channel) +gp_quit_write (GIOChannel *channel, + gpointer user_data) { WireMessage msg; msg.type = GP_QUIT; msg.data = NULL; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean gp_config_write (GIOChannel *channel, - GPConfig *config) + GPConfig *config, + gpointer user_data) { WireMessage msg; msg.type = GP_CONFIG; msg.data = config; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean gp_tile_req_write (GIOChannel *channel, - GPTileReq *tile_req) + GPTileReq *tile_req, + gpointer user_data) { WireMessage msg; msg.type = GP_TILE_REQ; msg.data = tile_req; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean -gp_tile_ack_write (GIOChannel *channel) +gp_tile_ack_write (GIOChannel *channel, + gpointer user_data) { WireMessage msg; msg.type = GP_TILE_ACK; msg.data = NULL; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean gp_tile_data_write (GIOChannel *channel, - GPTileData *tile_data) + GPTileData *tile_data, + gpointer user_data) { WireMessage msg; msg.type = GP_TILE_DATA; msg.data = tile_data; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean gp_proc_run_write (GIOChannel *channel, - GPProcRun *proc_run) + GPProcRun *proc_run, + gpointer user_data) { WireMessage msg; msg.type = GP_PROC_RUN; msg.data = proc_run; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean gp_proc_return_write (GIOChannel *channel, - GPProcReturn *proc_return) + GPProcReturn *proc_return, + gpointer user_data) { WireMessage msg; msg.type = GP_PROC_RETURN; msg.data = proc_return; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean gp_temp_proc_run_write (GIOChannel *channel, - GPProcRun *proc_run) + GPProcRun *proc_run, + gpointer user_data) { WireMessage msg; msg.type = GP_TEMP_PROC_RUN; msg.data = proc_run; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean gp_temp_proc_return_write (GIOChannel *channel, - GPProcReturn *proc_return) + GPProcReturn *proc_return, + gpointer user_data) { WireMessage msg; msg.type = GP_TEMP_PROC_RETURN; msg.data = proc_return; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean gp_proc_install_write (GIOChannel *channel, - GPProcInstall *proc_install) + GPProcInstall *proc_install, + gpointer user_data) { WireMessage msg; msg.type = GP_PROC_INSTALL; msg.data = proc_install; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean gp_proc_uninstall_write (GIOChannel *channel, - GPProcUninstall *proc_uninstall) + GPProcUninstall *proc_uninstall, + gpointer user_data) { WireMessage msg; msg.type = GP_PROC_UNINSTALL; msg.data = proc_uninstall; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean -gp_extension_ack_write (GIOChannel *channel) +gp_extension_ack_write (GIOChannel *channel, + gpointer user_data) { WireMessage msg; msg.type = GP_EXTENSION_ACK; msg.data = NULL; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } gboolean -gp_has_init_write (GIOChannel *channel) +gp_has_init_write (GIOChannel *channel, + gpointer user_data) { WireMessage msg; msg.type = GP_HAS_INIT; msg.data = NULL; - if (!wire_write_msg (channel, &msg)) + if (! wire_write_msg (channel, &msg, user_data)) return FALSE; - if (!wire_flush (channel)) + if (! wire_flush (channel, user_data)) return FALSE; return TRUE; } @@ -383,13 +425,15 @@ gp_has_init_write (GIOChannel *channel) static void _gp_quit_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { } static void _gp_quit_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { } @@ -402,29 +446,30 @@ _gp_quit_destroy (WireMessage *msg) static void _gp_config_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPConfig *config; config = g_new (GPConfig, 1); - if (!wire_read_int32 (channel, &config->version, 1)) + if (! wire_read_int32 (channel, &config->version, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &config->tile_width, 1)) + if (! wire_read_int32 (channel, &config->tile_width, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &config->tile_height, 1)) + if (! wire_read_int32 (channel, &config->tile_height, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, (guint32*) &config->shm_ID, 1)) + if (! wire_read_int32 (channel, (guint32*) &config->shm_ID, 1, user_data)) goto cleanup; - if (!wire_read_double (channel, &config->gamma, 1)) + if (! wire_read_double (channel, &config->gamma, 1, user_data)) goto cleanup; - if (!wire_read_int8 (channel, (guint8*) &config->install_cmap, 1)) + if (! wire_read_int8 (channel, (guint8*) &config->install_cmap, 1, user_data)) goto cleanup; - if (!wire_read_int8 (channel, (guint8*) &config->unused, 1)) + if (! wire_read_int8 (channel, (guint8*) &config->unused, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, (guint32*) &config->min_colors, 1)) + if (! wire_read_int32 (channel, (guint32*) &config->min_colors, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, (guint32*) &config->gdisp_ID, 1)) + if (! wire_read_int32 (channel, (guint32*) &config->gdisp_ID, 1, user_data)) goto cleanup; msg->data = config; @@ -436,28 +481,29 @@ _gp_config_read (GIOChannel *channel, static void _gp_config_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPConfig *config; config = msg->data; - if (!wire_write_int32 (channel, &config->version, 1)) + if (! wire_write_int32 (channel, &config->version, 1, user_data)) return; - if (!wire_write_int32 (channel, &config->tile_width, 1)) + if (! wire_write_int32 (channel, &config->tile_width, 1, user_data)) return; - if (!wire_write_int32 (channel, &config->tile_height, 1)) + if (! wire_write_int32 (channel, &config->tile_height, 1, user_data)) return; - if (!wire_write_int32 (channel, (guint32*) &config->shm_ID, 1)) + if (! wire_write_int32 (channel, (guint32*) &config->shm_ID, 1, user_data)) return; - if (!wire_write_double (channel, &config->gamma, 1)) + if (! wire_write_double (channel, &config->gamma, 1, user_data)) return; - if (!wire_write_int8 (channel, (guint8*) &config->install_cmap, 1)) + if (! wire_write_int8 (channel, (guint8*) &config->install_cmap, 1, user_data)) return; - if (!wire_write_int8 (channel, (guint8*) &config->unused, 1)) + if (! wire_write_int8 (channel, (guint8*) &config->unused, 1, user_data)) return; - if (!wire_write_int32 (channel, (guint32*) &config->min_colors, 1)) + if (! wire_write_int32 (channel, (guint32*) &config->min_colors, 1, user_data)) return; - if (!wire_write_int32 (channel, (guint32*) &config->gdisp_ID, 1)) + if (! wire_write_int32 (channel, (guint32*) &config->gdisp_ID, 1, user_data)) return; } @@ -471,17 +517,19 @@ _gp_config_destroy (WireMessage *msg) static void _gp_tile_req_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPTileReq *tile_req; tile_req = g_new (GPTileReq, 1); - if (!wire_read_int32 (channel, (guint32*) &tile_req->drawable_ID, 1)) + if (! wire_read_int32 (channel, (guint32*) &tile_req->drawable_ID, 1, + user_data)) goto cleanup; - if (!wire_read_int32 (channel, &tile_req->tile_num, 1)) + if (! wire_read_int32 (channel, &tile_req->tile_num, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &tile_req->shadow, 1)) + if (! wire_read_int32 (channel, &tile_req->shadow, 1, user_data)) goto cleanup; msg->data = tile_req; @@ -493,16 +541,18 @@ _gp_tile_req_read (GIOChannel *channel, static void _gp_tile_req_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPTileReq *tile_req; tile_req = msg->data; - if (!wire_write_int32 (channel, (guint32*) &tile_req->drawable_ID, 1)) + if (! wire_write_int32 (channel, (guint32*) &tile_req->drawable_ID, 1, + user_data)) return; - if (!wire_write_int32 (channel, &tile_req->tile_num, 1)) + if (! wire_write_int32 (channel, &tile_req->tile_num, 1, user_data)) return; - if (!wire_write_int32 (channel, &tile_req->shadow, 1)) + if (! wire_write_int32 (channel, &tile_req->shadow, 1, user_data)) return; } @@ -516,13 +566,15 @@ _gp_tile_req_destroy (WireMessage *msg) static void _gp_tile_ack_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { } static void _gp_tile_ack_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { } @@ -535,26 +587,28 @@ _gp_tile_ack_destroy (WireMessage *msg) static void _gp_tile_data_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPTileData *tile_data; guint length; tile_data = g_new0 (GPTileData, 1); - if (!wire_read_int32 (channel, (guint32*) &tile_data->drawable_ID, 1)) + if (! wire_read_int32 (channel, (guint32*) &tile_data->drawable_ID, 1, + user_data)) goto cleanup; - if (!wire_read_int32 (channel, &tile_data->tile_num, 1)) + if (! wire_read_int32 (channel, &tile_data->tile_num, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &tile_data->shadow, 1)) + if (! wire_read_int32 (channel, &tile_data->shadow, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &tile_data->bpp, 1)) + if (! wire_read_int32 (channel, &tile_data->bpp, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &tile_data->width, 1)) + if (! wire_read_int32 (channel, &tile_data->width, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &tile_data->height, 1)) + if (! wire_read_int32 (channel, &tile_data->height, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &tile_data->use_shm, 1)) + if (! wire_read_int32 (channel, &tile_data->use_shm, 1, user_data)) goto cleanup; if (!tile_data->use_shm) @@ -562,7 +616,8 @@ _gp_tile_data_read (GIOChannel *channel, length = tile_data->width * tile_data->height * tile_data->bpp; tile_data->data = g_new (guchar, length); - if (!wire_read_int8 (channel, (guint8*) tile_data->data, length)) + if (! wire_read_int8 (channel, (guint8*) tile_data->data, length, + user_data)) goto cleanup; } @@ -576,31 +631,34 @@ _gp_tile_data_read (GIOChannel *channel, static void _gp_tile_data_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPTileData *tile_data; guint length; tile_data = msg->data; - if (!wire_write_int32 (channel, (guint32*) &tile_data->drawable_ID, 1)) + if (! wire_write_int32 (channel, (guint32*) &tile_data->drawable_ID, 1, + user_data)) return; - if (!wire_write_int32 (channel, &tile_data->tile_num, 1)) + if (! wire_write_int32 (channel, &tile_data->tile_num, 1, user_data)) return; - if (!wire_write_int32 (channel, &tile_data->shadow, 1)) + if (! wire_write_int32 (channel, &tile_data->shadow, 1, user_data)) return; - if (!wire_write_int32 (channel, &tile_data->bpp, 1)) + if (! wire_write_int32 (channel, &tile_data->bpp, 1, user_data)) return; - if (!wire_write_int32 (channel, &tile_data->width, 1)) + if (! wire_write_int32 (channel, &tile_data->width, 1, user_data)) return; - if (!wire_write_int32 (channel, &tile_data->height, 1)) + if (! wire_write_int32 (channel, &tile_data->height, 1, user_data)) return; - if (!wire_write_int32 (channel, &tile_data->use_shm, 1)) + if (! wire_write_int32 (channel, &tile_data->use_shm, 1, user_data)) return; if (!tile_data->use_shm) { length = tile_data->width * tile_data->height * tile_data->bpp; - if (!wire_write_int8 (channel, (guint8*) tile_data->data, length)) + if (! wire_write_int8 (channel, (guint8*) tile_data->data, length, + user_data)) return; } } @@ -620,16 +678,19 @@ _gp_tile_data_destroy (WireMessage *msg) static void _gp_proc_run_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPProcRun *proc_run; proc_run = g_new (GPProcRun, 1); - if (!wire_read_string (channel, &proc_run->name, 1)) + if (! wire_read_string (channel, &proc_run->name, 1, user_data)) goto cleanup; - _gp_params_read (channel, &proc_run->params, (guint*) &proc_run->nparams); + _gp_params_read (channel, + &proc_run->params, (guint*) &proc_run->nparams, + user_data); msg->data = proc_run; return; @@ -640,16 +701,17 @@ _gp_proc_run_read (GIOChannel *channel, static void _gp_proc_run_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPProcRun *proc_run; proc_run = msg->data; - if (!wire_write_string (channel, &proc_run->name, 1)) + if (! wire_write_string (channel, &proc_run->name, 1, user_data)) return; - _gp_params_write (channel, proc_run->params, proc_run->nparams); + _gp_params_write (channel, proc_run->params, proc_run->nparams, user_data); } static void @@ -668,16 +730,19 @@ _gp_proc_run_destroy (WireMessage *msg) static void _gp_proc_return_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPProcReturn *proc_return; proc_return = g_new (GPProcReturn, 1); - if (!wire_read_string (channel, &proc_return->name, 1)) + if (! wire_read_string (channel, &proc_return->name, 1, user_data)) goto cleanup; - _gp_params_read (channel, &proc_return->params, (guint*) &proc_return->nparams); + _gp_params_read (channel, + &proc_return->params, (guint*) &proc_return->nparams, + user_data); msg->data = proc_return; return; @@ -688,15 +753,18 @@ _gp_proc_return_read (GIOChannel *channel, static void _gp_proc_return_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPProcReturn *proc_return; proc_return = msg->data; - if (!wire_write_string (channel, &proc_return->name, 1)) + if (! wire_write_string (channel, &proc_return->name, 1, user_data)) return; - _gp_params_write (channel, proc_return->params, proc_return->nparams); + + _gp_params_write (channel, proc_return->params, proc_return->nparams, + user_data); } static void @@ -715,16 +783,18 @@ _gp_proc_return_destroy (WireMessage *msg) static void _gp_temp_proc_run_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { - _gp_proc_run_read (channel, msg); + _gp_proc_run_read (channel, msg, user_data); } static void _gp_temp_proc_run_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { - _gp_proc_run_write (channel, msg); + _gp_proc_run_write (channel, msg, user_data); } static void @@ -737,16 +807,18 @@ _gp_temp_proc_run_destroy (WireMessage *msg) static void _gp_temp_proc_return_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { - _gp_proc_return_read (channel, msg); + _gp_proc_return_read (channel, msg, user_data); } static void _gp_temp_proc_return_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { - _gp_proc_return_write (channel, msg); + _gp_proc_return_write (channel, msg, user_data); } static void @@ -759,46 +831,53 @@ _gp_temp_proc_return_destroy (WireMessage *msg) static void _gp_proc_install_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPProcInstall *proc_install; gint i; proc_install = g_new0 (GPProcInstall, 1); - if (!wire_read_string (channel, &proc_install->name, 1)) + if (! wire_read_string (channel, &proc_install->name, 1, user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->blurb, 1)) + if (! wire_read_string (channel, &proc_install->blurb, 1, user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->help, 1)) + if (! wire_read_string (channel, &proc_install->help, 1, user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->author, 1)) + if (! wire_read_string (channel, &proc_install->author, 1, user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->copyright, 1)) + if (! wire_read_string (channel, &proc_install->copyright, 1, user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->date, 1)) + if (! wire_read_string (channel, &proc_install->date, 1, user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->menu_path, 1)) + if (! wire_read_string (channel, &proc_install->menu_path, 1, user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->image_types, 1)) + if (! wire_read_string (channel, &proc_install->image_types, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &proc_install->type, 1)) + if (! wire_read_int32 (channel, &proc_install->type, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &proc_install->nparams, 1)) + if (! wire_read_int32 (channel, &proc_install->nparams, 1, user_data)) goto cleanup; - if (!wire_read_int32 (channel, &proc_install->nreturn_vals, 1)) + if (! wire_read_int32 (channel, &proc_install->nreturn_vals, 1, user_data)) goto cleanup; proc_install->params = g_new0 (GPParamDef, proc_install->nparams); for (i = 0; i < proc_install->nparams; i++) { - if (!wire_read_int32 (channel, (guint32*) &proc_install->params[i].type, 1)) + if (! wire_read_int32 (channel, + (guint32*) &proc_install->params[i].type, 1, + user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->params[i].name, 1)) + if (! wire_read_string (channel, + &proc_install->params[i].name, 1, + user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->params[i].description, 1)) + if (! wire_read_string (channel, + &proc_install->params[i].description, 1, + user_data)) goto cleanup; } @@ -806,11 +885,17 @@ _gp_proc_install_read (GIOChannel *channel, for (i = 0; i < proc_install->nreturn_vals; i++) { - if (!wire_read_int32 (channel, (guint32*) &proc_install->return_vals[i].type, 1)) + if (! wire_read_int32 (channel, + (guint32*) &proc_install->return_vals[i].type, 1, + user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->return_vals[i].name, 1)) + if (! wire_read_string (channel, + &proc_install->return_vals[i].name, 1, + user_data)) goto cleanup; - if (!wire_read_string (channel, &proc_install->return_vals[i].description, 1)) + if (! wire_read_string (channel, + &proc_install->return_vals[i].description, 1, + user_data)) goto cleanup; } @@ -860,54 +945,67 @@ _gp_proc_install_read (GIOChannel *channel, static void _gp_proc_install_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPProcInstall *proc_install; gint i; proc_install = msg->data; - if (!wire_write_string (channel, &proc_install->name, 1)) + if (! wire_write_string (channel, &proc_install->name, 1, user_data)) return; - if (!wire_write_string (channel, &proc_install->blurb, 1)) + if (! wire_write_string (channel, &proc_install->blurb, 1, user_data)) return; - if (!wire_write_string (channel, &proc_install->help, 1)) + if (! wire_write_string (channel, &proc_install->help, 1, user_data)) return; - if (!wire_write_string (channel, &proc_install->author, 1)) + if (! wire_write_string (channel, &proc_install->author, 1, user_data)) return; - if (!wire_write_string (channel, &proc_install->copyright, 1)) + if (! wire_write_string (channel, &proc_install->copyright, 1, user_data)) return; - if (!wire_write_string (channel, &proc_install->date, 1)) + if (! wire_write_string (channel, &proc_install->date, 1, user_data)) return; - if (!wire_write_string (channel, &proc_install->menu_path, 1)) + if (! wire_write_string (channel, &proc_install->menu_path, 1, user_data)) return; - if (!wire_write_string (channel, &proc_install->image_types, 1)) + if (! wire_write_string (channel, &proc_install->image_types, 1, user_data)) return; - if (!wire_write_int32 (channel, &proc_install->type, 1)) + if (! wire_write_int32 (channel, &proc_install->type, 1, user_data)) return; - if (!wire_write_int32 (channel, &proc_install->nparams, 1)) + if (! wire_write_int32 (channel, &proc_install->nparams, 1, user_data)) return; - if (!wire_write_int32 (channel, &proc_install->nreturn_vals, 1)) + if (! wire_write_int32 (channel, &proc_install->nreturn_vals, 1, user_data)) return; for (i = 0; i < proc_install->nparams; i++) { - if (!wire_write_int32 (channel, (guint32*) &proc_install->params[i].type, 1)) + if (! wire_write_int32 (channel, + (guint32*) &proc_install->params[i].type, 1, + user_data)) return; - if (!wire_write_string (channel, &proc_install->params[i].name, 1)) + if (! wire_write_string (channel, + &proc_install->params[i].name, 1, + user_data)) return; - if (!wire_write_string (channel, &proc_install->params[i].description, 1)) + if (! wire_write_string (channel, + &proc_install->params[i].description, 1, + user_data)) return; } for (i = 0; i < proc_install->nreturn_vals; i++) { - if (!wire_write_int32 (channel, (guint32*) &proc_install->return_vals[i].type, 1)) + if (! wire_write_int32 (channel, + (guint32*) &proc_install->return_vals[i].type, 1, + user_data)) return; - if (!wire_write_string (channel, &proc_install->return_vals[i].name, 1)) + if (! wire_write_string (channel, + &proc_install->return_vals[i].name, 1, + user_data)) return; - if (!wire_write_string (channel, &proc_install->return_vals[i].description, 1)) + if (! wire_write_string (channel, + &proc_install->return_vals[i].description, 1, + user_data)) return; } } @@ -950,13 +1048,14 @@ _gp_proc_install_destroy (WireMessage *msg) static void _gp_proc_uninstall_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { GPProcUninstall *proc_uninstall; proc_uninstall = g_new (GPProcUninstall, 1); - if (!wire_read_string (channel, &proc_uninstall->name, 1)) + if (! wire_read_string (channel, &proc_uninstall->name, 1, user_data)) goto cleanup; msg->data = proc_uninstall; @@ -967,13 +1066,15 @@ _gp_proc_uninstall_read (GIOChannel *channel, } static void -_gp_proc_uninstall_write (GIOChannel *channel, WireMessage *msg) +_gp_proc_uninstall_write (GIOChannel *channel, + WireMessage *msg, + gpointer user_data) { GPProcUninstall *proc_uninstall; proc_uninstall = msg->data; - if (!wire_write_string (channel, &proc_uninstall->name, 1)) + if (! wire_write_string (channel, &proc_uninstall->name, 1, user_data)) return; } @@ -992,13 +1093,15 @@ _gp_proc_uninstall_destroy (WireMessage *msg) static void _gp_extension_ack_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { } static void _gp_extension_ack_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { } @@ -1012,11 +1115,12 @@ _gp_extension_ack_destroy (WireMessage *msg) static void _gp_params_read (GIOChannel *channel, GPParam **params, - guint *nparams) + guint *nparams, + gpointer user_data) { gint i, j; - if (!wire_read_int32 (channel, (guint32*) nparams, 1)) + if (! wire_read_int32 (channel, (guint32*) nparams, 1, user_data)) return; if (*nparams == 0) @@ -1029,41 +1133,55 @@ _gp_params_read (GIOChannel *channel, for (i = 0; i < *nparams; i++) { - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].type, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].type, 1, + user_data)) goto cleanup; switch ((*params)[i].type) { case GIMP_PDB_INT32: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_int32, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_int32, 1, + user_data)) goto cleanup; break; case GIMP_PDB_INT16: - if (!wire_read_int16 (channel, (guint16*) &(*params)[i].data.d_int16, 1)) + if (! wire_read_int16 (channel, + (guint16*) &(*params)[i].data.d_int16, 1, + user_data)) goto cleanup; break; case GIMP_PDB_INT8: - if (!wire_read_int8 (channel, (guint8*) &(*params)[i].data.d_int8, 1)) + if (! wire_read_int8 (channel, + (guint8*) &(*params)[i].data.d_int8, 1, + user_data)) goto cleanup; break; case GIMP_PDB_FLOAT: - if (!wire_read_double (channel, &(*params)[i].data.d_float, 1)) + if (! wire_read_double (channel, + &(*params)[i].data.d_float, 1, + user_data)) goto cleanup; break; case GIMP_PDB_STRING: - if (!wire_read_string (channel, &(*params)[i].data.d_string, 1)) + if (! wire_read_string (channel, + &(*params)[i].data.d_string, 1, + user_data)) goto cleanup; break; case GIMP_PDB_INT32ARRAY: (*params)[i].data.d_int32array = g_new (gint32, (*params)[i-1].data.d_int32); - if (!wire_read_int32 (channel, (guint32*) (*params)[i].data.d_int32array, - (*params)[i-1].data.d_int32)) + if (! wire_read_int32 (channel, + (guint32*) (*params)[i].data.d_int32array, + (*params)[i-1].data.d_int32, + user_data)) { g_free ((*params)[i].data.d_int32array); goto cleanup; @@ -1073,8 +1191,10 @@ _gp_params_read (GIOChannel *channel, case GIMP_PDB_INT16ARRAY: (*params)[i].data.d_int16array = g_new (gint16, (*params)[i-1].data.d_int32); - if (!wire_read_int16 (channel, (guint16*) (*params)[i].data.d_int16array, - (*params)[i-1].data.d_int32)) + if (! wire_read_int16 (channel, + (guint16*) (*params)[i].data.d_int16array, + (*params)[i-1].data.d_int32, + user_data)) { g_free ((*params)[i].data.d_int16array); goto cleanup; @@ -1084,8 +1204,10 @@ _gp_params_read (GIOChannel *channel, case GIMP_PDB_INT8ARRAY: (*params)[i].data.d_int8array = g_new (gint8, (*params)[i-1].data.d_int32); - if (!wire_read_int8 (channel, (guint8*) (*params)[i].data.d_int8array, - (*params)[i-1].data.d_int32)) + if (! wire_read_int8 (channel, + (guint8*) (*params)[i].data.d_int8array, + (*params)[i-1].data.d_int32, + user_data)) { g_free ((*params)[i].data.d_int8array); goto cleanup; @@ -1095,8 +1217,10 @@ _gp_params_read (GIOChannel *channel, case GIMP_PDB_FLOATARRAY: (*params)[i].data.d_floatarray = g_new (gdouble, (*params)[i-1].data.d_int32); - if (!wire_read_double (channel, (*params)[i].data.d_floatarray, - (*params)[i-1].data.d_int32)) + if (! wire_read_double (channel, + (*params)[i].data.d_floatarray, + (*params)[i-1].data.d_int32, + user_data)) { g_free ((*params)[i].data.d_floatarray); goto cleanup; @@ -1106,8 +1230,10 @@ _gp_params_read (GIOChannel *channel, case GIMP_PDB_STRINGARRAY: (*params)[i].data.d_stringarray = g_new0 (gchar*, (*params)[i-1].data.d_int32); - if (!wire_read_string (channel, (*params)[i].data.d_stringarray, - (*params)[i-1].data.d_int32)) + if (! wire_read_string (channel, + (*params)[i].data.d_stringarray, + (*params)[i-1].data.d_int32, + user_data)) { for (j = 0; j < (*params)[i-1].data.d_int32; j++) g_free (((*params)[i].data.d_stringarray)[j]); @@ -1117,13 +1243,21 @@ _gp_params_read (GIOChannel *channel, break; case GIMP_PDB_COLOR: - if (!wire_read_double (channel, &(*params)[i].data.d_color.r, 1)) + if (! wire_read_double (channel, + &(*params)[i].data.d_color.r, 1, + user_data)) goto cleanup; - if (!wire_read_double (channel, &(*params)[i].data.d_color.g, 1)) + if (! wire_read_double (channel, + &(*params)[i].data.d_color.g, 1, + user_data)) goto cleanup; - if (!wire_read_double (channel, &(*params)[i].data.d_color.b, 1)) + if (! wire_read_double (channel, + &(*params)[i].data.d_color.b, 1, + user_data)) goto cleanup; - if (!wire_read_double (channel, &(*params)[i].data.d_color.a, 1)) + if (! wire_read_double (channel, + &(*params)[i].data.d_color.a, 1, + user_data)) goto cleanup; break; @@ -1131,47 +1265,65 @@ _gp_params_read (GIOChannel *channel, break; case GIMP_PDB_DISPLAY: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_display, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_display, 1, + user_data)) goto cleanup; break; case GIMP_PDB_IMAGE: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_image, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_image, 1, + user_data)) goto cleanup; break; case GIMP_PDB_LAYER: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_layer, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_layer, 1, + user_data)) goto cleanup; break; case GIMP_PDB_CHANNEL: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_channel, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_channel, 1, + user_data)) goto cleanup; break; case GIMP_PDB_DRAWABLE: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_drawable, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_drawable, 1, + user_data)) goto cleanup; break; case GIMP_PDB_SELECTION: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_selection, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_selection, 1, + user_data)) goto cleanup; break; case GIMP_PDB_BOUNDARY: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_boundary, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_boundary, 1, + user_data)) goto cleanup; break; case GIMP_PDB_PATH: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_path, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_path, 1, + user_data)) goto cleanup; break; case GIMP_PDB_PARASITE: - if (!wire_read_string (channel, &(*params)[i].data.d_parasite.name, 1)) + if (! wire_read_string (channel, + &(*params)[i].data.d_parasite.name, 1, + user_data)) goto cleanup; if ((*params)[i].data.d_parasite.name == NULL) { @@ -1179,15 +1331,21 @@ _gp_params_read (GIOChannel *channel, (*params)[i].data.d_parasite.data = NULL; break; } - if (!wire_read_int32 (channel, &((*params)[i].data.d_parasite.flags), 1)) + if (! wire_read_int32 (channel, + &((*params)[i].data.d_parasite.flags), 1, + user_data)) goto cleanup; - if (!wire_read_int32 (channel, &((*params)[i].data.d_parasite.size), 1)) + if (! wire_read_int32 (channel, + &((*params)[i].data.d_parasite.size), 1, + user_data)) goto cleanup; if ((*params)[i].data.d_parasite.size > 0) { (*params)[i].data.d_parasite.data = g_malloc ((*params)[i].data.d_parasite.size); - if (!wire_read_int8 (channel, (*params)[i].data.d_parasite.data, - (*params)[i].data.d_parasite.size)) + if (! wire_read_int8 (channel, + (*params)[i].data.d_parasite.data, + (*params)[i].data.d_parasite.size, + user_data)) { g_free ((*params)[i].data.d_parasite.data); goto cleanup; @@ -1198,7 +1356,9 @@ _gp_params_read (GIOChannel *channel, break; case GIMP_PDB_STATUS: - if (!wire_read_int32 (channel, (guint32*) &(*params)[i].data.d_status, 1)) + if (! wire_read_int32 (channel, + (guint32*) &(*params)[i].data.d_status, 1, + user_data)) goto cleanup; break; @@ -1218,85 +1378,108 @@ _gp_params_read (GIOChannel *channel, static void _gp_params_write (GIOChannel *channel, GPParam *params, - gint nparams) + gint nparams, + gpointer user_data) { gint i; - if (!wire_write_int32 (channel, (guint32*) &nparams, 1)) + if (! wire_write_int32 (channel, (guint32*) &nparams, 1, user_data)) return; for (i = 0; i < nparams; i++) { - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].type, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].type, 1, + user_data)) return; switch (params[i].type) { case GIMP_PDB_INT32: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_int32, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_int32, 1, + user_data)) return; break; case GIMP_PDB_INT16: - if (!wire_write_int16 (channel, (guint16*) ¶ms[i].data.d_int16, 1)) + if (! wire_write_int16 (channel, + (guint16*) ¶ms[i].data.d_int16, 1, + user_data)) return; break; case GIMP_PDB_INT8: - if (!wire_write_int8 (channel, (guint8*) ¶ms[i].data.d_int8, 1)) + if (! wire_write_int8 (channel, + (guint8*) ¶ms[i].data.d_int8, 1, + user_data)) return; break; case GIMP_PDB_FLOAT: - if (!wire_write_double (channel, ¶ms[i].data.d_float, 1)) + if (! wire_write_double (channel, + ¶ms[i].data.d_float, 1, + user_data)) return; break; case GIMP_PDB_STRING: - if (!wire_write_string (channel, ¶ms[i].data.d_string, 1)) + if (! wire_write_string (channel, + ¶ms[i].data.d_string, 1, + user_data)) return; break; case GIMP_PDB_INT32ARRAY: - if (!wire_write_int32 (channel, (guint32*) params[i].data.d_int32array, - params[i-1].data.d_int32)) + if (! wire_write_int32 (channel, + (guint32*) params[i].data.d_int32array, + params[i-1].data.d_int32, + user_data)) return; break; case GIMP_PDB_INT16ARRAY: - if (!wire_write_int16 (channel, (guint16*) params[i].data.d_int16array, - params[i-1].data.d_int32)) + if (! wire_write_int16 (channel, + (guint16*) params[i].data.d_int16array, + params[i-1].data.d_int32, + user_data)) return; break; case GIMP_PDB_INT8ARRAY: - if (!wire_write_int8 (channel, (guint8*) params[i].data.d_int8array, - params[i-1].data.d_int32)) + if (! wire_write_int8 (channel, + (guint8*) params[i].data.d_int8array, + params[i-1].data.d_int32, + user_data)) return; break; case GIMP_PDB_FLOATARRAY: - if (!wire_write_double (channel, params[i].data.d_floatarray, - params[i-1].data.d_int32)) + if (! wire_write_double (channel, + params[i].data.d_floatarray, + params[i-1].data.d_int32, + user_data)) return; break; case GIMP_PDB_STRINGARRAY: - if (!wire_write_string (channel, params[i].data.d_stringarray, - params[i-1].data.d_int32)) + if (! wire_write_string (channel, + params[i].data.d_stringarray, + params[i-1].data.d_int32, + user_data)) return; break; case GIMP_PDB_COLOR: { GimpRGB *color = (GimpRGB *) ¶ms[i].data.d_color; - if (!wire_write_double (channel, &color->r, 1)) + if (! wire_write_double (channel, &color->r, 1, user_data)) return; - if (!wire_write_double (channel, &color->g, 1)) + if (! wire_write_double (channel, &color->g, 1, user_data)) return; - if (!wire_write_double (channel, &color->b, 1)) + if (! wire_write_double (channel, &color->b, 1, user_data)) return; - if (!wire_write_double (channel, &color->a, 1)) + if (! wire_write_double (channel, &color->a, 1, user_data)) return; } break; @@ -1305,42 +1488,58 @@ _gp_params_write (GIOChannel *channel, break; case GIMP_PDB_DISPLAY: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_display, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_display, 1, + user_data)) return; break; case GIMP_PDB_IMAGE: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_image, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_image, 1, + user_data)) return; break; case GIMP_PDB_LAYER: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_layer, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_layer, 1, + user_data)) return; break; case GIMP_PDB_CHANNEL: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_channel, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_channel, 1, + user_data)) return; break; case GIMP_PDB_DRAWABLE: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_drawable, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_drawable, 1, + user_data)) return; break; case GIMP_PDB_SELECTION: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_selection, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_selection, 1, + user_data)) return; break; case GIMP_PDB_BOUNDARY: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_boundary, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_boundary, 1, + user_data)) return; break; case GIMP_PDB_PATH: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_path, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_path, 1, + user_data)) return; break; @@ -1350,25 +1549,27 @@ _gp_params_write (GIOChannel *channel, if (p->name == NULL) { /* write a null string to signifly a null parasite */ - wire_write_string (channel, &p->name, 1); + wire_write_string (channel, &p->name, 1, user_data); break; } - if (!wire_write_string (channel, &p->name, 1)) + if (! wire_write_string (channel, &p->name, 1, user_data)) return; - if (!wire_write_int32 (channel, &p->flags, 1)) + if (! wire_write_int32 (channel, &p->flags, 1, user_data)) return; - if (!wire_write_int32 (channel, &p->size, 1)) + if (! wire_write_int32 (channel, &p->size, 1, user_data)) return; if (p->size > 0) { - if (!wire_write_int8 (channel, p->data, p->size)) + if (! wire_write_int8 (channel, p->data, p->size, user_data)) return; } } break; case GIMP_PDB_STATUS: - if (!wire_write_int32 (channel, (guint32*) ¶ms[i].data.d_status, 1)) + if (! wire_write_int32 (channel, + (guint32*) ¶ms[i].data.d_status, 1, + user_data)) return; break; @@ -1455,13 +1656,15 @@ _gp_params_destroy (GPParam *params, static void _gp_has_init_read (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { } static void _gp_has_init_write (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { } diff --git a/libgimpbase/gimpprotocol.h b/libgimpbase/gimpprotocol.h index 4c5d8dd507..ce69a8121e 100644 --- a/libgimpbase/gimpprotocol.h +++ b/libgimpbase/gimpprotocol.h @@ -181,28 +181,41 @@ struct _GPProcUninstall void gp_init (void); -gboolean gp_quit_write (GIOChannel *channel); +gboolean gp_quit_write (GIOChannel *channel, + gpointer user_data); gboolean gp_config_write (GIOChannel *channel, - GPConfig *config); + GPConfig *config, + gpointer user_data); gboolean gp_tile_req_write (GIOChannel *channel, - GPTileReq *tile_req); -gboolean gp_tile_ack_write (GIOChannel *channel); + GPTileReq *tile_req, + gpointer user_data); +gboolean gp_tile_ack_write (GIOChannel *channel, + gpointer user_data); gboolean gp_tile_data_write (GIOChannel *channel, - GPTileData *tile_data); + GPTileData *tile_data, + gpointer user_data); gboolean gp_proc_run_write (GIOChannel *channel, - GPProcRun *proc_run); + GPProcRun *proc_run, + gpointer user_data); gboolean gp_proc_return_write (GIOChannel *channel, - GPProcReturn *proc_return); + GPProcReturn *proc_return, + gpointer user_data); gboolean gp_temp_proc_run_write (GIOChannel *channel, - GPProcRun *proc_run); + GPProcRun *proc_run, + gpointer user_data); gboolean gp_temp_proc_return_write (GIOChannel *channel, - GPProcReturn *proc_return); + GPProcReturn *proc_return, + gpointer user_data); gboolean gp_proc_install_write (GIOChannel *channel, - GPProcInstall *proc_install); + GPProcInstall *proc_install, + gpointer user_data); gboolean gp_proc_uninstall_write (GIOChannel *channel, - GPProcUninstall *proc_uninstall); -gboolean gp_extension_ack_write (GIOChannel *channel); -gboolean gp_has_init_write (GIOChannel *channel); + GPProcUninstall *proc_uninstall, + gpointer user_data); +gboolean gp_extension_ack_write (GIOChannel *channel, + gpointer user_data); +gboolean gp_has_init_write (GIOChannel *channel, + gpointer user_data); G_END_DECLS diff --git a/libgimpbase/gimpwire.c b/libgimpbase/gimpwire.c index 5ca459c19d..07a5075830 100644 --- a/libgimpbase/gimpwire.c +++ b/libgimpbase/gimpwire.c @@ -109,11 +109,12 @@ wire_set_flusher (WireFlushFunc flush_func) gboolean wire_read (GIOChannel *channel, guint8 *buf, - gsize count) + gsize count, + gpointer user_data) { if (wire_read_func) { - if (!(* wire_read_func) (channel, buf, count)) + if (!(* wire_read_func) (channel, buf, count, user_data)) { g_warning ("%s: wire_read: error", g_get_prgname ()); wire_error_val = TRUE; @@ -174,11 +175,12 @@ wire_read (GIOChannel *channel, gboolean wire_write (GIOChannel *channel, guint8 *buf, - gsize count) + gsize count, + gpointer user_data) { if (wire_write_func) { - if (!(* wire_write_func) (channel, buf, count)) + if (!(* wire_write_func) (channel, buf, count, user_data)) { g_warning ("%s: wire_write: error", g_get_prgname ()); wire_error_val = TRUE; @@ -230,10 +232,11 @@ wire_write (GIOChannel *channel, } gboolean -wire_flush (GIOChannel *channel) +wire_flush (GIOChannel *channel, + gpointer user_data) { if (wire_flush_func) - return (* wire_flush_func) (channel); + return (* wire_flush_func) (channel, user_data); return FALSE; } @@ -252,28 +255,30 @@ wire_clear_error (void) gboolean wire_read_msg (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { WireHandler *handler; if (wire_error_val) return !wire_error_val; - if (! wire_read_int32 (channel, &msg->type, 1)) + if (! wire_read_int32 (channel, &msg->type, 1, user_data)) return FALSE; handler = g_hash_table_lookup (wire_ht, &msg->type); if (!handler) g_error ("could not find handler for message: %d", msg->type); - (* handler->read_func) (channel, msg); + (* handler->read_func) (channel, msg, user_data); return !wire_error_val; } gboolean wire_write_msg (GIOChannel *channel, - WireMessage *msg) + WireMessage *msg, + gpointer user_data) { WireHandler *handler; @@ -284,10 +289,10 @@ wire_write_msg (GIOChannel *channel, if (!handler) g_error ("could not find handler for message: %d", msg->type); - if (! wire_write_int32 (channel, &msg->type, 1)) + if (! wire_write_int32 (channel, &msg->type, 1, user_data)) return FALSE; - (* handler->write_func) (channel, msg); + (* handler->write_func) (channel, msg, user_data); return !wire_error_val; } @@ -307,11 +312,12 @@ wire_destroy (WireMessage *msg) gboolean wire_read_int32 (GIOChannel *channel, guint32 *data, - gint count) + gint count, + gpointer user_data) { if (count > 0) { - if (! wire_read_int8 (channel, (guint8 *) data, count * 4)) + if (! wire_read_int8 (channel, (guint8 *) data, count * 4, user_data)) return FALSE; while (count--) @@ -327,11 +333,12 @@ wire_read_int32 (GIOChannel *channel, gboolean wire_read_int16 (GIOChannel *channel, guint16 *data, - gint count) + gint count, + gpointer user_data) { if (count > 0) { - if (! wire_read_int8 (channel, (guint8 *) data, count * 2)) + if (! wire_read_int8 (channel, (guint8 *) data, count * 2, user_data)) return FALSE; while (count--) @@ -347,15 +354,17 @@ wire_read_int16 (GIOChannel *channel, gboolean wire_read_int8 (GIOChannel *channel, guint8 *data, - gint count) + gint count, + gpointer user_data) { - return wire_read (channel, data, count); + return wire_read (channel, data, count, user_data); } gboolean wire_read_double (GIOChannel *channel, gdouble *data, - gint count) + gint count, + gpointer user_data) { gdouble *t; guint32 tmp[2]; @@ -368,7 +377,7 @@ wire_read_double (GIOChannel *channel, for (i = 0; i < count; i++) { - if (! wire_read_int8 (channel, (guint8 *) tmp, 8)) + if (! wire_read_int8 (channel, (guint8 *) tmp, 8, user_data)) return FALSE; #if (G_BYTE_ORDER == G_LITTLE_ENDIAN) @@ -386,20 +395,21 @@ wire_read_double (GIOChannel *channel, gboolean wire_read_string (GIOChannel *channel, gchar **data, - gint count) + gint count, + gpointer user_data) { guint32 tmp; gint i; for (i = 0; i < count; i++) { - if (!wire_read_int32 (channel, &tmp, 1)) + if (!wire_read_int32 (channel, &tmp, 1, user_data)) return FALSE; if (tmp > 0) { data[i] = g_new (gchar, tmp); - if (! wire_read_int8 (channel, (guint8 *) data[i], tmp)) + if (! wire_read_int8 (channel, (guint8 *) data[i], tmp, user_data)) { g_free (data[i]); return FALSE; @@ -417,7 +427,8 @@ wire_read_string (GIOChannel *channel, gboolean wire_write_int32 (GIOChannel *channel, guint32 *data, - gint count) + gint count, + gpointer user_data) { guint32 tmp; gint i; @@ -427,7 +438,7 @@ wire_write_int32 (GIOChannel *channel, for (i = 0; i < count; i++) { tmp = g_htonl (data[i]); - if (! wire_write_int8 (channel, (guint8 *) &tmp, 4)) + if (! wire_write_int8 (channel, (guint8 *) &tmp, 4, user_data)) return FALSE; } } @@ -438,7 +449,8 @@ wire_write_int32 (GIOChannel *channel, gboolean wire_write_int16 (GIOChannel *channel, guint16 *data, - gint count) + gint count, + gpointer user_data) { guint16 tmp; gint i; @@ -448,7 +460,7 @@ wire_write_int16 (GIOChannel *channel, for (i = 0; i < count; i++) { tmp = g_htons (data[i]); - if (! wire_write_int8 (channel, (guint8 *) &tmp, 2)) + if (! wire_write_int8 (channel, (guint8 *) &tmp, 2, user_data)) return FALSE; } } @@ -459,15 +471,17 @@ wire_write_int16 (GIOChannel *channel, gboolean wire_write_int8 (GIOChannel *channel, guint8 *data, - gint count) + gint count, + gpointer user_data) { - return wire_write (channel, data, count); + return wire_write (channel, data, count, user_data); } gboolean wire_write_double (GIOChannel *channel, gdouble *data, - gint count) + gint count, + gpointer user_data) { gdouble *t; guint32 tmp[2]; @@ -488,7 +502,7 @@ wire_write_double (GIOChannel *channel, tmp[0] = swap; #endif - if (! wire_write_int8 (channel, (guint8 *) tmp, 8)) + if (! wire_write_int8 (channel, (guint8 *) tmp, 8, user_data)) return FALSE; #if 0 @@ -513,7 +527,8 @@ wire_write_double (GIOChannel *channel, gboolean wire_write_string (GIOChannel *channel, gchar **data, - gint count) + gint count, + gpointer user_data) { guint32 tmp; gint i; @@ -525,10 +540,10 @@ wire_write_string (GIOChannel *channel, else tmp = 0; - if (! wire_write_int32 (channel, &tmp, 1)) + if (! wire_write_int32 (channel, &tmp, 1, user_data)) return FALSE; if (tmp > 0) - if (! wire_write_int8 (channel, (guint8 *) data[i], tmp)) + if (! wire_write_int8 (channel, (guint8 *) data[i], tmp, user_data)) return FALSE; } diff --git a/libgimpbase/gimpwire.h b/libgimpbase/gimpwire.h index 3a828865c9..c26e681585 100644 --- a/libgimpbase/gimpwire.h +++ b/libgimpbase/gimpwire.h @@ -28,14 +28,18 @@ G_BEGIN_DECLS typedef struct _WireMessage WireMessage; typedef void (* WireReadFunc) (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); typedef void (* WireWriteFunc) (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); typedef void (* WireDestroyFunc) (WireMessage *msg); typedef gboolean (* WireIOFunc) (GIOChannel *channel, guint8 *buf, - gulong count); -typedef gboolean (* WireFlushFunc) (GIOChannel *channel); + gulong count, + gpointer user_data); +typedef gboolean (* WireFlushFunc) (GIOChannel *channel, + gpointer user_data); struct _WireMessage @@ -56,52 +60,67 @@ void wire_set_flusher (WireFlushFunc flush_func); gboolean wire_read (GIOChannel *channel, guint8 *buf, - gsize count); + gsize count, + gpointer user_data); gboolean wire_write (GIOChannel *channel, guint8 *buf, - gsize count); -gboolean wire_flush (GIOChannel *channel); + gsize count, + gpointer user_data); +gboolean wire_flush (GIOChannel *channel, + gpointer user_data); gboolean wire_error (void); void wire_clear_error (void); gboolean wire_read_msg (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); gboolean wire_write_msg (GIOChannel *channel, - WireMessage *msg); + WireMessage *msg, + gpointer user_data); void wire_destroy (WireMessage *msg); gboolean wire_read_int32 (GIOChannel *channel, guint32 *data, - gint count); + gint count, + gpointer user_data); gboolean wire_read_int16 (GIOChannel *channel, guint16 *data, - gint count); + gint count, + gpointer user_data); gboolean wire_read_int8 (GIOChannel *channel, guint8 *data, - gint count); + gint count, + gpointer user_data); gboolean wire_read_double (GIOChannel *channel, gdouble *data, - gint count); + gint count, + gpointer user_data); gboolean wire_read_string (GIOChannel *channel, gchar **data, - gint count); + gint count, + gpointer user_data); gboolean wire_write_int32 (GIOChannel *channel, guint32 *data, - gint count); + gint count, + gpointer user_data); gboolean wire_write_int16 (GIOChannel *channel, guint16 *data, - gint count); + gint count, + gpointer user_data); gboolean wire_write_int8 (GIOChannel *channel, guint8 *data, - gint count); + gint count, + gpointer user_data); gboolean wire_write_double (GIOChannel *channel, gdouble *data, - gint count); + gint count, + gpointer user_data); gboolean wire_write_string (GIOChannel *channel, gchar **data, - gint count); + gint count, + gpointer user_data); G_END_DECLS