home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / libgimp / gimpproceduraldb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-25  |  4.8 KB  |  171 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpproceduraldb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. #include "gimp.h"
  23.  
  24. /**
  25.  * gimp_procedural_db_proc_info:
  26.  * @procedure: The procedure name.
  27.  * @blurb: A short blurb.
  28.  * @help: Detailed procedure help.
  29.  * @author: Author(s) of the procedure.
  30.  * @copyright: The copyright.
  31.  * @date: Copyright date.
  32.  * @proc_type: The procedure type.
  33.  * @num_args: The number of input arguments.
  34.  * @num_values: The number of return values.
  35.  * @args: The input arguments.
  36.  * @return_vals: The return values.
  37.  *
  38.  * Queries the procedural database for information on the specified
  39.  * procedure.
  40.  *
  41.  * This procedure returns information on the specified procedure. A
  42.  * short blurb, detailed help, author(s), copyright information,
  43.  * procedure type, number of input, and number of return values are 
  44.  * returned. Additionally this function returns specific information 
  45.  * about each input argument and return value.
  46.  *
  47.  * Returns: TRUE on success.
  48.  */
  49. gboolean
  50. gimp_procedural_db_proc_info (gchar            *procedure,
  51.                   gchar           **blurb,
  52.                   gchar           **help,
  53.                   gchar           **author,
  54.                   gchar           **copyright,
  55.                   gchar           **date,
  56.                   GimpPDBProcType  *proc_type,
  57.                   gint             *num_args,
  58.                   gint             *num_values,
  59.                   GimpParamDef    **args,
  60.                   GimpParamDef    **return_vals)
  61. {
  62.   gint i;
  63.   gboolean success = TRUE;
  64.  
  65.   success = _gimp_procedural_db_proc_info (procedure,
  66.                        blurb,
  67.                        help,
  68.                        author,
  69.                        copyright,
  70.                        date,
  71.                        proc_type,
  72.                        num_args,
  73.                        num_values);
  74.  
  75.   if (success)
  76.     {
  77.       *args        = g_new (GimpParamDef, *num_args);
  78.       *return_vals = g_new (GimpParamDef, *num_values);
  79.  
  80.       for (i = 0; i < *num_args; i++)
  81.         {
  82.           if (! gimp_procedural_db_proc_arg (procedure,
  83.                          i,
  84.                          &(*args)[i].type,
  85.                          &(*args)[i].name,
  86.                          &(*args)[i].description))
  87.             {
  88.               g_free (*args);
  89.               g_free (*return_vals);
  90.  
  91.               return FALSE;
  92.             }
  93.         }
  94.  
  95.       for (i = 0; i < *num_values; i++)
  96.         {
  97.           if (! gimp_procedural_db_proc_val (procedure,
  98.                          i,
  99.                          &(*return_vals)[i].type,
  100.                          &(*return_vals)[i].name,
  101.                          &(*return_vals)[i].description))
  102.             {
  103.               g_free (*args);
  104.               g_free (*return_vals);
  105.  
  106.               return FALSE;
  107.             }
  108.         }
  109.      }
  110.  
  111.   return success;
  112. }
  113.  
  114. /**
  115.  * gimp_procedural_db_get_data:
  116.  * @identifier: The identifier associated with data.
  117.  * @data: A byte array containing data.
  118.  *
  119.  * Returns data associated with the specified identifier.
  120.  *
  121.  * This procedure returns any data which may have been associated with
  122.  * the specified identifier. The data is copied into the given memory 
  123.  * location.
  124.  *
  125.  * Returns: TRUE on success, FALSE if no data has been associated with 
  126.  * the identifier
  127.  */
  128. gboolean
  129. gimp_procedural_db_get_data (gchar    *identifier,
  130.                  gpointer  data)
  131. {
  132.   gint      size;
  133.   guint8   *hack;
  134.   gboolean  success;
  135.  
  136.   success = _gimp_procedural_db_get_data (identifier,
  137.                       &size,
  138.                       &hack);
  139.   if (hack)
  140.     {
  141.       memcpy (data, (gpointer) hack, size * sizeof (guint8));
  142.       g_free (hack);
  143.     }
  144.   
  145.   return success;
  146. }
  147.  
  148. /**
  149.  * gimp_procedural_db_set_data:
  150.  * @identifier: The identifier associated with data.
  151.  * @data: A byte array containing data.
  152.  * @bytes: The number of bytes in the data
  153.  *
  154.  * Associates the specified identifier with the supplied data.
  155.  *
  156.  * This procedure associates the supplied data with the provided
  157.  * identifier. The data may be subsequently retrieved by a call to
  158.  * 'procedural-db-get-data'.
  159.  *
  160.  * Returns: TRUE on success.
  161.  */
  162. gboolean
  163. gimp_procedural_db_set_data (gchar    *identifier,
  164.                  gpointer  data,
  165.                  guint32   bytes)
  166. {
  167.   return _gimp_procedural_db_set_data (identifier,
  168.                        bytes,
  169.                        data);
  170. }
  171.