~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/pdb/procedural_db_cmds.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
16
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
17
 */
18
18
 
19
 
/* NOTE: This file is autogenerated by pdbgen.pl. */
 
19
/* NOTE: This file is auto-generated by pdbgen.pl. */
20
20
 
21
21
#include "config.h"
22
22
 
23
 
#include <stdio.h>
24
 
#include <stdlib.h>
25
 
#include <string.h>
26
23
 
27
24
#include <glib-object.h>
28
25
 
 
26
#include "libgimpbase/gimpbase.h"
 
27
 
29
28
#include "pdb-types.h"
30
 
#include "procedural_db.h"
 
29
#include "gimppdb.h"
 
30
#include "gimpprocedure.h"
 
31
#include "core/gimpparamspecs.h"
31
32
 
32
33
#include "core/gimp.h"
33
 
#include "gimp-intl.h"
34
 
 
35
 
#ifdef HAVE_GLIBC_REGEX
36
 
#include <regex.h>
37
 
#else
38
 
#include "regexrepl/regex.h"
39
 
#endif
40
 
 
41
 
#define COMPAT_BLURB "This procedure is deprecated! Use '%s' instead."
42
 
 
43
 
 
44
 
/*  Query structure  */
45
 
typedef struct _PDBQuery PDBQuery;
46
 
 
47
 
struct _PDBQuery
48
 
{
49
 
  Gimp     *gimp;
50
 
 
51
 
  regex_t   name_regex;
52
 
  regex_t   blurb_regex;
53
 
  regex_t   help_regex;
54
 
  regex_t   author_regex;
55
 
  regex_t   copyright_regex;
56
 
  regex_t   date_regex;
57
 
  regex_t   proc_type_regex;
58
 
 
59
 
  gchar   **list_of_procs;
60
 
  gint      num_procs;
61
 
  gboolean  querying_compat;
62
 
};
63
 
 
64
 
 
65
 
typedef struct _PDBStrings PDBStrings;
66
 
 
67
 
struct _PDBStrings
68
 
{
69
 
  gboolean  compat;
70
 
 
71
 
  gchar    *blurb;
72
 
  gchar    *help;
73
 
  gchar    *author;
74
 
  gchar    *copyright;
75
 
  gchar    *date;
76
 
};
77
 
 
78
 
static gchar *proc_type_str[] =
79
 
{
80
 
  N_("Internal GIMP procedure"),
81
 
  N_("GIMP Plug-In"),
82
 
  N_("GIMP Extension"),
83
 
  N_("Temporary Procedure")
84
 
};
85
 
 
86
 
static const gchar * const type_str[] =
87
 
{
88
 
  "GIMP_PDB_INT32",
89
 
  "GIMP_PDB_INT16",
90
 
  "GIMP_PDB_INT8",
91
 
  "GIMP_PDB_FLOAT",
92
 
  "GIMP_PDB_STRING",
93
 
  "GIMP_PDB_INT32ARRAY",
94
 
  "GIMP_PDB_INT16ARRAY",
95
 
  "GIMP_PDB_INT8ARRAY",
96
 
  "GIMP_PDB_FLOATARRAY",
97
 
  "GIMP_PDB_STRINGARRAY",
98
 
  "GIMP_PDB_COLOR",
99
 
  "GIMP_PDB_REGION",
100
 
  "GIMP_PDB_DISPLAY",
101
 
  "GIMP_PDB_IMAGE",
102
 
  "GIMP_PDB_LAYER",
103
 
  "GIMP_PDB_CHANNEL",
104
 
  "GIMP_PDB_DRAWABLE",
105
 
  "GIMP_PDB_SELECTION",
106
 
  "GIMP_PDB_BOUNDARY",
107
 
  "GIMP_PDB_PATH",
108
 
  "GIMP_PDB_PARASITE",
109
 
  "GIMP_PDB_STATUS",
110
 
  "GIMP_PDB_END"
111
 
};
112
 
 
113
 
static ProcRecord procedural_db_temp_name_proc;
114
 
static ProcRecord procedural_db_dump_proc;
115
 
static ProcRecord procedural_db_query_proc;
116
 
static ProcRecord procedural_db_proc_info_proc;
117
 
static ProcRecord procedural_db_proc_arg_proc;
118
 
static ProcRecord procedural_db_proc_val_proc;
119
 
static ProcRecord procedural_db_get_data_proc;
120
 
static ProcRecord procedural_db_get_data_size_proc;
121
 
static ProcRecord procedural_db_set_data_proc;
122
 
 
123
 
void
124
 
register_procedural_db_procs (Gimp *gimp)
125
 
{
126
 
  procedural_db_register (gimp, &procedural_db_temp_name_proc);
127
 
  procedural_db_register (gimp, &procedural_db_dump_proc);
128
 
  procedural_db_register (gimp, &procedural_db_query_proc);
129
 
  procedural_db_register (gimp, &procedural_db_proc_info_proc);
130
 
  procedural_db_register (gimp, &procedural_db_proc_arg_proc);
131
 
  procedural_db_register (gimp, &procedural_db_proc_val_proc);
132
 
  procedural_db_register (gimp, &procedural_db_get_data_proc);
133
 
  procedural_db_register (gimp, &procedural_db_get_data_size_proc);
134
 
  procedural_db_register (gimp, &procedural_db_set_data_proc);
135
 
}
136
 
 
137
 
static int
138
 
match_strings (regex_t     *preg,
139
 
               const gchar *a)
140
 
{
141
 
  if (!a)
142
 
    a = "";
143
 
 
144
 
  return regexec (preg, a, 0, NULL, 0);
145
 
}
146
 
 
147
 
static void
148
 
get_pdb_strings (PDBStrings *strings,
149
 
                 ProcRecord *proc,
150
 
                 gboolean    compat)
151
 
{
152
 
  strings->compat = compat;
153
 
 
154
 
  if (compat)
155
 
    {
156
 
      strings->blurb     = g_strdup_printf (COMPAT_BLURB, proc->name);
157
 
      strings->help      = g_strdup (strings->blurb);
158
 
      strings->author    = NULL;
159
 
      strings->copyright = NULL;
160
 
      strings->date      = NULL;
161
 
    }
162
 
  else
163
 
    {
164
 
      strings->blurb     = proc->blurb;
165
 
      strings->help      = proc->help;
166
 
      strings->author    = proc->author;
167
 
      strings->copyright = proc->copyright;
168
 
      strings->date      = proc->date;
169
 
    }
170
 
}
171
 
 
172
 
static void
173
 
procedural_db_query_entry (gpointer key,
174
 
                           gpointer value,
175
 
                           gpointer user_data)
176
 
{
177
 
  PDBQuery    *pdb_query = user_data;
178
 
  GList       *list;
179
 
  ProcRecord  *proc;
180
 
  const gchar *proc_name;
181
 
  PDBStrings   strings;
182
 
 
183
 
  proc_name = key;
184
 
 
185
 
  if (pdb_query->querying_compat)
186
 
    list = g_hash_table_lookup (pdb_query->gimp->procedural_ht, value);
187
 
  else
188
 
    list = value;
189
 
 
190
 
  if (! list)
191
 
    return;
192
 
 
193
 
  proc = (ProcRecord *) list->data;
194
 
 
195
 
  get_pdb_strings (&strings, proc, pdb_query->querying_compat);
196
 
 
197
 
  if (! match_strings (&pdb_query->name_regex,      proc_name)         &&
198
 
      ! match_strings (&pdb_query->blurb_regex,     strings.blurb)     &&
199
 
      ! match_strings (&pdb_query->help_regex,      strings.help)      &&
200
 
      ! match_strings (&pdb_query->author_regex,    strings.author)    &&
201
 
      ! match_strings (&pdb_query->copyright_regex, strings.copyright) &&
202
 
      ! match_strings (&pdb_query->date_regex,      strings.date)      &&
203
 
      ! match_strings (&pdb_query->proc_type_regex,
204
 
                       proc_type_str[(gint) proc->proc_type]))
205
 
    {
206
 
      pdb_query->num_procs++;
207
 
      pdb_query->list_of_procs = g_renew (gchar *, pdb_query->list_of_procs,
208
 
                                          pdb_query->num_procs);
209
 
      pdb_query->list_of_procs[pdb_query->num_procs - 1] = g_strdup (proc_name);
210
 
    }
211
 
 
212
 
  if (strings.compat)
213
 
    {
214
 
      g_free (strings.blurb);
215
 
      g_free (strings.help);
216
 
    }
217
 
}
218
 
 
219
 
static gboolean
220
 
output_string (FILE        *file,
221
 
               const gchar *string)
222
 
{
223
 
  if (fprintf (file, "\"") < 0)
224
 
    return FALSE;
225
 
 
226
 
  if (string)
227
 
    while (*string)
228
 
      {
229
 
        switch (*string)
230
 
          {
231
 
          case '\\' : if (fprintf (file, "\\\\") < 0) return FALSE; break;
232
 
          case '\"' : if (fprintf (file, "\\\"") < 0) return FALSE; break;
233
 
          case '{'  : if (fprintf (file, "@{")   < 0) return FALSE; break;
234
 
          case '@'  : if (fprintf (file, "@@")   < 0) return FALSE; break;
235
 
          case '}'  : if (fprintf (file, "@}")   < 0) return FALSE; break;
236
 
 
237
 
          default:
238
 
            if (fprintf (file, "%c", *string) < 0)
239
 
              return FALSE;
240
 
          }
241
 
        string++;
242
 
      }
243
 
 
244
 
  if (fprintf (file, "\"\n") < 0)
245
 
    return FALSE;
246
 
 
247
 
  return TRUE;
248
 
}
249
 
 
250
 
static void
251
 
procedural_db_print_entry (gpointer key,
252
 
                           gpointer value,
253
 
                           gpointer user_data)
254
 
