2000-06-02 01:34:56 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpproceduraldb.c
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2000-06-02 01:34:56 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2000-06-02 01:34:56 +08:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2000-06-02 01:34:56 +08:00
|
|
|
*/
|
|
|
|
|
2002-05-14 07:30:23 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-05-26 06:04:21 +08:00
|
|
|
#include <string.h> /* memcmp */
|
|
|
|
|
2000-06-02 01:34:56 +08:00
|
|
|
#include "gimp.h"
|
|
|
|
|
2000-08-25 08:37:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedural_db_proc_info:
|
|
|
|
* @procedure: The procedure name.
|
|
|
|
* @blurb: A short blurb.
|
|
|
|
* @help: Detailed procedure help.
|
|
|
|
* @author: Author(s) of the procedure.
|
|
|
|
* @copyright: The copyright.
|
|
|
|
* @date: Copyright date.
|
|
|
|
* @proc_type: The procedure type.
|
|
|
|
* @num_args: The number of input arguments.
|
|
|
|
* @num_values: The number of return values.
|
|
|
|
* @args: The input arguments.
|
|
|
|
* @return_vals: The return values.
|
|
|
|
*
|
|
|
|
* Queries the procedural database for information on the specified
|
|
|
|
* procedure.
|
|
|
|
*
|
|
|
|
* This procedure returns information on the specified procedure. A
|
|
|
|
* short blurb, detailed help, author(s), copyright information,
|
2003-12-05 23:55:15 +08:00
|
|
|
* procedure type, number of input, and number of return values are
|
|
|
|
* returned. Additionally this function returns specific information
|
2000-08-25 08:37:35 +08:00
|
|
|
* about each input argument and return value.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*/
|
2000-06-02 01:34:56 +08:00
|
|
|
gboolean
|
2003-07-02 02:11:18 +08:00
|
|
|
gimp_procedural_db_proc_info (const gchar *procedure,
|
2006-04-12 18:53:28 +08:00
|
|
|
gchar **blurb,
|
|
|
|
gchar **help,
|
|
|
|
gchar **author,
|
|
|
|
gchar **copyright,
|
|
|
|
gchar **date,
|
|
|
|
GimpPDBProcType *proc_type,
|
|
|
|
gint *num_args,
|
|
|
|
gint *num_values,
|
|
|
|
GimpParamDef **args,
|
|
|
|
GimpParamDef **return_vals)
|
2000-06-02 01:34:56 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
2000-08-23 09:44:59 +08:00
|
|
|
success = _gimp_procedural_db_proc_info (procedure,
|
2006-04-12 18:53:28 +08:00
|
|
|
blurb,
|
|
|
|
help,
|
|
|
|
author,
|
|
|
|
copyright,
|
|
|
|
date,
|
|
|
|
proc_type,
|
|
|
|
num_args,
|
|
|
|
num_values);
|
2000-06-02 01:34:56 +08:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
*args = g_new (GimpParamDef, *num_args);
|
|
|
|
*return_vals = g_new (GimpParamDef, *num_values);
|
|
|
|
|
|
|
|
for (i = 0; i < *num_args; i++)
|
|
|
|
{
|
|
|
|
if (! gimp_procedural_db_proc_arg (procedure,
|
2006-04-12 18:53:28 +08:00
|
|
|
i,
|
|
|
|
&(*args)[i].type,
|
|
|
|
&(*args)[i].name,
|
|
|
|
&(*args)[i].description))
|
2000-06-02 01:34:56 +08:00
|
|
|
{
|
|
|
|
g_free (*args);
|
|
|
|
g_free (*return_vals);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < *num_values; i++)
|
|
|
|
{
|
|
|
|
if (! gimp_procedural_db_proc_val (procedure,
|
2006-04-12 18:53:28 +08:00
|
|
|
i,
|
|
|
|
&(*return_vals)[i].type,
|
|
|
|
&(*return_vals)[i].name,
|
|
|
|
&(*return_vals)[i].description))
|
2000-06-02 01:34:56 +08:00
|
|
|
{
|
|
|
|
g_free (*args);
|
|
|
|
g_free (*return_vals);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2000-08-25 08:37:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedural_db_get_data:
|
|
|
|
* @identifier: The identifier associated with data.
|
|
|
|
* @data: A byte array containing data.
|
|
|
|
*
|
|
|
|
* Returns data associated with the specified identifier.
|
|
|
|
*
|
|
|
|
* This procedure returns any data which may have been associated with
|
2003-12-05 23:55:15 +08:00
|
|
|
* the specified identifier. The data is copied into the given memory
|
2000-08-25 08:37:35 +08:00
|
|
|
* location.
|
|
|
|
*
|
2003-12-05 23:55:15 +08:00
|
|
|
* Returns: TRUE on success, FALSE if no data has been associated with
|
2000-08-25 08:37:35 +08:00
|
|
|
* the identifier
|
|
|
|
*/
|
2000-08-23 19:22:08 +08:00
|
|
|
gboolean
|
2003-07-02 02:11:18 +08:00
|
|
|
gimp_procedural_db_get_data (const gchar *identifier,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data)
|
2000-06-02 01:34:56 +08:00
|
|
|
{
|
2000-08-23 19:22:08 +08:00
|
|
|
gint size;
|
|
|
|
guint8 *hack;
|
|
|
|
gboolean success;
|
2000-06-03 10:04:33 +08:00
|
|
|
|
2000-08-23 19:22:08 +08:00
|
|
|
success = _gimp_procedural_db_get_data (identifier,
|
2006-04-12 18:53:28 +08:00
|
|
|
&size,
|
|
|
|
&hack);
|
2000-06-03 10:04:33 +08:00
|
|
|
if (hack)
|
|
|
|
{
|
2006-05-02 16:50:24 +08:00
|
|
|
memcpy (data, (gconstpointer) hack, size * sizeof (guint8));
|
2000-06-03 10:04:33 +08:00
|
|
|
g_free (hack);
|
|
|
|
}
|
2003-12-05 23:55:15 +08:00
|
|
|
|
2000-08-23 19:22:08 +08:00
|
|
|
return success;
|
2000-06-02 01:34:56 +08:00
|
|
|
}
|
|
|
|
|
2000-08-25 08:37:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_procedural_db_set_data:
|
|
|
|
* @identifier: The identifier associated with data.
|
|
|
|
* @data: A byte array containing data.
|
2000-08-25 08:47:03 +08:00
|
|
|
* @bytes: The number of bytes in the data
|
2000-08-25 08:37:35 +08:00
|
|
|
*
|
|
|
|
* Associates the specified identifier with the supplied data.
|
|
|
|
*
|
|
|
|
* This procedure associates the supplied data with the provided
|
|
|
|
* identifier. The data may be subsequently retrieved by a call to
|
|
|
|
* 'procedural-db-get-data'.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*/
|
2000-08-23 19:22:08 +08:00
|
|
|
gboolean
|
2006-05-02 16:50:24 +08:00
|
|
|
gimp_procedural_db_set_data (const gchar *identifier,
|
|
|
|
gconstpointer data,
|
|
|
|
guint32 bytes)
|
2000-06-02 01:34:56 +08:00
|
|
|
{
|
2000-08-23 19:22:08 +08:00
|
|
|
return _gimp_procedural_db_set_data (identifier,
|
2006-04-12 18:53:28 +08:00
|
|
|
bytes,
|
|
|
|
data);
|
2000-06-02 01:34:56 +08:00
|
|
|
}
|