2017-04-25 14:41:48 +02:00
|
|
|
/*
|
|
|
|
|
* DBprop.c --
|
|
|
|
|
*
|
|
|
|
|
* Implement properties on database cells. Properties are name-value pairs
|
|
|
|
|
* and provide a flexible way of extending the data that is stored in a
|
|
|
|
|
* CellDef. Maybe in the future properties will be added to other database
|
|
|
|
|
* objects.
|
|
|
|
|
*
|
2020-05-23 23:13:14 +02:00
|
|
|
* *********************************************************************
|
|
|
|
|
* * Copyright (C) 1985, 1990 Regents of the University of California. *
|
|
|
|
|
* * Permission to use, copy, modify, and distribute this *
|
|
|
|
|
* * software and its documentation for any purpose and without *
|
|
|
|
|
* * fee is hereby granted, provided that the above copyright *
|
|
|
|
|
* * notice appear in all copies. The University of California *
|
|
|
|
|
* * makes no representations about the suitability of this *
|
|
|
|
|
* * software for any purpose. It is provided "as is" without *
|
|
|
|
|
* * express or implied warranty. Export of this software outside *
|
|
|
|
|
* * of the United States of America may require an export license. *
|
2017-04-25 14:41:48 +02:00
|
|
|
* *********************************************************************
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef lint
|
|
|
|
|
static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/database/DBprop.c,v 1.1.1.1 2008/02/03 20:43:50 tim Exp $";
|
|
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2022-01-07 20:56:43 +01:00
|
|
|
#include <string.h>
|
2017-04-25 14:41:48 +02:00
|
|
|
#include "utils/magic.h"
|
|
|
|
|
#include "utils/geometry.h"
|
|
|
|
|
#include "tiles/tile.h"
|
|
|
|
|
#include "utils/hash.h"
|
|
|
|
|
#include "database/database.h"
|
|
|
|
|
#include "utils/malloc.h"
|
|
|
|
|
|
2026-02-18 22:17:03 +01:00
|
|
|
/* Global variable */
|
|
|
|
|
|
|
|
|
|
bool DBPropCompat = TRUE; /* If TRUE, then always save properties to
|
|
|
|
|
* .mag files as type "string" for backwards
|
|
|
|
|
* compatibility. If FALSE, then properties
|
|
|
|
|
* are saved to the .mag file along with their
|
|
|
|
|
* type. Regardless of the setting, properties
|
|
|
|
|
* which are reserved keywords are converted
|
|
|
|
|
* to the best internal representation on input.
|
|
|
|
|
*/
|
2020-05-23 23:13:14 +02:00
|
|
|
|
2017-04-25 14:41:48 +02:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
*
|
2021-01-06 17:35:03 +01:00
|
|
|
* DBPropPut --
|
2017-04-25 14:41:48 +02:00
|
|
|
*
|
|
|
|
|
* Put a property onto a celldef.
|
|
|
|
|
*
|
|
|
|
|
* Results:
|
|
|
|
|
* None.
|
|
|
|
|
*
|
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
DBPropPut(cellDef, name, value)
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
CellDef *cellDef; /* Pointer to definition of cell. */
|
|
|
|
|
char *name; /* The name of the property desired. */
|
|
|
|
|
PropertyRecord *value; /* MUST point to a malloc'ed structure, or NULL.
|
|
|
|
|
* This will be freed when the CellDef is freed.
|
|
|
|
|
*/
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
HashTable *htab;
|
|
|
|
|
HashEntry *entry;
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
PropertyRecord *oldvalue;
|
2017-04-25 14:41:48 +02:00
|
|
|
|
2020-12-14 22:16:37 +01:00
|
|
|
/* Honor the NOEDIT flag. Note that the caller always assumes that */
|
|
|
|
|
/* the value would be saved in the hash table, so if it is not */
|
|
|
|
|
/* being used, then it must be freed here. */
|
|
|
|
|
|
|
|
|
|
if (cellDef->cd_flags & CDNOEDIT)
|
|
|
|
|
{
|
2022-02-15 18:01:11 +01:00
|
|
|
if (value != (ClientData)NULL)
|
|
|
|
|
freeMagic((char *)value);
|
2020-12-14 22:16:37 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2017-04-25 14:41:48 +02:00
|
|
|
|
2020-05-23 23:13:14 +02:00
|
|
|
if (cellDef->cd_props == (ClientData) NULL)
|
2017-04-25 14:41:48 +02:00
|
|
|
{
|
|
|
|
|
cellDef->cd_props = (ClientData) mallocMagic(sizeof(HashTable));
|
|
|
|
|
HashInit( (HashTable *) cellDef->cd_props, 8, 0);
|
|
|
|
|
}
|
|
|
|
|
htab = (HashTable *) cellDef->cd_props;
|
2019-08-20 14:42:07 +02:00
|
|
|
|
|
|
|
|
/* Special handling of FIXED_BBOX, which uses CDFIXEDBBOX as a quick lookup */
|
|
|
|
|
if (!strcmp(name, "FIXED_BBOX"))
|
|
|
|
|
{
|
|
|
|
|
if (value == (ClientData)NULL)
|
|
|
|
|
cellDef->cd_flags &= ~CDFIXEDBBOX;
|
|
|
|
|
else
|
|
|
|
|
cellDef->cd_flags |= CDFIXEDBBOX;
|
|
|
|
|
}
|
2020-05-23 23:13:14 +02:00
|
|
|
|
2021-02-18 21:36:29 +01:00
|
|
|
/* Special handling of GDS_FILE, which uses CDVENDORGDS as a quick lookup */
|
|
|
|
|
if (!strcmp(name, "GDS_FILE"))
|
|
|
|
|
{
|
|
|
|
|
if (value == (ClientData)NULL)
|
|
|
|
|
cellDef->cd_flags &= ~CDVENDORGDS;
|
|
|
|
|
else
|
|
|
|
|
cellDef->cd_flags |= CDVENDORGDS;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-25 14:41:48 +02:00
|
|
|
entry = HashFind(htab, name);
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
oldvalue = (PropertyRecord *)HashGetValue(entry);
|
|
|
|
|
if (oldvalue != NULL) freeMagic((char *)oldvalue);
|
|
|
|
|
if (value == (PropertyRecord *)NULL)
|
2019-10-17 22:21:56 +02:00
|
|
|
HashRemove(htab, name);
|
|
|
|
|
else
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
HashSetValue(entry, PTR2CD(value));
|
2017-04-25 14:41:48 +02:00
|
|
|
}
|
2020-05-23 23:13:14 +02:00
|
|
|
|
2017-04-25 14:41:48 +02:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* DBPropGet --
|
|
|
|
|
*
|
|
|
|
|
* Get a property from a celldef.
|
|
|
|
|
*
|
|
|
|
|
* Results:
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
* NULL if the property didn't exist, or if the property record was NULL.
|
|
|
|
|
* Otherwise, returns a pointer to the property record.
|
2017-04-25 14:41:48 +02:00
|
|
|
*
|
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
PropertyRecord *
|
2017-04-25 14:41:48 +02:00
|
|
|
DBPropGet(cellDef, name, found)
|
|
|
|
|
CellDef *cellDef; /* Pointer to definition of cell. */
|
|
|
|
|
char *name; /* The name of the property desired. */
|
|
|
|
|
bool *found; /* If not NULL, filled in with TRUE iff the property
|
|
|
|
|
* exists.
|
|
|
|
|
*/
|
|
|
|
|
{
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
PropertyRecord *result;
|
2017-04-25 14:41:48 +02:00
|
|
|
bool haveit;
|
|
|
|
|
HashTable *htab;
|
|
|
|
|
HashEntry *entry;
|
|
|
|
|
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
result = (PropertyRecord *)NULL;
|
2017-04-25 14:41:48 +02:00
|
|
|
haveit = FALSE;
|
|
|
|
|
htab = (HashTable *) cellDef->cd_props;
|
|
|
|
|
if (htab == (HashTable *) NULL) goto done;
|
|
|
|
|
|
|
|
|
|
entry = HashLookOnly(htab, name);
|
|
|
|
|
if (entry != NULL)
|
|
|
|
|
{
|
|
|
|
|
haveit = TRUE;
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
result = (PropertyRecord *)HashGetValue(entry);
|
2017-04-25 14:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
if (found != (bool *) NULL) *found = haveit;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2020-05-23 23:13:14 +02:00
|
|
|
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* DBPropGetString --
|
|
|
|
|
*
|
|
|
|
|
* Get a string property from a celldef.
|
|
|
|
|
*
|
|
|
|
|
* Results:
|
|
|
|
|
* NULL if the property didn't exist, or if the property record was NULL.
|
|
|
|
|
* Otherwise, returns a pointer to the property's string record.
|
|
|
|
|
*
|
|
|
|
|
* Notes:
|
|
|
|
|
* This is basically the original DBPropGet(), when properties were only
|
|
|
|
|
* allowed to be strings.
|
|
|
|
|
*
|
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
DBPropGetString(cellDef, name, found)
|
|
|
|
|
CellDef *cellDef; /* Pointer to definition of cell. */
|
|
|
|
|
char *name; /* The name of the property desired. */
|
|
|
|
|
bool *found; /* If not NULL, filled in with TRUE iff the property
|
|
|
|
|
* exists.
|
|
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
char *result = NULL;
|
|
|
|
|
PropertyRecord *proprec;
|
|
|
|
|
bool haveit;
|
|
|
|
|
HashTable *htab;
|
|
|
|
|
HashEntry *entry;
|
|
|
|
|
|
|
|
|
|
haveit = FALSE;
|
|
|
|
|
htab = (HashTable *) cellDef->cd_props;
|
|
|
|
|
if (htab == (HashTable *) NULL) goto pdone;
|
|
|
|
|
|
|
|
|
|
entry = HashLookOnly(htab, name);
|
|
|
|
|
if (entry != NULL)
|
|
|
|
|
{
|
|
|
|
|
proprec = (PropertyRecord *)HashGetValue(entry);
|
|
|
|
|
if (proprec->prop_type == PROPERTY_TYPE_STRING)
|
|
|
|
|
{
|
|
|
|
|
haveit = TRUE;
|
|
|
|
|
result = proprec->prop_value.prop_string;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pdone:
|
|
|
|
|
if (found != (bool *) NULL) *found = haveit;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* DBPropGetDouble --
|
|
|
|
|
*
|
|
|
|
|
* Get a single double-long integer property from a celldef.
|
|
|
|
|
*
|
|
|
|
|
* Results:
|
|
|
|
|
* NULL if the property didn't exist, or if the property record was NULL.
|
|
|
|
|
* Otherwise, returns a pointer to the property's value record.
|
|
|
|
|
*
|
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
dlong
|
|
|
|
|
DBPropGetDouble(cellDef, name, found)
|
|
|
|
|
CellDef *cellDef; /* Pointer to definition of cell. */
|
|
|
|
|
char *name; /* The name of the property desired. */
|
|
|
|
|
bool *found; /* If not NULL, filled in with TRUE iff the property
|
|
|
|
|
* exists.
|
|
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
dlong result = 0;
|
|
|
|
|
PropertyRecord *proprec;
|
|
|
|
|
bool haveit;
|
|
|
|
|
HashTable *htab;
|
|
|
|
|
HashEntry *entry;
|
|
|
|
|
|
|
|
|
|
haveit = FALSE;
|
|
|
|
|
htab = (HashTable *) cellDef->cd_props;
|
|
|
|
|
if (htab == (HashTable *) NULL) goto ddone;
|
|
|
|
|
|
|
|
|
|
entry = HashLookOnly(htab, name);
|
|
|
|
|
if (entry != NULL)
|
|
|
|
|
{
|
|
|
|
|
proprec = (PropertyRecord *)HashGetValue(entry);
|
|
|
|
|
if (proprec->prop_type == PROPERTY_TYPE_DOUBLE)
|
|
|
|
|
{
|
|
|
|
|
haveit = TRUE;
|
|
|
|
|
result = proprec->prop_value.prop_double[0];
|
|
|
|
|
}
|
|
|
|
|
else if (proprec->prop_type == PROPERTY_TYPE_STRING)
|
|
|
|
|
{
|
|
|
|
|
haveit = TRUE;
|
|
|
|
|
sscanf(proprec->prop_value.prop_string, "%"DLONG_PREFIX"d", &result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ddone:
|
|
|
|
|
if (found != (bool *) NULL) *found = haveit;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-25 14:41:48 +02:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* DBPropEnum --
|
|
|
|
|
*
|
|
|
|
|
* Enumerate all the properties on a cell.
|
|
|
|
|
*
|
|
|
|
|
* Results:
|
|
|
|
|
* 0 if the search completed, else whatever value was returned by the
|
|
|
|
|
* called proc.
|
|
|
|
|
*
|
|
|
|
|
* Side effects:
|
|
|
|
|
* Depends on the called proc.
|
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
DBPropEnum(cellDef, func, cdata)
|
|
|
|
|
CellDef *cellDef; /* Pointer to definition of cell. */
|
|
|
|
|
int (*func)(); /* Function of the form:
|
|
|
|
|
*
|
|
|
|
|
* int foo(name, value, cdata)
|
|
|
|
|
* char *name;
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
* PropertyRecord *value;
|
2017-04-25 14:41:48 +02:00
|
|
|
* ClientData cdata;
|
|
|
|
|
* {
|
2020-05-23 23:13:14 +02:00
|
|
|
* -- return 0 to continue,
|
2017-04-25 14:41:48 +02:00
|
|
|
* -- nonzero to abort.
|
|
|
|
|
* return result;
|
|
|
|
|
* }
|
|
|
|
|
*/
|
|
|
|
|
ClientData cdata;
|
|
|
|
|
{
|
|
|
|
|
HashTable *htab;
|
|
|
|
|
HashSearch hs;
|
|
|
|
|
HashEntry *entry;
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
if (cellDef->cd_props == (ClientData) NULL) return 0;
|
|
|
|
|
htab = (HashTable *) cellDef->cd_props;
|
|
|
|
|
|
|
|
|
|
HashStartSearch(&hs);
|
|
|
|
|
while ((entry = HashNext(htab, &hs)) != NULL)
|
|
|
|
|
{
|
Extended the "property" command and modified the way that properties
are handled. Properties were previously only character strings,
which had become cumbersome because properties were being used for
mask hints and bounding boxes, with the necessity of constantly
converting values from string to integer and back, which can cause
a performance impact as well as just being messy. The main difference
to the command is the addition of an optional first keyword argument
for the property type, which can be "string", "integer", "dimension",
or "double". All types except "string" can consist of multiple
values. Multiple values can be specified as separate arguments on
the command line, so that, for example, values of FIXED_BBOX or
MASKHINTS_* no longer need to be quoted. In addition, this completes
the handling of "units" implemented recently, as all properties of
the type "dimension" can be entered in the current units, will display
in the current units, and will scale with the database.
2026-02-18 16:48:47 +01:00
|
|
|
res = (*func)(entry->h_key.h_name, (PropertyRecord *)entry->h_pointer, cdata);
|
2017-04-25 14:41:48 +02:00
|
|
|
if (res != 0) return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-23 23:13:14 +02:00
|
|
|
|
2017-04-25 14:41:48 +02:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* DBPropClearAll --
|
|
|
|
|
*
|
|
|
|
|
* Free up all properties and associated storage for a CellDef.
|
|
|
|
|
*
|
|
|
|
|
* Results:
|
|
|
|
|
* none.
|
|
|
|
|
*
|
|
|
|
|
* Side effects:
|
|
|
|
|
* Frees up storage, even for the property table itself.
|
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
DBPropClearAll(cellDef)
|
|
|
|
|
CellDef *cellDef; /* Pointer to definition of cell. */
|
|
|
|
|
{
|
|
|
|
|
HashTable *htab;
|
|
|
|
|
HashSearch hs;
|
|
|
|
|
HashEntry *entry;
|
|
|
|
|
|
|
|
|
|
if (cellDef->cd_props == (ClientData) NULL) return;
|
|
|
|
|
htab = (HashTable *) cellDef->cd_props;
|
|
|
|
|
|
|
|
|
|
HashStartSearch(&hs);
|
|
|
|
|
while ((entry = HashNext(htab, &hs)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (entry->h_pointer != NULL) freeMagic((char *) entry->h_pointer);
|
|
|
|
|
HashSetValue(entry, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HashKill(htab);
|
|
|
|
|
freeMagic((char *) htab);
|
|
|
|
|
cellDef->cd_props = (ClientData) NULL;
|
2019-08-20 14:42:07 +02:00
|
|
|
|
|
|
|
|
/* Since CDFIXEDBBOX requires a FIXED_BBOX property, clearing all */
|
|
|
|
|
/* properties necessarily means this flag must be clear. */
|
|
|
|
|
cellDef->cd_flags &= ~CDFIXEDBBOX;
|
2017-04-25 14:41:48 +02:00
|
|
|
}
|