{
255
 
  ProcRecord *procedure;
256
 
  GString    *buf;
257
 
  GList      *list;
258
 
  FILE       *file;
259
 
  gint        i;
260
 
  gint        num = 0;
261
 
 
262
 
  list = (GList *) value;
263
 
  file = (FILE *) user_data;
264
 
 
265
 
  buf = g_string_new ("");
266
 
 
267
 
  while (list)
268
 
    {
269
 
      num++;
270
 
      procedure = (ProcRecord*) list->data;
271
 
      list = list->next;
272
 
 
273
 
      fprintf (file, "\n(register-procedure ");
274
 
 
275
 
      if (list || num != 1)
276
 
        {
277
 
          g_string_printf (buf, "%s <%d>", procedure->name, num);
278
 
          output_string (file, buf->str);
279
 
        }
280
 
      else
281
 
        output_string (file, procedure->name);
282
 
 
283
 
      output_string (file, procedure->blurb);
284
 
      output_string (file, procedure->help);
285
 
      output_string (file, procedure->author);
286
 
      output_string (file, procedure->copyright);
287
 
      output_string (file, procedure->date);
288
 
      output_string (file, proc_type_str[(int) procedure->proc_type]);
289
 
 
290
 
      fprintf (file, "( ");
291
 
      for (i = 0; i < procedure->num_args; i++)
292
 
        {
293
 
          fprintf (file, "( ");
294
 
 
295
 
          output_string (file, procedure->args[i].name );
296
 
          output_string (file, type_str[procedure->args[i].arg_type]);
297
 
          output_string (file, procedure->args[i].description);
298
 
 
299
 
          fprintf (file, " ) ");
300
 
        }
301
 
      fprintf (file, " ) ");
302
 
 
303
 
      fprintf (file, "( ");
304
 
      for (i = 0; i < procedure->num_values; i++)
305
 
        {
306
 
          fprintf (file, "( ");
307
 
          output_string (file, procedure->values[i].name );
308
 
          output_string (file, type_str[procedure->values[i].arg_type]);
309
 
          output_string (file, procedure->values[i].description);
310
 
 
311
 
          fprintf (file, " ) ");
312
 
        }
313
 
      fprintf (file, " ) ");
314
 
      fprintf (file, " ) ");
315
 
    }
316
 
 
317
 
  g_string_free (buf, TRUE);
318
 
}
319
 
 
320
 
/* This really doesn't belong here, but it depends on our generated type_str
321
 
 * array.
322
 
 */
323
 
const char *
324
 
pdb_type_name (gint type)
325
 
{
326
 
  if (type >= 0 && type <= GIMP_PDB_END)
327
 
    return type_str[type];
328
 
  else
329
 
    return g_strdup_printf ("(PDB type %d unknown)", type);
330
 
   /* Yeah, we leak the memory.  But then you shouldn't try and
331
 
    * get the name of a PDB type that doesn't exist, should you.
332
 
    */
333
 
}
334
 
 
335
 
static Argument *
336
 
procedural_db_temp_name_invoker (Gimp         *gimp,
337
 
                                 GimpContext  *context,
338
 
                                 GimpProgress *progress,
339
 
                                 Argument     *args)
340
 
