/*
- * Copyright (c) 1995-1998, Index Data.
+ * Copyright (c) 1995-2002, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Log: d1_espec.c,v $
- * Revision 1.15 1998-10-13 16:09:49 adam
- * Added support for arbitrary OID's for tagsets, schemas and attribute sets.
- * Added support for multiple attribute set references and tagset references
- * from an abstract syntax file.
- * Fixed many bad logs-calls in routines that read the various
- * specifications regarding data1 (*.abs,*.att,...) and made the messages
- * consistent whenever possible.
- * Added extra 'lineno' argument to function readconf_line.
- *
- * Revision 1.14 1998/02/11 11:53:35 adam
- * Changed code so that it compiles as C++.
- *
- * Revision 1.13 1997/11/24 11:33:56 adam
- * Using function odr_nullval() instead of global ODR_NULLVAL when
- * appropriate.
- *
- * Revision 1.12 1997/10/31 12:20:09 adam
- * Improved memory debugging for xmalloc/nmem.c. References to NMEM
- * instead of ODR in n ESPEC-1 handling in source d1_espec.c.
- * Bug fix: missing fclose in data1_read_espec1.
- *
- * Revision 1.11 1997/09/29 13:18:59 adam
- * Added function, oid_ent_to_oid, to replace the function
- * oid_getoidbyent, which is not thread safe.
- *
- * Revision 1.10 1997/09/29 07:21:10 adam
- * Added typecast to avoid warnings on MSVC.
- *
- * 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
- * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
- *
- * Revision 1.4 1995/12/05 11:16:10 quinn
- * Fixed malloc of 0.
- *
- * Revision 1.3 1995/11/13 09:27:34 quinn
- * Fiddling with the variant stuff.
- *
- * Revision 1.2 1995/11/01 16:34:56 quinn
- * Making data1 look for tables in data1_tabpath
- *
- * Revision 1.1 1995/11/01 11:56:07 quinn
- * Added Retrieval (data management) functions en masse.
- *
- *
+ * $Id: d1_espec.c,v 1.22 2002-05-03 13:48:27 adam Exp $
*/
-
#include <stdlib.h>
#include <assert.h>
#include <string.h>
-#include <ctype.h>
-#include <odr.h>
-#include <proto.h>
-#include <log.h>
-#include <data1.h>
+
+#include <yaz/odr.h>
+#include <yaz/proto.h>
+#include <yaz/log.h>
+#include <yaz/data1.h>
static Z_Variant *read_variant(int argc, char **argv, NMEM nmem,
const char *file, int lineno)
char value[512];
Z_Triple *t;
- if (sscanf(argv[i], "(%d,%d,%[^)])", &zclass, &type, value) < 3)
+ if (sscanf(argv[i], "(%d,%d,%511[^)])", &zclass, &type, value) < 3)
{
- logf(LOG_WARN, "%s:%d: Syntax error in variant component '%s'",
- file, lineno, argv[i]);
+ yaz_log(LOG_WARN, "%s:%d: Syntax error in variant component '%s'",
+ file, lineno, argv[i]);
return 0;
}
t = r->triples[i] = (Z_Triple *)nmem_malloc(nmem, sizeof(Z_Triple));
t->which = Z_Triple_null;
t->value.null = odr_nullval();
}
- else if (isdigit(*value))
+ else if (d1_isdigit(*value))
{
t->which = Z_Triple_integer;
t->value.integer = (int *)
{
Z_OccurValues *ov = (Z_OccurValues *)nmem_malloc(nmem, sizeof(*ov));
- if (!isdigit(*occ))
+ if (!d1_isdigit(*occ))
{
- logf(LOG_WARN, "%s:%d: Bad occurrences-spec %s",
- file, lineno, occ);
+ yaz_log(LOG_WARN, "%s:%d: Bad occurrences-spec %s",
+ file, lineno, occ);
return 0;
}
op->which = Z_Occurrences_values;
else
u->u.wildThing = read_occurrences(0, nmem, file, lineno);
}
- else if ((terms = sscanf(buf, "(%d,%[^)]):%[a-z0-9+]", &type, value,
- occ)) >= 2)
+ else if ((terms = sscanf(buf, "(%d,%511[^)]):%511[a-zA-Z0-9+]",
+ &type, value, occ)) >= 2)
{
int numval;
Z_SpecificTag *t;
char *argv[50], line[512];
Z_Espec1 *res = (Z_Espec1 *)nmem_malloc(nmem, sizeof(*res));
- if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r")))
+ if (!(f = data1_path_fopen(dh, file, "r")))
{
- logf(LOG_WARN|LOG_ERRNO, "%s", file);
+ yaz_log(LOG_WARN|LOG_ERRNO, "%s", file);
return 0;
}
if (!nnames)
{
- logf(LOG_WARN, "%s:%d: Empty elementsetnames directive",
- file, lineno);
+ yaz_log(LOG_WARN, "%s:%d: Empty elementsetnames directive",
+ file, lineno);
continue;
}
{
if (argc != 2)
{
- logf(LOG_WARN, "%s:%d: Bad # of args for %s",
- file, lineno, argv[0]);
+ yaz_log(LOG_WARN, "%s:%d: Bad # of args for %s",
+ file, lineno, argv[0]);
continue;
}
if (!(res->defaultVariantSetId =
odr_getoidbystr_nmem(nmem, argv[1])))
{
- logf(LOG_WARN, "%s:%d: Bad defaultvariantsetid",
- file, lineno);
+ yaz_log(LOG_WARN, "%s:%d: Bad defaultvariantsetid",
+ file, lineno);
continue;
}
}
{
if (argc != 2)
{
- logf(LOG_WARN, "%s:%d: Bad # of args for %s",
- file, lineno, argv[0]);
+ yaz_log(LOG_WARN, "%s:%d: Bad # of args for %s",
+ file, lineno, argv[0]);
continue;
}
res->defaultTagType = (int *)nmem_malloc(nmem, sizeof(int));
if (!(res->defaultVariantRequest =
read_variant(argc-1, argv+1, nmem, file, lineno)))
{
- logf(LOG_WARN, "%s:%d: Bad defaultvariantrequest",
- file, lineno);
+ yaz_log(LOG_WARN, "%s:%d: Bad defaultvariantrequest",
+ file, lineno);
continue;
}
}
}
if (argc < 2)
{
- logf(LOG_WARN, "%s:%d: Bad # of args for %s",
- file, lineno, argv[0]);
+ yaz_log(LOG_WARN, "%s:%d: Bad # of args for %s",
+ file, lineno, argv[0]);
continue;
}
for ((ep = strchr(path, '/')) ; path ;
(void)((path = ep) && (ep = strchr(path, '/'))))
{
+ Z_ETagUnit *tagunit;
if (ep)
ep++;
assert(i<num);
- tp->tags[tp->num_tags++] =
- read_tagunit(path, nmem, file, lineno);
+ tagunit = read_tagunit(path, nmem, file, lineno);
+ if (!tagunit)
+ {
+ yaz_log (LOG_WARN, "%s%d: Bad tag unit at %s",
+ file, lineno, path);
+ break;
+ }
+ tp->tags[tp->num_tags++] = tagunit;
}
if (argc > 2 && !strcmp(argv[2], "variant"))
read_variant(argc-3, argv+3, nmem, file, lineno);
}
else
- logf(LOG_WARN, "%s:%d: Unknown directive '%s'",
- file, lineno, argv[0]);
+ yaz_log(LOG_WARN, "%s:%d: Unknown directive '%s'",
+ file, lineno, argv[0]);
fclose (f);
return res;
}