Commit 5267f601 authored by jaycox's avatar jaycox
Browse files

app/drawable_cmds.c, app/gimage_cmds.c app/parasite_cmds.c,


	* app/drawable_cmds.c, app/gimage_cmds.c
	* app/parasite_cmds.c, libgimp/parasite.[ch],
	* libgimp/gimp.c, libgimp/gimpprotocol.c
	* tiff.c, gif.c, script-fu.c: removed all references to
 	parasite_error() and parasite_is_error().  Enable the
	passing of null parasites in the pdb.  Return a copy of the
	parasite instead of the orginal in all pdb functions.
parent 476d9300
1998-11-12 Jay Cox <jaycox@earthlink.net>
* app/drawable_cmds.c, app/gimage_cmds.c
* app/parasite_cmds.c, libgimp/parasite.[ch],
* libgimp/gimp.c, libgimp/gimpprotocol.c
* tiff.c, gif.c, script-fu.c: removed all references to
parasite_error() and parasite_is_error(). Enable the
passing of null parasites in the pdb. Return a copy of the
parasite instead of the orginal in all pdb functions.
Wed Nov 11 04:18:57 PST 1998 Manish Singh <yosh@gimp.org>
* configure.in: fix buglet with making GLIB_LIBS (shouldn't have
......
......@@ -1525,9 +1525,7 @@ gimp_drawable_find_parasite_invoker (Argument *args)
if (success)
{
return_args[1].value.pdb_pointer =
gimp_drawable_find_parasite (gdrawable, name);
if (return_args[1].value.pdb_pointer == NULL)
return_args[1].value.pdb_pointer = parasite_error();
parasite_copy(gimp_drawable_find_parasite (gdrawable, name));
}
return return_args;
......
......@@ -4394,9 +4394,7 @@ gimp_image_find_parasite_invoker (Argument *args)
if (success)
{
return_args[1].value.pdb_pointer =
gimp_image_find_parasite (gimage, name);
if (return_args[1].value.pdb_pointer == NULL)
return_args[1].value.pdb_pointer = parasite_error();
parasite_copy(gimp_image_find_parasite (gimage, name));
}
return return_args;
......
......@@ -437,18 +437,18 @@ static void test_gserialize()
g_deserialize(test_struct_descript, (char *)(void*)to, ser_1);
if (to->test_gint32 != ts->test_gint32)
g_message("gint32 test failed: %d\n", to->test_gint32);
g_message("gint32 test failed (please email your system configuration to jaycox@earthlink.net): %d\n", to->test_gint32);
if (to->test_float != ts->test_float)
g_message("float test failed: %f\n", to->test_float);
g_message("float test failed (please email your system configuration to jaycox@earthlink.net): %f\n", to->test_float);
if (strcmp(to->test_string, ts->test_string) != 0)
g_message("string test failed: %s\n", to->test_string);
g_message("string test failed (please email your system configuration to jaycox@earthlink.net): %s\n", to->test_string);
if (to->test_length != ts->test_length)
g_message("array length test failed: %d\n", to->test_length);
g_message("array length test failed(please email your system configuration to jaycox@earthlink.net): %d\n", to->test_length);
if (to->test_array[0] != ts->test_array[0])
g_message("int16array value 0 test failed: %d\n", to->test_array[0]);
g_message("int16array value 0 test failed(please email your system configuration to jaycox@earthlink.net): %d\n", to->test_array[0]);
g_return_if_fail (to->test_array[1] == ts->test_array[1]);
if (to->test_array[1] != ts->test_array[1])
g_message("int16array value 1 test failed: %d\n", to->test_array[1]);
g_message("int16array value 1 test failed(please email your system configuration to jaycox@earthlink.net): %d\n", to->test_array[1]);
/* really should free the memory... */
g_message("Passed serialization test\n");
}/*
......
......@@ -182,9 +182,7 @@ gimp_find_parasite_invoker (Argument *args)
if (success)
{
return_args[1].value.pdb_pointer =
gimp_find_parasite (name);
if (return_args[1].value.pdb_pointer == NULL)
return_args[1].value.pdb_pointer = parasite_error();
parasite_copy(gimp_find_parasite (name));
}
return return_args;
......
......@@ -715,11 +715,17 @@ gimp_run_procedure (char *name,
{
Parasite *p = va_arg (args, Parasite*);
if (p == NULL)
p = parasite_error();
proc_run.params[i].data.d_parasite.name = p->name;
proc_run.params[i].data.d_parasite.flags = p->flags;
proc_run.params[i].data.d_parasite.size = p->size;
proc_run.params[i].data.d_parasite.data = p->data;
{
proc_run.params[i].data.d_parasite.name = NULL;
proc_run.params[i].data.d_parasite.data = NULL;
}
else
{
proc_run.params[i].data.d_parasite.name = p->name;
proc_run.params[i].data.d_parasite.flags = p->flags;
proc_run.params[i].data.d_parasite.size = p->size;
proc_run.params[i].data.d_parasite.data = p->data;
}
} break;
case PARAM_STATUS:
proc_run.params[i].data.d_status = va_arg (args, gint32);
......
......@@ -51,7 +51,11 @@ parasite_new (const char *name, guint32 flags,
if (name)
p->name = g_strdup(name);
else
{
p->name = NULL;
g_free (p);
return NULL;
}
p->flags = flags;
p->size = size;
if (size)
......@@ -61,11 +65,11 @@ parasite_new (const char *name, guint32 flags,
return p;
}
void
parasite_free (Parasite *parasite)
{
g_return_if_fail(parasite != NULL);
if (parasite == NULL)
return;
if (parasite->name)
g_free(parasite->name);
if (parasite->data)
......@@ -90,23 +94,6 @@ parasite_copy (const Parasite *parasite)
parasite->size, parasite->data);
}
Parasite *
parasite_error()
{
static Parasite *error_p = NULL;
if (!error_p)
error_p = parasite_new("error", 0, 0, NULL);
return error_p;
}
int
parasite_is_error(const Parasite *p)
{
if (p == NULL)
return TRUE;
return parasite_is_type(p, "error");
}
int
parasite_is_persistant(const Parasite *p)
{
......
......@@ -36,10 +36,6 @@ void parasite_free (Parasite *parasite);
int parasite_is_type (const Parasite *parasite, const char *name);
Parasite *parasite_copy (const Parasite *parasite);
Parasite *parasite_error ();
int parasite_is_error (const Parasite *p);
int parasite_is_persistant (const Parasite *p);
#ifdef __cplusplus
......
......@@ -914,6 +914,11 @@ _gp_params_read (int fd, GPParam **params, guint *nparams)
{
if (!wire_read_string (fd, &(*params)[i].data.d_parasite.name, 1))
return;
if ((*params)[i].data.d_parasite.name == NULL)
{ /* we have a null parasite */
(*params)[i].data.d_parasite.data = NULL;
break;
}
if (!wire_read_int32 (fd, &((*params)[i].data.d_parasite.flags), 1))
return;
if (!wire_read_int32 (fd, &((*params)[i].data.d_parasite.size), 1))
......@@ -1047,6 +1052,11 @@ _gp_params_write (int fd, GPParam *params, int nparams)
case PARAM_PARASITE:
{
Parasite *p = (Parasite *)&params[i].data.d_parasite;
if (p->name == NULL)
{ /* write a null string to signifly a null parasite */
wire_write_string (fd, &p->name, 1);
break;
}
if (!wire_write_string (fd, &p->name, 1))
return;
if (!wire_write_int32 (fd, &p->flags, 1))
......@@ -1136,6 +1146,8 @@ _gp_params_destroy (GPParam *params, int nparams)
}
break;
case PARAM_PARASITE:
if (params[i].data.d_parasite.name)
g_free(params[i].data.d_parasite.name);
if (params[i].data.d_parasite.data)
g_free(params[i].data.d_parasite.data);
break;
......
......@@ -51,7 +51,11 @@ parasite_new (const char *name, guint32 flags,
if (name)
p->name = g_strdup(name);
else
{
p->name = NULL;
g_free (p);
return NULL;
}
p->flags = flags;
p->size = size;
if (size)
......@@ -61,11 +65,11 @@ parasite_new (const char *name, guint32 flags,
return p;
}
void
parasite_free (Parasite *parasite)
{
g_return_if_fail(parasite != NULL);
if (parasite == NULL)
return;
if (parasite->name)
g_free(parasite->name);
if (parasite->data)
......@@ -90,23 +94,6 @@ parasite_copy (const Parasite *parasite)
parasite->size, parasite->data);
}
Parasite *
parasite_error()
{
static Parasite *error_p = NULL;
if (!error_p)
error_p = parasite_new("error", 0, 0, NULL);
return error_p;
}
int
parasite_is_error(const Parasite *p)
{
if (p == NULL)
return TRUE;
return parasite_is_type(p, "error");
}
int
parasite_is_persistant(const Parasite *p)
{
......
......@@ -36,10 +36,6 @@ void parasite_free (Parasite *parasite);
int parasite_is_type (const Parasite *parasite, const char *name);
Parasite *parasite_copy (const Parasite *parasite);
Parasite *parasite_error ();
int parasite_is_error (const Parasite *p);
int parasite_is_persistant (const Parasite *p);
#ifdef __cplusplus
......
......@@ -51,7 +51,11 @@ parasite_new (const char *name, guint32 flags,
if (name)
p->name = g_strdup(name);
else
{
p->name = NULL;
g_free (p);
return NULL;
}
p->flags = flags;
p->size = size;
if (size)
......@@ -61,11 +65,11 @@ parasite_new (const char *name, guint32 flags,
return p;
}
void
parasite_free (Parasite *parasite)
{
g_return_if_fail(parasite != NULL);
if (parasite == NULL)
return;
if (parasite->name)
g_free(parasite->name);
if (parasite->data)
......@@ -90,23 +94,6 @@ parasite_copy (const Parasite *parasite)
parasite->size, parasite->data);
}
Parasite *
parasite_error()
{
static Parasite *error_p = NULL;
if (!error_p)
error_p = parasite_new("error", 0, 0, NULL);
return error_p;
}
int
parasite_is_error(const Parasite *p)
{
if (p == NULL)
return TRUE;
return parasite_is_type(p, "error");
}
int
parasite_is_persistant(const Parasite *p)
{
......
......@@ -36,10 +36,6 @@ void parasite_free (Parasite *parasite);
int parasite_is_type (const Parasite *parasite, const char *name);
Parasite *parasite_copy (const Parasite *parasite);
Parasite *parasite_error ();
int parasite_is_error (const Parasite *p);
int parasite_is_persistant (const Parasite *p);
#ifdef __cplusplus
......
......@@ -914,6 +914,11 @@ _gp_params_read (int fd, GPParam **params, guint *nparams)
{
if (!wire_read_string (fd, &(*params)[i].data.d_parasite.name, 1))
return;
if ((*params)[i].data.d_parasite.name == NULL)
{ /* we have a null parasite */
(*params)[i].data.d_parasite.data = NULL;
break;
}
if (!wire_read_int32 (fd, &((*params)[i].data.d_parasite.flags), 1))
return;
if (!wire_read_int32 (fd, &((*params)[i].data.d_parasite.size), 1))
......@@ -1047,6 +1052,11 @@ _gp_params_write (int fd, GPParam *params, int nparams)
case PARAM_PARASITE:
{
Parasite *p = (Parasite *)&params[i].data.d_parasite;
if (p->name == NULL)
{ /* write a null string to signifly a null parasite */
wire_write_string (fd, &p->name, 1);
break;
}
if (!wire_write_string (fd, &p->name, 1))
return;
if (!wire_write_int32 (fd, &p->flags, 1))
......@@ -1136,6 +1146,8 @@ _gp_params_destroy (GPParam *params, int nparams)
}
break;
case PARAM_PARASITE:
if (params[i].data.d_parasite.name)
g_free(params[i].data.d_parasite.name);
if (params[i].data.d_parasite.data)
g_free(params[i].data.d_parasite.data);
break;
......
......@@ -2142,7 +2142,7 @@ save_dialog ( gint32 image_ID )
}
#ifdef FACEHUGGERS
GIF2_CMNT = gimp_image_find_parasite (image_ID, "gimp-comment");
if (!parasite_is_error(GIF2_CMNT))
if (GIF2_CMNT)
{
globalcomment = g_malloc(GIF2_CMNT->size);
strcpy(globalcomment, GIF2_CMNT->data);
......
......@@ -225,7 +225,7 @@ run (char *name,
int image = param[1].data.d_int32;
parasite = gimp_image_find_parasite(image, "gimp-comment");
if (!parasite_is_error(parasite))
if (parasite)
image_comment = g_strdup(parasite->data);
parasite_free(parasite);
#endif /* GIMP_HAVE_PARASITES */
......@@ -240,7 +240,7 @@ run (char *name,
gimp_get_data ("file_tiff_save", &tsvals);
#ifdef GIMP_HAVE_PARASITES
parasite = gimp_image_find_parasite(image, "tiff-save-options");
if (!parasite_is_error(parasite))
if (parasite)
{
tsvals.compression = ((TiffSaveVals *)parasite->data)->compression;
tsvals.fillorder = ((TiffSaveVals *)parasite->data)->fillorder;
......@@ -280,7 +280,7 @@ run (char *name,
gimp_get_data ("file_tiff_save", &tsvals);
#ifdef GIMP_HAVE_PARASITES
parasite = gimp_image_find_parasite(image, "tiff-save-options");
if (!parasite_is_error(parasite))
if (parasite)
{
tsvals.compression = ((TiffSaveVals *)parasite->data)->compression;
tsvals.fillorder = ((TiffSaveVals *)parasite->data)->fillorder;
......@@ -1141,7 +1141,7 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
TIFFSetField (tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
}
}
#endif GIMP_HAVE_RESOLUTION_INFO
#endif /* GIMP_HAVE_RESOLUTION_INFO */
/* do we have a comment? If so, create a new parasite to hold it,
* and attach it to the image. The attach function automatically
......
......@@ -2142,7 +2142,7 @@ save_dialog ( gint32 image_ID )
}
#ifdef FACEHUGGERS
GIF2_CMNT = gimp_image_find_parasite (image_ID, "gimp-comment");
if (!parasite_is_error(GIF2_CMNT))
if (GIF2_CMNT)
{
globalcomment = g_malloc(GIF2_CMNT->size);
strcpy(globalcomment, GIF2_CMNT->data);
......
......@@ -788,12 +788,12 @@ marshall_proc_db_call (LISP a)
/* parasite->size */
intermediate_val = cdr (intermediate_val);
args[i].data.d_parasite.size = (car (intermediate_val))->storage_as.string.dim;
args[i].data.d_parasite.size =
(car (intermediate_val))->storage_as.string.dim;
/* parasite->data */
args[i].data.d_parasite.data = (void*) (car (intermediate_val))->storage_as.string.data;
printf("e\n");
args[i].data.d_parasite.data =
(void*) (car (intermediate_val))->storage_as.string.data;
}
break;
case PARAM_STATUS:
......@@ -950,19 +950,26 @@ marshall_proc_db_call (LISP a)
{
LISP name, flags, data;
string_len = strlen (values[i + 1].data.d_parasite.name);
name = strcons (string_len,
values[i + 1].data.d_parasite.name);
flags = flocons (values[i + 1].data.d_parasite.flags);
data = arcons (tc_byte_array,
values[i+1].data.d_parasite.size, 0);
memcpy(data->storage_as.string.data,
values[i+1].data.d_parasite.data,
values[i+1].data.d_parasite.size);
intermediate_val = cons (name, cons(flags, cons(data, NIL)));
return_val = cons (intermediate_val, return_val);
if (values[i + 1].data.d_parasite.name == NULL)
{
return_val = my_err("Error: null parasite", NIL);
}
else
{
string_len = strlen (values[i + 1].data.d_parasite.name);
name = strcons (string_len,
values[i + 1].data.d_parasite.name);
flags = flocons (values[i + 1].data.d_parasite.flags);
data = arcons (tc_byte_array,
values[i+1].data.d_parasite.size, 0);
memcpy(data->storage_as.string.data,
values[i+1].data.d_parasite.data,
values[i+1].data.d_parasite.size);
intermediate_val = cons (name, cons(flags, cons(data, NIL)));
return_val = cons (intermediate_val, return_val);
}
}
break;
case PARAM_STATUS:
......
......@@ -225,7 +225,7 @@ run (char *name,
int image = param[1].data.d_int32;
parasite = gimp_image_find_parasite(image, "gimp-comment");
if (!parasite_is_error(parasite))
if (parasite)
image_comment = g_strdup(parasite->data);
parasite_free(parasite);
#endif /* GIMP_HAVE_PARASITES */
......@@ -240,7 +240,7 @@ run (char *name,
gimp_get_data ("file_tiff_save", &tsvals);
#ifdef GIMP_HAVE_PARASITES
parasite = gimp_image_find_parasite(image, "tiff-save-options");
if (!parasite_is_error(parasite))
if (parasite)
{
tsvals.compression = ((TiffSaveVals *)parasite->data)->compression;
tsvals.fillorder = ((TiffSaveVals *)parasite->data)->fillorder;
......@@ -280,7 +280,7 @@ run (char *name,
gimp_get_data ("file_tiff_save", &tsvals);
#ifdef GIMP_HAVE_PARASITES
parasite = gimp_image_find_parasite(image, "tiff-save-options");
if (!parasite_is_error(parasite))
if (parasite)
{
tsvals.compression = ((TiffSaveVals *)parasite->data)->compression;
tsvals.fillorder = ((TiffSaveVals *)parasite->data)->fillorder;
......@@ -1141,7 +1141,7 @@ static gint save_image (char *filename, gint32 image, gint32 layer) {
TIFFSetField (tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
}
}
#endif GIMP_HAVE_RESOLUTION_INFO
#endif /* GIMP_HAVE_RESOLUTION_INFO */
/* do we have a comment? If so, create a new parasite to hold it,
* and attach it to the image. The attach function automatically
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment