1
/* LIBGIMP - The GIMP Library
2
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
5
* Copyright (C) 1998 Jay Cox <jaycox@earthlink.net>
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the
19
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
31
#include <glib-object.h>
34
#include <process.h> /* For _getpid() */
37
#include "gimpbasetypes.h"
39
#include "gimpparasite.h"
44
gimp_parasite_print (GimpParasite *parasite)
48
g_print ("pid %d: attempt to print a null parasite\n", getpid ());
52
g_print ("pid %d: parasite: %p\n", getpid (), parasite);
55
g_print ("\tname: %s\n", parasite->name);
57
g_print ("\tname: NULL\n");
59
g_print ("\tflags: %d\n", parasite->flags);
60
g_print ("\tsize: %d\n", parasite->size);
61
if (parasite->size > 0)
62
g_print ("\tdata: %p\n", parasite->data);
67
gimp_parasite_new (const gchar *name,
72
GimpParasite *parasite;
77
parasite = g_new (GimpParasite, 1);
78
parasite->name = g_strdup (name);
79
parasite->flags = (flags & 0xFF);
80
parasite->size = size;
82
parasite->data = g_memdup (data, size);
84
parasite->data = NULL;
90
gimp_parasite_free (GimpParasite *parasite)
96
g_free (parasite->name);
98
g_free (parasite->data);
104
gimp_parasite_is_type (const GimpParasite *parasite,
107
if (!parasite || !parasite->name)
110
return (strcmp (parasite->name, name) == 0);
114
gimp_parasite_copy (const GimpParasite *parasite)
116
if (parasite == NULL)
119
return gimp_parasite_new (parasite->name, parasite->flags,
120
parasite->size, parasite->data);
124
gimp_parasite_compare (const GimpParasite *a,
125
const GimpParasite *b)
128
a->name && b->name &&
129
strcmp (a->name, b->name) == 0 &&
130
a->flags == b->flags &&
133
if (a->data == NULL && b->data == NULL)
135
else if (a->data && b->data && memcmp (a->data, b->data, a->size) == 0)
143
gimp_parasite_flags (const GimpParasite *parasite)
145
if (parasite == NULL)
148
return parasite->flags;
152
gimp_parasite_is_persistent (const GimpParasite *parasite)
154
if (parasite == NULL)
157
return (parasite->flags & GIMP_PARASITE_PERSISTENT);
161
gimp_parasite_is_undoable (const GimpParasite *parasite)
163
if (parasite == NULL)
166
return (parasite->flags & GIMP_PARASITE_UNDOABLE);
170
gimp_parasite_has_flag (const GimpParasite *parasite,
173
if (parasite == NULL)
176
return (parasite->flags & flag);
180
gimp_parasite_name (const GimpParasite *parasite)
183
return parasite->name;
189
gimp_parasite_data (const GimpParasite *parasite)
192
return parasite->data;
198
gimp_parasite_data_size (const GimpParasite *parasite)
201
return parasite->size;