{
341
 
  Argument *return_args;
342
 
  gchar *temp_name;
 
34
#include "core/gimpparamspecs-desc.h"
 
35
#include "gimp-pdb-compat.h"
 
36
#include "gimppdb-query.h"
 
37
#include "plug-in/gimppluginmanager-data.h"
 
38
 
 
39
#include "internal_procs.h"
 
40
 
 
41
 
 
42
static GValueArray *
 
43
procedural_db_temp_name_invoker (GimpProcedure     *procedure,
 
44
                                 Gimp              *gimp,
 
45
                                 GimpContext       *context,
 
46
                                 GimpProgress      *progress,
 
47
                                 const GValueArray *args)
 
48
{
 
49
  GValueArray *return_vals;
 
50
  gchar *temp_name = NULL;
 
51
 
343
52
  static gint proc_number = 0;
344
53
 
345
 
  temp_name = g_strdup_printf ("temp_procedure_number_%d", proc_number++);
346
 
 
347
 
  return_args = procedural_db_return_args (&procedural_db_temp_name_proc, TRUE);
348
 
  return_args[1].value.pdb_pointer = temp_name;
349
 
 
350
 
  return return_args;
351
 
}
352
 
 
353
 
static ProcArg procedural_db_temp_name_outargs[] =
354
 
{
355
 
  {
356
 
    GIMP_PDB_STRING,
357
 
    "temp_name",
358
 
    "A unique temporary name for a temporary PDB entry"
359
 
  }
360
 
};
361
 
 
362
 
static ProcRecord procedural_db_temp_name_proc =
363
 
{
364
 
  "gimp_procedural_db_temp_name",
365
 
  "Generates a unique temporary PDB name.",
366
 
  "This procedure generates a temporary PDB entry name that is guaranteed to be unique. It is many used by the interactive popup dialogs to generate a PDB entry name.",
367
 
  "Andy Thomas",
368
 
  "Andy Thomas",
369
 
  "1998",
370
 
  NULL,
371
 
  GIMP_INTERNAL,
372
 
  0,
373
 
  NULL,
374
 
  1,
375
 
  procedural_db_temp_name_outargs,
376
 
  { { procedural_db_temp_name_invoker } }
377
 
};
378
 
 
379
 
static Argument *
380
 
procedural_db_dump_invoker (Gimp         *gimp,
381
 
                            GimpContext  *context,
382
 
                            GimpProgress *progress,
383
 
                            Argument     *args)
384
 
{
385
 
  gboolean success = TRUE;
386
 
  gchar *filename;
387
 
  FILE *file;
388
 
 
389
 
  filename = (gchar *) args[0].value.pdb_pointer;
390
 
  if (filename == NULL)
391
 
    success = FALSE;
392
 
 
393
 
  if (success)
394
 
    {
395
 
      if ((file = fopen (filename, "w")))
396
 
        {
397
 
          g_hash_table_foreach (gimp->procedural_ht,
398
 
                                procedural_db_print_entry, file);
399
 
          fclose (file);
400
 
        }
401
 
      else
402
 
        success = FALSE;
403
 
    }
404
 
 
405
 
  return procedural_db_return_args (&procedural_db_dump_proc, success);
406
 
}
407
 
 
408
 
static ProcArg procedural_db_dump_inargs[] =
409
 
{
410
 
  {
411
 
    GIMP_PDB_STRING,
412
 
    "filename",
413
 
    "The dump filename"
414
 
  }
415
 
};
416
 
 
417
 
static ProcRecord procedural_db_dump_proc =
418
 
{
419
 
  "gimp_procedural_db_dump",
420
 
  "Dumps the current contents of the procedural database",
421
 
  "This procedure dumps the contents of the procedural database to the specified file. The file will contain all of the information provided for each registered procedure. This file is in a format appropriate for use with the supplied \"pdb_self_doc.el\" Elisp script, which generates a texinfo document.",
422
 
  "Spencer Kimball & Josh MacDonald",
423
 
  "Spencer Kimball & Josh MacDonald & Peter Mattis",
424
 
  "1995-1996",
425
 
  NULL,
426
 
  GIMP_INTERNAL,
427
 
  1,
428
 
  procedural_db_dump_inargs,
429
 
  0,
430
 
  NULL,
431
 
  { { procedural_db_dump_invoker } }
432
 
};
433
 
 
434
 
static Argument *
435
 
procedural_db_query_invoker (Gimp         *gimp,
436
 
                             GimpContext  *context,
437
 
                             GimpProgress *progress,
438
 
                             Argument     *args)
439
 
{
440
 
  gboolean success = TRUE;
441
 
  Argument *return_args;
442
 
  gchar *name;
443
 
  gchar *blurb;
444
 
  gchar *help;
445
 
  gchar *author;
446
 
  gchar *copyright;
447
 
  gchar *date;
448
 
  gchar *proc_type;
449
 
  PDBQuery pdb_query;
450
 
 
451
 
  name = (gchar *) args[0].value.pdb_pointer;
452
 
  if (name == NULL)
453
 
    success = FALSE;
454
 
 
455
 
  blurb = (gchar *) args[1].value.pdb_pointer;
456
 
  if (blurb == NULL)
457
 
    success = FALSE;
458
 
 
459
 
  help = (gchar *) args[2].value.pdb_pointer;
460
 
  if (help == NULL)
461
 
    success = FALSE;
462
 
 
463
 
  author = (gchar *) args[3].value.pdb_pointer;
464
 
  if (author == NULL)
465
 
    success = FALSE;
466
 
 
467
 
  copyright = (gchar *) args[4].value.pdb_pointer;
468
 
  if (copyright == NULL)
469
 
    success = FALSE;
470
 
 
471
 
  date = (gchar *) args[5].value.pdb_pointer;
472
 
  if (date == NULL)
473
 
    success = FALSE;
474
 
 
475
 
  proc_type = (gchar *) args[6].value.pdb_pointer;
476
 
  if (proc_type == NULL)
477
 
    success = FALSE;
478
 
 
479
 
  if (success)
480
 
    {
481
 
      success = FALSE;
482
 
 
483
 
      if (regcomp (&pdb_query.name_regex, name, 0))
484
 
        goto free_name;
485
 
      if (regcomp (&pdb_query.blurb_regex, blurb, 0))
486
 
        goto free_blurb;
487
 
      if (regcomp (&pdb_query.help_regex, help, 0))
488
 
        goto free_help;
489
 
      if (regcomp (&pdb_query.author_regex, author, 0))
490
 
        goto free_author;
491
 
      if (regcomp (&pdb_query.copyright_regex, copyright, 0))
492
 
        goto free_copyright;
493
 
      if (regcomp (&pdb_query.date_regex, date, 0))
494
 
        goto free_date;
495
 
      if (regcomp (&pdb_query.proc_type_regex, proc_type, 0))
496
 
        goto free_proc_type;
497
 
 
498
 
      success = TRUE;
499
 
 
500
 
      pdb_query.gimp            = gimp;
501
 
      pdb_query.list_of_procs   = NULL;
502
 
      pdb_query.num_procs       = 0;
503
 
      pdb_query.querying_compat = FALSE;
504
 
 
505
 
      g_hash_table_foreach (gimp->procedural_ht,
506
 
                            procedural_db_query_entry, &pdb_query);
507
 
 
508
 
      pdb_query.querying_compat = TRUE;
509
 
 
510
 
      g_hash_table_foreach (gimp->procedural_compat_ht,
511
 
                            procedural_db_query_entry, &pdb_query);
512
 
 
513
 
      free_proc_type:
514
 
        regfree (&pdb_query.proc_type_regex);
515
 
      free_date:
516
 
        regfree (&pdb_query.date_regex);
517
 
      free_copyright:
518
 
        regfree (&pdb_query.copyright_regex);
519
 
      free_author:
520
 
        regfree (&pdb_query.author_regex);
521
 
      free_help:
522
 
        regfree (&pdb_query.help_regex);
523
 
      free_blurb:
524
 
        regfree (&pdb_query.blurb_regex);
525
 
      free_name:
526
 
        regfree (&pdb_query.name_regex);
527
 
    }
528
 
 
529
 
  return_args = procedural_db_return_args (&procedural_db_query_proc, success);
530
 
 
531
 
  if (success)
532
 
    {
533
 
      return_args[1].value.pdb_int = pdb_query.num_procs;
534
 
      return_args[2].value.pdb_pointer = pdb_query.list_of_procs;
535
 
    }
536
 
 
537
 
  return return_args;
538
 
}
539
 
 
540
 
static ProcArg procedural_db_query_inargs[] =
541
 
{
542
 
  {
543
 
    GIMP_PDB_STRING,
544
 
    "name",
545
 
    "The regex for procedure name"
546
 
  },
547
 
  {
548
 
    GIMP_PDB_STRING,
549
 
    "blurb",
550
 
    "The regex for procedure blurb"
551
 
  },
552
 
  {
553
 
    GIMP_PDB_STRING,
554
 
    "help",
555
 
    "The regex for procedure help"
556
 
  },
557
 
  {
558
 
    GIMP_PDB_STRING,
559
 
    "author",
560
 
    "The regex for procedure author"
561
 
  },
562
 
  {
563
 
    GIMP_PDB_STRING,
564
 
    "copyright",
565
 
    "The regex for procedure copyright"
566
 
  },
567
 
  {
568
 
    GIMP_PDB_STRING,
569
 
    "date",
570
 
    "The regex for procedure date"
571
 
  },
572
 
  {
573
 
    GIMP_PDB_STRING,
574
 
    "proc_type",
575
 
    "The regex for procedure type: { 'Internal GIMP procedure', 'GIMP Plug-in', 'GIMP Extension' }"
576
 
  }
577
 
};
578
 
 
579
 
static ProcArg procedural_db_query_outargs[] =
580
 
{
581
 
  {
582
 
    GIMP_PDB_INT32,
583
 
    "num_matches",
584
 
    "The number of matching procedures"
585
 
  },
586
 
  {
587
 
    GIMP_PDB_STRINGARRAY,
588
 
    "procedure_names",
589
 
    "The list of procedure names"
590
 
  }
591
 
};
592
 
 
593
 
static ProcRecord procedural_db_query_proc =
594
 
{
595
 
  "gimp_procedural_db_query",
596
 
  "Queries the procedural database for its contents using regular expression matching.",
597
 
  "This procedure queries the contents of the procedural database. It is supplied with seven arguments matching procedures on { name, blurb, help, author, copyright, date, procedure type}. This is accomplished using regular expression matching. For instance, to find all procedures with \"jpeg\" listed in the blurb, all seven arguments can be supplied as \".*\", except for the second, which can be supplied as \".*jpeg.*\". There are two return arguments for this procedure. The first is the number of procedures matching the query. The second is a concatenated list of procedure names corresponding to those matching the query. If no matching entries are found, then the returned string is NULL and the number of entries is 0.",
598
 
  "Spencer Kimball & Peter Mattis",
599
 
  "Spencer Kimball & Peter Mattis",
600
 
  "1995-1996",
601
 
  NULL,
602
 
  GIMP_INTERNAL,
603
 
  7,
604
 
  procedural_db_query_inargs,
605
 
  2,
606
 
  procedural_db_query_outargs,
607
 
  { { procedural_db_query_invoker } }
608
 
};
609
 
 
610
 
static Argument *
611
 
procedural_db_proc_info_invoker (Gimp         *gimp,
612
 
                                 GimpContext  *context,
613
 
                                 GimpProgress *progress,
614
 
                                 Argument     *args)
615
 
{
616
 
  gboolean success = TRUE;
617
 
  Argument *return_args;
618
 
  gchar *proc_name;
619
 
  PDBStrings strings;
620
 
  ProcRecord *proc = NULL;
621
 
 
622
 
  proc_name = (gchar *) args[0].value.pdb_pointer;
623
 
  if (proc_name == NULL || !g_utf8_validate (proc_name, -1, NULL))
624
 
    success = FALSE;
625
 
 
626
 
  if (success)
627
 
    {
628
 
      proc = procedural_db_lookup (gimp, proc_name);
629
 
 
630
 
      if (proc)
631
 
        {
632
 
          get_pdb_strings (&strings, proc, FALSE);
633
 
        }
634
 
      else
635
 
        {
636
 
          const gchar *compat_name;
637
 
 
638
 
          compat_name = g_hash_table_lookup (gimp->procedural_compat_ht, proc_name);
639
 
 
640
 
          if (compat_name)
641
 
            {
642
 
              proc = procedural_db_lookup (gimp, compat_name);
643
 
 
644
 
              if (proc)
645
 
                get_pdb_strings (&strings, proc, TRUE);
646
 
            }
647
 
        }
648
 
 
649
 
      success = (proc != NULL);
650
 
    }
651
 
 
652
 
  return_args = procedural_db_return_args (&procedural_db_proc_info_proc, success);
653
 
 
654
 
  if (success)
655
 
    {
656
 
      return_args[1].value.pdb_pointer = strings.compat ? strings.blurb : g_strdup (strings.blurb);
657
 
      return_args[2].value.pdb_pointer = strings.compat ? strings.help : g_strdup (strings.help);
658
 
      return_args[3].value.pdb_pointer = strings.compat ? strings.author : g_strdup (strings.author);
659
 
      return_args[4].value.pdb_pointer = strings.compat ? strings.copyright : g_strdup (strings.copyright);
660
 
      return_args[5].value.pdb_pointer = strings.compat ? strings.date : g_strdup (strings.date);
661
 
      return_args[6].value.pdb_int = proc->proc_type;
662
 
      return_args[7].value.pdb_int = proc->num_args;
663
 
      return_args[8].value.pdb_int = proc->num_values;
664
 
    }
665
 
 
666
 
  return return_args;
667
 
}
668
 
 
669
 
static ProcArg procedural_db_proc_info_inargs[] =
670
 
{
671
 
  {
672
 
    GIMP_PDB_STRING,
673
 
    "procedure",
674
 
    "The procedure name"
675
 
  }
676
 
};
677
 
 
678
 
static ProcArg procedural_db_proc_info_outargs[] =
679
 
{
680
 
  {
681
 
    GIMP_PDB_STRING,
682
 
    "blurb",
683
 
    "A short blurb"
684
 
  },
685
 
  {
686
 
    GIMP_PDB_STRING,
687
 
    "help",
688
 
    "Detailed procedure help"
689
 
  },
690
 
  {
691
 
    GIMP_PDB_STRING,
692
 
    "author",
693
 
    "Author(s) of the procedure"
694
 
  },
695
 
  {
696
 
    GIMP_PDB_STRING,
697
 
    "copyright",
698
 
    "The copyright"
699
 
  },
700
 
  {
701
 
    GIMP_PDB_STRING,
702
 
    "date",
703
 
    "Copyright date"
704
 
  },
705
 
  {
706
 
    GIMP_PDB_INT32,
707
 
    "proc_type",
708
 
    "The procedure type: { GIMP_INTERNAL (0), GIMP_PLUGIN (1), GIMP_EXTENSION (2), GIMP_TEMPORARY (3) }"
709
 
  },
710
 
  {
711
 
    GIMP_PDB_INT32,
712
 
    "num_args",
713
 
    "The number of input arguments"
714
 
  },
715
 
  {
716
 
    GIMP_PDB_INT32,
717
 
    "num_values",
718
 
    "The number of return values"
719
 
  }
720
 
};
721
 
 
722
 
static ProcRecord procedural_db_proc_info_proc =
723
 
{
724
 
  "gimp_procedural_db_proc_info",
725
 
  "Queries the procedural database for information on the specified procedure.",
726
 
  "This procedure returns information on the specified procedure. A short blurb, detailed help, author(s), copyright information, procedure type, number of input, and number of return values are returned. For specific information on each input argument and return value, use the 'gimp_procedural_db_proc_arg' and 'gimp_procedural_db_proc_val' procedures.",
727
 
  "Spencer Kimball & Peter Mattis",
728
 
  "Spencer Kimball & Peter Mattis",
729
 
  "1997",
730
 
  NULL,
731
 
  GIMP_INTERNAL,
732
 
  1,
733
 
  procedural_db_proc_info_inargs,
734
 
  8,
735
 
  procedural_db_proc_info_outargs,
736
 
  { { procedural_db_proc_info_invoker } }
737
 
};
738
 
 
739
 
static Argument *
740
 
procedural_db_proc_arg_invoker (Gimp         *gimp,
741
 
                                GimpContext  *context,
742
 
                                GimpProgress *progress,
743
 
                                Argument     *args)
744
 
{
745
 
  gboolean success = TRUE;
746
 
  Argument *return_args;
747
 
  gchar *proc_name;
 
54
  temp_name = g_strdup_printf ("temp-procedure-number-%d", proc_number++);
 
55
 
 
56
  return_vals = gimp_procedure_get_return_values (procedure, TRUE);
 
57
  g_value_take_string (&return_vals->values[1], temp_name);
 
58
 
 
59
  return return_vals;
 
60
}
 
61
 
 
62
static GValueArray *
 
63
procedural_db_dump_invoker (GimpProcedure     *procedure,
 
64
                            Gimp              *gimp,
 
65
                            GimpContext       *context,
 
66
                            GimpProgress      *progress,
 
67
                            const GValueArray *args)
 
68
{
 
69
  gboolean success = TRUE;
 
70
  const gchar *filename;
 
71
 
 
72
  filename = g_value_get_string (&args->values[0]);
 
73
 
 
74
  if (success)
 
75
    {
 
76
      success = gimp_pdb_dump (gimp->pdb, filename);
 
77
    }
 
78
 
 
79
  return gimp_procedure_get_return_values (procedure, success);
 
80
}
 
81
 
 
82
static GValueArray *
 
83
procedural_db_query_invoker (GimpProcedure     *procedure,
 
84
                             Gimp              *gimp,
 
85
                             GimpContext       *context,
 
86
                             GimpProgress      *progress,
 
87
                             const GValueArray *args)
 
88
{
 
89
  gboolean success = TRUE;
 
90
  GValueArray *return_vals;
 
91
  const gchar *name;
 
92
  const gchar *blurb;
 
93
  const gchar *help;
 
94
  const gchar *author;
 
95
  const gchar *copyright;
 
96
  const gchar *date;
 
97
  const gchar *proc_type;
 
98
  gint32 num_matches = 0;
 
99
  gchar **procedure_names = NULL;
 
100
 
 
101
  name = g_value_get_string (&args->values[0]);
 
102
  blurb = g_value_get_string (&args->values[1]);
 
103
  help = g_value_get_string (&args->values[2]);
 
104
  author = g_value_get_string (&args->values[3]);
 
105
  copyright = g_value_get_string (&args->values[4]);
 
106
  date = g_value_get_string (&args->values[5]);
 
107
  proc_type = g_value_get_string (&args->values[6]);
 
108
 
 
109
  if (success)
 
110
    {
 
111
      success = gimp_pdb_query (gimp->pdb,
 
112
                                name, blurb, help, author,
 
113
                                copyright, date, proc_type,
 
114
                                &num_matches, &procedure_names);
 
115
    }
 
116
 
 
117
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
118
 
 
119
  if (success)
 
120
    {
 
121
      g_value_set_int (&return_vals->values[1], num_matches);
 
122
      gimp_value_take_stringarray (&return_vals->values[2], procedure_names, num_matches);
 
123
    }
 
124
 
 
125
  return return_vals;
 
126
}
 
127
 
 
128
static GValueArray *
 
129
procedural_db_proc_info_invoker (GimpProcedure     *procedure,
 
130
                                 Gimp              *gimp,
 
131
                                 GimpContext       *context,
 
132
                                 GimpProgress      *progress,
 
133
                                 const GValueArray *args)
 
134
{
 
135
  gboolean success = TRUE;
 
136
  GValueArray *return_vals;
 
137
  const gchar *procedure_name;
 
138
  gchar *blurb = NULL;
 
139
  gchar *help = NULL;
 
140
  gchar *author = NULL;
 
141
  gchar *copyright = NULL;
 
142
  gchar *date = NULL;
 
143
  gint32 proc_type = 0;
 
144
  gint32 num_args = 0;
 
145
  gint32 num_values = 0;
 
146
 
 
147
  procedure_name = g_value_get_string (&args->values[0]);
 
148
 
 
149
  if (success)
 
150
    {
 
151
      GimpPDBProcType  ptype;
 
152
      gchar           *canonical;
 
153
 
 
154
      canonical = gimp_canonicalize_identifier (procedure_name);
 
155
 
 
156
      success = gimp_pdb_proc_info (gimp->pdb, canonical,
 
157
                                    &blurb, &help, &author,
 
158
                                    &copyright, &date, &ptype,
 
159
                                    &num_args, &num_values);
 
160
      proc_type = ptype;
 
161
 
 
162
      g_free (canonical);
 
163
    }
 
164
 
 
165
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
166
 
 
167
  if (success)
 
168
    {
 
169
      g_value_take_string (&return_vals->values[1], blurb);
 
170
      g_value_take_string (&return_vals->values[2], help);
 
171
      g_value_take_string (&return_vals->values[3], author);
 
172
      g_value_take_string (&return_vals->values[4], copyright);
 
173
      g_value_take_string (&return_vals->values[5], date);
 
174
      g_value_set_enum (&return_vals->values[6], proc_type);
 
175
      g_value_set_int (&return_vals->values[7], num_args);
 
176
      g_value_set_int (&return_vals->values[8], num_values);
 
177
    }
 
178
 
 
179
  return return_vals;
 
180
}
 
181
 
 
182
static GValueArray *
 
183
procedural_db_proc_arg_invoker (GimpProcedure     *procedure,
 
184
                                Gimp              *gimp,
 
185
                                GimpContext       *context,
 
186
                                GimpProgress      *progress,
 
187
                                const GValueArray *args)
 
188
{
 
189
  gboolean success = TRUE;
 
190
  GValueArray *return_vals;
 
191
  const gchar *procedure_name;
748
192
  gint32 arg_num;
749
 
  ProcRecord *proc;
750
 
  ProcArg *arg = NULL;
751
 
 
752
 
  proc_name = (gchar *) args[0].value.pdb_pointer;
753
 
  if (proc_name == NULL || !g_utf8_validate (proc_name, -1, NULL))
754
 
    success = FALSE;
755
 
 
756
 
  arg_num = args[1].value.pdb_int;
 
193
  gint32 arg_type = 0;
 
194
  gchar *arg_name = NULL;
 
195
  gchar *arg_desc = NULL;
 
196
 
 
197
  procedure_name = g_value_get_string (&args->values[0]);
 
198
  arg_num = g_value_get_int (&args->values[1]);
757
199
 
758
200
  if (success)
759
201
    {
760
 
      proc = procedural_db_lookup (gimp, proc_name);
 
202
      GimpProcedure *proc;
 
203
      gchar         *canonical;
 
204
 
 
205
      canonical = gimp_canonicalize_identifier (procedure_name);
 
206
 
 
207
      proc = gimp_pdb_lookup_procedure (gimp->pdb, canonical);
761
208
 
762
209
      if (! proc)
763
210
        {
764
211
          const gchar *compat_name;
765
212
 
766
 
          compat_name = g_hash_table_lookup (gimp->procedural_compat_ht, proc_name);
 
213
          compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb, canonical);
767
214
 
768
215
          if (compat_name)
769
 
            proc = procedural_db_lookup (gimp, compat_name);
 
216
            proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
770
217
        }
771
218
 
 
219
      g_free (canonical);
 
220
 
772
221
      if (proc && (arg_num >= 0 && arg_num < proc->num_args))
773
 
        arg = &proc->args[arg_num];
 
222
        {
 
223
          GParamSpec *pspec = proc->args[arg_num];
 
224
 
 
225
          arg_type = gimp_pdb_compat_arg_type_from_gtype (G_PARAM_SPEC_VALUE_TYPE (pspec));
 
226
          arg_name = g_strdup (g_param_spec_get_name (pspec));
 
227
          arg_desc = gimp_param_spec_get_desc (pspec);
 
228
        }
774
229
      else
775
230
        success = FALSE;
776
231
    }
777
232
 
778
 
  return_args = procedural_db_return_args (&procedural_db_proc_arg_proc, success);
 
233
  return_vals = gimp_procedure_get_return_values (procedure, success);
779
234
 
780
235
  if (success)
781
236
    {
782
 
      return_args[1].value.pdb_int = arg->arg_type;
783
 
      return_args[2].value.pdb_pointer = g_strdup (arg->name);
784
 
      return_args[3].value.pdb_pointer = g_strdup (arg->description);
 
237
      g_value_set_enum (&return_vals->values[1], arg_type);
 
238
      g_value_take_string (&return_vals->values[2], arg_name);
 
239
      g_value_take_string (&return_vals->values[3], arg_desc);
785
240
    }
786
241
 
787
 
  return return_args;
 
242
  return return_vals;
788
243
}
789
244
 
