- minor improvements

This commit is contained in:
zolliker
2009-11-10 10:38:48 +00:00
parent 7e10c5e296
commit 1c6c3c603e
4 changed files with 38 additions and 9 deletions

View File

@ -41,10 +41,18 @@ void DefaultFree(void *data)
static void saveSICSNode(pHdb node, char *prefix, FILE * fd)
{
char newprefix[1024], val[20];
char path[MAX_HDB_PATH];
pHdb child;
hdbValue v;
pDynString data = NULL;
char *cmd;
cmd = GetHdbProp(node, "creationCmd");
if (cmd != NULL) {
GetHdbPath(node, path, sizeof path);
fprintf(fd, cmd, prefix, path);
fprintf(fd, "\n");
}
if (GetHdbProperty(node, "__save", val, 20) == 1) {
GetHipadabaPar(node, &v, NULL);
data = formatValue(v, node);
@ -67,10 +75,18 @@ int SaveSICSOBJ(void *data, char *name, FILE * fd)
{
pSICSOBJ self = (pSICSOBJ) data;
char prefix[1024];
char path[MAX_HDB_PATH];
pHdb node;
char *cmd;
if (self != NULL && self->objectNode != NULL) {
node = self->objectNode->child;
cmd = GetHdbProp(self->objectNode, "creationCmd");
if (cmd != NULL) {
GetHdbPath(self->objectNode, path, sizeof path);
fprintf(fd, cmd, name, path);
fprintf(fd, "\n");
}
while (node != NULL) {
snprintf(prefix, 1024, "%s %s", name, node->name);
saveSICSNode(node, prefix, fd);
@ -138,6 +154,7 @@ pSICSOBJ MakeSICSOBJv(char *name, char *class, int type, int priv)
pNew->objectNode = MakeSICSHdbPar(name, priv, val);
ReleaseHdbValue(&val);
}
SetHdbProperty(pNew->objectNode, "sicscommand", name);
if (pNew->pDes == NULL || pNew->objectNode == NULL) {
free(pNew);
return (NULL);
@ -536,7 +553,7 @@ pSICSOBJ SetupSICSOBJ(SConnection * pCon, SicsInterp * pSics, void *pData,
return NULL;
}
if (strcasecmp(argv[0], "DynSicsObj") == 0) {
/* make object dynamic by defining a descriptor command */
/* make object dynamic by defining a creation command */
SetDescriptorKey(pNew->pDes, "creationCommand", "0");
}