1999-02-21 07:20:54 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
#include "appenv.h"
|
|
|
|
#include "app_procs.h"
|
|
|
|
#include "batch.h"
|
|
|
|
#include "procedural_db.h"
|
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void batch_run_cmd (char *cmd);
|
|
|
|
static void batch_read (gpointer data,
|
|
|
|
gint source,
|
|
|
|
GdkInputCondition condition);
|
1999-03-17 05:53:10 +08:00
|
|
|
static void batch_pserver (int run_mode,
|
|
|
|
int flags,
|
|
|
|
int extra);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
1998-09-11 03:03:20 +08:00
|
|
|
static ProcRecord *eval_proc;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
|
|
|
batch_init ()
|
|
|
|
{
|
|
|
|
extern char **batch_cmds;
|
|
|
|
|
|
|
|
int read_from_stdin;
|
|
|
|
int i;
|
1999-03-17 05:53:10 +08:00
|
|
|
int perl_server_already_running = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-09-11 03:03:20 +08:00
|
|
|
eval_proc = procedural_db_lookup ("extension_script_fu_eval");
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
read_from_stdin = FALSE;
|
|
|
|
for (i = 0; batch_cmds[i]; i++)
|
|
|
|
{
|
1999-03-17 05:53:10 +08:00
|
|
|
|
|
|
|
/* until --batch-interp=xxx or something similar is implemented
|
|
|
|
* and gimp-1.0 is not extinct use a shortcut to speed up starting the
|
1999-10-17 08:07:55 +08:00
|
|
|
* perl-server tremendously. This is also fully compatible with 1.0.
|
1999-03-17 05:53:10 +08:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
int run_mode, flags, extra;
|
|
|
|
|
|
|
|
if (sscanf (batch_cmds[i], "(extension%*[-_]perl%*[-_]server %i %i %i)", &run_mode, &flags, &extra) == 3)
|
|
|
|
{
|
|
|
|
if (!perl_server_already_running)
|
|
|
|
{
|
|
|
|
batch_pserver (run_mode, flags, extra);
|
|
|
|
perl_server_already_running = 1;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eval_proc)
|
|
|
|
{
|
1999-09-23 19:49:16 +08:00
|
|
|
g_message ("script-fu not available: batch mode disabled\n");
|
1999-03-17 05:53:10 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (strcmp (batch_cmds[i], "-") == 0)
|
|
|
|
{
|
|
|
|
if (!read_from_stdin)
|
|
|
|
{
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32 /* for now */
|
1999-09-23 19:49:16 +08:00
|
|
|
g_print ("reading batch commands from stdin\n");
|
1997-11-25 06:05:25 +08:00
|
|
|
gdk_input_add (STDIN_FILENO, GDK_INPUT_READ, batch_read, NULL);
|
|
|
|
read_from_stdin = TRUE;
|
1999-02-21 07:20:54 +08:00
|
|
|
#else
|
|
|
|
g_error ("Batch mode from standard input not implemented on Win32");
|
|
|
|
#endif
|
1999-03-07 20:56:03 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-09-11 03:03:20 +08:00
|
|
|
batch_run_cmd (batch_cmds[i]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
batch_run_cmd (char *cmd)
|
|
|
|
{
|
|
|
|
Argument *args;
|
|
|
|
Argument *vals;
|
|
|
|
int i;
|
|
|
|
|
1998-09-11 03:03:20 +08:00
|
|
|
if (g_strcasecmp (cmd, "(gimp-quit 0)") == 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
app_exit (FALSE);
|
1998-09-11 03:03:20 +08:00
|
|
|
exit (0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-09-11 03:03:20 +08:00
|
|
|
args = g_new0 (Argument, eval_proc->num_args);
|
|
|
|
for (i = 0; i < eval_proc->num_args; i++)
|
|
|
|
args[i].arg_type = eval_proc->args[i].arg_type;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-09-11 03:03:20 +08:00
|
|
|
args[0].value.pdb_int = 1;
|
|
|
|
args[1].value.pdb_pointer = cmd;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-09-11 03:03:20 +08:00
|
|
|
vals = procedural_db_execute ("extension_script_fu_eval", args);
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (vals[0].value.pdb_int)
|
|
|
|
{
|
|
|
|
case PDB_EXECUTION_ERROR:
|
1999-09-23 19:49:16 +08:00
|
|
|
g_print ("batch command: experienced an execution error.\n");
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case PDB_CALLING_ERROR:
|
1999-09-23 19:49:16 +08:00
|
|
|
g_print ("batch command: experienced a calling error.\n");
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case PDB_SUCCESS:
|
1999-09-23 19:49:16 +08:00
|
|
|
g_print ("batch command: executed successfully.\n");
|
1998-09-11 03:03:20 +08:00
|
|
|
break;
|
|
|
|
default:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
1998-09-11 03:03:20 +08:00
|
|
|
|
|
|
|
procedural_db_destroy_args (vals, eval_proc->num_values);
|
|
|
|
g_free(args);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#ifndef G_OS_WIN32
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
batch_read (gpointer data,
|
|
|
|
gint source,
|
|
|
|
GdkInputCondition condition)
|
|
|
|
{
|
|
|
|
static GString *string;
|
|
|
|
char buf[32], *t;
|
|
|
|
int nread, done;
|
|
|
|
|
|
|
|
if (condition & GDK_INPUT_READ)
|
|
|
|
{
|
|
|
|
do {
|
|
|
|
nread = read (source, &buf, sizeof (char) * 31);
|
|
|
|
} while ((nread == -1) && ((errno == EAGAIN) || (errno == EINTR)));
|
|
|
|
|
|
|
|
if ((nread == 0) && (!string || (string->len == 0)))
|
|
|
|
app_exit (FALSE);
|
|
|
|
|
|
|
|
buf[nread] = '\0';
|
|
|
|
|
|
|
|
if (!string)
|
|
|
|
string = g_string_new ("");
|
|
|
|
|
|
|
|
t = buf;
|
|
|
|
if (string->len == 0)
|
|
|
|
{
|
|
|
|
while (*t)
|
|
|
|
{
|
|
|
|
if (isspace (*t))
|
|
|
|
t++;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_string_append (string, t);
|
|
|
|
|
|
|
|
done = FALSE;
|
|
|
|
|
|
|
|
while (*t)
|
|
|
|
{
|
|
|
|
if ((*t == '\n') || (*t == '\r'))
|
|
|
|
done = TRUE;
|
|
|
|
t++;
|
|
|
|
}
|
|
|
|
|
1998-09-11 03:03:20 +08:00
|
|
|
if (done)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
batch_run_cmd (string->str);
|
|
|
|
g_string_truncate (string, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-03-17 05:53:10 +08:00
|
|
|
|
1999-10-05 03:26:07 +08:00
|
|
|
#endif /* !G_OS_WIN32 */
|
1999-06-15 06:18:02 +08:00
|
|
|
|
1999-03-17 05:53:10 +08:00
|
|
|
static void
|
|
|
|
batch_pserver (int run_mode,
|
|
|
|
int flags,
|
|
|
|
int extra)
|
|
|
|
{
|
|
|
|
ProcRecord *pserver_proc;
|
|
|
|
Argument *args;
|
|
|
|
Argument *vals;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
pserver_proc = procedural_db_lookup ("extension_perl_server");
|
|
|
|
|
|
|
|
if (!pserver_proc)
|
|
|
|
{
|
1999-09-23 19:49:16 +08:00
|
|
|
g_message ("extension_perl_server not available: unable to start the perl server\n");
|
1999-03-17 05:53:10 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
args = g_new0 (Argument, pserver_proc->num_args);
|
|
|
|
for (i = 0; i < pserver_proc->num_args; i++)
|
|
|
|
args[i].arg_type = pserver_proc->args[i].arg_type;
|
|
|
|
|
|
|
|
args[0].value.pdb_int = run_mode;
|
|
|
|
args[1].value.pdb_int = flags;
|
|
|
|
args[2].value.pdb_int = extra;
|
|
|
|
|
|
|
|
vals = procedural_db_execute ("extension_perl_server", args);
|
|
|
|
switch (vals[0].value.pdb_int)
|
|
|
|
{
|
|
|
|
case PDB_EXECUTION_ERROR:
|
1999-09-23 19:49:16 +08:00
|
|
|
g_print ("perl server: experienced an execution error.\n");
|
1999-03-17 05:53:10 +08:00
|
|
|
break;
|
|
|
|
case PDB_CALLING_ERROR:
|
1999-09-23 19:49:16 +08:00
|
|
|
g_print ("perl server: experienced a calling error.\n");
|
1999-03-17 05:53:10 +08:00
|
|
|
break;
|
|
|
|
case PDB_SUCCESS:
|
1999-09-23 19:49:16 +08:00
|
|
|
g_print ("perl server: executed successfully.\n");
|
1999-03-17 05:53:10 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
procedural_db_destroy_args (vals, pserver_proc->num_values);
|
|
|
|
g_free(args);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|