790
 
static ProcArg procedural_db_proc_arg_inargs[] =
791
 
{
792
 
  {
793
 
    GIMP_PDB_STRING,
794
 
    "procedure",
795
 
    "The procedure name"
796
 
  },
797
 
  {
798
 
    GIMP_PDB_INT32,
799
 
    "arg_num",
800
 
    "The argument number"
801
 
  }
802
 
};
803
 
 
804
 
static ProcArg procedural_db_proc_arg_outargs[] =
805
 
{
806
 
  {
807
 
    GIMP_PDB_INT32,
808
 
    "arg_type",
809
 
    "The type of argument { GIMP_PDB_INT32 (0), GIMP_PDB_INT16 (1), GIMP_PDB_INT8 (2), GIMP_PDB_FLOAT (3), GIMP_PDB_STRING (4), GIMP_PDB_INT32ARRAY (5), GIMP_PDB_INT16ARRAY (6), GIMP_PDB_INT8ARRAY (7), GIMP_PDB_FLOATARRAY (8), GIMP_PDB_STRINGARRAY (9), GIMP_PDB_COLOR (10), GIMP_PDB_REGION (11), GIMP_PDB_DISPLAY (12), GIMP_PDB_IMAGE (13), GIMP_PDB_LAYER (14), GIMP_PDB_CHANNEL (15), GIMP_PDB_DRAWABLE (16), GIMP_PDB_SELECTION (17), GIMP_PDB_BOUNDARY (18), GIMP_PDB_PATH (19), GIMP_PDB_PARASITE (20), GIMP_PDB_STATUS (21) }"
810
 
  },
811
 
  {
812
 
    GIMP_PDB_STRING,
813
 
    "arg_name",
814
 
    "The name of the argument"
815
 
  },
816
 
  {
817
 
    GIMP_PDB_STRING,
818
 
    "arg_desc",
819
 
    "A description of the argument"
820
 
  }
821
 
};
822
 
 
823
 
static ProcRecord procedural_db_proc_arg_proc =
824
 
