X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=retrieval%2Fd1_map.c;h=15d14cb886d2bfad029475e01534583f6e38e819;hp=e1eaf853dc73917efcf2336c1613537ed8b51d00;hb=548d8ab9b0b5930db27643b47fc55afce5511219;hpb=db9513f9eca4ef13d3cea779a695bb822fd973a9 diff --git a/retrieval/d1_map.c b/retrieval/d1_map.c index e1eaf85..15d14cb 100644 --- a/retrieval/d1_map.c +++ b/retrieval/d1_map.c @@ -1,10 +1,24 @@ /* - * Copyright (c) 1995-1997, Index Data. + * Copyright (c) 1995-2000, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: d1_map.c,v $ - * Revision 1.14 1998-10-13 16:09:50 adam + * Revision 1.18 2000-11-29 14:22:47 adam + * Implemented XML/SGML attributes for data1 so that d1_read reads them + * and d1_write generates proper attributes for XML/SGML records. Added + * register locking for threaded version. + * + * Revision 1.17 1999/11/30 13:47:12 adam + * Improved installation. Moved header files to include/yaz. + * + * Revision 1.16 1999/10/21 12:06:29 adam + * Retrieval module no longer uses ctype.h - functions. + * + * Revision 1.15 1999/08/27 09:40:32 adam + * Renamed logf function to yaz_log. Removed VC++ project files. + * + * Revision 1.14 1998/10/13 16:09:50 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. @@ -60,15 +74,13 @@ #include #include #include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include data1_maptab *data1_read_maptab (data1_handle dh, const char *file) { @@ -83,7 +95,7 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) if (!(f = yaz_path_fopen(data1_get_tabpath(dh), file, "r"))) { - logf(LOG_WARN|LOG_ERRNO, "%s", file); + yaz_log(LOG_WARN|LOG_ERRNO, "%s", file); return 0; } @@ -98,15 +110,15 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) { if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # args for targetref", - file, lineno); + yaz_log(LOG_WARN, "%s:%d: Bad # args for targetref", + file, lineno); continue; } if ((res->target_absyn_ref = oid_getvalbyname(argv[1])) == VAL_NONE) { - logf(LOG_WARN, "%s:%d: Unknown reference '%s'", - file, lineno, argv[1]); + yaz_log(LOG_WARN, "%s:%d: Unknown reference '%s'", + file, lineno, argv[1]); continue; } } @@ -114,8 +126,8 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) { if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # args for targetname", - file, lineno); + yaz_log(LOG_WARN, "%s:%d: Bad # args for targetname", + file, lineno); continue; } res->target_absyn_name = @@ -128,7 +140,7 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) { if (argc != 2) { - logf(LOG_WARN, "%s:%d: Bad # args for name", file, lineno); + yaz_log(LOG_WARN, "%s:%d: Bad # args for name", file, lineno); continue; } res->name = (char *)nmem_malloc(mem, strlen(argv[1])+1); @@ -141,8 +153,8 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) if (argc < 3) { - logf(LOG_WARN, "%s:%d: Bad # of args for map", - file, lineno); + yaz_log(LOG_WARN, "%s:%d: Bad # of args for map", + file, lineno); continue; } *mapp = (data1_mapunit *)nmem_malloc(mem, sizeof(**mapp)); @@ -168,8 +180,8 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) if ((np = sscanf(path, "(%d,%[^)]):%[^/]", &type, valstr, parm)) < 2) { - logf(LOG_WARN, "%s:%d: Syntax error in map directive: %s", - file, lineno, argv[2]); + yaz_log(LOG_WARN, "%s:%d: Syntax error in map " + "directive: %s", file, lineno, argv[2]); fclose(f); return 0; } @@ -180,7 +192,7 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) (*mtp)->new_field = 1; else (*mtp)->new_field = 0; - if ((type != 3 || local_numeric) && isdigit(*valstr)) + if ((type != 3 || local_numeric) && d1_isdigit(*valstr)) { (*mtp)->which = D1_MAPTAG_numeric; (*mtp)->value.numeric = atoi(valstr); @@ -197,8 +209,8 @@ data1_maptab *data1_read_maptab (data1_handle dh, const char *file) mapp = &(*mapp)->next; } 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; @@ -296,11 +308,9 @@ static int map_children(data1_handle dh, data1_node *n, data1_maptab *map, { if (!cur || mt->new_field || !tagmatch(cur, mt)) { - cur = data1_mk_node (dh, mem); - cur->which = DATA1N_tag; - cur->u.tag.element = 0; + cur = data1_mk_node_type (dh, mem, DATA1N_tag); cur->u.tag.tag = mt->value.string; - cur->u.tag.node_selected = 0; + cur->parent = pn; cur->root = pn->root; if (!pn->child) @@ -343,8 +353,8 @@ data1_node *data1_map_record (data1_handle dh, data1_node *n, res->u.root.type = map->target_absyn_name; if (!(res->u.root.absyn = data1_get_absyn(dh, map->target_absyn_name))) { - logf(LOG_WARN, "%s: Failed to load target absyn '%s'", - map->name, map->target_absyn_name); + yaz_log(LOG_WARN, "%s: Failed to load target absyn '%s'", + map->name, map->target_absyn_name); } res->parent = 0; res->root = res;