+
+static int parse_termlists (data1_handle dh, data1_termlist ***tpp,
+ char *p, const char *file, int lineno,
+ const char *element_name, data1_absyn *res)
+{
+ data1_termlist **tp = *tpp;
+ do
+ {
+ char attname[512], structure[512];
+ char *source;
+ int r;
+
+ if (!(r = sscanf(p, "%511[^:,]:%511[^,]", attname,
+ structure)))
+ {
+ yaz_log(LOG_WARN,
+ "%s:%d: Syntax error in termlistspec '%s'",
+ file, lineno, p);
+ return -1;
+ }
+ if (*attname == '!')
+ strcpy(attname, element_name);
+ *tp = (data1_termlist *)
+ nmem_malloc(data1_nmem_get(dh), sizeof(**tp));
+ (*tp)->next = 0;
+ if (!((*tp)->att = data1_getattbyname(dh, res->attset,
+ attname)))
+ {
+ yaz_log(LOG_WARN,
+ "%s:%d: Couldn't find att '%s' in attset",
+ file, lineno, attname);
+ return -1;
+ }
+ if (r == 2 && (source = strchr(structure, ':')))
+ *source++ = '\0'; /* cut off structure .. */
+ else
+ source = "data"; /* ok: default is leaf data */
+ (*tp)->source = (char *)
+ nmem_strdup (data1_nmem_get (dh), source);
+
+ if (r < 2) /* is the structure qualified? */
+ (*tp)->structure = "w";
+ else
+ (*tp)->structure = (char *)
+ nmem_strdup (data1_nmem_get (dh), structure);
+ tp = &(*tp)->next;
+ }
+ while ((p = strchr(p, ',')) && *(++p));
+ *tpp = tp;
+ return 0;
+}
+
+data1_absyn *data1_read_absyn (data1_handle dh, const char *file,
+ int file_must_exist)