{
825
 
  "gimp_procedural_db_proc_arg",
826
 
  "Queries the procedural database for information on the specified procedure's argument.",
827
 
  "This procedure returns information on the specified procedure's argument. The argument type, name, and a description are retrieved.",
828
 
  "Spencer Kimball & Peter Mattis",
829
 
  "Spencer Kimball & Peter Mattis",
830
 
  "1997",
831
 
  NULL,
832
 
  GIMP_INTERNAL,
833
 
  2,
834
 
  procedural_db_proc_arg_inargs,
835
 
  3,
836
 
  procedural_db_proc_arg_outargs,
837
 
  { { procedural_db_proc_arg_invoker } }
838
 
};
839
 
 
840
 
static Argument *
841
 
procedural_db_proc_val_invoker (Gimp         *gimp,
842
 
                                GimpContext  *context,
843
 
                                GimpProgress *progress,
844
 
                                Argument     *args)
 
245
static GValueArray *
 
246
procedural_db_proc_val_invoker (GimpProcedure     *procedure,
 
247
                                Gimp              *gimp,
 
248
                                GimpContext       *context,
 
249
                                GimpProgress      *progress,
 
250
                                const GValueArray *args)
845
251
{
846
252
  gboolean success = TRUE;
847
 
  Argument *return_args;
848
 
  gchar *proc_name;
 
253
  GValueArray *return_vals;
 
254
  const gchar *procedure_name;
849
255
  gint32 val_num;
850
 
  ProcRecord *proc;
851
 
  ProcArg *val = NULL;
852
 
 
853
 
  proc_name = (gchar *) args[0].value.pdb_pointer;
854
 
  if (proc_name == NULL || !g_utf8_validate (proc_name, -1, NULL))
855
 
    success = FALSE;
856
 
 
857
 
  val_num = args[1].value.pdb_int;
 
256
  gint32 val_type = 0;
 
257
  gchar *val_name = NULL;
 
258
  gchar *val_desc = NULL;
 
259
 
 
260
  procedure_name = g_value_get_string (&args->values[0]);
 
261
  val_num = g_value_get_int (&args->values[1]);
858
262
 
859
263
  if (success)
860
264
    {
861
 
      proc = procedural_db_lookup (gimp, proc_name);
 
265
      GimpProcedure *proc;
 
266
      gchar         *canonical;
 
267
 
 
268
      canonical = gimp_canonicalize_identifier (procedure_name);
 
269
 
 
270
      proc = gimp_pdb_lookup_procedure (gimp->pdb, canonical);
862
271
 
863
272
      if (! proc)
864
273
        {
865
274
          const gchar *compat_name;
866
275
 
867
 
          compat_name = g_hash_table_lookup (gimp->procedural_compat_ht, proc_name);
 
276
          compat_name = gimp_pdb_lookup_compat_proc_name (gimp->pdb, canonical);
868
277
 
869
278
          if (compat_name)
870
 
            proc = procedural_db_lookup (gimp, compat_name);
 
279
            proc = gimp_pdb_lookup_procedure (gimp->pdb, compat_name);
871
280
        }
872
281
 
 
282
      g_free (canonical);
 
283
 
873
284
      if (proc && (val_num >= 0 && val_num < proc->num_values))
874
 
        val = &proc->values[val_num];
875
 
      else
876
 
        success = FALSE;
877
 
    }
878
 
 
879
 
  return_args = procedural_db_return_args (&procedural_db_proc_val_proc, success);
880
 
 
881
 
  if (success)
882
 
    {
883
 
      return_args[1].value.pdb_int = val->arg_type;
884
 
      return_args[2].value.pdb_pointer = g_strdup (val->name);
885
 
      return_args[3].value.pdb_pointer = g_strdup (val->description);
886
 
    }
887
 
 
888
 
  return return_args;
889
 
}
890
 
 
891
 
static ProcArg procedural_db_proc_val_inargs[] =
892
 
{
893
 
  {
894
 
    GIMP_PDB_STRING,
895
 
    "procedure",
896
 
    "The procedure name"
897
 
  },
898
 
  {
899
 
    GIMP_PDB_INT32,
900
 
    "val_num",
901
 
    "The return value number"
902
 
  }
903
 
};
904
 
 
905
 
static ProcArg procedural_db_proc_val_outargs[] =
906
 
{
907
 
  {
908
 
    GIMP_PDB_INT32,
909
 
    "val_type",
910
 
    "The type of return value { GIMP_PDB_INT32 (0), GIMP_PDB_INT16 (1), GIMP_PDB_INT8 (2), GIMP_PDB_FLOAT (3), GIMP_PDB_STRING (4), GIMP_PDB_INT32ARRAY (5), GIMP_PDB_INT16ARRAY (6), GIMP_PDB_INT8ARRAY (7), GIMP_PDB_FLOATARRAY (8), GIMP_PDB_STRINGARRAY (9), GIMP_PDB_COLOR (10), GIMP_PDB_REGION (11), GIMP_PDB_DISPLAY (12), GIMP_PDB_IMAGE (13), GIMP_PDB_LAYER (14), GIMP_PDB_CHANNEL (15), GIMP_PDB_DRAWABLE (16), GIMP_PDB_SELECTION (17), GIMP_PDB_BOUNDARY (18), GIMP_PDB_PATH (19), GIMP_PDB_PARASITE (20), GIMP_PDB_STATUS (21) }"
911
 
  },
912
 
  {
913
 
    GIMP_PDB_STRING,
914
 
    "val_name",
915
 
    "The name of the return value"
916
 
  },
917
 
  {
918
 
    GIMP_PDB_STRING,
919
 
    "val_desc",
920
 
    "A description of the return value"
921
 
  }
922
 
};
923
 
 
924
 
static ProcRecord procedural_db_proc_val_proc =
925
 
{
926
 
  "gimp_procedural_db_proc_val",
927
 
  "Queries the procedural database for information on the specified procedure's return value.",
928
 
  "This procedure returns information on the specified procedure's return value. The return value type, name, and a description are retrieved.",
929
 
  "Spencer Kimball & Peter Mattis",
930
 
  "Spencer Kimball & Peter Mattis",
931
 
  "1997",
932
 
  NULL,
933
 
  GIMP_INTERNAL,
934
 
  2,
935
 
  procedural_db_proc_val_inargs,
936
 
  3,
937
 
  procedural_db_proc_val_outargs,
938
 
  { { procedural_db_proc_val_invoker } }
939
 
};
940
 
 
941
 
static Argument *
942
 
procedural_db_get_data_invoker (Gimp         *gimp,
943
 
                                GimpContext  *context,
944
 
                                GimpProgress *progress,
945
 
                                Argument     *args)
946
 
{
947
 
  gboolean success = TRUE;
948
 
  Argument *return_args;
949
 
  gchar *identifier;
950
 
  gint32 bytes;
951
 
  guint8 *data_copy = NULL;
952
 
  const guint8 *data;
953
 
 
954
 
  identifier = (gchar *) args[0].value.pdb_pointer;
955
 
  if (identifier == NULL || !g_utf8_validate (identifier, -1, NULL))
956
 
    success = FALSE;
957
 
 
958
 
  if (success)
959
 
    {
960
 
      data = procedural_db_get_data (gimp, identifier, &bytes);
961
 
      success = (data != NULL);
962
 
 
963
 
      if (success)
964
 
        data_copy = g_memdup (data, bytes);
965
 
    }
966
 
 
967
 
  return_args = procedural_db_return_args (&procedural_db_get_data_proc, success);
968
 
 
969
 
  if (success)
970
 
    {
971
 
      return_args[1].value.pdb_int = bytes;
972
 
      return_args[2].value.pdb_pointer = data_copy;
973
 
    }
974
 
 
975
 
  return return_args;
976
 
}
977
 
 
978
 
static ProcArg procedural_db_get_data_inargs[] =
979
 
{
980
 
  {
981
 
    GIMP_PDB_STRING,
982
 
    "identifier",
983
 
    "The identifier associated with data"
984
 
  }
985
 
};
986
 
 
987
 
static ProcArg procedural_db_get_data_outargs[] =
988
 
{
989
 
  {
990
 
    GIMP_PDB_INT32,
991
 
    "bytes",
992
 
    "The number of bytes in the data"
993
 
  },
994
 
  {
995
 
    GIMP_PDB_INT8ARRAY,
996
 
    "data",
997
 
    "A byte array containing data"
998
 
  }
999
 
};
1000
 
 
1001
 
static ProcRecord procedural_db_get_data_proc =
1002
 
{
1003
 
  "gimp_procedural_db_get_data",
1004
 
  "Returns data associated with the specified identifier.",
1005
 
  "This procedure returns any data which may have been associated with the specified identifier. The data is a variable length array of bytes. If no data has been associated with the identifier, an error is returned.",
1006
 
  "Spencer Kimball & Peter Mattis",
1007
 
  "Spencer Kimball & Peter Mattis",
1008
 
  "1997",
1009
 
  NULL,
1010
 
  GIMP_INTERNAL,
1011
 
  1,
1012
 
  procedural_db_get_data_inargs,
1013
 
  2,
1014
 
  procedural_db_get_data_outargs,
1015
 
  { { procedural_db_get_data_invoker } }
1016
 
};
1017
 
 
1018
 
static Argument *
1019
 
procedural_db_get_data_size_invoker (Gimp         *gimp,
1020
 
                                     GimpContext  *context,
1021
 
                                     GimpProgress *progress,
1022
 
                                     Argument     *args)
1023
 
{
1024
 
  gboolean success = TRUE;
1025
 
  Argument *return_args;
1026
 
  gchar *identifier;
1027
 
  gint32 bytes;
1028
 
  const guint8 *data;
1029
 
 
1030
 
  identifier = (gchar *) args[0].value.pdb_pointer;
1031
 
  if (identifier == NULL || !g_utf8_validate (identifier, -1, NULL))
1032
 
    success = FALSE;
1033
 
 
1034
 
  if (success)
1035
 
    {
1036
 
      data = procedural_db_get_data (gimp, identifier, &bytes);
1037
 
      success = (data != NULL);
1038
 
    }
1039
 
 
1040
 
  return_args = procedural_db_return_args (&procedural_db_get_data_size_proc, success);
1041
 
 
1042
 
  if (success)
1043
 
    return_args[1].value.pdb_int = bytes;
1044
 
 
1045
 
  return return_args;
1046
 
}
1047
 
 
1048
 
