gimp/libgimp/gimpproceduraldb_pdb.c

228 lines
6.1 KiB
C
Raw Normal View History

Sven Neumann <sven@gimp.org> 2000-05-31 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Episode IV... * app/Makefile.am * app/message_cmds.c: new name * app/interface_cmds.c: removed * app/help_cmds.c: new name * app/gimphelp_cmds.c: removed * app/internal_procs.c * app/gimphelp_cmds.c * app/plug_in_cmds.c: moved gimp_plugin_help_register to plug_in_cmds.c, s/gimp_plugin_domain_add/gimp_plugin_domain_register/ * libgimp/Makefile.am * libgimp/gimp_pdb.h * libgimp/gimpfileops_pdb.[ch] * libgimp/gimpguides_pdb.[ch] * libgimp/gimpmessage_pdb.[ch] * libgimp/gimpprocedural_db_pdb.[ch] * libgimp/gimpplugin_pdb.[ch]: new files containing PDB wrappers moved out of libgimp/gimp.[ch] * libgimp/gimpchannel_pdb.c * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpdrawable_pdb.[ch] * libgimp/gimphelp_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimplayer_pdb.c * libgimp/gimpparasite_pdb.c * libgimp/gimpselection_pdb.c: various changes. * libgimp/gimpunit.c: new file * libgimp/gimpunit_pdb.[ch]: contains only PDB wrappers prefixed with "_" which are called from libgimp/gimpunit.c only. * libgimp/gimpunit.h: minor stuff * libgimp/gimpcompat.h: declared the following functions obsolete: gimp_query_database gimp_query_images * libgimp/gimp.[ch]: removed all PDB wrappers. * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl: changed * tools/pdbgen/lib.pl: tried to fix libgimp autogeneration and fixed just a few comments. * tools/pdbgen/pdb/interface.pdb * tools/pdbgen/pdb/gimphelp.pdb: removed * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/message.pdb: new names * plug-ins/script-fu/script-fu.c * plug-ins/perl/Gimp/Lib.xs: s/gimp_plugin_domain_add/gimp_plugin_domain_register/ 2000-05-31 Michael Natterer <mitch@gimp.org> * POTFILES.in: s/gimpunit_pdb/gimpunit/
2000-05-31 21:24:14 +08:00
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* gimpproceduraldb_pdb.c
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gimp.h"
void
gimp_procedural_db_set_data (gchar *id,
gpointer data,
guint32 length)
{
GimpParam *return_vals;
int nreturn_vals;
return_vals = gimp_run_procedure ("gimp_procedural_db_set_data",
&nreturn_vals,
PARAM_STRING, id,
PARAM_INT32, length,
PARAM_INT8ARRAY, data,
PARAM_END);
gimp_destroy_params (return_vals, nreturn_vals);
}
guint32
gimp_procedural_db_get_data_size (gchar *id)
{
GimpParam *return_vals;
gint nreturn_vals;
guint32 length;
return_vals = gimp_run_procedure ("gimp_procedural_db_get_data_size",
&nreturn_vals,
PARAM_STRING, id,
PARAM_END);
if (return_vals[0].data.d_status == STATUS_SUCCESS)
length= return_vals[1].data.d_int32;
else
length= 0;
gimp_destroy_params (return_vals, nreturn_vals);
return length;
}
void
gimp_procedural_db_get_data (gchar *id,
gpointer data)
{
GimpParam *return_vals;
gint nreturn_vals;
gint length;
gchar *returned_data;
return_vals = gimp_run_procedure ("gimp_procedural_db_get_data",
&nreturn_vals,
PARAM_STRING, id,
PARAM_END);
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
length = return_vals[1].data.d_int32;
returned_data = (gchar *) return_vals[2].data.d_int8array;
memcpy (data, returned_data, length);
}
gimp_destroy_params (return_vals, nreturn_vals);
}
void
gimp_procedural_db_query (gchar *name_regexp,
gchar *blurb_regexp,
gchar *help_regexp,
gchar *author_regexp,
gchar *copyright_regexp,
gchar *date_regexp,
gchar *proc_type_regexp,
gint *nprocs,
gchar ***proc_names)
{
GimpParam *return_vals;
gint nreturn_vals;
gint i;
return_vals = gimp_run_procedure ("gimp_procedural_db_query",
&nreturn_vals,
PARAM_STRING, name_regexp,
PARAM_STRING, blurb_regexp,
PARAM_STRING, help_regexp,
PARAM_STRING, author_regexp,
PARAM_STRING, copyright_regexp,
PARAM_STRING, date_regexp,
PARAM_STRING, proc_type_regexp,
PARAM_END);
*nprocs = 0;
*proc_names = NULL;
if (return_vals[0].data.d_status == STATUS_SUCCESS)
{
*nprocs = return_vals[1].data.d_int32;
*proc_names = g_new (gchar*, *nprocs);
for (i = 0; i < *nprocs; i++)
(*proc_names)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
}
gimp_destroy_params (return_vals, nreturn_vals);
}
gboolean
gimp_procedural_db_proc_info (gchar *proc_name,
gchar **proc_blurb,
gchar **proc_help,
gchar **proc_author,
gchar **proc_copyright,
gchar **proc_date,
gint *proc_type,
gint *nparams,
gint *nreturn_vals,
GimpParamDef **params,
GimpParamDef **return_vals)
{
GimpParam *ret_vals;
gint nret_vals;
gint i;
gboolean success = TRUE;
ret_vals = gimp_run_procedure ("gimp_procedural_db_proc_info",
&nret_vals,
PARAM_STRING, proc_name,
PARAM_END);
if (ret_vals[0].data.d_status == STATUS_SUCCESS)
{
*proc_blurb = g_strdup (ret_vals[1].data.d_string);
*proc_help = g_strdup (ret_vals[2].data.d_string);
*proc_author = g_strdup (ret_vals[3].data.d_string);
*proc_copyright = g_strdup (ret_vals[4].data.d_string);
*proc_date = g_strdup (ret_vals[5].data.d_string);
*proc_type = ret_vals[6].data.d_int32;
*nparams = ret_vals[7].data.d_int32;
*nreturn_vals = ret_vals[8].data.d_int32;
*params = g_new (GimpParamDef, *nparams);
*return_vals = g_new (GimpParamDef, *nreturn_vals);
for (i = 0; i < *nparams; i++)
{
GimpParam *rvals;
gint nrvals;
rvals = gimp_run_procedure ("gimp_procedural_db_proc_arg",
&nrvals,
PARAM_STRING, proc_name,
PARAM_INT32, i,
PARAM_END);
if (rvals[0].data.d_status == STATUS_SUCCESS)
{
(* params) [i].type = rvals[1].data.d_int32;
(* params) [i].name = g_strdup (rvals[2].data.d_string);
(* params) [i].description = g_strdup (rvals[3].data.d_string);
}
else
{
g_free (*params);
g_free (*return_vals);
gimp_destroy_params (rvals, nrvals);
return FALSE;
}
gimp_destroy_params (rvals, nrvals);
}
for (i = 0; i < *nreturn_vals; i++)
{
GimpParam *rvals;
gint nrvals;
rvals = gimp_run_procedure ("gimp_procedural_db_proc_val",
&nrvals,
PARAM_STRING, proc_name,
PARAM_INT32, i,
PARAM_END);
if (rvals[0].data.d_status == STATUS_SUCCESS)
{
(* return_vals)[i].type = rvals[1].data.d_int32;
(* return_vals)[i].name = g_strdup (rvals[2].data.d_string);
(* return_vals)[i].description = g_strdup (rvals[3].data.d_string);
}
else
{
g_free (*params);
g_free (*return_vals);
gimp_destroy_params (rvals, nrvals);
return FALSE;
}
gimp_destroy_params (rvals, nrvals);
}
}
else
success = FALSE;
gimp_destroy_params (ret_vals, nret_vals);
return success;
}