+ assert (res->attset);
+ do
+ {
+ char attname[512], structure[512];
+ int r;
+
+ if (!(r = sscanf(p, "%511[^:,]:%511[^,]", attname,
+ structure)))
+ {
+ yaz_log(LOG_WARN,
+ "%s:%d: Syntax error in termlistspec '%s'",
+ file, lineno, p);
+ fclose(f);
+ return 0;
+ }
+ if (*attname == '!')
+ strcpy(attname, 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);
+ fclose(f);
+ return 0;
+ }
+ if (r < 2) /* is the structure qualified? */
+ (*tp)->structure = "w";
+ else
+ {
+ (*tp)->structure = (char *)
+ nmem_malloc (data1_nmem_get (dh),
+ strlen(structure)+1);
+ strcpy ((*tp)->structure, structure);
+ }
+ tp = &(*tp)->next;
+ }
+ while ((p = strchr(p, ',')) && *(++p));
+ *tp = all; /* append any ALL entries to the list */
+ }
+ new_element->name = nmem_strdup(data1_nmem_get (dh), name);
+ }
+ else if (!strcmp(cmd, "section"))
+ {
+ char *name;
+
+ if (argc < 2)
+ {
+ yaz_log(LOG_WARN, "%s:%d: Bad # of args to section",
+ file, lineno);
+ continue;
+ }
+ name = argv[1];
+
+ cur_elements = (data1_sub_elements *)
+ nmem_malloc(data1_nmem_get(dh), sizeof(*cur_elements));
+ cur_elements->next = res->sub_elements;
+ cur_elements->elements = NULL;
+ cur_elements->name = nmem_strdup (data1_nmem_get(dh), name);
+ res->sub_elements = cur_elements;
+
+ level = 0;
+ ppl[level] = &cur_elements->elements;
+ }
+ else if (!strcmp(cmd, "all"))
+ {
+ char *p;
+ data1_termlist **tp = &all;
+
+ if (all)
+ {
+ yaz_log(LOG_WARN, "%s:%d: Too many 'all' directives - ignored",
+ file, lineno);
+ continue;
+ }
+
+ if (argc != 2)
+ {
+ yaz_log(LOG_WARN, "%s:%d: Bad # of args to 'all' directive",
+ file, lineno);
+ continue;
+ }
+ p = argv[1];
+ assert (res->attset);
+ do
+ {
+ char attname[512], structure[512];
+ int r;
+
+ if (!(r = sscanf(p, "%511[^:,]:%511[^,]", attname,
+ structure)))