static ProcArg procedural_db_get_data_size_inargs[] =
1049
 
{
1050
 
  {
1051
 
    GIMP_PDB_STRING,
1052
 
    "identifier",
1053
 
    "The identifier associated with data"
1054
 
  }
1055
 
};
1056
 
 
1057
 
static ProcArg procedural_db_get_data_size_outargs[] =
1058
 
{
1059
 
  {
1060
 
    GIMP_PDB_INT32,
1061
 
    "bytes",
1062
 
    "The number of bytes in the data"
1063
 
  }
1064
 
};
1065
 
 
1066
 
static ProcRecord procedural_db_get_data_size_proc =
1067
 
{
1068
 
  "gimp_procedural_db_get_data_size",
1069
 
  "Returns size of data associated with the specified identifier.",
1070
 
  "This procedure returns the size of any data which may have been associated with the specified identifier. If no data has been associated with the identifier, an error is returned.",
1071
 
  "Nick Lamb",
1072
 
  "Nick Lamb",
1073
 
  "1998",
1074
 
  NULL,
1075
 
  GIMP_INTERNAL,
1076
 
  1,
1077
 
  procedural_db_get_data_size_inargs,
1078
 
  1,
1079
 
  procedural_db_get_data_size_outargs,
1080
 
  { { procedural_db_get_data_size_invoker } }
1081
 
};
1082
 
 
1083
 
static Argument *
1084
 
procedural_db_set_data_invoker (Gimp         *gimp,
1085
 
                                GimpContext  *context,
1086
 
                                GimpProgress *progress,
1087
 
                                Argument     *args)
1088
 
{
1089
 
  gboolean success = TRUE;
1090
 
  gchar *identifier;
1091
 
  gint32 bytes;
1092
 
  guint8 *data;
1093
 
 
1094
 
  identifier = (gchar *) args[0].value.pdb_pointer;
1095
 
  if (identifier == NULL || !g_utf8_validate (identifier, -1, NULL))
1096
 
    success = FALSE;
1097
 
 
1098
 
  bytes = args[1].value.pdb_int;
1099
 
  if (bytes <= 0)
1100
 
    success = FALSE;
1101
 
 
1102
 
  data = (guint8 *) args[2].value.pdb_pointer;
1103
 
 
1104
 
  if (success)
1105
 
    procedural_db_set_data (gimp, identifier, bytes, data);
1106
 
 
1107
 
  return procedural_db_return_args (&procedural_db_set_data_proc, success);
1108
 
}
1109
 
 
1110
 
static ProcArg procedural_db_set_data_inargs[] =
1111
 
{
1112
 
  {
1113
 
    GIMP_PDB_STRING,
1114
 
    "identifier",
1115
 
    "The identifier associated with data"
1116
 
  },
1117
 
  {
1118
 
    GIMP_PDB_INT32,
1119
 
    "bytes",
1120
 
    "The number of bytes in the data"
1121
 
  },
1122
 
  {
1123
 
    GIMP_PDB_INT8ARRAY,
1124
 
    "data",
1125
 
    "A byte array containing data"
1126
 
  }
1127
 
};
1128
 
 
1129
 
static ProcRecord procedural_db_set_data_proc =
1130
 
{
1131
 
  "gimp_procedural_db_set_data",
1132
 
  "Associates the specified identifier with the supplied data.",
1133
 
  "This procedure associates the supplied data with the provided identifier. The data may be subsequently retrieved by a call to 'procedural-db-get-data'.",
1134
 
  "Spencer Kimball & Peter Mattis",
1135
 
  "Spencer Kimball & Peter Mattis",
1136
 
  "1997",
1137
 
  NULL,
1138
 
  GIMP_INTERNAL,
1139
 
  3,
1140
 
  procedural_db_set_data_inargs,
1141
 
  0,
1142
 
  NULL,
1143
 
  { { procedural_db_set_data_invoker } }
1144
 
};
 
285
        {
 
286
          GParamSpec *pspec = proc->values[val_num];
 
287
 
 
288
          val_type = gimp_pdb_compat_arg_type_from_gtype (G_PARAM_SPEC_VALUE_TYPE (pspec));
 
289
          val_name = g_strdup (g_param_spec_get_name (pspec));
 
290
          val_desc = gimp_param_spec_get_desc (pspec);
 
291
        }
 
292
      else
 
293
        success = FALSE;
 
294
    }
 
295
 
 
296
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
297
 
 
298
  if (success)
 
299
    {
 
300
      g_value_set_enum (&return_vals->values[1], val_type);
 
301
      g_value_take_string (&return_vals->values[2], val_name);
 
302
      g_value_take_string (&return_vals->values[3], val_desc);
 
303
    }
 
304
 
 
305
  return return_vals;
 
306
}
 
307
 
 
308
static GValueArray *
 
309
procedural_db_get_data_invoker (GimpProcedure     *procedure,
 
310
                                Gimp              *gimp,
 
311
                                GimpContext       *context,
 
312
                                GimpProgress      *progress,
 
313
                                const GValueArray *args)
 
314
{
 
315
  gboolean success = TRUE;
 
316
  GValueArray *return_vals;
 
317
  const gchar *identifier;
 
318
  gint32 bytes = 0;
 
319
  guint8 *data = NULL;
 
320
 
 
321
  identifier = g_value_get_string (&args->values[0]);
 
322
 
 
323
  if (success)
 
324
    {
 
325
      gchar        *canonical = gimp_canonicalize_identifier (identifier);
 
326
      const guint8 *orig_data;
 
327
 
 
328
      orig_data = gimp_plug_in_manager_get_data (gimp->plug_in_manager,
 
329
                                                 canonical, &bytes);
 
330
 
 
331
      g_free (canonical);
 
332
 
 
333
      if (orig_data)
 
334
        data = g_memdup (orig_data, bytes);
 
335
      else
 
336
        success = FALSE;
 
337
    }
 
338
 
 
339
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
340
 
 
341
  if (success)
 
342
    {
 
343
      g_value_set_int (&return_vals->values[1], bytes);
 
344
      gimp_value_take_int8array (&return_vals->values[2], data, bytes);
 
345
    }
 
346
 
 
347
  return return_vals;
 
348
}
 
349
 
 
350
static GValueArray *
 
351
procedural_db_get_data_size_invoker (GimpProcedure     *procedure,
 
352
                                     Gimp              *gimp,
 
353
                                     GimpContext       *context,
 
354
                                     GimpProgress      *progress,
 
355
                                     const GValueArray *args)
 
356
{
 
357
  gboolean success = TRUE;
 
358
  GValueArray *return_vals;
 
359
  const gchar *identifier;
 
360
  gint32 bytes = 0;
 
361
 
 
362
  identifier = g_value_get_string (&args->values[0]);
 
363
 
 
364
  if (success)
 
365
    {
 
366
      gchar *canonical = gimp_canonicalize_identifier (identifier);
 
367
 
 
368
      if (! gimp_plug_in_manager_get_data (gimp->plug_in_manager,
 
369
                                           canonical, &bytes))
 
370
        success = FALSE;
 
371
 
 
372
      g_free (canonical);
 
373
    }
 
374
 
 
375
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
376
 
 
377
  if (success)
 
378
    g_value_set_int (&return_vals->values[1], bytes);
 
379
 
 
380
  return return_vals;
 
381
}
 
382
 
 
383
static GValueArray *
 
384
procedural_db_set_data_invoker (GimpProcedure     *procedure,
 
385
                                Gimp              *gimp,
 
386
                                GimpContext       *context,
 
387
                                GimpProgress      *progress,
 
388
                                const GValueArray *args)
 
389
{
 
390
  gboolean success = TRUE;
 
391
  const gchar *identifier;
 
392
  gint32 bytes;
 
393
  const guint8 *data;
 
394
 
 
395
  identifier = g_value_get_string (&args->values[0]);
 
396
  bytes = g_value_get_int (&args->values[1]);
 
397
  data = gimp_value_get_int8array (&args->values[2]);
 
398
 
 
399
  if (success)
 
400
    {
 
401
      gchar *canonical = gimp_canonicalize_identifier (identifier);
 
402
 
 
403
      gimp_plug_in_manager_set_data (gimp->plug_in_manager,
 
404
                                     canonical, bytes, data);
 
405
 
 
406
      g_free (canonical);
 
407
    }
 
408
 
 
409
  return gimp_procedure_get_return_values (procedure, success);
 
410
}
 
411
 
 
412
void
 
413
register_procedural_db_procs (GimpPDB *pdb)
 
