gimp/app/fileops_cmds.c

493 lines
12 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
#include "procedural_db.h"
#include "config.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "fileops.h"
#include "gimprc.h"
#include "plug_in.h"
#include "libgimp/gimpintl.h"
static ProcRecord file_load_proc;
static ProcRecord file_save_proc;
static ProcRecord temp_name_proc;
static ProcRecord register_magic_load_handler_proc;
static ProcRecord register_load_handler_proc;
static ProcRecord register_save_handler_proc;
void
register_fileops_procs (void)
{
procedural_db_register (&file_load_proc);
procedural_db_register (&file_save_proc);
procedural_db_register (&temp_name_proc);
procedural_db_register (&register_magic_load_handler_proc);
procedural_db_register (&register_load_handler_proc);
procedural_db_register (&register_save_handler_proc);
}
static Argument *
file_load_invoker (Argument *args)
{
PlugInProcDef *file_proc;
ProcRecord *proc;
file_proc = file_proc_find (load_procs, (gchar *) args[2].value.pdb_pointer);
if (!file_proc)
return procedural_db_return_args (&file_load_proc, FALSE);
proc = &file_proc->db_info;
return procedural_db_execute (proc->name, args);
}
static ProcArg file_load_inargs[] =
{
{
PDB_INT32,
"run_mode",
add sample_colorize and curve_bend defs * plug-ins/common/plugin-defs.pl: add sample_colorize and curve_bend defs * libgimp/color_selector.h: minor consistency cleanup * libgimp/gimpchainbutton.[ch]: use new style gtk object helper macros * libgimp/gimpfileselection.c * libgimp/gimpmatrix.h: minor cleanup * libgimp/gimpintl.h: resync with gnome-i18n.h * libgimp/color_display.h * app/gimp.sym * app/gdisplay_color.[ch] * app/app_procs.c * app/gdisplay.h * app/image_render.c: color display transformation code. Still unfinished, so it's not activated yet. * app/buildmenu.h: remove unused defines (PULLDOWN, POPUP, OPTION) * app/colormaps.[ch] * app/image_render.c: remove vestigal dithering stuff * app/convolve.h * app/gimpdrawable.h * app/gimpimage.h * app/lut_funcs.h * app/paint_funcs.h * app/plug_in.h: enum nick changes from Marc * app/channel_ops.c * app/crop.c * app/gdisplay.c * app/gimpimage.[ch] * app/move.c: s/([A-Z]+)_GUIDE/ORIENTATION_$1/ * app/flip_tool.[ch] * app/shear_tool.[ch]: use ORIENTATION_* constants instead of our own * app/disp_callbacks.c: remove HORIZONTAL and VERTICAL #defines * app/general.h: enumified TOKEN_* symbols * app/lc_dialog.c * app/paint_funcs.c: remove unused variables * tools/pdbgen/lib.pl: autogen gimpenums.h (unfinished) * tools/pdbgen/stddefs.pdb: new std_orientation_enum, remove layer_mode shortcut since we've skipped it in app/ * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gimage.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: reflect above enum changes, whitespace cleanups * tools/pdbgen/enums.pl * app/brush_select_cmds.c * app/brushes_cmds.c * app/color_cmds.c * app/drawable_cmds.c * app/gimage_cmds.c * app/layer_cmds.c * app/procedural_db_cmds.c * app/tools_cmds.c: reflect pdb and enum nick changes above -Yosh
1999-07-29 07:00:08 +08:00
"The run mode: RUN_INTERACTIVE (0) or RUN_NONINTERACTIVE (1)"
},
{
PDB_STRING,
"filename",
"The name of the file to load"
},
{
PDB_STRING,
"raw_filename",
"The name entered"
}
};
static ProcArg file_load_outargs[] =
{
{
PDB_IMAGE,
"image",
"The output image"
}
};
static ProcRecord file_load_proc =
{
"gimp_file_load",
"Loads a file by extension.",
"This procedure invokes the correct file load handler according to the file's extension and/or prefix. The name of the file to load is typically a full pathname, and the name entered is what the user actually typed before prepending a directory path. The reason for this is that if the user types http://www.xcf/~gimp/ he wants to fetch a URL, and the full pathname will not look like a URL.",
"Josh MacDonald",
"Josh MacDonald",
"1997",
PDB_INTERNAL,
3,
file_load_inargs,
1,
file_load_outargs,
{ { file_load_invoker } }
};
static Argument *
file_save_invoker (Argument *args)
{
Argument *new_args;
Argument *return_vals;
PlugInProcDef *file_proc;
ProcRecord *proc;
gint i;
1999-05-02 05:48:26 +08:00
file_proc = file_proc_find (save_procs, (gchar *) args[4].value.pdb_pointer);
if (!file_proc)
return procedural_db_return_args (&file_save_proc, FALSE);
proc = &file_proc->db_info;
new_args = g_new (Argument, proc->num_args);
memset (new_args, 0, sizeof (Argument) * proc->num_args);
memcpy (new_args, args, sizeof (Argument) * 5);
for (i=5; i<proc->num_args; i++)
{
new_args[i].arg_type = proc->args[i].arg_type;
if (proc->args[i].arg_type == PDB_STRING)
new_args[i].value.pdb_pointer = g_strdup("\0");
}
return_vals = procedural_db_execute (proc->name, new_args);
g_free (new_args);
return return_vals;
}
static ProcArg file_save_inargs[] =
{
{
PDB_INT32,
"run_mode",
add sample_colorize and curve_bend defs * plug-ins/common/plugin-defs.pl: add sample_colorize and curve_bend defs * libgimp/color_selector.h: minor consistency cleanup * libgimp/gimpchainbutton.[ch]: use new style gtk object helper macros * libgimp/gimpfileselection.c * libgimp/gimpmatrix.h: minor cleanup * libgimp/gimpintl.h: resync with gnome-i18n.h * libgimp/color_display.h * app/gimp.sym * app/gdisplay_color.[ch] * app/app_procs.c * app/gdisplay.h * app/image_render.c: color display transformation code. Still unfinished, so it's not activated yet. * app/buildmenu.h: remove unused defines (PULLDOWN, POPUP, OPTION) * app/colormaps.[ch] * app/image_render.c: remove vestigal dithering stuff * app/convolve.h * app/gimpdrawable.h * app/gimpimage.h * app/lut_funcs.h * app/paint_funcs.h * app/plug_in.h: enum nick changes from Marc * app/channel_ops.c * app/crop.c * app/gdisplay.c * app/gimpimage.[ch] * app/move.c: s/([A-Z]+)_GUIDE/ORIENTATION_$1/ * app/flip_tool.[ch] * app/shear_tool.[ch]: use ORIENTATION_* constants instead of our own * app/disp_callbacks.c: remove HORIZONTAL and VERTICAL #defines * app/general.h: enumified TOKEN_* symbols * app/lc_dialog.c * app/paint_funcs.c: remove unused variables * tools/pdbgen/lib.pl: autogen gimpenums.h (unfinished) * tools/pdbgen/stddefs.pdb: new std_orientation_enum, remove layer_mode shortcut since we've skipped it in app/ * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gimage.pdb * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: reflect above enum changes, whitespace cleanups * tools/pdbgen/enums.pl * app/brush_select_cmds.c * app/brushes_cmds.c * app/color_cmds.c * app/drawable_cmds.c * app/gimage_cmds.c * app/layer_cmds.c * app/procedural_db_cmds.c * app/tools_cmds.c: reflect pdb and enum nick changes above -Yosh
1999-07-29 07:00:08 +08:00
"The run mode: RUN_INTERACTIVE (0) or RUN_NONINTERACTIVE (1)"
},
{
PDB_IMAGE,
"image",
"Input image"
},
{
PDB_DRAWABLE,
"drawable",
"Drawable to save"
},
{
PDB_STRING,
"filename",
"The name of the file to save the image in"
},
{
PDB_STRING,
"raw_filename",
"The name of the file to save the image in"
}
};
static ProcRecord file_save_proc =
{
"gimp_file_save",
"Saves a file by extension.",
"This procedure invokes the correct file save handler according to the file's extension and/or prefix. The name of the file to save is typically a full pathname, and the name entered is what the user actually typed before prepending a directory path. The reason for this is that if the user types http://www.xcf/~gimp/ she wants to fetch a URL, and the full pathname will not look like a URL.",
"Josh MacDonald",
"Josh MacDonald",
"1997",
PDB_INTERNAL,
5,
file_save_inargs,
0,
NULL,
{ { file_save_invoker } }
};
static Argument *
temp_name_invoker (Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *extension;
gchar *name = NULL;
static gint id = 0;
static gint pid;
extension = (gchar *) args[0].value.pdb_pointer;
if (extension == NULL)
success = FALSE;
if (success)
{
if (id == 0)
pid = getpid();
name = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp_temp.%d%d.%s",
temp_path, pid, id++, extension);
}
return_args = procedural_db_return_args (&temp_name_proc, success);
if (success)
return_args[1].value.pdb_pointer = name;
return return_args;
}
static ProcArg temp_name_inargs[] =
{
{
PDB_STRING,
"extension",
"The extension the file will have"
}
};
static ProcArg temp_name_outargs[] =
{
{
PDB_STRING,
"name",
"The new temp filename"
}
};
static ProcRecord temp_name_proc =
{
"gimp_temp_name",
"Generates a unique filename.",
"Generates a unique filename using the temp path supplied in the user's gimprc.",
"Josh MacDonald",
"Josh MacDonald",
"1997",
PDB_INTERNAL,
1,
temp_name_inargs,
1,
temp_name_outargs,
{ { temp_name_invoker } }
};
static Argument *
register_magic_load_handler_invoker (Argument *args)
{
gboolean success = TRUE;
gchar *name;
gchar *extensions;
gchar *prefixes;
gchar *magics;
ProcRecord *proc;
PlugInProcDef *file_proc;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL)
success = FALSE;
extensions = (gchar *) args[1].value.pdb_pointer;
prefixes = (gchar *) args[2].value.pdb_pointer;
magics = (gchar *) args[3].value.pdb_pointer;
if (success)
{
success = FALSE;
proc = procedural_db_lookup (name);
if (proc && ((proc->num_args < 3) ||
(proc->num_values < 1) ||
(proc->args[0].arg_type != PDB_INT32) ||
(proc->args[1].arg_type != PDB_STRING) ||
(proc->args[2].arg_type != PDB_STRING) ||
(proc->values[0].arg_type != PDB_IMAGE)))
{
g_message (_("load handler \"%s\" does not take the standard load handler args"),
name);
goto done;
}
file_proc = plug_in_file_handler (name, extensions, prefixes, magics);
if (!file_proc)
{
g_message (_("attempt to register non-existant load handler \"%s\""),
name);
goto done;
}
load_procs = g_slist_prepend (load_procs, file_proc);
success = TRUE;
Win32 portability changes: * config.h.win32, README.win32: Small changes. * tools/pdbgen/pdb/*.pdb: Include <string.h>. * app/*_cmds.c: Autogenerated files reflect above changes. * libgimp/makefile.msc app/makefile.msc: Various updates, including new object files. Gtk+ directory now should be called gtk+ (not gtk-plus). Use win32-specific gdk subdir. Glib directory now should be called just glib. * libgimp/gimp.def: Updates. * libgimp/gimpfeatures.h.win32: Made current with gimpfeatures.h.in. * libgimp/gimpfileselection.c: Define S_ISDIR and S_ISREG if necessary. * tools/pdbgen/pdb/fileops.pdb: Must have a statement (even an empty one) after a label. * app/fileops_cmds.c: Autogenerated file reflects above changes. * app/crop.c: Include <string.h>. * app/{app_procs,batch,fileops,datafiles,errorconsole,general, plug_in,temp_buf,tile_swap}.c: Test NATIVE_WIN32, not _MSC_VER. (NATIVE_WIN32 means we are using the Microsoft C runtime, even if we might be compiling with gcc.) * app/fileops.c: Don't include <process.h> here. * app/fileops.h: Do include <process.h> here. * app/gimpparasite.c: Include config.h, guard inclusion of <unistd.h>. (Is the inclusion of unistd.h in source files all over the place really necessary?) * app/ink.c: MSC doesn't handle conversion from unsigned __int64 to double, so cast to signed. * app/lut_funcs.c: Include config.h, and define rint() if necessary. * app/pixel_processor.c: Include config.h without "..", like in all the other places. Include <string.h> * app/text_tool.c: Guard the "POINTS" identifier that clashes with <windows.h>, sigh.
1999-05-05 05:32:17 +08:00
done: ;
}
return procedural_db_return_args (&register_magic_load_handler_proc, success);
}
static ProcArg register_magic_load_handler_inargs[] =
{
{
PDB_STRING,
"procedure_name",
"The name of the procedure to be used for loading"
},
{
PDB_STRING,
"extensions",
"comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\")"
},
{
PDB_STRING,
"prefixes",
"comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\")"
},
{
PDB_STRING,
"magics",
"comma separated list of magic file information this handler can load (i.e. \"0,string,GIF\")"
}
};
static ProcRecord register_magic_load_handler_proc =
{
"gimp_register_magic_load_handler",
"Registers a file load handler procedure.",
"Registers a procedural database procedure to be called to load files of a particular file format using magic file information.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
4,
register_magic_load_handler_inargs,
0,
NULL,
{ { register_magic_load_handler_invoker } }
};
static Argument *
register_load_handler_invoker (Argument *args)
{
int i;
Argument argv[4];
for (i = 0; i < 3; i++)
argv[i] = args[i];
argv[3].arg_type = PDB_STRING;
argv[3].value.pdb_pointer = NULL;
return register_magic_load_handler_invoker (argv);
}
static ProcArg register_load_handler_inargs[] =
{
{
PDB_STRING,
"procedure_name",
"The name of the procedure to be used for loading"
},
{
PDB_STRING,
"extensions",
"comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\")"
},
{
PDB_STRING,
"prefixes",
"comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\")"
}
};
static ProcRecord register_load_handler_proc =
{
"gimp_register_load_handler",
"Registers a file load handler procedure.",
"Registers a procedural database procedure to be called to load files of a particular file format.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
3,
register_load_handler_inargs,
0,
NULL,
{ { register_load_handler_invoker } }
};
static Argument *
register_save_handler_invoker (Argument *args)
{
gboolean success = TRUE;
gchar *name;
gchar *extensions;
gchar *prefixes;
ProcRecord *proc;
PlugInProcDef *file_proc;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL)
success = FALSE;
extensions = (gchar *) args[1].value.pdb_pointer;
prefixes = (gchar *) args[2].value.pdb_pointer;
if (success)
{
success = FALSE;
proc = procedural_db_lookup (name);
if (proc && ((proc->num_args < 5) ||
(proc->args[0].arg_type != PDB_INT32) ||
(proc->args[1].arg_type != PDB_IMAGE) ||
(proc->args[2].arg_type != PDB_DRAWABLE) ||
(proc->args[3].arg_type != PDB_STRING) ||
(proc->args[4].arg_type != PDB_STRING)))
{
g_message (_("save handler \"%s\" does not take the standard save handler args"),
name);
goto done;
}
file_proc = plug_in_file_handler (name, extensions, prefixes, NULL);
if (!file_proc)
{
g_message (_("attempt to register non-existant save handler \"%s\""),
name);
goto done;
}
save_procs = g_slist_prepend (save_procs, file_proc);
success = TRUE;
Win32 portability changes: * config.h.win32, README.win32: Small changes. * tools/pdbgen/pdb/*.pdb: Include <string.h>. * app/*_cmds.c: Autogenerated files reflect above changes. * libgimp/makefile.msc app/makefile.msc: Various updates, including new object files. Gtk+ directory now should be called gtk+ (not gtk-plus). Use win32-specific gdk subdir. Glib directory now should be called just glib. * libgimp/gimp.def: Updates. * libgimp/gimpfeatures.h.win32: Made current with gimpfeatures.h.in. * libgimp/gimpfileselection.c: Define S_ISDIR and S_ISREG if necessary. * tools/pdbgen/pdb/fileops.pdb: Must have a statement (even an empty one) after a label. * app/fileops_cmds.c: Autogenerated file reflects above changes. * app/crop.c: Include <string.h>. * app/{app_procs,batch,fileops,datafiles,errorconsole,general, plug_in,temp_buf,tile_swap}.c: Test NATIVE_WIN32, not _MSC_VER. (NATIVE_WIN32 means we are using the Microsoft C runtime, even if we might be compiling with gcc.) * app/fileops.c: Don't include <process.h> here. * app/fileops.h: Do include <process.h> here. * app/gimpparasite.c: Include config.h, guard inclusion of <unistd.h>. (Is the inclusion of unistd.h in source files all over the place really necessary?) * app/ink.c: MSC doesn't handle conversion from unsigned __int64 to double, so cast to signed. * app/lut_funcs.c: Include config.h, and define rint() if necessary. * app/pixel_processor.c: Include config.h without "..", like in all the other places. Include <string.h> * app/text_tool.c: Guard the "POINTS" identifier that clashes with <windows.h>, sigh.
1999-05-05 05:32:17 +08:00
done: ;
}
return procedural_db_return_args (&register_save_handler_proc, success);
}
static ProcArg register_save_handler_inargs[] =
{
{
PDB_STRING,
"procedure_name",
"The name of the procedure to be used for saving"
},
{
PDB_STRING,
"extensions",
"comma separated list of extensions this handler can save (i.e. \"jpg,jpeg\")"
},
{
PDB_STRING,
"prefixes",
"comma separated list of prefixes this handler can save (i.e. \"http:,ftp:\")"
}
};
static ProcRecord register_save_handler_proc =
{
"gimp_register_save_handler",
"Registers a file save handler procedure.",
"Registers a procedural database procedure to be called to save files in a particular file format.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
3,
register_save_handler_inargs,
0,
NULL,
{ { register_save_handler_invoker } }
};