renamed plug_in_progress_init() to plug_in_progress_start() so it matches
2003-01-20 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in-progress.[ch]: renamed plug_in_progress_init() to plug_in_progress_start() so it matches plug_in_progress_end(). Added g_return_if_fail() to all functions. * app/plug-in/plug-in.[ch]: plug_in_new(): require the passed path to be absolute. Removed plug_in_search_in_path(). Replaced some if(plug_in){...} by g_return_if_fail(plug_in!=NULL). Cleanup. * app/plug-in/plug-ins.c: plug_ins_def_add_from_rc(): refuse to add plug_in_defs with non-absolute paths (should never happen). Misc cleanup all over the place like s/GSList *tmp/GSList *list/. * app/plug-in/plug-in-params.c: cleanup. * tools/pdbgen/pdb/plug_in.pdb: changed accordingly. * app/pdb/plug_in_cmds.c: regenerated. * app/gui/brush-select.c * app/gui/gradient-select.c * app/gui/palette-select.c * app/gui/pattern-select.c: some code review & cleanup.
This commit is contained in:

committed by
Michael Natterer

parent
63e197b610
commit
d407244f7e
25
ChangeLog
25
ChangeLog
@ -1,3 +1,28 @@
|
||||
2003-01-20 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/plug-in/plug-in-progress.[ch]: renamed plug_in_progress_init()
|
||||
to plug_in_progress_start() so it matches plug_in_progress_end().
|
||||
Added g_return_if_fail() to all functions.
|
||||
|
||||
* app/plug-in/plug-in.[ch]: plug_in_new(): require the passed
|
||||
path to be absolute. Removed plug_in_search_in_path(). Replaced
|
||||
some if(plug_in){...} by g_return_if_fail(plug_in!=NULL). Cleanup.
|
||||
|
||||
* app/plug-in/plug-ins.c: plug_ins_def_add_from_rc(): refuse to
|
||||
add plug_in_defs with non-absolute paths (should never happen).
|
||||
Misc cleanup all over the place like s/GSList *tmp/GSList *list/.
|
||||
|
||||
* app/plug-in/plug-in-params.c: cleanup.
|
||||
|
||||
* tools/pdbgen/pdb/plug_in.pdb: changed accordingly.
|
||||
|
||||
* app/pdb/plug_in_cmds.c: regenerated.
|
||||
|
||||
* app/gui/brush-select.c
|
||||
* app/gui/gradient-select.c
|
||||
* app/gui/palette-select.c
|
||||
* app/gui/pattern-select.c: some code review & cleanup.
|
||||
|
||||
2003-01-19 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* libgimp/gimp.def: Add gimp_show_tool_tips.
|
||||
|
@ -46,11 +46,6 @@
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
#define MIN_CELL_SIZE GIMP_PREVIEW_SIZE_EXTRA_SMALL
|
||||
#define STD_BRUSH_COLUMNS 5
|
||||
#define STD_BRUSH_ROWS 5
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void brush_select_change_callbacks (BrushSelect *bsp,
|
||||
@ -165,9 +160,8 @@ brush_select_new (Gimp *gimp,
|
||||
dialogs_edit_brush_func,
|
||||
bsp->context,
|
||||
FALSE,
|
||||
MIN_CELL_SIZE,
|
||||
STD_BRUSH_COLUMNS,
|
||||
STD_BRUSH_ROWS,
|
||||
GIMP_PREVIEW_SIZE_EXTRA_SMALL,
|
||||
5, 5,
|
||||
global_menu_factory);
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (bsp->view), 4);
|
||||
@ -284,10 +278,8 @@ static void
|
||||
brush_select_change_callbacks (BrushSelect *bsp,
|
||||
gboolean closing)
|
||||
{
|
||||
ProcRecord *proc = NULL;
|
||||
ProcRecord *proc;
|
||||
GimpBrush *brush;
|
||||
Argument *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
static gboolean busy = FALSE;
|
||||
|
||||
@ -303,6 +295,9 @@ brush_select_change_callbacks (BrushSelect *bsp,
|
||||
|
||||
if (proc && brush)
|
||||
{
|
||||
Argument *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals =
|
||||
procedural_db_run_proc (bsp->context->gimp,
|
||||
bsp->callback_name,
|
||||
@ -318,7 +313,7 @@ brush_select_change_callbacks (BrushSelect *bsp,
|
||||
GIMP_PDB_INT8ARRAY, temp_buf_data (brush->mask),
|
||||
GIMP_PDB_INT32, closing,
|
||||
GIMP_PDB_END);
|
||||
|
||||
|
||||
if (!return_vals || return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
|
||||
g_message (_("Unable to run brush callback.\n"
|
||||
"The corresponding plug-in may have crashed."));
|
||||
|
@ -71,7 +71,6 @@ gradient_select_new (Gimp *gimp,
|
||||
GradientSelect *gsp;
|
||||
GimpGradient *active = NULL;
|
||||
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (title != NULL, NULL);
|
||||
|
||||
@ -127,7 +126,7 @@ gradient_select_new (Gimp *gimp,
|
||||
|
||||
/* the gradient list */
|
||||
gsp->view = gimp_data_factory_view_new (GIMP_VIEW_TYPE_LIST,
|
||||
gsp->context->gimp->gradient_factory,
|
||||
gimp->gradient_factory,
|
||||
dialogs_edit_gradient_func,
|
||||
gsp->context,
|
||||
GIMP_PREVIEW_SIZE_EXTRA_SMALL,
|
||||
@ -210,8 +209,6 @@ gradient_select_change_callbacks (GradientSelect *gsp,
|
||||
{
|
||||
ProcRecord *proc = NULL;
|
||||
GimpGradient *gradient;
|
||||
Argument *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
static gboolean busy = FALSE;
|
||||
|
||||
@ -227,6 +224,8 @@ gradient_select_change_callbacks (GradientSelect *gsp,
|
||||
|
||||
if (proc && gradient)
|
||||
{
|
||||
Argument *return_vals;
|
||||
gint nreturn_vals;
|
||||
gdouble *values, *pv;
|
||||
double pos, delta;
|
||||
GimpRGB color;
|
||||
|
@ -195,7 +195,7 @@ palette_select_dialogs_check (void)
|
||||
list = g_slist_next (list);
|
||||
|
||||
if (psp->callback_name)
|
||||
{
|
||||
{
|
||||
if (! procedural_db_lookup (psp->context->gimp, psp->callback_name))
|
||||
palette_select_close_callback (NULL, psp);
|
||||
}
|
||||
@ -209,10 +209,8 @@ static void
|
||||
palette_select_change_callbacks (PaletteSelect *psp,
|
||||
gboolean closing)
|
||||
{
|
||||
ProcRecord *proc = NULL;
|
||||
ProcRecord *proc;
|
||||
GimpPalette *palette;
|
||||
Argument *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
static gboolean busy = FALSE;
|
||||
|
||||
@ -228,6 +226,9 @@ palette_select_change_callbacks (PaletteSelect *psp,
|
||||
|
||||
if (proc && palette)
|
||||
{
|
||||
Argument *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals =
|
||||
procedural_db_run_proc (psp->context->gimp,
|
||||
psp->callback_name,
|
||||
|
@ -44,11 +44,6 @@
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
#define MIN_CELL_SIZE GIMP_PREVIEW_SIZE_SMALL
|
||||
#define STD_PATTERN_COLUMNS 5
|
||||
#define STD_PATTERN_ROWS 5
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void pattern_select_change_callbacks (PatternSelect *psp,
|
||||
@ -132,9 +127,8 @@ pattern_select_new (Gimp *gimp,
|
||||
gimp->pattern_factory,
|
||||
NULL,
|
||||
psp->context,
|
||||
MIN_CELL_SIZE,
|
||||
STD_PATTERN_COLUMNS,
|
||||
STD_PATTERN_ROWS,
|
||||
GIMP_PREVIEW_SIZE_SMALL,
|
||||
5, 5,
|
||||
global_menu_factory, "<Patterns>");
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (psp->view), 4);
|
||||
@ -197,7 +191,7 @@ pattern_select_dialogs_check (void)
|
||||
list = g_slist_next (list);
|
||||
|
||||
if (psp->callback_name)
|
||||
{
|
||||
{
|
||||
if (! procedural_db_lookup (psp->context->gimp, psp->callback_name))
|
||||
pattern_select_close_callback (NULL, psp);
|
||||
}
|
||||
@ -211,10 +205,8 @@ static void
|
||||
pattern_select_change_callbacks (PatternSelect *psp,
|
||||
gboolean closing)
|
||||
{
|
||||
ProcRecord *proc = NULL;
|
||||
ProcRecord *proc;
|
||||
GimpPattern *pattern;
|
||||
Argument *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
static gboolean busy = FALSE;
|
||||
|
||||
@ -230,6 +222,9 @@ pattern_select_change_callbacks (PatternSelect *psp,
|
||||
|
||||
if (proc && pattern)
|
||||
{
|
||||
Argument *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
return_vals =
|
||||
procedural_db_run_proc (psp->context->gimp,
|
||||
psp->callback_name,
|
||||
|
@ -86,7 +86,7 @@ progress_init_invoker (Gimp *gimp,
|
||||
success = TRUE;
|
||||
|
||||
if (! gimp->no_interface)
|
||||
plug_in_progress_init (current_plug_in, message, gdisplay);
|
||||
plug_in_progress_start (current_plug_in, message, gdisplay);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&progress_init_proc, success);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -56,7 +57,7 @@
|
||||
#define _O_BINARY 0x0200 /* binary file */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <fcntl.h>
|
||||
@ -82,15 +83,12 @@
|
||||
#include "base/tile.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpenvirontable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/brush-select.h"
|
||||
#include "gui/gradient-select.h"
|
||||
@ -103,7 +101,6 @@
|
||||
#include "plug-in-params.h"
|
||||
#include "plug-in-proc.h"
|
||||
#include "plug-in-progress.h"
|
||||
#include "plug-in-rc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -117,15 +114,6 @@ struct _PlugInBlocked
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PlugInHelpPathDef PlugInHelpPathDef;
|
||||
|
||||
struct _PlugInHelpPathDef
|
||||
{
|
||||
gchar *prog_name;
|
||||
gchar *help_path;
|
||||
};
|
||||
|
||||
|
||||
static gboolean plug_in_write (GIOChannel *channel,
|
||||
guint8 *buf,
|
||||
gulong count,
|
||||
@ -158,24 +146,21 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
||||
gint argc);
|
||||
static void plug_in_init_shm (void);
|
||||
|
||||
static gchar * plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename);
|
||||
|
||||
static void plug_in_prep_for_exec (gpointer data);
|
||||
|
||||
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
static HANDLE shm_handle;
|
||||
@ -389,29 +374,10 @@ plug_in_new (Gimp *gimp,
|
||||
gchar *name)
|
||||
{
|
||||
PlugIn *plug_in;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
if (! g_path_is_absolute (name))
|
||||
{
|
||||
gchar *plug_in_path;
|
||||
|
||||
plug_in_path = gimp_config_path_expand (gimp->config->plug_in_path,
|
||||
FALSE, NULL);
|
||||
path = plug_in_search_in_path (plug_in_path, name);
|
||||
g_free (plug_in_path);
|
||||
|
||||
if (! path)
|
||||
{
|
||||
g_message (_("Unable to locate Plug-In: \"%s\""), name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
||||
|
||||
plug_in = g_new0 (PlugIn, 1);
|
||||
|
||||
@ -424,7 +390,7 @@ plug_in_new (Gimp *gimp,
|
||||
plug_in->recurse = FALSE;
|
||||
plug_in->busy = FALSE;
|
||||
plug_in->pid = 0;
|
||||
plug_in->args[0] = g_strdup (path);
|
||||
plug_in->args[0] = g_strdup (name);
|
||||
plug_in->args[1] = g_strdup ("-gimp");
|
||||
plug_in->args[2] = NULL;
|
||||
plug_in->args[3] = NULL;
|
||||
@ -447,32 +413,31 @@ plug_in_new (Gimp *gimp,
|
||||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
if (plug_in)
|
||||
{
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -492,127 +457,122 @@ plug_in_prep_for_exec (gpointer data)
|
||||
gboolean
|
||||
plug_in_open (PlugIn *plug_in)
|
||||
{
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gchar **envp;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (plug_in != NULL, FALSE);
|
||||
|
||||
if (plug_in)
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (!plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id =
|
||||
g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (! plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI |
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +629,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
DWORD dwExitCode = STILL_ACTIVE;
|
||||
DWORD dwTries = 10;
|
||||
while ((STILL_ACTIVE == dwExitCode)
|
||||
&& GetExitCodeProcess((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& (dwTries > 0))
|
||||
{
|
||||
Sleep(10);
|
||||
@ -677,7 +637,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
}
|
||||
if (STILL_ACTIVE == dwExitCode)
|
||||
{
|
||||
g_warning("Terminating %s ...", plug_in->args[0]);
|
||||
g_warning ("Terminating %s ...", plug_in->args[0]);
|
||||
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
||||
}
|
||||
}
|
||||
@ -1307,11 +1267,11 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
GPProcInstall *proc_install)
|
||||
{
|
||||
PlugInDef *plug_in_def = NULL;
|
||||
PlugInProcDef *proc_def;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid;
|
||||
PlugInProcDef *proc_def = NULL;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid_utf8 = FALSE;
|
||||
gint i;
|
||||
|
||||
/* Argument checking
|
||||
@ -1421,7 +1381,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
}
|
||||
|
||||
/* Sanity check strings for UTF-8 validity */
|
||||
valid = FALSE;
|
||||
|
||||
if ((proc_install->menu_path == NULL ||
|
||||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
||||
@ -1437,25 +1396,25 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
(proc_install->date == NULL ||
|
||||
g_utf8_validate (proc_install->date, -1, NULL)))
|
||||
{
|
||||
valid = TRUE;
|
||||
valid_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < proc_install->nparams && valid; i++)
|
||||
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
||||
(proc_install->params[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid; i++)
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
||||
(proc_install->return_vals[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (! valid_utf8)
|
||||
{
|
||||
g_message ("Plug-In \"%s\"\n(%s)\n"
|
||||
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
||||
@ -1466,8 +1425,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
|
||||
/* Initialization */
|
||||
|
||||
proc_def = NULL;
|
||||
|
||||
switch (proc_install->type)
|
||||
{
|
||||
case GIMP_PLUGIN:
|
||||
@ -1795,36 +1752,3 @@ plug_in_temp_run (ProcRecord *proc_rec,
|
||||
done:
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename)
|
||||
{
|
||||
gchar *local_path;
|
||||
gchar *token;
|
||||
gchar *next_token;
|
||||
gchar *path;
|
||||
|
||||
local_path = g_strdup (search_path);
|
||||
next_token = local_path;
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path = g_build_filename (token, filename, NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
token = path;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -43,13 +43,15 @@ static void plug_in_progress_cancel (GtkWidget *widget,
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
gchar *message,
|
||||
gint gdisp_ID)
|
||||
plug_in_progress_start (PlugIn *plug_in,
|
||||
const gchar *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GimpDisplay *gdisp = NULL;
|
||||
|
||||
if (!message)
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (! message)
|
||||
message = plug_in->args[0];
|
||||
|
||||
if (gdisp_ID > 0)
|
||||
@ -69,8 +71,10 @@ void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
gdouble percentage)
|
||||
{
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (! plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
plug_in_progress_start (plug_in, NULL, -1);
|
||||
|
||||
gimp_progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
@ -78,6 +82,8 @@ plug_in_progress_update (PlugIn *plug_in,
|
||||
void
|
||||
plug_in_progress_end (PlugIn *plug_in)
|
||||
{
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gimp_progress_end (plug_in->progress);
|
||||
|
@ -20,12 +20,12 @@
|
||||
#define __PLUG_IN_PROGRESS_H__
|
||||
|
||||
|
||||
void plug_in_progress_init (PlugIn *plug_in,
|
||||
gchar *message,
|
||||
gint gdisp_ID);
|
||||
void plug_in_progress_update (PlugIn *plug_in,
|
||||
gdouble percentage);
|
||||
void plug_in_progress_end (PlugIn *plug_in);
|
||||
void plug_in_progress_start (PlugIn *plug_in,
|
||||
const gchar *message,
|
||||
gint gdisp_ID);
|
||||
void plug_in_progress_update (PlugIn *plug_in,
|
||||
gdouble percentage);
|
||||
void plug_in_progress_end (PlugIn *plug_in);
|
||||
|
||||
|
||||
#endif /* __PLUG_IN_PROGRESS_H__ */
|
||||
|
@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -56,7 +57,7 @@
|
||||
#define _O_BINARY 0x0200 /* binary file */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <fcntl.h>
|
||||
@ -82,15 +83,12 @@
|
||||
#include "base/tile.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpenvirontable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/brush-select.h"
|
||||
#include "gui/gradient-select.h"
|
||||
@ -103,7 +101,6 @@
|
||||
#include "plug-in-params.h"
|
||||
#include "plug-in-proc.h"
|
||||
#include "plug-in-progress.h"
|
||||
#include "plug-in-rc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -117,15 +114,6 @@ struct _PlugInBlocked
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PlugInHelpPathDef PlugInHelpPathDef;
|
||||
|
||||
struct _PlugInHelpPathDef
|
||||
{
|
||||
gchar *prog_name;
|
||||
gchar *help_path;
|
||||
};
|
||||
|
||||
|
||||
static gboolean plug_in_write (GIOChannel *channel,
|
||||
guint8 *buf,
|
||||
gulong count,
|
||||
@ -158,24 +146,21 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
||||
gint argc);
|
||||
static void plug_in_init_shm (void);
|
||||
|
||||
static gchar * plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename);
|
||||
|
||||
static void plug_in_prep_for_exec (gpointer data);
|
||||
|
||||
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
static HANDLE shm_handle;
|
||||
@ -389,29 +374,10 @@ plug_in_new (Gimp *gimp,
|
||||
gchar *name)
|
||||
{
|
||||
PlugIn *plug_in;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
if (! g_path_is_absolute (name))
|
||||
{
|
||||
gchar *plug_in_path;
|
||||
|
||||
plug_in_path = gimp_config_path_expand (gimp->config->plug_in_path,
|
||||
FALSE, NULL);
|
||||
path = plug_in_search_in_path (plug_in_path, name);
|
||||
g_free (plug_in_path);
|
||||
|
||||
if (! path)
|
||||
{
|
||||
g_message (_("Unable to locate Plug-In: \"%s\""), name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
||||
|
||||
plug_in = g_new0 (PlugIn, 1);
|
||||
|
||||
@ -424,7 +390,7 @@ plug_in_new (Gimp *gimp,
|
||||
plug_in->recurse = FALSE;
|
||||
plug_in->busy = FALSE;
|
||||
plug_in->pid = 0;
|
||||
plug_in->args[0] = g_strdup (path);
|
||||
plug_in->args[0] = g_strdup (name);
|
||||
plug_in->args[1] = g_strdup ("-gimp");
|
||||
plug_in->args[2] = NULL;
|
||||
plug_in->args[3] = NULL;
|
||||
@ -447,32 +413,31 @@ plug_in_new (Gimp *gimp,
|
||||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
if (plug_in)
|
||||
{
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -492,127 +457,122 @@ plug_in_prep_for_exec (gpointer data)
|
||||
gboolean
|
||||
plug_in_open (PlugIn *plug_in)
|
||||
{
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gchar **envp;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (plug_in != NULL, FALSE);
|
||||
|
||||
if (plug_in)
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (!plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id =
|
||||
g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (! plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI |
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +629,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
DWORD dwExitCode = STILL_ACTIVE;
|
||||
DWORD dwTries = 10;
|
||||
while ((STILL_ACTIVE == dwExitCode)
|
||||
&& GetExitCodeProcess((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& (dwTries > 0))
|
||||
{
|
||||
Sleep(10);
|
||||
@ -677,7 +637,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
}
|
||||
if (STILL_ACTIVE == dwExitCode)
|
||||
{
|
||||
g_warning("Terminating %s ...", plug_in->args[0]);
|
||||
g_warning ("Terminating %s ...", plug_in->args[0]);
|
||||
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
||||
}
|
||||
}
|
||||
@ -1307,11 +1267,11 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
GPProcInstall *proc_install)
|
||||
{
|
||||
PlugInDef *plug_in_def = NULL;
|
||||
PlugInProcDef *proc_def;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid;
|
||||
PlugInProcDef *proc_def = NULL;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid_utf8 = FALSE;
|
||||
gint i;
|
||||
|
||||
/* Argument checking
|
||||
@ -1421,7 +1381,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
}
|
||||
|
||||
/* Sanity check strings for UTF-8 validity */
|
||||
valid = FALSE;
|
||||
|
||||
if ((proc_install->menu_path == NULL ||
|
||||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
||||
@ -1437,25 +1396,25 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
(proc_install->date == NULL ||
|
||||
g_utf8_validate (proc_install->date, -1, NULL)))
|
||||
{
|
||||
valid = TRUE;
|
||||
valid_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < proc_install->nparams && valid; i++)
|
||||
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
||||
(proc_install->params[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid; i++)
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
||||
(proc_install->return_vals[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (! valid_utf8)
|
||||
{
|
||||
g_message ("Plug-In \"%s\"\n(%s)\n"
|
||||
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
||||
@ -1466,8 +1425,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
|
||||
/* Initialization */
|
||||
|
||||
proc_def = NULL;
|
||||
|
||||
switch (proc_install->type)
|
||||
{
|
||||
case GIMP_PLUGIN:
|
||||
@ -1795,36 +1752,3 @@ plug_in_temp_run (ProcRecord *proc_rec,
|
||||
done:
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename)
|
||||
{
|
||||
gchar *local_path;
|
||||
gchar *token;
|
||||
gchar *next_token;
|
||||
gchar *path;
|
||||
|
||||
local_path = g_strdup (search_path);
|
||||
next_token = local_path;
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path = g_build_filename (token, filename, NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
token = path;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ struct _PlugIn
|
||||
{
|
||||
Gimp *gimp;
|
||||
|
||||
guint open : 1; /* Is the plug-in open* */
|
||||
guint open : 1; /* Is the plug-in open? */
|
||||
guint query : 1; /* Are we querying the plug-in? */
|
||||
guint init : 1; /* Are we initialing the plug-in? */
|
||||
guint synchronous : 1; /* Is the plug-in running synchronously? */
|
||||
|
@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -56,7 +57,7 @@
|
||||
#define _O_BINARY 0x0200 /* binary file */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <fcntl.h>
|
||||
@ -82,15 +83,12 @@
|
||||
#include "base/tile.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpenvirontable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/brush-select.h"
|
||||
#include "gui/gradient-select.h"
|
||||
@ -103,7 +101,6 @@
|
||||
#include "plug-in-params.h"
|
||||
#include "plug-in-proc.h"
|
||||
#include "plug-in-progress.h"
|
||||
#include "plug-in-rc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -117,15 +114,6 @@ struct _PlugInBlocked
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PlugInHelpPathDef PlugInHelpPathDef;
|
||||
|
||||
struct _PlugInHelpPathDef
|
||||
{
|
||||
gchar *prog_name;
|
||||
gchar *help_path;
|
||||
};
|
||||
|
||||
|
||||
static gboolean plug_in_write (GIOChannel *channel,
|
||||
guint8 *buf,
|
||||
gulong count,
|
||||
@ -158,24 +146,21 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
||||
gint argc);
|
||||
static void plug_in_init_shm (void);
|
||||
|
||||
static gchar * plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename);
|
||||
|
||||
static void plug_in_prep_for_exec (gpointer data);
|
||||
|
||||
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
static HANDLE shm_handle;
|
||||
@ -389,29 +374,10 @@ plug_in_new (Gimp *gimp,
|
||||
gchar *name)
|
||||
{
|
||||
PlugIn *plug_in;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
if (! g_path_is_absolute (name))
|
||||
{
|
||||
gchar *plug_in_path;
|
||||
|
||||
plug_in_path = gimp_config_path_expand (gimp->config->plug_in_path,
|
||||
FALSE, NULL);
|
||||
path = plug_in_search_in_path (plug_in_path, name);
|
||||
g_free (plug_in_path);
|
||||
|
||||
if (! path)
|
||||
{
|
||||
g_message (_("Unable to locate Plug-In: \"%s\""), name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
||||
|
||||
plug_in = g_new0 (PlugIn, 1);
|
||||
|
||||
@ -424,7 +390,7 @@ plug_in_new (Gimp *gimp,
|
||||
plug_in->recurse = FALSE;
|
||||
plug_in->busy = FALSE;
|
||||
plug_in->pid = 0;
|
||||
plug_in->args[0] = g_strdup (path);
|
||||
plug_in->args[0] = g_strdup (name);
|
||||
plug_in->args[1] = g_strdup ("-gimp");
|
||||
plug_in->args[2] = NULL;
|
||||
plug_in->args[3] = NULL;
|
||||
@ -447,32 +413,31 @@ plug_in_new (Gimp *gimp,
|
||||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
if (plug_in)
|
||||
{
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -492,127 +457,122 @@ plug_in_prep_for_exec (gpointer data)
|
||||
gboolean
|
||||
plug_in_open (PlugIn *plug_in)
|
||||
{
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gchar **envp;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (plug_in != NULL, FALSE);
|
||||
|
||||
if (plug_in)
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (!plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id =
|
||||
g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (! plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI |
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +629,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
DWORD dwExitCode = STILL_ACTIVE;
|
||||
DWORD dwTries = 10;
|
||||
while ((STILL_ACTIVE == dwExitCode)
|
||||
&& GetExitCodeProcess((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& (dwTries > 0))
|
||||
{
|
||||
Sleep(10);
|
||||
@ -677,7 +637,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
}
|
||||
if (STILL_ACTIVE == dwExitCode)
|
||||
{
|
||||
g_warning("Terminating %s ...", plug_in->args[0]);
|
||||
g_warning ("Terminating %s ...", plug_in->args[0]);
|
||||
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
||||
}
|
||||
}
|
||||
@ -1307,11 +1267,11 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
GPProcInstall *proc_install)
|
||||
{
|
||||
PlugInDef *plug_in_def = NULL;
|
||||
PlugInProcDef *proc_def;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid;
|
||||
PlugInProcDef *proc_def = NULL;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid_utf8 = FALSE;
|
||||
gint i;
|
||||
|
||||
/* Argument checking
|
||||
@ -1421,7 +1381,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
}
|
||||
|
||||
/* Sanity check strings for UTF-8 validity */
|
||||
valid = FALSE;
|
||||
|
||||
if ((proc_install->menu_path == NULL ||
|
||||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
||||
@ -1437,25 +1396,25 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
(proc_install->date == NULL ||
|
||||
g_utf8_validate (proc_install->date, -1, NULL)))
|
||||
{
|
||||
valid = TRUE;
|
||||
valid_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < proc_install->nparams && valid; i++)
|
||||
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
||||
(proc_install->params[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid; i++)
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
||||
(proc_install->return_vals[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (! valid_utf8)
|
||||
{
|
||||
g_message ("Plug-In \"%s\"\n(%s)\n"
|
||||
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
||||
@ -1466,8 +1425,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
|
||||
/* Initialization */
|
||||
|
||||
proc_def = NULL;
|
||||
|
||||
switch (proc_install->type)
|
||||
{
|
||||
case GIMP_PLUGIN:
|
||||
@ -1795,36 +1752,3 @@ plug_in_temp_run (ProcRecord *proc_rec,
|
||||
done:
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename)
|
||||
{
|
||||
gchar *local_path;
|
||||
gchar *token;
|
||||
gchar *next_token;
|
||||
gchar *path;
|
||||
|
||||
local_path = g_strdup (search_path);
|
||||
next_token = local_path;
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path = g_build_filename (token, filename, NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
token = path;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -56,7 +57,7 @@
|
||||
#define _O_BINARY 0x0200 /* binary file */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <fcntl.h>
|
||||
@ -82,15 +83,12 @@
|
||||
#include "base/tile.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpenvirontable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/brush-select.h"
|
||||
#include "gui/gradient-select.h"
|
||||
@ -103,7 +101,6 @@
|
||||
#include "plug-in-params.h"
|
||||
#include "plug-in-proc.h"
|
||||
#include "plug-in-progress.h"
|
||||
#include "plug-in-rc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -117,15 +114,6 @@ struct _PlugInBlocked
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PlugInHelpPathDef PlugInHelpPathDef;
|
||||
|
||||
struct _PlugInHelpPathDef
|
||||
{
|
||||
gchar *prog_name;
|
||||
gchar *help_path;
|
||||
};
|
||||
|
||||
|
||||
static gboolean plug_in_write (GIOChannel *channel,
|
||||
guint8 *buf,
|
||||
gulong count,
|
||||
@ -158,24 +146,21 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
||||
gint argc);
|
||||
static void plug_in_init_shm (void);
|
||||
|
||||
static gchar * plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename);
|
||||
|
||||
static void plug_in_prep_for_exec (gpointer data);
|
||||
|
||||
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
static HANDLE shm_handle;
|
||||
@ -389,29 +374,10 @@ plug_in_new (Gimp *gimp,
|
||||
gchar *name)
|
||||
{
|
||||
PlugIn *plug_in;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
if (! g_path_is_absolute (name))
|
||||
{
|
||||
gchar *plug_in_path;
|
||||
|
||||
plug_in_path = gimp_config_path_expand (gimp->config->plug_in_path,
|
||||
FALSE, NULL);
|
||||
path = plug_in_search_in_path (plug_in_path, name);
|
||||
g_free (plug_in_path);
|
||||
|
||||
if (! path)
|
||||
{
|
||||
g_message (_("Unable to locate Plug-In: \"%s\""), name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
||||
|
||||
plug_in = g_new0 (PlugIn, 1);
|
||||
|
||||
@ -424,7 +390,7 @@ plug_in_new (Gimp *gimp,
|
||||
plug_in->recurse = FALSE;
|
||||
plug_in->busy = FALSE;
|
||||
plug_in->pid = 0;
|
||||
plug_in->args[0] = g_strdup (path);
|
||||
plug_in->args[0] = g_strdup (name);
|
||||
plug_in->args[1] = g_strdup ("-gimp");
|
||||
plug_in->args[2] = NULL;
|
||||
plug_in->args[3] = NULL;
|
||||
@ -447,32 +413,31 @@ plug_in_new (Gimp *gimp,
|
||||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
if (plug_in)
|
||||
{
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -492,127 +457,122 @@ plug_in_prep_for_exec (gpointer data)
|
||||
gboolean
|
||||
plug_in_open (PlugIn *plug_in)
|
||||
{
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gchar **envp;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (plug_in != NULL, FALSE);
|
||||
|
||||
if (plug_in)
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (!plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id =
|
||||
g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (! plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI |
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +629,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
DWORD dwExitCode = STILL_ACTIVE;
|
||||
DWORD dwTries = 10;
|
||||
while ((STILL_ACTIVE == dwExitCode)
|
||||
&& GetExitCodeProcess((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& (dwTries > 0))
|
||||
{
|
||||
Sleep(10);
|
||||
@ -677,7 +637,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
}
|
||||
if (STILL_ACTIVE == dwExitCode)
|
||||
{
|
||||
g_warning("Terminating %s ...", plug_in->args[0]);
|
||||
g_warning ("Terminating %s ...", plug_in->args[0]);
|
||||
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
||||
}
|
||||
}
|
||||
@ -1307,11 +1267,11 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
GPProcInstall *proc_install)
|
||||
{
|
||||
PlugInDef *plug_in_def = NULL;
|
||||
PlugInProcDef *proc_def;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid;
|
||||
PlugInProcDef *proc_def = NULL;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid_utf8 = FALSE;
|
||||
gint i;
|
||||
|
||||
/* Argument checking
|
||||
@ -1421,7 +1381,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
}
|
||||
|
||||
/* Sanity check strings for UTF-8 validity */
|
||||
valid = FALSE;
|
||||
|
||||
if ((proc_install->menu_path == NULL ||
|
||||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
||||
@ -1437,25 +1396,25 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
(proc_install->date == NULL ||
|
||||
g_utf8_validate (proc_install->date, -1, NULL)))
|
||||
{
|
||||
valid = TRUE;
|
||||
valid_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < proc_install->nparams && valid; i++)
|
||||
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
||||
(proc_install->params[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid; i++)
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
||||
(proc_install->return_vals[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (! valid_utf8)
|
||||
{
|
||||
g_message ("Plug-In \"%s\"\n(%s)\n"
|
||||
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
||||
@ -1466,8 +1425,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
|
||||
/* Initialization */
|
||||
|
||||
proc_def = NULL;
|
||||
|
||||
switch (proc_install->type)
|
||||
{
|
||||
case GIMP_PLUGIN:
|
||||
@ -1795,36 +1752,3 @@ plug_in_temp_run (ProcRecord *proc_rec,
|
||||
done:
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename)
|
||||
{
|
||||
gchar *local_path;
|
||||
gchar *token;
|
||||
gchar *next_token;
|
||||
gchar *path;
|
||||
|
||||
local_path = g_strdup (search_path);
|
||||
next_token = local_path;
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path = g_build_filename (token, filename, NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
token = path;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -424,9 +424,18 @@ plug_ins_file_handler (gchar *name,
|
||||
void
|
||||
plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
{
|
||||
GSList *tmp;
|
||||
GSList *list;
|
||||
gchar *basename1;
|
||||
gchar *basename2;
|
||||
|
||||
g_return_if_fail (plug_in_def != NULL);
|
||||
g_return_if_fail (plug_in_def->prog != NULL);
|
||||
|
||||
if (! g_path_is_absolute (plug_in_def->prog))
|
||||
{
|
||||
g_warning ("plug_ins_def_add_from_rc: filename not absolute (skipping)");
|
||||
plug_in_def_free (plug_in_def, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
basename1 = g_path_get_basename (plug_in_def->prog);
|
||||
|
||||
@ -437,11 +446,11 @@ plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
* loader needs to be able to register no extensions, prefixes or
|
||||
* magics. -- austin 13/Feb/99
|
||||
*/
|
||||
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = plug_in_def->proc_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
PlugInProcDef *proc_def;
|
||||
|
||||
proc_def = tmp->data;
|
||||
proc_def = (PlugInProcDef *) list->data;
|
||||
|
||||
if (! proc_def->extensions &&
|
||||
! proc_def->prefixes &&
|
||||
@ -457,11 +466,12 @@ plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
/* Check if the entry mentioned in pluginrc matches an executable
|
||||
* found in the plug_in_path.
|
||||
*/
|
||||
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = plug_in_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
PlugInDef *ondisk_plug_in_def;
|
||||
gchar *basename2;
|
||||
|
||||
ondisk_plug_in_def = tmp->data;
|
||||
ondisk_plug_in_def = (PlugInDef *) list->data;
|
||||
|
||||
basename2 = g_path_get_basename (ondisk_plug_in_def->prog);
|
||||
|
||||
@ -472,7 +482,7 @@ plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
(plug_in_def->mtime == ondisk_plug_in_def->mtime))
|
||||
{
|
||||
/* Use pluginrc entry, deleting ondisk entry */
|
||||
tmp->data = plug_in_def;
|
||||
list->data = plug_in_def;
|
||||
plug_in_def_free (ondisk_plug_in_def, TRUE);
|
||||
}
|
||||
else
|
||||
@ -493,7 +503,7 @@ plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
g_free (basename1);
|
||||
|
||||
write_pluginrc = TRUE;
|
||||
g_print ("\"%s\" executable not found\n", plug_in_def->prog);
|
||||
g_print ("executable not found: \"%s\"\n", plug_in_def->prog);
|
||||
plug_in_def_free (plug_in_def, FALSE);
|
||||
}
|
||||
|
||||
@ -724,25 +734,26 @@ plug_ins_image_types_parse (gchar *image_types)
|
||||
static void
|
||||
plug_ins_init_file (GimpDatafileData *file_data)
|
||||
{
|
||||
GSList **plug_in_defs;
|
||||
GSList *tmp;
|
||||
PlugInDef *plug_in_def;
|
||||
gchar *plug_in_name;
|
||||
GSList **plug_in_defs;
|
||||
GSList *list;
|
||||
gchar *basename;
|
||||
|
||||
plug_in_defs = file_data->user_data;
|
||||
|
||||
basename = g_path_get_basename (file_data->filename);
|
||||
|
||||
for (tmp = *plug_in_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = *plug_in_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
plug_in_def = tmp->data;
|
||||
gchar *plug_in_name;
|
||||
|
||||
plug_in_def = (PlugInDef *) list->data;
|
||||
|
||||
plug_in_name = g_path_get_basename (plug_in_def->prog);
|
||||
|
||||
if (g_ascii_strcasecmp (basename, plug_in_name) == 0)
|
||||
{
|
||||
g_print ("duplicate plug-in: \"%s\" (skipping)\n",
|
||||
g_print ("skipping duplicate plug-in: \"%s\"\n",
|
||||
file_data->filename);
|
||||
|
||||
g_free (plug_in_name);
|
||||
@ -770,11 +781,11 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
PlugInProcDef *proc_def;
|
||||
Argument args[4];
|
||||
Argument *return_vals;
|
||||
GSList *tmp;
|
||||
GSList *list;
|
||||
|
||||
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = proc_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
proc_def = tmp->data;
|
||||
proc_def = (PlugInProcDef *) list->data;
|
||||
|
||||
if (proc_def->prog && (proc_def->db_info.proc_type != GIMP_INTERNAL))
|
||||
{
|
||||
@ -783,9 +794,9 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
}
|
||||
}
|
||||
|
||||
for (tmp = proc_defs; tmp; tmp = tmp->next)
|
||||
for (list = proc_defs; list; list = list->next)
|
||||
{
|
||||
proc_def = tmp->data;
|
||||
proc_def = (PlugInProcDef *) list->data;
|
||||
|
||||
if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
|
||||
{
|
||||
@ -803,7 +814,7 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
|
||||
if (proc_def->image_types)
|
||||
{
|
||||
return_vals =
|
||||
return_vals =
|
||||
procedural_db_execute (gimp,
|
||||
"gimp_register_save_handler",
|
||||
args);
|
||||
@ -811,7 +822,7 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
}
|
||||
else
|
||||
{
|
||||
return_vals =
|
||||
return_vals =
|
||||
procedural_db_execute (gimp,
|
||||
"gimp_register_magic_load_handler",
|
||||
args);
|
||||
@ -824,20 +835,18 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
static PlugInProcDef *
|
||||
plug_ins_proc_def_insert (PlugInProcDef *proc_def)
|
||||
{
|
||||
PlugInProcDef *tmp_proc_def;
|
||||
GSList *tmp;
|
||||
GSList *prev;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
GSList *prev = NULL;
|
||||
|
||||
prev = NULL;
|
||||
|
||||
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = proc_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
tmp_proc_def = tmp->data;
|
||||
PlugInProcDef *tmp_proc_def;
|
||||
|
||||
tmp_proc_def = (PlugInProcDef *) list->data;
|
||||
|
||||
if (strcmp (proc_def->db_info.name, tmp_proc_def->db_info.name) == 0)
|
||||
{
|
||||
tmp->data = proc_def;
|
||||
list->data = proc_def;
|
||||
|
||||
if (proc_def->menu_path)
|
||||
g_free (proc_def->menu_path);
|
||||
@ -852,23 +861,25 @@ plug_ins_proc_def_insert (PlugInProcDef *proc_def)
|
||||
|
||||
return tmp_proc_def;
|
||||
}
|
||||
else if (!proc_def->menu_path ||
|
||||
else if (! proc_def->menu_path ||
|
||||
(tmp_proc_def->menu_path &&
|
||||
(strcmp (proc_def->menu_path, tmp_proc_def->menu_path) < 0)))
|
||||
{
|
||||
list = g_slist_alloc ();
|
||||
list->data = proc_def;
|
||||
GSList *new;
|
||||
|
||||
list->next = tmp;
|
||||
new = g_slist_alloc ();
|
||||
new->data = proc_def;
|
||||
|
||||
new->next = list;
|
||||
if (prev)
|
||||
prev->next = list;
|
||||
prev->next = new;
|
||||
else
|
||||
proc_defs = list;
|
||||
proc_defs = new;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prev = tmp;
|
||||
prev = list;
|
||||
}
|
||||
|
||||
proc_defs = g_slist_append (proc_defs, proc_def);
|
||||
|
@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -56,7 +57,7 @@
|
||||
#define _O_BINARY 0x0200 /* binary file */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <fcntl.h>
|
||||
@ -82,15 +83,12 @@
|
||||
#include "base/tile.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpenvirontable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/brush-select.h"
|
||||
#include "gui/gradient-select.h"
|
||||
@ -103,7 +101,6 @@
|
||||
#include "plug-in-params.h"
|
||||
#include "plug-in-proc.h"
|
||||
#include "plug-in-progress.h"
|
||||
#include "plug-in-rc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -117,15 +114,6 @@ struct _PlugInBlocked
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PlugInHelpPathDef PlugInHelpPathDef;
|
||||
|
||||
struct _PlugInHelpPathDef
|
||||
{
|
||||
gchar *prog_name;
|
||||
gchar *help_path;
|
||||
};
|
||||
|
||||
|
||||
static gboolean plug_in_write (GIOChannel *channel,
|
||||
guint8 *buf,
|
||||
gulong count,
|
||||
@ -158,24 +146,21 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
||||
gint argc);
|
||||
static void plug_in_init_shm (void);
|
||||
|
||||
static gchar * plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename);
|
||||
|
||||
static void plug_in_prep_for_exec (gpointer data);
|
||||
|
||||
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
static HANDLE shm_handle;
|
||||
@ -389,29 +374,10 @@ plug_in_new (Gimp *gimp,
|
||||
gchar *name)
|
||||
{
|
||||
PlugIn *plug_in;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
if (! g_path_is_absolute (name))
|
||||
{
|
||||
gchar *plug_in_path;
|
||||
|
||||
plug_in_path = gimp_config_path_expand (gimp->config->plug_in_path,
|
||||
FALSE, NULL);
|
||||
path = plug_in_search_in_path (plug_in_path, name);
|
||||
g_free (plug_in_path);
|
||||
|
||||
if (! path)
|
||||
{
|
||||
g_message (_("Unable to locate Plug-In: \"%s\""), name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
||||
|
||||
plug_in = g_new0 (PlugIn, 1);
|
||||
|
||||
@ -424,7 +390,7 @@ plug_in_new (Gimp *gimp,
|
||||
plug_in->recurse = FALSE;
|
||||
plug_in->busy = FALSE;
|
||||
plug_in->pid = 0;
|
||||
plug_in->args[0] = g_strdup (path);
|
||||
plug_in->args[0] = g_strdup (name);
|
||||
plug_in->args[1] = g_strdup ("-gimp");
|
||||
plug_in->args[2] = NULL;
|
||||
plug_in->args[3] = NULL;
|
||||
@ -447,32 +413,31 @@ plug_in_new (Gimp *gimp,
|
||||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
if (plug_in)
|
||||
{
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -492,127 +457,122 @@ plug_in_prep_for_exec (gpointer data)
|
||||
gboolean
|
||||
plug_in_open (PlugIn *plug_in)
|
||||
{
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gchar **envp;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (plug_in != NULL, FALSE);
|
||||
|
||||
if (plug_in)
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (!plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id =
|
||||
g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (! plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI |
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +629,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
DWORD dwExitCode = STILL_ACTIVE;
|
||||
DWORD dwTries = 10;
|
||||
while ((STILL_ACTIVE == dwExitCode)
|
||||
&& GetExitCodeProcess((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& (dwTries > 0))
|
||||
{
|
||||
Sleep(10);
|
||||
@ -677,7 +637,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
}
|
||||
if (STILL_ACTIVE == dwExitCode)
|
||||
{
|
||||
g_warning("Terminating %s ...", plug_in->args[0]);
|
||||
g_warning ("Terminating %s ...", plug_in->args[0]);
|
||||
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
||||
}
|
||||
}
|
||||
@ -1307,11 +1267,11 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
GPProcInstall *proc_install)
|
||||
{
|
||||
PlugInDef *plug_in_def = NULL;
|
||||
PlugInProcDef *proc_def;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid;
|
||||
PlugInProcDef *proc_def = NULL;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid_utf8 = FALSE;
|
||||
gint i;
|
||||
|
||||
/* Argument checking
|
||||
@ -1421,7 +1381,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
}
|
||||
|
||||
/* Sanity check strings for UTF-8 validity */
|
||||
valid = FALSE;
|
||||
|
||||
if ((proc_install->menu_path == NULL ||
|
||||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
||||
@ -1437,25 +1396,25 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
(proc_install->date == NULL ||
|
||||
g_utf8_validate (proc_install->date, -1, NULL)))
|
||||
{
|
||||
valid = TRUE;
|
||||
valid_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < proc_install->nparams && valid; i++)
|
||||
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
||||
(proc_install->params[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid; i++)
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
||||
(proc_install->return_vals[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (! valid_utf8)
|
||||
{
|
||||
g_message ("Plug-In \"%s\"\n(%s)\n"
|
||||
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
||||
@ -1466,8 +1425,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
|
||||
/* Initialization */
|
||||
|
||||
proc_def = NULL;
|
||||
|
||||
switch (proc_install->type)
|
||||
{
|
||||
case GIMP_PLUGIN:
|
||||
@ -1795,36 +1752,3 @@ plug_in_temp_run (ProcRecord *proc_rec,
|
||||
done:
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename)
|
||||
{
|
||||
gchar *local_path;
|
||||
gchar *token;
|
||||
gchar *next_token;
|
||||
gchar *path;
|
||||
|
||||
local_path = g_strdup (search_path);
|
||||
next_token = local_path;
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path = g_build_filename (token, filename, NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
token = path;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -56,7 +57,7 @@
|
||||
#define _O_BINARY 0x0200 /* binary file */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <fcntl.h>
|
||||
@ -82,15 +83,12 @@
|
||||
#include "base/tile.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpenvirontable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/brush-select.h"
|
||||
#include "gui/gradient-select.h"
|
||||
@ -103,7 +101,6 @@
|
||||
#include "plug-in-params.h"
|
||||
#include "plug-in-proc.h"
|
||||
#include "plug-in-progress.h"
|
||||
#include "plug-in-rc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -117,15 +114,6 @@ struct _PlugInBlocked
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PlugInHelpPathDef PlugInHelpPathDef;
|
||||
|
||||
struct _PlugInHelpPathDef
|
||||
{
|
||||
gchar *prog_name;
|
||||
gchar *help_path;
|
||||
};
|
||||
|
||||
|
||||
static gboolean plug_in_write (GIOChannel *channel,
|
||||
guint8 *buf,
|
||||
gulong count,
|
||||
@ -158,24 +146,21 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
||||
gint argc);
|
||||
static void plug_in_init_shm (void);
|
||||
|
||||
static gchar * plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename);
|
||||
|
||||
static void plug_in_prep_for_exec (gpointer data);
|
||||
|
||||
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
static HANDLE shm_handle;
|
||||
@ -389,29 +374,10 @@ plug_in_new (Gimp *gimp,
|
||||
gchar *name)
|
||||
{
|
||||
PlugIn *plug_in;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
if (! g_path_is_absolute (name))
|
||||
{
|
||||
gchar *plug_in_path;
|
||||
|
||||
plug_in_path = gimp_config_path_expand (gimp->config->plug_in_path,
|
||||
FALSE, NULL);
|
||||
path = plug_in_search_in_path (plug_in_path, name);
|
||||
g_free (plug_in_path);
|
||||
|
||||
if (! path)
|
||||
{
|
||||
g_message (_("Unable to locate Plug-In: \"%s\""), name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
||||
|
||||
plug_in = g_new0 (PlugIn, 1);
|
||||
|
||||
@ -424,7 +390,7 @@ plug_in_new (Gimp *gimp,
|
||||
plug_in->recurse = FALSE;
|
||||
plug_in->busy = FALSE;
|
||||
plug_in->pid = 0;
|
||||
plug_in->args[0] = g_strdup (path);
|
||||
plug_in->args[0] = g_strdup (name);
|
||||
plug_in->args[1] = g_strdup ("-gimp");
|
||||
plug_in->args[2] = NULL;
|
||||
plug_in->args[3] = NULL;
|
||||
@ -447,32 +413,31 @@ plug_in_new (Gimp *gimp,
|
||||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
if (plug_in)
|
||||
{
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -492,127 +457,122 @@ plug_in_prep_for_exec (gpointer data)
|
||||
gboolean
|
||||
plug_in_open (PlugIn *plug_in)
|
||||
{
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gchar **envp;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (plug_in != NULL, FALSE);
|
||||
|
||||
if (plug_in)
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (!plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id =
|
||||
g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (! plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI |
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +629,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
DWORD dwExitCode = STILL_ACTIVE;
|
||||
DWORD dwTries = 10;
|
||||
while ((STILL_ACTIVE == dwExitCode)
|
||||
&& GetExitCodeProcess((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& (dwTries > 0))
|
||||
{
|
||||
Sleep(10);
|
||||
@ -677,7 +637,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
}
|
||||
if (STILL_ACTIVE == dwExitCode)
|
||||
{
|
||||
g_warning("Terminating %s ...", plug_in->args[0]);
|
||||
g_warning ("Terminating %s ...", plug_in->args[0]);
|
||||
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
||||
}
|
||||
}
|
||||
@ -1307,11 +1267,11 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
GPProcInstall *proc_install)
|
||||
{
|
||||
PlugInDef *plug_in_def = NULL;
|
||||
PlugInProcDef *proc_def;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid;
|
||||
PlugInProcDef *proc_def = NULL;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid_utf8 = FALSE;
|
||||
gint i;
|
||||
|
||||
/* Argument checking
|
||||
@ -1421,7 +1381,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
}
|
||||
|
||||
/* Sanity check strings for UTF-8 validity */
|
||||
valid = FALSE;
|
||||
|
||||
if ((proc_install->menu_path == NULL ||
|
||||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
||||
@ -1437,25 +1396,25 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
(proc_install->date == NULL ||
|
||||
g_utf8_validate (proc_install->date, -1, NULL)))
|
||||
{
|
||||
valid = TRUE;
|
||||
valid_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < proc_install->nparams && valid; i++)
|
||||
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
||||
(proc_install->params[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid; i++)
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
||||
(proc_install->return_vals[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (! valid_utf8)
|
||||
{
|
||||
g_message ("Plug-In \"%s\"\n(%s)\n"
|
||||
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
||||
@ -1466,8 +1425,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
|
||||
/* Initialization */
|
||||
|
||||
proc_def = NULL;
|
||||
|
||||
switch (proc_install->type)
|
||||
{
|
||||
case GIMP_PLUGIN:
|
||||
@ -1795,36 +1752,3 @@ plug_in_temp_run (ProcRecord *proc_rec,
|
||||
done:
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename)
|
||||
{
|
||||
gchar *local_path;
|
||||
gchar *token;
|
||||
gchar *next_token;
|
||||
gchar *path;
|
||||
|
||||
local_path = g_strdup (search_path);
|
||||
next_token = local_path;
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path = g_build_filename (token, filename, NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
token = path;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -34,9 +34,9 @@
|
||||
|
||||
|
||||
Argument *
|
||||
plug_in_params_to_args (GPParam *params,
|
||||
gint nparams,
|
||||
gboolean full_copy)
|
||||
plug_in_params_to_args (GPParam *params,
|
||||
gint nparams,
|
||||
gboolean full_copy)
|
||||
{
|
||||
Argument *args;
|
||||
gchar **stringarray;
|
||||
@ -368,7 +368,7 @@ plug_in_args_to_params (Argument *args,
|
||||
}
|
||||
|
||||
void
|
||||
plug_in_params_destroy (GPParam *params,
|
||||
plug_in_params_destroy (GPParam *params,
|
||||
gint nparams,
|
||||
gboolean full_destroy)
|
||||
{
|
||||
@ -442,8 +442,8 @@ plug_in_params_destroy (GPParam *params,
|
||||
|
||||
void
|
||||
plug_in_args_destroy (Argument *args,
|
||||
gint nargs,
|
||||
gboolean full_destroy)
|
||||
gint nargs,
|
||||
gboolean full_destroy)
|
||||
{
|
||||
if (full_destroy)
|
||||
{
|
||||
|
@ -43,13 +43,15 @@ static void plug_in_progress_cancel (GtkWidget *widget,
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
gchar *message,
|
||||
gint gdisp_ID)
|
||||
plug_in_progress_start (PlugIn *plug_in,
|
||||
const gchar *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GimpDisplay *gdisp = NULL;
|
||||
|
||||
if (!message)
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (! message)
|
||||
message = plug_in->args[0];
|
||||
|
||||
if (gdisp_ID > 0)
|
||||
@ -69,8 +71,10 @@ void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
gdouble percentage)
|
||||
{
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (! plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
plug_in_progress_start (plug_in, NULL, -1);
|
||||
|
||||
gimp_progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
@ -78,6 +82,8 @@ plug_in_progress_update (PlugIn *plug_in,
|
||||
void
|
||||
plug_in_progress_end (PlugIn *plug_in)
|
||||
{
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gimp_progress_end (plug_in->progress);
|
||||
|
@ -20,12 +20,12 @@
|
||||
#define __PLUG_IN_PROGRESS_H__
|
||||
|
||||
|
||||
void plug_in_progress_init (PlugIn *plug_in,
|
||||
gchar *message,
|
||||
gint gdisp_ID);
|
||||
void plug_in_progress_update (PlugIn *plug_in,
|
||||
gdouble percentage);
|
||||
void plug_in_progress_end (PlugIn *plug_in);
|
||||
void plug_in_progress_start (PlugIn *plug_in,
|
||||
const gchar *message,
|
||||
gint gdisp_ID);
|
||||
void plug_in_progress_update (PlugIn *plug_in,
|
||||
gdouble percentage);
|
||||
void plug_in_progress_end (PlugIn *plug_in);
|
||||
|
||||
|
||||
#endif /* __PLUG_IN_PROGRESS_H__ */
|
||||
|
@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -56,7 +57,7 @@
|
||||
#define _O_BINARY 0x0200 /* binary file */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <fcntl.h>
|
||||
@ -82,15 +83,12 @@
|
||||
#include "base/tile.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpenvirontable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/brush-select.h"
|
||||
#include "gui/gradient-select.h"
|
||||
@ -103,7 +101,6 @@
|
||||
#include "plug-in-params.h"
|
||||
#include "plug-in-proc.h"
|
||||
#include "plug-in-progress.h"
|
||||
#include "plug-in-rc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -117,15 +114,6 @@ struct _PlugInBlocked
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PlugInHelpPathDef PlugInHelpPathDef;
|
||||
|
||||
struct _PlugInHelpPathDef
|
||||
{
|
||||
gchar *prog_name;
|
||||
gchar *help_path;
|
||||
};
|
||||
|
||||
|
||||
static gboolean plug_in_write (GIOChannel *channel,
|
||||
guint8 *buf,
|
||||
gulong count,
|
||||
@ -158,24 +146,21 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
||||
gint argc);
|
||||
static void plug_in_init_shm (void);
|
||||
|
||||
static gchar * plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename);
|
||||
|
||||
static void plug_in_prep_for_exec (gpointer data);
|
||||
|
||||
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
static HANDLE shm_handle;
|
||||
@ -389,29 +374,10 @@ plug_in_new (Gimp *gimp,
|
||||
gchar *name)
|
||||
{
|
||||
PlugIn *plug_in;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
if (! g_path_is_absolute (name))
|
||||
{
|
||||
gchar *plug_in_path;
|
||||
|
||||
plug_in_path = gimp_config_path_expand (gimp->config->plug_in_path,
|
||||
FALSE, NULL);
|
||||
path = plug_in_search_in_path (plug_in_path, name);
|
||||
g_free (plug_in_path);
|
||||
|
||||
if (! path)
|
||||
{
|
||||
g_message (_("Unable to locate Plug-In: \"%s\""), name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
||||
|
||||
plug_in = g_new0 (PlugIn, 1);
|
||||
|
||||
@ -424,7 +390,7 @@ plug_in_new (Gimp *gimp,
|
||||
plug_in->recurse = FALSE;
|
||||
plug_in->busy = FALSE;
|
||||
plug_in->pid = 0;
|
||||
plug_in->args[0] = g_strdup (path);
|
||||
plug_in->args[0] = g_strdup (name);
|
||||
plug_in->args[1] = g_strdup ("-gimp");
|
||||
plug_in->args[2] = NULL;
|
||||
plug_in->args[3] = NULL;
|
||||
@ -447,32 +413,31 @@ plug_in_new (Gimp *gimp,
|
||||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
if (plug_in)
|
||||
{
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -492,127 +457,122 @@ plug_in_prep_for_exec (gpointer data)
|
||||
gboolean
|
||||
plug_in_open (PlugIn *plug_in)
|
||||
{
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gchar **envp;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (plug_in != NULL, FALSE);
|
||||
|
||||
if (plug_in)
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (!plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id =
|
||||
g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (! plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI |
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +629,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
DWORD dwExitCode = STILL_ACTIVE;
|
||||
DWORD dwTries = 10;
|
||||
while ((STILL_ACTIVE == dwExitCode)
|
||||
&& GetExitCodeProcess((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& (dwTries > 0))
|
||||
{
|
||||
Sleep(10);
|
||||
@ -677,7 +637,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
}
|
||||
if (STILL_ACTIVE == dwExitCode)
|
||||
{
|
||||
g_warning("Terminating %s ...", plug_in->args[0]);
|
||||
g_warning ("Terminating %s ...", plug_in->args[0]);
|
||||
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
||||
}
|
||||
}
|
||||
@ -1307,11 +1267,11 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
GPProcInstall *proc_install)
|
||||
{
|
||||
PlugInDef *plug_in_def = NULL;
|
||||
PlugInProcDef *proc_def;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid;
|
||||
PlugInProcDef *proc_def = NULL;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid_utf8 = FALSE;
|
||||
gint i;
|
||||
|
||||
/* Argument checking
|
||||
@ -1421,7 +1381,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
}
|
||||
|
||||
/* Sanity check strings for UTF-8 validity */
|
||||
valid = FALSE;
|
||||
|
||||
if ((proc_install->menu_path == NULL ||
|
||||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
||||
@ -1437,25 +1396,25 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
(proc_install->date == NULL ||
|
||||
g_utf8_validate (proc_install->date, -1, NULL)))
|
||||
{
|
||||
valid = TRUE;
|
||||
valid_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < proc_install->nparams && valid; i++)
|
||||
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
||||
(proc_install->params[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid; i++)
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
||||
(proc_install->return_vals[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (! valid_utf8)
|
||||
{
|
||||
g_message ("Plug-In \"%s\"\n(%s)\n"
|
||||
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
||||
@ -1466,8 +1425,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
|
||||
/* Initialization */
|
||||
|
||||
proc_def = NULL;
|
||||
|
||||
switch (proc_install->type)
|
||||
{
|
||||
case GIMP_PLUGIN:
|
||||
@ -1795,36 +1752,3 @@ plug_in_temp_run (ProcRecord *proc_rec,
|
||||
done:
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename)
|
||||
{
|
||||
gchar *local_path;
|
||||
gchar *token;
|
||||
gchar *next_token;
|
||||
gchar *path;
|
||||
|
||||
local_path = g_strdup (search_path);
|
||||
next_token = local_path;
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path = g_build_filename (token, filename, NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
token = path;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -56,7 +57,7 @@
|
||||
#define _O_BINARY 0x0200 /* binary file */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <fcntl.h>
|
||||
@ -82,15 +83,12 @@
|
||||
#include "base/tile.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpenvirontable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/brush-select.h"
|
||||
#include "gui/gradient-select.h"
|
||||
@ -103,7 +101,6 @@
|
||||
#include "plug-in-params.h"
|
||||
#include "plug-in-proc.h"
|
||||
#include "plug-in-progress.h"
|
||||
#include "plug-in-rc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -117,15 +114,6 @@ struct _PlugInBlocked
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PlugInHelpPathDef PlugInHelpPathDef;
|
||||
|
||||
struct _PlugInHelpPathDef
|
||||
{
|
||||
gchar *prog_name;
|
||||
gchar *help_path;
|
||||
};
|
||||
|
||||
|
||||
static gboolean plug_in_write (GIOChannel *channel,
|
||||
guint8 *buf,
|
||||
gulong count,
|
||||
@ -158,24 +146,21 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
||||
gint argc);
|
||||
static void plug_in_init_shm (void);
|
||||
|
||||
static gchar * plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename);
|
||||
|
||||
static void plug_in_prep_for_exec (gpointer data);
|
||||
|
||||
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
static HANDLE shm_handle;
|
||||
@ -389,29 +374,10 @@ plug_in_new (Gimp *gimp,
|
||||
gchar *name)
|
||||
{
|
||||
PlugIn *plug_in;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
if (! g_path_is_absolute (name))
|
||||
{
|
||||
gchar *plug_in_path;
|
||||
|
||||
plug_in_path = gimp_config_path_expand (gimp->config->plug_in_path,
|
||||
FALSE, NULL);
|
||||
path = plug_in_search_in_path (plug_in_path, name);
|
||||
g_free (plug_in_path);
|
||||
|
||||
if (! path)
|
||||
{
|
||||
g_message (_("Unable to locate Plug-In: \"%s\""), name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
||||
|
||||
plug_in = g_new0 (PlugIn, 1);
|
||||
|
||||
@ -424,7 +390,7 @@ plug_in_new (Gimp *gimp,
|
||||
plug_in->recurse = FALSE;
|
||||
plug_in->busy = FALSE;
|
||||
plug_in->pid = 0;
|
||||
plug_in->args[0] = g_strdup (path);
|
||||
plug_in->args[0] = g_strdup (name);
|
||||
plug_in->args[1] = g_strdup ("-gimp");
|
||||
plug_in->args[2] = NULL;
|
||||
plug_in->args[3] = NULL;
|
||||
@ -447,32 +413,31 @@ plug_in_new (Gimp *gimp,
|
||||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
if (plug_in)
|
||||
{
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -492,127 +457,122 @@ plug_in_prep_for_exec (gpointer data)
|
||||
gboolean
|
||||
plug_in_open (PlugIn *plug_in)
|
||||
{
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gchar **envp;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (plug_in != NULL, FALSE);
|
||||
|
||||
if (plug_in)
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (!plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id =
|
||||
g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (! plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI |
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +629,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
DWORD dwExitCode = STILL_ACTIVE;
|
||||
DWORD dwTries = 10;
|
||||
while ((STILL_ACTIVE == dwExitCode)
|
||||
&& GetExitCodeProcess((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& (dwTries > 0))
|
||||
{
|
||||
Sleep(10);
|
||||
@ -677,7 +637,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
}
|
||||
if (STILL_ACTIVE == dwExitCode)
|
||||
{
|
||||
g_warning("Terminating %s ...", plug_in->args[0]);
|
||||
g_warning ("Terminating %s ...", plug_in->args[0]);
|
||||
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
||||
}
|
||||
}
|
||||
@ -1307,11 +1267,11 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
GPProcInstall *proc_install)
|
||||
{
|
||||
PlugInDef *plug_in_def = NULL;
|
||||
PlugInProcDef *proc_def;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid;
|
||||
PlugInProcDef *proc_def = NULL;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid_utf8 = FALSE;
|
||||
gint i;
|
||||
|
||||
/* Argument checking
|
||||
@ -1421,7 +1381,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
}
|
||||
|
||||
/* Sanity check strings for UTF-8 validity */
|
||||
valid = FALSE;
|
||||
|
||||
if ((proc_install->menu_path == NULL ||
|
||||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
||||
@ -1437,25 +1396,25 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
(proc_install->date == NULL ||
|
||||
g_utf8_validate (proc_install->date, -1, NULL)))
|
||||
{
|
||||
valid = TRUE;
|
||||
valid_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < proc_install->nparams && valid; i++)
|
||||
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
||||
(proc_install->params[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid; i++)
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
||||
(proc_install->return_vals[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (! valid_utf8)
|
||||
{
|
||||
g_message ("Plug-In \"%s\"\n(%s)\n"
|
||||
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
||||
@ -1466,8 +1425,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
|
||||
/* Initialization */
|
||||
|
||||
proc_def = NULL;
|
||||
|
||||
switch (proc_install->type)
|
||||
{
|
||||
case GIMP_PLUGIN:
|
||||
@ -1795,36 +1752,3 @@ plug_in_temp_run (ProcRecord *proc_rec,
|
||||
done:
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename)
|
||||
{
|
||||
gchar *local_path;
|
||||
gchar *token;
|
||||
gchar *next_token;
|
||||
gchar *path;
|
||||
|
||||
local_path = g_strdup (search_path);
|
||||
next_token = local_path;
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path = g_build_filename (token, filename, NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
token = path;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
@ -56,7 +57,7 @@
|
||||
#define _O_BINARY 0x0200 /* binary file */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
|
||||
|
||||
#ifdef __EMX__
|
||||
#include <fcntl.h>
|
||||
@ -82,15 +83,12 @@
|
||||
#include "base/tile.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
#include "config/gimpconfig-path.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpenvirontable.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/brush-select.h"
|
||||
#include "gui/gradient-select.h"
|
||||
@ -103,7 +101,6 @@
|
||||
#include "plug-in-params.h"
|
||||
#include "plug-in-proc.h"
|
||||
#include "plug-in-progress.h"
|
||||
#include "plug-in-rc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -117,15 +114,6 @@ struct _PlugInBlocked
|
||||
};
|
||||
|
||||
|
||||
typedef struct _PlugInHelpPathDef PlugInHelpPathDef;
|
||||
|
||||
struct _PlugInHelpPathDef
|
||||
{
|
||||
gchar *prog_name;
|
||||
gchar *help_path;
|
||||
};
|
||||
|
||||
|
||||
static gboolean plug_in_write (GIOChannel *channel,
|
||||
guint8 *buf,
|
||||
gulong count,
|
||||
@ -158,24 +146,21 @@ static Argument * plug_in_temp_run (ProcRecord *proc_rec,
|
||||
gint argc);
|
||||
static void plug_in_init_shm (void);
|
||||
|
||||
static gchar * plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename);
|
||||
|
||||
static void plug_in_prep_for_exec (gpointer data);
|
||||
|
||||
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
PlugIn *current_plug_in = NULL;
|
||||
ProcRecord *last_plug_in = NULL;
|
||||
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
static GSList *open_plug_ins = NULL;
|
||||
static GSList *blocked_plug_ins = NULL;
|
||||
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
static GSList *plug_in_stack = NULL;
|
||||
static Argument *current_return_vals = NULL;
|
||||
static gint current_return_nvals = 0;
|
||||
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
static gint shm_ID = -1;
|
||||
static guchar *shm_addr = NULL;
|
||||
|
||||
#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
|
||||
static HANDLE shm_handle;
|
||||
@ -389,29 +374,10 @@ plug_in_new (Gimp *gimp,
|
||||
gchar *name)
|
||||
{
|
||||
PlugIn *plug_in;
|
||||
gchar *path;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
if (! g_path_is_absolute (name))
|
||||
{
|
||||
gchar *plug_in_path;
|
||||
|
||||
plug_in_path = gimp_config_path_expand (gimp->config->plug_in_path,
|
||||
FALSE, NULL);
|
||||
path = plug_in_search_in_path (plug_in_path, name);
|
||||
g_free (plug_in_path);
|
||||
|
||||
if (! path)
|
||||
{
|
||||
g_message (_("Unable to locate Plug-In: \"%s\""), name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
path = name;
|
||||
}
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (g_path_is_absolute (name), NULL);
|
||||
|
||||
plug_in = g_new0 (PlugIn, 1);
|
||||
|
||||
@ -424,7 +390,7 @@ plug_in_new (Gimp *gimp,
|
||||
plug_in->recurse = FALSE;
|
||||
plug_in->busy = FALSE;
|
||||
plug_in->pid = 0;
|
||||
plug_in->args[0] = g_strdup (path);
|
||||
plug_in->args[0] = g_strdup (name);
|
||||
plug_in->args[1] = g_strdup ("-gimp");
|
||||
plug_in->args[2] = NULL;
|
||||
plug_in->args[3] = NULL;
|
||||
@ -447,32 +413,31 @@ plug_in_new (Gimp *gimp,
|
||||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
if (plug_in)
|
||||
{
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
g_return_if_fail (plug_in != NULL);
|
||||
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
if (plug_in->open)
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
if (plug_in->args[0])
|
||||
g_free (plug_in->args[0]);
|
||||
if (plug_in->args[1])
|
||||
g_free (plug_in->args[1]);
|
||||
if (plug_in->args[2])
|
||||
g_free (plug_in->args[2]);
|
||||
if (plug_in->args[3])
|
||||
g_free (plug_in->args[3]);
|
||||
if (plug_in->args[4])
|
||||
g_free (plug_in->args[4]);
|
||||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
if (plug_in->progress)
|
||||
plug_in_progress_end (plug_in);
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
||||
g_free (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -492,127 +457,122 @@ plug_in_prep_for_exec (gpointer data)
|
||||
gboolean
|
||||
plug_in_open (PlugIn *plug_in)
|
||||
{
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gint my_read[2];
|
||||
gint my_write[2];
|
||||
gchar **envp;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (plug_in != NULL, FALSE);
|
||||
|
||||
if (plug_in)
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
/* Open two pipes. (Bidirectional communication).
|
||||
*/
|
||||
if ((pipe (my_read) == -1) || (pipe (my_write) == -1))
|
||||
{
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (!plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id =
|
||||
g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
g_message ("pipe() failed: Unable to start Plug-In \"%s\"\n(%s)",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
#if defined(G_WITH_CYGWIN) || defined(__EMX__)
|
||||
/* Set to binary mode */
|
||||
setmode (my_read[0], _O_BINARY);
|
||||
setmode (my_write[0], _O_BINARY);
|
||||
setmode (my_read[1], _O_BINARY);
|
||||
setmode (my_write[1], _O_BINARY);
|
||||
#endif
|
||||
|
||||
plug_in->my_read = g_io_channel_unix_new (my_read[0]);
|
||||
plug_in->my_write = g_io_channel_unix_new (my_write[1]);
|
||||
plug_in->his_read = g_io_channel_unix_new (my_write[0]);
|
||||
plug_in->his_write = g_io_channel_unix_new (my_read[1]);
|
||||
|
||||
g_io_channel_set_encoding (plug_in->my_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->my_write, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_read, NULL, NULL);
|
||||
g_io_channel_set_encoding (plug_in->his_write, NULL, NULL);
|
||||
|
||||
g_io_channel_set_buffered (plug_in->my_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->my_write, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_read, FALSE);
|
||||
g_io_channel_set_buffered (plug_in->his_write, FALSE);
|
||||
|
||||
g_io_channel_set_close_on_unref (plug_in->my_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->my_write, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_read, TRUE);
|
||||
g_io_channel_set_close_on_unref (plug_in->his_write, TRUE);
|
||||
|
||||
/* Remember the file descriptors for the pipes.
|
||||
*/
|
||||
plug_in->args[2] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_read));
|
||||
plug_in->args[3] =
|
||||
g_strdup_printf ("%d", g_io_channel_unix_get_fd (plug_in->his_write));
|
||||
|
||||
/* Set the rest of the command line arguments.
|
||||
* FIXME: this is ugly. Pass in the mode as a separate argument?
|
||||
*/
|
||||
if (plug_in->query)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-query");
|
||||
}
|
||||
else if (plug_in->init)
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-init");
|
||||
}
|
||||
else
|
||||
{
|
||||
plug_in->args[4] = g_strdup ("-run");
|
||||
}
|
||||
|
||||
plug_in->args[5] = g_strdup_printf ("%d", plug_in->gimp->stack_trace_mode);
|
||||
|
||||
#ifdef __EMX__
|
||||
fcntl (my_read[0], F_SETFD, 1);
|
||||
fcntl (my_write[1], F_SETFD, 1);
|
||||
#endif
|
||||
|
||||
/* Fork another process. We'll remember the process id
|
||||
* so that we can later use it to kill the filter if
|
||||
* necessary.
|
||||
*/
|
||||
envp = gimp_environ_table_get_envp (plug_in->gimp->environ_table);
|
||||
if (! g_spawn_async (NULL, plug_in->args, envp,
|
||||
G_SPAWN_LEAVE_DESCRIPTORS_OPEN |
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
plug_in_prep_for_exec, plug_in,
|
||||
&plug_in->pid,
|
||||
&error))
|
||||
{
|
||||
g_message ("Unable to run Plug-In: \"%s\"\n(%s)\n%s",
|
||||
g_path_get_basename (plug_in->args[0]),
|
||||
plug_in->args[0],
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
|
||||
plug_in_destroy (plug_in);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_io_channel_unref (plug_in->his_read);
|
||||
plug_in->his_read = NULL;
|
||||
|
||||
g_io_channel_unref (plug_in->his_write);
|
||||
plug_in->his_write = NULL;
|
||||
|
||||
if (! plug_in->synchronous)
|
||||
{
|
||||
plug_in->input_id = g_io_add_watch (plug_in->my_read,
|
||||
G_IO_IN | G_IO_PRI |
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
plug_in_recv_message,
|
||||
plug_in);
|
||||
|
||||
open_plug_ins = g_slist_prepend (open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
plug_in->open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -669,7 +629,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
DWORD dwExitCode = STILL_ACTIVE;
|
||||
DWORD dwTries = 10;
|
||||
while ((STILL_ACTIVE == dwExitCode)
|
||||
&& GetExitCodeProcess((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& GetExitCodeProcess ((HANDLE) plug_in->pid, &dwExitCode)
|
||||
&& (dwTries > 0))
|
||||
{
|
||||
Sleep(10);
|
||||
@ -677,7 +637,7 @@ plug_in_close (PlugIn *plug_in,
|
||||
}
|
||||
if (STILL_ACTIVE == dwExitCode)
|
||||
{
|
||||
g_warning("Terminating %s ...", plug_in->args[0]);
|
||||
g_warning ("Terminating %s ...", plug_in->args[0]);
|
||||
TerminateProcess ((HANDLE) plug_in->pid, 0);
|
||||
}
|
||||
}
|
||||
@ -1307,11 +1267,11 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
GPProcInstall *proc_install)
|
||||
{
|
||||
PlugInDef *plug_in_def = NULL;
|
||||
PlugInProcDef *proc_def;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid;
|
||||
PlugInProcDef *proc_def = NULL;
|
||||
ProcRecord *proc = NULL;
|
||||
GSList *tmp = NULL;
|
||||
gchar *prog = NULL;
|
||||
gboolean valid_utf8 = FALSE;
|
||||
gint i;
|
||||
|
||||
/* Argument checking
|
||||
@ -1421,7 +1381,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
}
|
||||
|
||||
/* Sanity check strings for UTF-8 validity */
|
||||
valid = FALSE;
|
||||
|
||||
if ((proc_install->menu_path == NULL ||
|
||||
g_utf8_validate (proc_install->menu_path, -1, NULL)) &&
|
||||
@ -1437,25 +1396,25 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
(proc_install->date == NULL ||
|
||||
g_utf8_validate (proc_install->date, -1, NULL)))
|
||||
{
|
||||
valid = TRUE;
|
||||
valid_utf8 = TRUE;
|
||||
|
||||
for (i = 0; i < proc_install->nparams && valid; i++)
|
||||
for (i = 0; i < proc_install->nparams && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->params[i].name, -1, NULL) &&
|
||||
(proc_install->params[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->params[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid; i++)
|
||||
for (i = 0; i < proc_install->nreturn_vals && valid_utf8; i++)
|
||||
{
|
||||
if (! (g_utf8_validate (proc_install->return_vals[i].name, -1, NULL) &&
|
||||
(proc_install->return_vals[i].description == NULL ||
|
||||
g_utf8_validate (proc_install->return_vals[i].description, -1, NULL))))
|
||||
valid = FALSE;
|
||||
valid_utf8 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
if (! valid_utf8)
|
||||
{
|
||||
g_message ("Plug-In \"%s\"\n(%s)\n"
|
||||
"attempted to install a procedure with invalid UTF-8 strings.\n",
|
||||
@ -1466,8 +1425,6 @@ plug_in_handle_proc_install (PlugIn *plug_in,
|
||||
|
||||
/* Initialization */
|
||||
|
||||
proc_def = NULL;
|
||||
|
||||
switch (proc_install->type)
|
||||
{
|
||||
case GIMP_PLUGIN:
|
||||
@ -1795,36 +1752,3 @@ plug_in_temp_run (ProcRecord *proc_rec,
|
||||
done:
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
plug_in_search_in_path (gchar *search_path,
|
||||
gchar *filename)
|
||||
{
|
||||
gchar *local_path;
|
||||
gchar *token;
|
||||
gchar *next_token;
|
||||
gchar *path;
|
||||
|
||||
local_path = g_strdup (search_path);
|
||||
next_token = local_path;
|
||||
token = strtok (next_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
while (token)
|
||||
{
|
||||
path = g_build_filename (token, filename, NULL);
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
{
|
||||
token = path;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
|
||||
token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ struct _PlugIn
|
||||
{
|
||||
Gimp *gimp;
|
||||
|
||||
guint open : 1; /* Is the plug-in open* */
|
||||
guint open : 1; /* Is the plug-in open? */
|
||||
guint query : 1; /* Are we querying the plug-in? */
|
||||
guint init : 1; /* Are we initialing the plug-in? */
|
||||
guint synchronous : 1; /* Is the plug-in running synchronously? */
|
||||
|
@ -424,9 +424,18 @@ plug_ins_file_handler (gchar *name,
|
||||
void
|
||||
plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
{
|
||||
GSList *tmp;
|
||||
GSList *list;
|
||||
gchar *basename1;
|
||||
gchar *basename2;
|
||||
|
||||
g_return_if_fail (plug_in_def != NULL);
|
||||
g_return_if_fail (plug_in_def->prog != NULL);
|
||||
|
||||
if (! g_path_is_absolute (plug_in_def->prog))
|
||||
{
|
||||
g_warning ("plug_ins_def_add_from_rc: filename not absolute (skipping)");
|
||||
plug_in_def_free (plug_in_def, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
basename1 = g_path_get_basename (plug_in_def->prog);
|
||||
|
||||
@ -437,11 +446,11 @@ plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
* loader needs to be able to register no extensions, prefixes or
|
||||
* magics. -- austin 13/Feb/99
|
||||
*/
|
||||
for (tmp = plug_in_def->proc_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = plug_in_def->proc_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
PlugInProcDef *proc_def;
|
||||
|
||||
proc_def = tmp->data;
|
||||
proc_def = (PlugInProcDef *) list->data;
|
||||
|
||||
if (! proc_def->extensions &&
|
||||
! proc_def->prefixes &&
|
||||
@ -457,11 +466,12 @@ plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
/* Check if the entry mentioned in pluginrc matches an executable
|
||||
* found in the plug_in_path.
|
||||
*/
|
||||
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = plug_in_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
PlugInDef *ondisk_plug_in_def;
|
||||
gchar *basename2;
|
||||
|
||||
ondisk_plug_in_def = tmp->data;
|
||||
ondisk_plug_in_def = (PlugInDef *) list->data;
|
||||
|
||||
basename2 = g_path_get_basename (ondisk_plug_in_def->prog);
|
||||
|
||||
@ -472,7 +482,7 @@ plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
(plug_in_def->mtime == ondisk_plug_in_def->mtime))
|
||||
{
|
||||
/* Use pluginrc entry, deleting ondisk entry */
|
||||
tmp->data = plug_in_def;
|
||||
list->data = plug_in_def;
|
||||
plug_in_def_free (ondisk_plug_in_def, TRUE);
|
||||
}
|
||||
else
|
||||
@ -493,7 +503,7 @@ plug_ins_def_add_from_rc (PlugInDef *plug_in_def)
|
||||
g_free (basename1);
|
||||
|
||||
write_pluginrc = TRUE;
|
||||
g_print ("\"%s\" executable not found\n", plug_in_def->prog);
|
||||
g_print ("executable not found: \"%s\"\n", plug_in_def->prog);
|
||||
plug_in_def_free (plug_in_def, FALSE);
|
||||
}
|
||||
|
||||
@ -724,25 +734,26 @@ plug_ins_image_types_parse (gchar *image_types)
|
||||
static void
|
||||
plug_ins_init_file (GimpDatafileData *file_data)
|
||||
{
|
||||
GSList **plug_in_defs;
|
||||
GSList *tmp;
|
||||
PlugInDef *plug_in_def;
|
||||
gchar *plug_in_name;
|
||||
GSList **plug_in_defs;
|
||||
GSList *list;
|
||||
gchar *basename;
|
||||
|
||||
plug_in_defs = file_data->user_data;
|
||||
|
||||
basename = g_path_get_basename (file_data->filename);
|
||||
|
||||
for (tmp = *plug_in_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = *plug_in_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
plug_in_def = tmp->data;
|
||||
gchar *plug_in_name;
|
||||
|
||||
plug_in_def = (PlugInDef *) list->data;
|
||||
|
||||
plug_in_name = g_path_get_basename (plug_in_def->prog);
|
||||
|
||||
if (g_ascii_strcasecmp (basename, plug_in_name) == 0)
|
||||
{
|
||||
g_print ("duplicate plug-in: \"%s\" (skipping)\n",
|
||||
g_print ("skipping duplicate plug-in: \"%s\"\n",
|
||||
file_data->filename);
|
||||
|
||||
g_free (plug_in_name);
|
||||
@ -770,11 +781,11 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
PlugInProcDef *proc_def;
|
||||
Argument args[4];
|
||||
Argument *return_vals;
|
||||
GSList *tmp;
|
||||
GSList *list;
|
||||
|
||||
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = proc_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
proc_def = tmp->data;
|
||||
proc_def = (PlugInProcDef *) list->data;
|
||||
|
||||
if (proc_def->prog && (proc_def->db_info.proc_type != GIMP_INTERNAL))
|
||||
{
|
||||
@ -783,9 +794,9 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
}
|
||||
}
|
||||
|
||||
for (tmp = proc_defs; tmp; tmp = tmp->next)
|
||||
for (list = proc_defs; list; list = list->next)
|
||||
{
|
||||
proc_def = tmp->data;
|
||||
proc_def = (PlugInProcDef *) list->data;
|
||||
|
||||
if (proc_def->extensions || proc_def->prefixes || proc_def->magics)
|
||||
{
|
||||
@ -803,7 +814,7 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
|
||||
if (proc_def->image_types)
|
||||
{
|
||||
return_vals =
|
||||
return_vals =
|
||||
procedural_db_execute (gimp,
|
||||
"gimp_register_save_handler",
|
||||
args);
|
||||
@ -811,7 +822,7 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
}
|
||||
else
|
||||
{
|
||||
return_vals =
|
||||
return_vals =
|
||||
procedural_db_execute (gimp,
|
||||
"gimp_register_magic_load_handler",
|
||||
args);
|
||||
@ -824,20 +835,18 @@ plug_ins_add_to_db (Gimp *gimp)
|
||||
static PlugInProcDef *
|
||||
plug_ins_proc_def_insert (PlugInProcDef *proc_def)
|
||||
{
|
||||
PlugInProcDef *tmp_proc_def;
|
||||
GSList *tmp;
|
||||
GSList *prev;
|
||||
GSList *list;
|
||||
GSList *list;
|
||||
GSList *prev = NULL;
|
||||
|
||||
prev = NULL;
|
||||
|
||||
for (tmp = proc_defs; tmp; tmp = g_slist_next (tmp))
|
||||
for (list = proc_defs; list; list = g_slist_next (list))
|
||||
{
|
||||
tmp_proc_def = tmp->data;
|
||||
PlugInProcDef *tmp_proc_def;
|
||||
|
||||
tmp_proc_def = (PlugInProcDef *) list->data;
|
||||
|
||||
if (strcmp (proc_def->db_info.name, tmp_proc_def->db_info.name) == 0)
|
||||
{
|
||||
tmp->data = proc_def;
|
||||
list->data = proc_def;
|
||||
|
||||
if (proc_def->menu_path)
|
||||
g_free (proc_def->menu_path);
|
||||
@ -852,23 +861,25 @@ plug_ins_proc_def_insert (PlugInProcDef *proc_def)
|
||||
|
||||
return tmp_proc_def;
|
||||
}
|
||||
else if (!proc_def->menu_path ||
|
||||
else if (! proc_def->menu_path ||
|
||||
(tmp_proc_def->menu_path &&
|
||||
(strcmp (proc_def->menu_path, tmp_proc_def->menu_path) < 0)))
|
||||
{
|
||||
list = g_slist_alloc ();
|
||||
list->data = proc_def;
|
||||
GSList *new;
|
||||
|
||||
list->next = tmp;
|
||||
new = g_slist_alloc ();
|
||||
new->data = proc_def;
|
||||
|
||||
new->next = list;
|
||||
if (prev)
|
||||
prev->next = list;
|
||||
prev->next = new;
|
||||
else
|
||||
proc_defs = list;
|
||||
proc_defs = new;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prev = tmp;
|
||||
prev = list;
|
||||
}
|
||||
|
||||
proc_defs = g_slist_append (proc_defs, proc_def);
|
||||
|
@ -62,7 +62,7 @@ HELP
|
||||
success = TRUE;
|
||||
|
||||
if (! gimp->no_interface)
|
||||
plug_in_progress_init (current_plug_in, message, gdisplay);
|
||||
plug_in_progress_start (current_plug_in, message, gdisplay);
|
||||
}
|
||||
}
|
||||
CODE
|
||||
@ -275,8 +275,7 @@ HELP
|
||||
desc => 'The absolute path to the compiled message catalog (may be NULL).',
|
||||
no_success => 1 },
|
||||
);
|
||||
|
||||
|
||||
|
||||
%invoke = (
|
||||
success => 'TRUE',
|
||||
code => <<'CODE',
|
||||
|
Reference in New Issue
Block a user