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

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpproceduraldb_pdb.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. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include "gimp.h"
  25.  
  26. /**
  27.  * gimp_procedural_db_dump:
  28.  * @filename: The dump filename.
  29.  *
  30.  * Dumps the current contents of the procedural database
  31.  *
  32.  * This procedure dumps the contents of the procedural database to the
  33.  * specified file. The file will contain all of the information
  34.  * provided for each registered procedure. This file is in a format
  35.  * appropriate for use with the supplied \"pdb_self_doc.el\" Elisp
  36.  * script, which generates a texinfo document.
  37.  *
  38.  * Returns: TRUE on success.
  39.  */
  40. gboolean
  41. gimp_procedural_db_dump (gchar *filename)
  42. {
  43.   GimpParam *return_vals;
  44.   gint nreturn_vals;
  45.   gboolean success = TRUE;
  46.  
  47.   return_vals = gimp_run_procedure ("gimp_procedural_db_dump",
  48.                     &nreturn_vals,
  49.                     GIMP_PDB_STRING, filename,
  50.                     GIMP_PDB_END);
  51.  
  52.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  53.  
  54.   gimp_destroy_params (return_vals, nreturn_vals);
  55.  
  56.   return success;
  57. }
  58.  
  59. /**
  60.  * gimp_procedural_db_query:
  61.  * @name: The regex for procedure name.
  62.  * @blurb: The regex for procedure blurb.
  63.  * @help: The regex for procedure help.
  64.  * @author: The regex for procedure author.
  65.  * @copyright: The regex for procedure copyright.
  66.  * @date: The regex for procedure date.
  67.  * @proc_type: The regex for procedure type: { 'Internal GIMP procedure', 'GIMP Plug-in', 'GIMP Extension' }.
  68.  * @num_matches: The number of matching procedures.
  69.  * @procedure_names: The list of procedure names.
  70.  *
  71.  * Queries the procedural database for its contents using regular
  72.  * expression matching.
  73.  *
  74.  * This procedure queries the contents of the procedural database. It
  75.  * is supplied with seven arguments matching procedures on { name,
  76.  * blurb, help, author, copyright, date, procedure type}. This is
  77.  * accomplished using regular expression matching. For instance, to
  78.  * find all procedures with \"jpeg\" listed in the blurb, all seven
  79.  * arguments can be supplied as \".*\", except for the second, which
  80.  * can be supplied as \".*jpeg.*\". There are two return arguments for
  81.  * this procedure. The first is the number of procedures matching the
  82.  * query. The second is a concatenated list of procedure names
  83.  * corresponding to those matching the query. If no matching entries
  84.  * are found, then the returned string is NULL and the number of
  85.  * entries is 0.
  86.  *
  87.  * Returns: TRUE on success.
  88.  */
  89. gboolean
  90. gimp_procedural_db_query (gchar   *name,
  91.               gchar   *blurb,
  92.               gchar   *help,
  93.               gchar   *author,
  94.               gchar   *copyright,
  95.               gchar   *date,
  96.               gchar   *proc_type,
  97.               gint    *num_matches,
  98.               gchar ***procedure_names)
  99. {
  100.   GimpParam *return_vals;
  101.   gint nreturn_vals;
  102.   gboolean success = TRUE;
  103.   gint i;
  104.  
  105.   return_vals = gimp_run_procedure ("gimp_procedural_db_query",
  106.                     &nreturn_vals,
  107.                     GIMP_PDB_STRING, name,
  108.                     GIMP_PDB_STRING, blurb,
  109.                     GIMP_PDB_STRING, help,
  110.                     GIMP_PDB_STRING, author,
  111.                     GIMP_PDB_STRING, copyright,
  112.                     GIMP_PDB_STRING, date,
  113.                     GIMP_PDB_STRING, proc_type,
  114.                     GIMP_PDB_END);
  115.  
  116.   *num_matches = 0;
  117.   *procedure_names = NULL;
  118.  
  119.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  120.  
  121.   if (success)
  122.     {
  123.       *num_matches = return_vals[1].data.d_int32;
  124.       *procedure_names = g_new (gchar *, *num_matches);
  125.       for (i = 0; i < *num_matches; i++)
  126.     (*procedure_names)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
  127.     }
  128.  
  129.   gimp_destroy_params (return_vals, nreturn_vals);
  130.  
  131.   return success;
  132. }
  133.  
  134. /**
  135.  * _gimp_procedural_db_proc_info:
  136.  * @procedure: The procedure name.
  137.  * @blurb: A short blurb.
  138.  * @help: Detailed procedure help.
  139.  * @author: Author(s) of the procedure.
  140.  * @copyright: The copyright.
  141.  * @date: Copyright date.
  142.  * @proc_type: The procedure type.
  143.  * @num_args: The number of input arguments.
  144.  * @num_values: The number of return values.
  145.  *
  146.  * Queries the procedural database for information on the specified
  147.  * procedure.
  148.  *
  149.  * This procedure returns information on the specified procedure. A
  150.  * short blurb, detailed help, author(s), copyright information,
  151.  * procedure type, number of input, and number of return values are
  152.  * returned. For specific information on each input argument and return
  153.  * value, use the 'gimp_procedural_db_proc_arg' and
  154.  * 'gimp_procedural_db_proc_val' procedures.
  155.  *
  156.  * Returns: TRUE on success.
  157.  */
  158. gboolean
  159. _gimp_procedural_db_proc_info (gchar            *procedure,
  160.                    gchar           **blurb,
  161.                    gchar           **help,
  162.                    gchar           **author,
  163.                    gchar           **copyright,
  164.                    gchar           **date,
  165.                    GimpPDBProcType  *proc_type,
  166.                    gint             *num_args,
  167.                    gint             *num_values)
  168. {
  169.   GimpParam *return_vals;
  170.   gint nreturn_vals;
  171.   gboolean success = TRUE;
  172.  
  173.   return_vals = gimp_run_procedure ("gimp_procedural_db_proc_info",
  174.                     &nreturn_vals,
  175.                     GIMP_PDB_STRING, procedure,
  176.                     GIMP_PDB_END);
  177.  
  178.   *blurb = NULL;
  179.   *help = NULL;
  180.   *author = NULL;
  181.   *copyright = NULL;
  182.   *date = NULL;
  183.   *proc_type = 0;
  184.   *num_args = 0;
  185.   *num_values = 0;
  186.  
  187.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  188.  
  189.   if (success)
  190.     {
  191.       *blurb = g_strdup (return_vals[1].data.d_string);
  192.       *help = g_strdup (return_vals[2].data.d_string);
  193.       *author = g_strdup (return_vals[3].data.d_string);
  194.       *copyright = g_strdup (return_vals[4].data.d_string);
  195.       *date = g_strdup (return_vals[5].data.d_string);
  196.       *proc_type = return_vals[6].data.d_int32;
  197.       *num_args = return_vals[7].data.d_int32;
  198.       *num_values = return_vals[8].data.d_int32;
  199.     }
  200.  
  201.   gimp_destroy_params (return_vals, nreturn_vals);
  202.  
  203.   return success;
  204. }
  205.  
  206. /**
  207.  * gimp_procedural_db_proc_arg:
  208.  * @procedure: The procedure name.
  209.  * @arg_num: The argument number.
  210.  * @arg_type: The type of argument.
  211.  * @arg_name: The name of the argument.
  212.  * @arg_desc: A description of the argument.
  213.  *
  214.  * Queries the procedural database for information on the specified
  215.  * procedure's argument.
  216.  *
  217.  * This procedure returns information on the specified procedure's
  218.  * argument. The argument type, name, and a description are retrieved.
  219.  *
  220.  * Returns: TRUE on success.
  221.  */
  222. gboolean
  223. gimp_procedural_db_proc_arg (gchar           *procedure,
  224.                  gint             arg_num,
  225.                  GimpPDBArgType  *arg_type,
  226.                  gchar          **arg_name,
  227.                  gchar          **arg_desc)
  228. {
  229.   GimpParam *return_vals;
  230.   gint nreturn_vals;
  231.   gboolean success = TRUE;
  232.  
  233.   return_vals = gimp_run_procedure ("gimp_procedural_db_proc_arg",
  234.                     &nreturn_vals,
  235.                     GIMP_PDB_STRING, procedure,
  236.                     GIMP_PDB_INT32, arg_num,
  237.                     GIMP_PDB_END);
  238.  
  239.   *arg_type = 0;
  240.   *arg_name = NULL;
  241.   *arg_desc = NULL;
  242.  
  243.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  244.  
  245.   if (success)
  246.     {
  247.       *arg_type = return_vals[1].data.d_int32;
  248.       *arg_name = g_strdup (return_vals[2].data.d_string);
  249.       *arg_desc = g_strdup (return_vals[3].data.d_string);
  250.     }
  251.  
  252.   gimp_destroy_params (return_vals, nreturn_vals);
  253.  
  254.   return success;
  255. }
  256.  
  257. /**
  258.  * gimp_procedural_db_proc_val:
  259.  * @procedure: The procedure name.
  260.  * @val_num: The return value number.
  261.  * @val_type: The type of return value.
  262.  * @val_name: The name of the return value.
  263.  * @val_desc: A description of the return value.
  264.  *
  265.  * Queries the procedural database for information on the specified
  266.  * procedure's return value.
  267.  *
  268.  * This procedure returns information on the specified procedure's
  269.  * return value. The return value type, name, and a description are
  270.  * retrieved.
  271.  *
  272.  * Returns: TRUE on success.
  273.  */
  274. gboolean
  275. gimp_procedural_db_proc_val (gchar           *procedure,
  276.                  gint             val_num,
  277.                  GimpPDBArgType  *val_type,
  278.                  gchar          **val_name,
  279.                  gchar          **val_desc)
  280. {
  281.   GimpParam *return_vals;
  282.   gint nreturn_vals;
  283.   gboolean success = TRUE;
  284.  
  285.   return_vals = gimp_run_procedure ("gimp_procedural_db_proc_val",
  286.                     &nreturn_vals,
  287.                     GIMP_PDB_STRING, procedure,
  288.                     GIMP_PDB_INT32, val_num,
  289.                     GIMP_PDB_END);
  290.  
  291.   *val_type = 0;
  292.   *val_name = NULL;
  293.   *val_desc = NULL;
  294.  
  295.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  296.  
  297.   if (success)
  298.     {
  299.       *val_type = return_vals[1].data.d_int32;
  300.       *val_name = g_strdup (return_vals[2].data.d_string);
  301.       *val_desc = g_strdup (return_vals[3].data.d_string);
  302.     }
  303.  
  304.   gimp_destroy_params (return_vals, nreturn_vals);
  305.  
  306.   return success;
  307. }
  308.  
  309. /**
  310.  * _gimp_procedural_db_get_data:
  311.  * @identifier: The identifier associated with data.
  312.  * @bytes: The number of bytes in the data.
  313.  * @data: A byte array containing data.
  314.  *
  315.  * Returns data associated with the specified identifier.
  316.  *
  317.  * This procedure returns any data which may have been associated with
  318.  * the specified identifier. The data is a variable length array of
  319.  * bytes. If no data has been associated with the identifier, an error
  320.  * is returned.
  321.  *
  322.  * Returns: TRUE on success.
  323.  */
  324. gboolean
  325. _gimp_procedural_db_get_data (gchar   *identifier,
  326.                   gint    *bytes,
  327.                   guint8 **data)
  328. {
  329.   GimpParam *return_vals;
  330.   gint nreturn_vals;
  331.   gboolean success = TRUE;
  332.  
  333.   return_vals = gimp_run_procedure ("gimp_procedural_db_get_data",
  334.                     &nreturn_vals,
  335.                     GIMP_PDB_STRING, identifier,
  336.                     GIMP_PDB_END);
  337.  
  338.   *bytes = 0;
  339.   *data = NULL;
  340.  
  341.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  342.  
  343.   if (success)
  344.     {
  345.       *bytes = return_vals[1].data.d_int32;
  346.       *data = g_new (guint8, *bytes);
  347.       memcpy (*data, return_vals[2].data.d_int8array,
  348.           *bytes * sizeof (guint8));
  349.     }
  350.  
  351.   gimp_destroy_params (return_vals, nreturn_vals);
  352.  
  353.   return success;
  354. }
  355.  
  356. /**
  357.  * gimp_procedural_db_get_data_size:
  358.  * @identifier: The identifier associated with data.
  359.  *
  360.  * Returns size of data associated with the specified identifier.
  361.  *
  362.  * This procedure returns the size of any data which may have been
  363.  * associated with the specified identifier. If no data has been
  364.  * associated with the identifier, an error is returned.
  365.  *
  366.  * Returns: The number of bytes in the data.
  367.  */
  368. gint
  369. gimp_procedural_db_get_data_size (gchar *identifier)
  370. {
  371.   GimpParam *return_vals;
  372.   gint nreturn_vals;
  373.   gint bytes = 0;
  374.  
  375.   return_vals = gimp_run_procedure ("gimp_procedural_db_get_data_size",
  376.                     &nreturn_vals,
  377.                     GIMP_PDB_STRING, identifier,
  378.                     GIMP_PDB_END);
  379.  
  380.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  381.     bytes = return_vals[1].data.d_int32;
  382.  
  383.   gimp_destroy_params (return_vals, nreturn_vals);
  384.  
  385.   return bytes;
  386. }
  387.  
  388. /**
  389.  * _gimp_procedural_db_set_data:
  390.  * @identifier: The identifier associated with data.
  391.  * @bytes: The number of bytes in the data.
  392.  * @data: A byte array containing data.
  393.  *
  394.  * Associates the specified identifier with the supplied data.
  395.  *
  396.  * This procedure associates the supplied data with the provided
  397.  * identifier. The data may be subsequently retrieved by a call to
  398.  * 'procedural-db-get-data'.
  399.  *
  400.  * Returns: TRUE on success.
  401.  */
  402. gboolean
  403. _gimp_procedural_db_set_data (gchar  *identifier,
  404.                   gint    bytes,
  405.                   guint8 *data)
  406. {
  407.   GimpParam *return_vals;
  408.   gint nreturn_vals;
  409.   gboolean success = TRUE;
  410.  
  411.   return_vals = gimp_run_procedure ("gimp_procedural_db_set_data",
  412.                     &nreturn_vals,
  413.                     GIMP_PDB_STRING, identifier,
  414.                     GIMP_PDB_INT32, bytes,
  415.                     GIMP_PDB_INT8ARRAY, data,
  416.                     GIMP_PDB_END);
  417.  
  418.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  419.  
  420.   gimp_destroy_params (return_vals, nreturn_vals);
  421.  
  422.   return success;
  423. }
  424.