X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=retrieval%2Fd1_absyn.c;h=38843d2577e1a0bb5c3469516568feae3cb4faba;hp=6b9a413245cd0fe1999aa6191c458fe2822770f6;hb=d9ee01635f03f9095a66f71b73580560d48798e8;hpb=db9513f9eca4ef13d3cea779a695bb822fd973a9 diff --git a/retrieval/d1_absyn.c b/retrieval/d1_absyn.c index 6b9a413..38843d2 100644 --- a/retrieval/d1_absyn.c +++ b/retrieval/d1_absyn.c @@ -1,10 +1,23 @@ /* - * Copyright (c) 1995-1998, Index Data. + * Copyright (c) 1995-1999, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_absyn.c,v $ - * Revision 1.22 1998-10-13 16:09:47 adam + * Revision 1.26 1999-11-30 13:47:12 adam + * Improved installation. Moved header files to include/yaz. + * + * Revision 1.25 1999/10/21 12:06:29 adam + * Retrieval module no longer uses ctype.h - functions. + * + * Revision 1.24 1999/08/27 09:40:32 adam + * Renamed logf function to yaz_log. Removed VC++ project files. + * + * Revision 1.23 1998/10/15 08:29:16 adam + * Tag set type may be specified in reference to it using "tagset" + * directive in .abs-files and "include" directive in .tag-files. + * + * Revision 1.22 1998/10/13 16:09:47 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. @@ -89,15 +102,14 @@ * */ -#include #include #include #include #include -#include -#include -#include +#include +#include +#include #define D1_MAX_NESTING 128 @@ -208,7 +220,7 @@ data1_attset *data1_attset_add (data1_handle dh, const char *name) *cp = '\0'; } if (!attset) - logf (LOG_WARN|LOG_ERRNO, "Couldn't load attribute set %s", name); + yaz_log (LOG_WARN|LOG_ERRNO, "Couldn't load attribute set %s", name); else { data1_attset_cache p = (data1_attset_cache) @@ -294,7 +306,7 @@ void fix_element_ref (data1_handle dh, data1_absyn *absyn, data1_element *e) if (sub_e) e->children = sub_e->elements; else - logf (LOG_WARN, "Unresolved reference to sub-elements %s", + yaz_log (LOG_WARN, "Unresolved reference to sub-elements %s", e->sub_name); } } @@ -319,7 +331,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (!(f = yaz_path_fopen(data1_get_tabpath (dh), file, "r"))) { - logf(LOG_WARN|LOG_ERRNO, "Couldn't open %s", file); + yaz_log(LOG_WARN|LOG_ERRNO, "Couldn't open %s", file); return 0; } @@ -356,7 +368,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (argc < 4) { - logf(LOG_WARN, "%s:%d: Bad # of args to elm", file, lineno); + yaz_log(LOG_WARN, "%s:%d: Bad # of args to elm", file, lineno); continue; } path = argv[1]; @@ -387,7 +399,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) } if (i > level + 1) { - logf(LOG_WARN, "%s:%d: Bad level increase", file, lineno); + yaz_log(LOG_WARN, "%s:%d: Bad level increase", file, lineno); fclose(f); return 0; } @@ -415,14 +427,14 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) { if (!res->tagset) { - logf(LOG_WARN, "%s:%d: No tagset loaded", file, lineno); + yaz_log(LOG_WARN, "%s:%d: No tagset loaded", file, lineno); fclose(f); return 0; } if (!(new_element->tag = data1_gettagbynum (dh, res->tagset, type, value))) { - logf(LOG_WARN, "%s:%d: Couldn't find tag %s in tagset", + yaz_log(LOG_WARN, "%s:%d: Couldn't find tag %s in tagset", file, lineno, p); fclose(f); return 0; @@ -448,7 +460,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) } else { - logf(LOG_WARN, "%s:%d: Bad element", file, lineno); + yaz_log(LOG_WARN, "%s:%d: Bad element", file, lineno); fclose(f); return 0; } @@ -467,7 +479,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (!(r = sscanf(p, "%511[^:,]:%511[^,]", attname, structure))) { - logf(LOG_WARN, + yaz_log(LOG_WARN, "%s:%d: Syntax error in termlistspec '%s'", file, lineno, p); fclose(f); @@ -481,7 +493,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (!((*tp)->att = data1_getattbyname(dh, res->attset, attname))) { - logf(LOG_WARN, + yaz_log(LOG_WARN, "%s:%d: Couldn't find att '%s' in attset", file, lineno, attname); fclose(f); @@ -509,7 +521,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (argc < 2) { - logf(LOG_WARN, "%s:%d: Bad # of args to section", + yaz_log(LOG_WARN, "%s:%d: Bad # of args to section", file, lineno); continue; } @@ -532,14 +544,14 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (all) { - logf(LOG_WARN, "%s:%d: Too many 'all' directives - ignored", + yaz_log(LOG_WARN, "%s:%d: Too many 'all' directives - ignored", file, lineno); continue; } if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # of args to 'all' directive", + yaz_log(LOG_WARN, "%s:%d: Bad # of args to 'all' directive", file, lineno); continue; } @@ -553,7 +565,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (!(r = sscanf(p, "%511[^:,]:%511[^,]", attname, structure))) { - logf(LOG_WARN, "%s:%d: Syntax error in termlistspec", + yaz_log(LOG_WARN, "%s:%d: Syntax error in termlistspec", file, lineno); fclose(f); return 0; @@ -563,7 +575,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (!((*tp)->att = data1_getattbyname (dh, res->attset, attname))) { - logf(LOG_WARN, "%s:%d: Couldn't find att '%s' in attset", + yaz_log(LOG_WARN, "%s:%d: Couldn't find att '%s' in attset", file, lineno, attname); fclose(f); return 0; @@ -586,7 +598,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) { if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # of args to name directive", + yaz_log(LOG_WARN, "%s:%d: Bad # of args to name directive", file, lineno); continue; } @@ -598,14 +610,14 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # of args to reference", + yaz_log(LOG_WARN, "%s:%d: Bad # of args to reference", file, lineno); continue; } name = argv[1]; if ((res->reference = oid_getvalbyname(name)) == VAL_NONE) { - logf(LOG_WARN, "%s:%d: Unknown tagset ref '%s'", + yaz_log(LOG_WARN, "%s:%d: Unknown tagset ref '%s'", file, lineno, name); continue; } @@ -617,14 +629,14 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # of args to attset", + yaz_log(LOG_WARN, "%s:%d: Bad # of args to attset", file, lineno); continue; } name = argv[1]; if (!(attset = data1_get_attset (dh, name))) { - logf(LOG_WARN, "%s:%d: Couldn't find attset %s", + yaz_log(LOG_WARN, "%s:%d: Couldn't find attset %s", file, lineno, name); continue; } @@ -637,16 +649,20 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) else if (!strcmp(cmd, "tagset")) { char *name; - if (argc != 2) + int type = 0; + if (argc < 2) { - logf(LOG_WARN, "%s:%d: Bad # of args to tagset", + yaz_log(LOG_WARN, "%s:%d: Bad # of args to tagset", file, lineno); continue; } name = argv[1]; - if (!(*tagset_childp = data1_read_tagset (dh, name))) + if (argc == 3) + type = atoi(argv[2]); + *tagset_childp = data1_read_tagset (dh, name, type); + if (!(*tagset_childp)) { - logf(LOG_WARN, "%s:%d: Couldn't load tagset %s", + yaz_log(LOG_WARN, "%s:%d: Couldn't load tagset %s", file, lineno, name); continue; } @@ -658,14 +674,14 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # of args in varset", + yaz_log(LOG_WARN, "%s:%d: Bad # of args in varset", file, lineno); continue; } name = argv[1]; if (!(res->varset = data1_read_varset (dh, name))) { - logf(LOG_WARN, "%s:%d: Couldn't load Varset %s", + yaz_log(LOG_WARN, "%s:%d: Couldn't load Varset %s", file, lineno, name); continue; } @@ -676,7 +692,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (argc != 3) { - logf(LOG_WARN, "%s:%d: Bad # of args in esetname", + yaz_log(LOG_WARN, "%s:%d: Bad # of args in esetname", file, lineno); continue; } @@ -691,7 +707,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) (*esetpp)->spec = 0; else if (!((*esetpp)->spec = data1_read_espec1 (dh, fname))) { - logf(LOG_WARN, "%s:%d: Espec-1 read failed for %s", + yaz_log(LOG_WARN, "%s:%d: Espec-1 read failed for %s", file, lineno, fname); continue; } @@ -703,14 +719,14 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # of args for maptab", + yaz_log(LOG_WARN, "%s:%d: Bad # of args for maptab", file, lineno); continue; } name = argv[1]; if (!(*maptabp = data1_read_maptab (dh, name))) { - logf(LOG_WARN, "%s:%d: Couldn't load maptab %s", + yaz_log(LOG_WARN, "%s:%d: Couldn't load maptab %s", file, lineno, name); continue; } @@ -722,14 +738,14 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # or args for marc", + yaz_log(LOG_WARN, "%s:%d: Bad # or args for marc", file, lineno); continue; } name = argv[1]; if (!(*marcp = data1_read_marctab (dh, name))) { - logf(LOG_WARN, "%s:%d: Couldn't read marctab %s", + yaz_log(LOG_WARN, "%s:%d: Couldn't read marctab %s", file, lineno, name); continue; } @@ -737,7 +753,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) } else { - logf(LOG_WARN, "%s:%d: Unknown directive '%s'", file, lineno, cmd); + yaz_log(LOG_WARN, "%s:%d: Unknown directive '%s'", file, lineno, cmd); continue; } } @@ -750,6 +766,6 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file) res->main_elements = cur_elements->elements; fix_element_ref (dh, res, cur_elements->elements); } - logf (LOG_DEBUG, "%s: data1_read_absyn end", file); + yaz_log (LOG_DEBUG, "%s: data1_read_absyn end", file); return res; }