414
{
 
415
  GimpProcedure *procedure;
 
416
 
 
417
  /*
 
418
   * gimp-procedural-db-temp-name
 
419
   */
 
420
  procedure = gimp_procedure_new (procedural_db_temp_name_invoker);
 
421
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-procedural-db-temp-name");
 
422
  gimp_procedure_set_static_strings (procedure,
 
423
                                     "gimp-procedural-db-temp-name",
 
424
                                     "Generates a unique temporary PDB name.",
 
425
                                     "This procedure generates a temporary PDB entry name that is guaranteed to be unique.",
 
426
                                     "Andy Thomas",
 
427
                                     "Andy Thomas",
 
428
                                     "1998",
 
429
                                     NULL);
 
430
  gimp_procedure_add_return_value (procedure,
 
431
                                   gimp_param_spec_string ("temp-name",
 
432
                                                           "temp name",
 
433
                                                           "A unique temporary name for a temporary PDB entry",
 
434
                                                           FALSE, FALSE,
 
435
                                                           NULL,
 
436
                                                           GIMP_PARAM_READWRITE));
 
437
  gimp_pdb_register_procedure (pdb, procedure);
 
438
  g_object_unref (procedure);
 
439
 
 
440
  /*
 
441
   * gimp-procedural-db-dump
 
442
   */
 
443
  procedure = gimp_procedure_new (procedural_db_dump_invoker);
 
444
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-procedural-db-dump");
 
445
  gimp_procedure_set_static_strings (procedure,
 
446
                                     "gimp-procedural-db-dump",
 
447
                                     "Dumps the current contents of the procedural database",
 
448
                                     "This procedure dumps the contents of the procedural database to the specified file. The file will contain all of the information provided for each registered procedure. This file is in a format appropriate for use with the supplied \"pdb_self_doc.el\" Elisp script, which generates a texinfo document.",
 
449
                                     "Spencer Kimball & Josh MacDonald",
 
450
                                     "Spencer Kimball & Josh MacDonald & Peter Mattis",
 
451
                                     "1995-1996",
 
452
                                     NULL);
 
453
  gimp_procedure_add_argument (procedure,
 
454
                               gimp_param_spec_string ("filename",
 
455
                                                       "filename",
 
456
                                                       "The dump filename",
 
457
                                                       TRUE, FALSE,
 
458
                                                       NULL,
 
459
                                                       GIMP_PARAM_READWRITE));
 
460
  gimp_pdb_register_procedure (pdb, procedure);
 
461
  g_object_unref (procedure);
 
462
 
 
463
  /*
 
464
   * gimp-procedural-db-query
 
465
   */
 
466
  procedure = gimp_procedure_new (procedural_db_query_invoker);
 
467
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-procedural-db-query");
 
468
  gimp_procedure_set_static_strings (procedure,
 
469
                                     "gimp-procedural-db-query",
 
470
                                     "Queries the procedural database for its contents using regular expression matching.",
 
471
                                     "This procedure queries the contents of the procedural database. It is supplied with seven arguments matching procedures on { name, blurb, help, author, copyright, date, procedure type}. This is accomplished using regular expression matching. For instance, to find all procedures with \"jpeg\" listed in the blurb, all seven arguments can be supplied as \".*\", except for the second, which can be supplied as \".*jpeg.*\". There are two return arguments for this procedure. The first is the number of procedures matching the query. The second is a concatenated list of procedure names corresponding to those matching the query. If no matching entries are found, then the returned string is NULL and the number of entries is 0.",
 
472
                                     "Spencer Kimball & Peter Mattis",
 
473
                                     "Spencer Kimball & Peter Mattis",
 
474
                                     "1995-1996",
 
475
                                     NULL);
 
476
  gimp_procedure_add_argument (procedure,
 
477
                               gimp_param_spec_string ("name",
 
478
                                                       "name",
 
479
                                                       "The regex for procedure name",
 
480
                                                       TRUE, FALSE,
 
481
                                                       NULL,
 
482
                                                       GIMP_PARAM_READWRITE));
 
483
  gimp_procedure_add_argument (procedure,
 
484
                               gimp_param_spec_string ("blurb",
 
485
                                                       "blurb",
 
486
                                                       "The regex for procedure blurb",
 
487
                                                       TRUE, FALSE,
 
488
                                                       NULL,
 
489
                                                       GIMP_PARAM_READWRITE));
 
490
  gimp_procedure_add_argument (procedure,
 
491
                               gimp_param_spec_string ("help",
 
492
                                                       "help",
 
493
                                                       "The regex for procedure help",
 
494
                                                       TRUE, FALSE,
 
495
                                                       NULL,
 
496
                                                       GIMP_PARAM_READWRITE));
 
497
  gimp_procedure_add_argument (procedure,
 
498
                               gimp_param_spec_string ("author",
 
499
                                                       "author",
 
500
                                                       "The regex for procedure author",
 
501
                                                       TRUE, FALSE,
 
502
                                                       NULL,
 
503
                                                       GIMP_PARAM_READWRITE));
 
504
  gimp_procedure_add_argument (procedure,
 
505
                               gimp_param_spec_string ("copyright",
 
506
                                                       "copyright",
 
507
                                                       "The regex for procedure copyright",
 
508
                                                       TRUE, FALSE,
 
509
                                                       NULL,
 
510
                                                       GIMP_PARAM_READWRITE));
 
511
  gimp_procedure_add_argument (procedure,
 
512
                               gimp_param_spec_string ("date",
 
513
                                                       "date",
 
514
                                                       "The regex for procedure date",
 
515
                                                       TRUE, FALSE,
 
516
                                                       NULL,
 
517
                                                       GIMP_PARAM_READWRITE));
 
518
  gimp_procedure_add_argument (procedure,
 
519
                               gimp_param_spec_string ("proc-type",
 
520
                                                       "proc type",
 
521
                                                       "The regex for procedure type: { 'Internal GIMP procedure', 'GIMP Plug-In', 'GIMP Extension', 'Temporary Procedure' }",
 
522
                                                       TRUE, FALSE,
 
523
                                                       NULL,
 
524
                                                       GIMP_PARAM_READWRITE));
 
525
  gimp_procedure_add_return_value (procedure,
 
526
                                   gimp_param_spec_int32 ("num-matches",
 
527
                                                          "num matches",
 
528
                                                          "The number of matching procedures",
 
529
                                                          0, G_MAXINT32, 0,
 
530
                                                          GIMP_PARAM_READWRITE));
 
531
  gimp_procedure_add_return_value (procedure,
 
532
                                   gimp_param_spec_string_array ("procedure-names",
 
533
                                                                 "procedure names",
 
534
                                                                 "The list of procedure names",
 
535
                                                                 GIMP_PARAM_READWRITE));
 
536
  gimp_pdb_register_procedure (pdb, procedure);
 
537
  g_object_unref (procedure);
 
538
 
 
539
  /*
 
540
   * gimp-procedural-db-proc-info
 
541
   */
 
542
  procedure = gimp_procedure_new (procedural_db_proc_info_invoker);
 
543
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-procedural-db-proc-info");
 
544
  gimp_procedure_set_static_strings (procedure,
 
545
                                     "gimp-procedural-db-proc-info",
 
546
                                     "Queries the procedural database for information on the specified procedure.",
 
547
                                     "This procedure returns information on the specified procedure. A short blurb, detailed help, author(s), copyright information, procedure type, number of input, and number of return values are returned. For specific information on each input argument and return value, use the 'gimp-procedural-db-proc-arg' and 'gimp-procedural-db-proc-val' procedures.",
 
548
                                     "Spencer Kimball & Peter Mattis",
 
549
                                     "Spencer Kimball & Peter Mattis",
 
550
                                     "1997",
 
551
                                     NULL);
 
552
  gimp_procedure_add_argument (procedure,
 
553
                               gimp_param_spec_string ("procedure-name",
 
554
                                                       "procedure name",
 
555
                                                       "The procedure name",
 
556
                                                       FALSE, FALSE,
 
557
                                                       NULL,
 
558
                                                       GIMP_PARAM_READWRITE));
 
559
  gimp_procedure_add_return_value (procedure,
 
560
                                   gimp_param_spec_string ("blurb",
 
561
                                                           "blurb",
 
562
                                                           "A short blurb",
 
563
                                                           FALSE, FALSE,
 
564
                                                           NULL,
 
565
                                                           GIMP_PARAM_READWRITE));
 
566
  gimp_procedure_add_return_value (procedure,
 
567
                                   gimp_param_spec_string ("help",
 
568
                                                           "help",
 
569
                                                           "Detailed procedure help",
 
570
                                                           FALSE, FALSE,
 
571
                                                           NULL,
 
572
                                                           GIMP_PARAM_READWRITE));
 
573
  gimp_procedure_add_return_value (procedure,
 
574
                                   gimp_param_spec_string ("author",
 
575
                                                           "author",
 
576
                                                           "Author(s) of the procedure",
 
577
                                                           FALSE, FALSE,
 
578
                                                           NULL,
 
579
                                                           GIMP_PARAM_READWRITE));
 
580
  gimp_procedure_add_return_value (procedure,
 
581
                                   gimp_param_spec_string ("copyright",
 
582
                                                           "copyright",
 
583
                                                           "The copyright",
 
584
                                                           FALSE, FALSE,
 
585
                                                           NULL,
 
586
                                                           GIMP_PARAM_READWRITE));
 
587
  gimp_procedure_add_return_value (procedure,
 
588
                                   gimp_param_spec_string ("date",
 
589
                                                           "date",
 
590
                                                           "Copyright date",
 
591
                                                           FALSE, FALSE,
 
592
                                                           NULL,
 
593
                                                           GIMP_PARAM_READWRITE));
 
594
  gimp_procedure_add_return_value (procedure,
 
595
                                   g_param_spec_enum ("proc-type",
 
596
                                                      "proc type",
 
597
                                                      "The procedure type",
 
598
                                                      GIMP_TYPE_PDB_PROC_TYPE,
 
599
                                                      GIMP_INTERNAL,
 
600
                                                      GIMP_PARAM_READWRITE));
 
601
  gimp_procedure_add_return_value (procedure,
 
602
                                   gimp_param_spec_int32 ("num-args",
 
603
                                                          "num args",
 
604
                                                          "The number of input arguments",
 
605
                                                          G_MININT32, G_MAXINT32, 0,
 
606
                                                          GIMP_PARAM_READWRITE));
 
607
  gimp_procedure_add_return_value (procedure,
 
608
                                   gimp_param_spec_int32 ("num-values",
 
609
                                                          "num values",
 
610
                                                          "The number of return values",
 
611
                                                          G_MININT32, G_MAXINT32, 0,
 
612
                                                          GIMP_PARAM_READWRITE));
 
613
  gimp_pdb_register_procedure (pdb, procedure);
 
614
  g_object_unref (procedure);
 
615
 
 
616
  /*
 
617
   * gimp-procedural-db-proc-arg
 
618
   */
 
619
  procedure = gimp_procedure_new (procedural_db_proc_arg_invoker);
 
620
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-procedural-db-proc-arg");
 
621
  gimp_procedure_set_static_strings (procedure,
 
622
                                     "gimp-procedural-db-proc-arg",
 
623
                                     "Queries the procedural database for information on the specified procedure's argument.",
 
624
                                     "This procedure returns information on the specified procedure's argument. The argument type, name, and a description are retrieved.",
 
625
                                     "Spencer Kimball & Peter Mattis",
 
626
                                     "Spencer Kimball & Peter Mattis",
 
627
                                     "1997",
 
628
                                     NULL);
 
629
  gimp_procedure_add_argument (procedure,
 
630
                               gimp_param_spec_string ("procedure-name",
 
631
                                                       "procedure name",
 
632
                                                       "The procedure name",
 
633
                                                       FALSE, FALSE,
 
634
                                                       NULL,
 
635
                                                       GIMP_PARAM_READWRITE));
 
636
  gimp_procedure_add_argument (procedure,
 
637
                               gimp_param_spec_int32 ("arg-num",
 
638
                                                      "arg num",
 
639
                                                      "The argument number",
 
640
                                                      G_MININT32, G_MAXINT32, 0,
 
641
                                                      GIMP_PARAM_READWRITE));
 
642
  gimp_procedure_add_return_value (procedure,
 
643
                                   gimp_param_spec_enum ("arg-type",
 
644
                                                         "arg type",
 
645
                                                         "The type of argument",
 
646
                                                         GIMP_TYPE_PDB_ARG_TYPE,
 
647
                                                         GIMP_PDB_INT32,
 
648
                                                         GIMP_PARAM_READWRITE));
 
649
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->values[0]),
 
