28 #include <yaz/oid_db.h>
29 #include <yaz/snprintf.h>
30 #include <yaz/readconf.h>
31 #include <yaz/tpath.h>
50 char *argv[50], line[512];
52 int local_numeric = 0;
63 while ((argc = readconf_line(f, &lineno, line, 512, argv, 50)))
64 if (!strcmp(argv[0],
"targetref"))
68 yaz_log(YLOG_WARN,
"%s:%d: Bad # args for targetref",
72 res->
oid = yaz_string_to_oid_nmem(yaz_oid_std(),
73 CLASS_RECSYN, argv[1], mem);
76 yaz_log(YLOG_WARN,
"%s:%d: Unknown reference '%s'",
77 file, lineno, argv[1]);
81 else if (!strcmp(argv[0],
"targetname"))
85 yaz_log(YLOG_WARN,
"%s:%d: Bad # args for targetname",
91 else if (!yaz_matchstr(argv[0],
"localnumeric"))
93 else if (!strcmp(argv[0],
"name"))
97 yaz_log(YLOG_WARN,
"%s:%d: Bad # args for name", file, lineno);
100 res->
name = nmem_strdup(mem, argv[1]);
102 else if (!strcmp(argv[0],
"map"))
105 char *ep, *path = argv[2];
109 yaz_log(YLOG_WARN,
"%s:%d: Bad # of args for map",
118 (*mapp)->no_data = 0;
120 (*mapp)->no_chop = 1;
122 (*mapp)->no_chop = 0;
123 (*mapp)->source_element_name = nmem_strdup(mem, argv[1]);
124 mtp = &(*mapp)->target_path;
127 for (ep = strchr(path,
'/'); path; (void)((path = ep) &&
128 (ep = strchr(path,
'/'))))
131 char valstr[512], parm[512];
135 if ((np = sscanf(path,
"(%d,%511[^)]):%511[^/]", &type, valstr,
138 yaz_log(YLOG_WARN,
"%s:%d: Syntax error in map "
139 "directive: %s", file, lineno, argv[2]);
147 (*mtp)->new_field = 1;
149 (*mtp)->new_field = 0;
150 if ((type != 3 || local_numeric) &&
d1_isdigit(*valstr))
153 (*mtp)->value.numeric = atoi(valstr);
158 (*mtp)->value.string = nmem_strdup(mem, valstr);
162 mapp = &(*mapp)->
next;
165 yaz_log(YLOG_WARN,
"%s:%d: Unknown directive '%s'",
166 file, lineno, argv[0]);
179 if (n->
u.
tag.element)
181 if (n->
u.
tag.element->tag->tagset)
183 if (n->
u.
tag.element->tag->tagset->type != t->
type)
186 else if (t->
type != 3)
231 for (; n; n = n->
next)
233 *last = *m = (
data1_node *) nmem_malloc(mem,
sizeof(**m));
234 memcpy(*m, n,
sizeof(**m));
236 (*m)->parent = parent;
256 for (m = map->
map; m; m = m->
next)
259 c->
u.
tag.element->name))
282 pn->
root->u.root.absyn->tagset,
332 yaz_log(YLOG_WARN,
"%s: Failed to load target absyn '%s'",
data1_maptab * data1_read_maptab(data1_handle dh, const char *file)
static data1_node * dup_child(data1_handle dh, data1_node *n, data1_node **last, NMEM mem, data1_node *parent)
static int tagmatch(data1_node *n, data1_maptag *t)
data1_node * data1_map_record(data1_handle dh, data1_node *n, data1_maptab *map, NMEM m)
static int map_children(data1_handle dh, data1_node *n, data1_maptab *map, data1_node *res, NMEM mem)
data1_node * data1_mk_tag(data1_handle dh, NMEM nmem, const char *tag, const char **attr, data1_node *at)
data1_absyn * data1_get_absyn(data1_handle dh, const char *name, enum DATA1_XPATH_INDEXING en)
void data1_concat_text(data1_handle dh, NMEM m, data1_node *n)
FILE * data1_path_fopen(data1_handle dh, const char *file, const char *mode)
data1_tag * data1_gettagbynum(data1_handle dh, data1_tagset *s, int type, int value)
NMEM data1_nmem_get(data1_handle dh)
#define data1_matchstr(s1, s2)
data1_node * data1_mk_node2(data1_handle dh, NMEM m, int type, data1_node *parent)
void data1_chop_text(data1_handle dh, NMEM m, data1_node *n)
@ DATA1_XPATH_INDEXING_ENABLE
#define D1_MAPTAG_numeric
struct data1_maptab * next
struct data1_maptag * next
union data1_maptag::@0 value
struct data1_mapunit * next
data1_maptag * target_path
char * source_element_name
struct data1_node::@2::@3 root
struct data1_node * child
struct data1_node * last_child