/*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1997, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_attset.c,v $
- * Revision 1.5 1996-05-09 07:27:43 quinn
+ * Revision 1.8 1998-02-11 11:53:35 adam
+ * Changed code so that it compiles as C++.
+ *
+ * Revision 1.7 1997/09/17 12:10:34 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.6 1997/09/05 09:50:56 adam
+ * Removed global data1_tabpath - uses data1_get_tabpath() instead.
+ *
+ * Revision 1.5 1996/05/09 07:27:43 quinn
* Multiple local attributes values supported.
*
* Revision 1.4 1996/02/21 15:23:36 quinn
#include <assert.h>
#include <stdlib.h>
-#include <xmalloc.h>
#include <log.h>
#include <d1_attset.h>
#include <data1.h>
#include <tpath.h>
-data1_att *data1_getattbyname(data1_attset *s, char *name)
+data1_att *data1_getattbyname(data1_handle dh, data1_attset *s, char *name)
{
data1_att *r;
if (!data1_matchstr(r->name, name))
return r;
/* scan included sets */
- if (s->children && (r = data1_getattbyname(s->children, name)))
+ if (s->children && (r = data1_getattbyname (dh, s->children, name)))
return r;
}
return 0;
}
-data1_attset *data1_read_attset(char *file)
+data1_attset *data1_read_attset(data1_handle dh, char *file)
{
char line[512], *r, cmd[512], args[512];
data1_attset *res = 0, **childp;
data1_att **attp;
FILE *f;
+ NMEM mem = data1_nmem_get (dh);
- if (!(f = yaz_path_fopen(data1_tabpath, file, "r")))
+ if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
{
logf(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
}
- if (!(res = xmalloc(sizeof(*res))))
- abort();
+ res = (data1_attset *)nmem_malloc(mem, sizeof(*res));
res->name = 0;
res->reference = VAL_NONE;
res->ordinal = -1;
}
if (rr < 3) /* no local attributes given */
{
- locals = xmalloc(sizeof(*locals));
+ locals = (data1_local_attribute *)nmem_malloc(mem, sizeof(*locals));
locals->local = num;
locals->next = 0;
}
data1_local_attribute **ap = &locals;
do
{
- *ap = xmalloc(sizeof(**ap));
+ *ap = (data1_local_attribute *)nmem_malloc(mem, sizeof(**ap));
(*ap)->local = atoi(p);
(*ap)->next = 0;
ap = &(*ap)->next;
}
while ((p = strchr(p, ',')) && *(++p));
}
- if (!(t = *attp = xmalloc(sizeof(*t))))
- abort();
+ t = *attp = (data1_att *)nmem_malloc(mem, sizeof(*t));
t->parent = res;
- if (!(t->name = xmalloc(strlen(name)+1)))
- abort();
- strcpy(t->name, name);
+ t->name = nmem_strdup(mem, name);
t->value = num;
t->locals = locals;
t->next = 0;
fclose(f);
return 0;
}
- if (!(res->name = xmalloc(strlen(args)+1)))
- abort();
- strcpy(res->name, name);
+ res->name = nmem_strdup(mem, args);
}
else if (!strcmp(cmd, "reference"))
{
fclose(f);
return 0;
}
- if (!(*childp = data1_read_attset(name)))
+ if (!(*childp = data1_read_attset (dh, name)))
{
logf(LOG_WARN, "Inclusion failed in %s", file);
fclose(f);