650
                                      GIMP_PDB_END);
 
651
  gimp_procedure_add_return_value (procedure,
 
652
                                   gimp_param_spec_string ("arg-name",
 
653
                                                           "arg name",
 
654
                                                           "The name of the argument",
 
655
                                                           FALSE, FALSE,
 
656
                                                           NULL,
 
657
                                                           GIMP_PARAM_READWRITE));
 
658
  gimp_procedure_add_return_value (procedure,
 
659
                                   gimp_param_spec_string ("arg-desc",
 
660
                                                           "arg desc",
 
661
                                                           "A description of the argument",
 
662
                                                           FALSE, FALSE,
 
663
                                                           NULL,
 
664
                                                           GIMP_PARAM_READWRITE));
 
665
  gimp_pdb_register_procedure (pdb, procedure);
 
666
  g_object_unref (procedure);
 
667
 
 
668
  /*
 
669
   * gimp-procedural-db-proc-val
 
670
   */
 
671
  procedure = gimp_procedure_new (procedural_db_proc_val_invoker);
 
672
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-procedural-db-proc-val");
 
673
  gimp_procedure_set_static_strings (procedure,
 
674
                                     "gimp-procedural-db-proc-val",
 
675
                                     "Queries the procedural database for information on the specified procedure's return value.",
 
676
                                     "This procedure returns information on the specified procedure's return value. The return value type, name, and a description are retrieved.",
 
677
                                     "Spencer Kimball & Peter Mattis",
 
678
                                     "Spencer Kimball & Peter Mattis",
 
679
                                     "1997",
 
680
                                     NULL);
 
681
  gimp_procedure_add_argument (procedure,
 
682
                               gimp_param_spec_string ("procedure-name",
 
683
                                                       "procedure name",
 
684
                                                       "The procedure name",
 
685
                                                       FALSE, FALSE,
 
686
                                                       NULL,
 
687
                                                       GIMP_PARAM_READWRITE));
 
688
  gimp_procedure_add_argument (procedure,
 
689
                               gimp_param_spec_int32 ("val-num",
 
690
                                                      "val num",
 
691
                                                      "The return value number",
 
692
                                                      G_MININT32, G_MAXINT32, 0,
 
693
                                                      GIMP_PARAM_READWRITE));
 
694
  gimp_procedure_add_return_value (procedure,
 
695
                                   gimp_param_spec_enum ("val-type",
 
696
                                                         "val type",
 
697
                                                         "The type of return value",
 
698
                                                         GIMP_TYPE_PDB_ARG_TYPE,
 
699
                                                         GIMP_PDB_INT32,
 
700
                                                         GIMP_PARAM_READWRITE));
 
701
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->values[0]),
 
702
                                      GIMP_PDB_END);
 
703
  gimp_procedure_add_return_value (procedure,
 
704
                                   gimp_param_spec_string ("val-name",
 
705
                                                           "val name",
 
706
                                                           "The name of the return value",
 
707
                                                           FALSE, FALSE,
 
708
                                                           NULL,
 
709
                                                           GIMP_PARAM_READWRITE));
 
710
  gimp_procedure_add_return_value (procedure,
 
711
                                   gimp_param_spec_string ("val-desc",
 
712
                                                           "val desc",
 
713
                                                           "A description of the return value",
 
714
                                                           FALSE, FALSE,
 
715
                                                           NULL,
 
716
                                                           GIMP_PARAM_READWRITE));
 
717
  gimp_pdb_register_procedure (pdb, procedure);
 
718
  g_object_unref (procedure);
 
719
 
 
720
  /*
 
721
   * gimp-procedural-db-get-data
 
722
   */
 
723
  procedure = gimp_procedure_new (procedural_db_get_data_invoker);
 
724
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-procedural-db-get-data");
 
725
  gimp_procedure_set_static_strings (procedure,
 
726
                                     "gimp-procedural-db-get-data",
 
727
                                     "Returns data associated with the specified identifier.",
 
728
                                     "This procedure returns any data which may have been associated with the specified identifier. The data is a variable length array of bytes. If no data has been associated with the identifier, an error is returned.",
 
729
                                     "Spencer Kimball & Peter Mattis",
 
730
                                     "Spencer Kimball & Peter Mattis",
 
731
                                     "1997",
 
732
                                     NULL);
 
733
  gimp_procedure_add_argument (procedure,
 
734
                               gimp_param_spec_string ("identifier",
 
735
                                                       "identifier",
 
736
                                                       "The identifier associated with data",
 
737
                                                       FALSE, FALSE,
 
738
                                                       NULL,
 
739
                                                       GIMP_PARAM_READWRITE));
 
740
  gimp_procedure_add_return_value (procedure,
 
741
                                   gimp_param_spec_int32 ("bytes",
 
742
                                                          "bytes",
 
743
                                                          "The number of bytes in the data",
 
744
                                                          1, G_MAXINT32, 1,
 
745
                                                          GIMP_PARAM_READWRITE));
 
746
  gimp_procedure_add_return_value (procedure,
 
747
                                   gimp_param_spec_int8_array ("data",
 
748
                                                               "data",
 
749
                                                               "A byte array containing data",
 
750
                                                               GIMP_PARAM_READWRITE));
 
751
  gimp_pdb_register_procedure (pdb, procedure);
 
752
  g_object_unref (procedure);
 
753
 
 
754
  /*
 
755
   * gimp-procedural-db-get-data-size
 
756
   */
 
757
  procedure = gimp_procedure_new (procedural_db_get_data_size_invoker);
 
758
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-procedural-db-get-data-size");
 
759
  gimp_procedure_set_static_strings (procedure,
 
760
                                     "gimp-procedural-db-get-data-size",
 
761
                                     "Returns size of data associated with the specified identifier.",
 
762
                                     "This procedure returns the size of any data which may have been associated with the specified identifier. If no data has been associated with the identifier, an error is returned.",
 
763
                                     "Nick Lamb",
 
764
                                     "Nick Lamb",
 
765
                                     "1998",
 
766
                                     NULL);
 
767
  gimp_procedure_add_argument (procedure,
 
768
                               gimp_param_spec_string ("identifier",
 
769
                                                       "identifier",
 
770
                                                       "The identifier associated with data",
 
771
                                                       FALSE, FALSE,
 
772
                                                       NULL,
 
773
                                                       GIMP_PARAM_READWRITE));
 
774
  gimp_procedure_add_return_value (procedure,
 
775
                                   gimp_param_spec_int32 ("bytes",
 
776
                                                          "bytes",
 
777
                                                          "The number of bytes in the data",
 
778
                                                          1, G_MAXINT32, 1,
 
779
                                                          GIMP_PARAM_READWRITE));
 
780
  gimp_pdb_register_procedure (pdb, procedure);
 
781
  g_object_unref (procedure);
 
782
 
 
783
  /*
 
784
   * gimp-procedural-db-set-data
 
785
   */
 
786
  procedure = gimp_procedure_new (procedural_db_set_data_invoker);
 
787
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-procedural-db-set-data");
 
788
  gimp_procedure_set_static_strings (procedure,
 
789
                                     "gimp-procedural-db-set-data",
 
790
                                     "Associates the specified identifier with the supplied data.",
 
791
                                     "This procedure associates the supplied data with the provided identifier. The data may be subsequently retrieved by a call to 'procedural-db-get-data'.",
 
792
                                     "Spencer Kimball & Peter Mattis",
 
793
                                     "Spencer Kimball & Peter Mattis",
 
794
                                     "1997",
 
795
                                     NULL);
 
796
  gimp_procedure_add_argument (procedure,
 
797
                               gimp_param_spec_string ("identifier",
 
798
                                                       "identifier",
 
799
                                                       "The identifier associated with data",
 
800
                                                       FALSE, FALSE,
 
801
                                                       NULL,
 
802
                                                       GIMP_PARAM_READWRITE));
 
803
  gimp_procedure_add_argument (procedure,
 
804
                               gimp_param_spec_int32 ("bytes",
 
805
                                                      "bytes",
 
806
                                                      "The number of bytes in the data",
 
807
                                                      1, G_MAXINT32, 1,
 
808
                                                      GIMP_PARAM_READWRITE));
 
809
  gimp_procedure_add_argument (procedure,
 
810
                               gimp_param_spec_int8_array ("data",
 
811
                                                           "data",
 
812
                                                           "A byte array containing data",
 
813
                                                           GIMP_PARAM_READWRITE));
 
814
  gimp_pdb_register_procedure (pdb, procedure);
 
815
  g_object_unref (procedure);
 
816
}