* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_espec.c,v $
- * Revision 1.6 1996-07-06 19:58:34 quinn
+ * Revision 1.9 1997-09-17 12:10:35 adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.8 1997/09/05 09:50:56 adam
+ * Removed global data1_tabpath - uses data1_get_tabpath() instead.
+ *
+ * Revision 1.7 1997/05/14 06:54:02 adam
+ * C++ support.
+ *
+ * Revision 1.6 1996/07/06 19:58:34 quinn
* System headerfiles gathered in yconfig
*
* Revision 1.5 1996/01/02 08:57:44 quinn
r->num_triples = argc;
for (i = 0; i < argc; i++)
{
- int class, type;
+ int zclass, type;
char value[512];
Z_Triple *t;
- if (sscanf(argv[i], "(%d,%d,%[^)])", &class, &type, value) < 3)
+ if (sscanf(argv[i], "(%d,%d,%[^)])", &zclass, &type, value) < 3)
{
logf(LOG_WARN, "Syntax error in variant component '%s'",
argv[i]);
}
t = r->triples[i] = odr_malloc(o, sizeof(Z_Triple));
t->variantSetId = 0;
- t->class = odr_malloc(o, sizeof(int));
- *t->class = class;
+ t->zclass = odr_malloc(o, sizeof(int));
+ *t->zclass = zclass;
t->type = odr_malloc(o, sizeof(int));
*t->type = type;
/*
* Read an element-set specification from a file.
* NOTE: If !o, memory is allocated directly from the heap by odr_malloc().
*/
-Z_Espec1 *data1_read_espec1(char *file, ODR o)
+Z_Espec1 *data1_read_espec1 (data1_handle dh, const char *file, ODR o)
{
FILE *f;
int argc, size_esn = 0;
char *argv[50], line[512];
Z_Espec1 *res = odr_malloc(o, sizeof(*res));
- 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;
continue;
}
- res->elementSetNames = odr_malloc(o, sizeof(char*)*nnames);
+ res->elementSetNames = odr_malloc(o, sizeof(char**)*nnames);
for (i = 0; i < nnames; i++)
{
res->elementSetNames[i] = odr_malloc(o, strlen(argv[i+1])+1);
char *path = argv[1];
char *ep;
int num, i = 0;
-
+
if (!res->elements)
- res->elements = odr_malloc(o, size_esn = 24*sizeof(*er));
- else if (res->num_elements >= size_esn)
+ res->elements = odr_malloc(o, size_esn = 24*sizeof(er));
+ else if (res->num_elements >= size_esn/sizeof(er))
{
size_esn *= 2;
- res->elements = o ? odr_malloc(o, size_esn) :
- xrealloc(res->elements, size_esn);
+ if (o)
+ {
+ Z_ElementRequest **oe = res->elements;
+
+ res->elements = odr_malloc (o, size_esn*sizeof(er));
+ memcpy (res->elements, oe, size_esn/2);
+ }
+ else
+ res->elements =
+ xrealloc(res->elements, size_esn*sizeof(er));
}
if (argc < 2)
{
logf(LOG_WARN, "%s: Empty simpleelement directive", file);
continue;
}
-
+
res->elements[res->num_elements++] = er =
odr_malloc(o, sizeof(*er));
er->which = Z_ERequest_simpleElement;
/*
* Parse the element selector.
*/
- for (num = 1, ep = path; (ep = strchr(ep, '/')); num++, ep++);
+ for (num = 1, ep = path; (ep = strchr(ep, '/')); num++, ep++)
+ ;
tp->tags = odr_malloc(o, sizeof(Z_ETagUnit*)*num);
-
- for ((ep = strchr(path, '/')) ; path ; (void)((path = ep) &&
- (ep = strchr(path, '/'))))
+
+ for ((ep = strchr(path, '/')) ; path ;
+ (void)((path = ep) && (ep = strchr(path, '/'))))
{
if (ep)
ep++;
-
+
assert(i<num);
tp->tags[tp->num_tags++] = read_tagunit(path, o);
}
-
+
if (argc > 2 && !strcmp(argv[2], "variant"))
se->variantRequest= read_variant(argc-3, argv+3, o);
}