Tag set type may be specified in reference to it using "tagset"
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 15 Oct 1998 08:29:14 +0000 (08:29 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 15 Oct 1998 08:29:14 +0000 (08:29 +0000)
directive in .abs-files and "include" directive in .tag-files.

CHANGELOG
include/data1.h
retrieval/d1_absyn.c
retrieval/d1_tagset.c

index d9ee307..afa3db6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,17 +1,24 @@
 Possible compatibility problems with earlier versions marked with '*'.
 
-Backend interface change. Individual Scan terms returned from
-bend_scan may also be tagged as Surrogate Diagnostics. Refer
-to struct scan_entry in include/backend.h.
-
-Retrieval module enhancements. Multiple tag sets and attribute sets
-may be specified in abstract syntax specs. Revised the error/warning
+Retrieval module enhancements. Tag sets may be typed in the reference
+to it. From the .abs-file the "tagset" directive takes a third optional
+integer type for the tag set referenced. From a .tag-file the "include"
+directive takes a third optional type as well. The old "type" directive
+in the tag set itself is still recognized but acts as the default type
+for the tag set.
+
+Backend interface change. Individual Scan terms returned from bend_scan
+may also be tagged as Surrogate Diagnostics. Refer to struct scan_entry
+in include/backend.h.
+
+Retrieval module enhancements. Multiple tag sets and attribute sets may
+be specified in abstract syntax specs. Revised the error/warning for
 logging messages reported by the retrieval module when reading the
 various spec files.
 
 Object Identifier system (oid_..) changed. The API is backwards
-compatible but the oid-routines now allocates new OID's
-when needed. Raw OID's may be specified in oid_getvalbyname.
+compatible but the oid-routines now allocates new OID's when needed.
+Raw OID's may be specified in oid_getvalbyname.
 
 YAZ now uses GNU configure to generate Makefile(s).
 
index d5dc4e7..e7982d4 100644 (file)
  * OF THIS SOFTWARE.
  *
  * $Log: data1.h,v $
- * Revision 1.37  1998-10-13 16:09:46  adam
+ * Revision 1.38  1998-10-15 08:29:15  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.37  1998/10/13 16:09:46  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.
@@ -228,7 +232,8 @@ typedef struct data1_attset_cache_info *data1_attset_cache;
 
 typedef enum data1_datatype
 {
-    DATA1K_structured = 1,
+    DATA1K_unknown,
+    DATA1K_structured,
     DATA1K_string,
     DATA1K_numeric,
     DATA1K_bool,
@@ -320,15 +325,17 @@ typedef struct data1_tag
     struct data1_tag *next;
 } data1_tag;
 
-typedef struct data1_tagset
+typedef struct data1_tagset data1_tagset;
+
+struct data1_tagset
 {
+    int type;                        /* type of tagset in current context */
     char *name;                      /* symbolic name */
     oid_value reference;
-    int type;                        /* type of tagset in current context */
     data1_tag *tags;                 /* tags defined by this set */
-    struct data1_tagset *children;   /* included tagsets */
-    struct data1_tagset *next;       /* sibling */
-} data1_tagset;
+    data1_tagset *children;          /* children */
+    data1_tagset *next;              /* sibling */
+};
 
 typedef struct data1_termlist
 {
@@ -451,10 +458,13 @@ YAZ_EXPORT data1_node *data1_read_record(data1_handle dh,
                                         int (*rf)(void *, char *, size_t),
                                         void *fh, NMEM m);
 YAZ_EXPORT data1_absyn *data1_read_absyn(data1_handle dh, const char *file);
-YAZ_EXPORT data1_tag *data1_gettagbynum(data1_handle dh, data1_tagset *s,
+YAZ_EXPORT data1_tag *data1_gettagbynum(data1_handle dh,
+                                       data1_tagset *s,
                                        int type, int value);
 YAZ_EXPORT data1_tagset *data1_empty_tagset (data1_handle dh);
-YAZ_EXPORT data1_tagset *data1_read_tagset(data1_handle dh, char *file);
+YAZ_EXPORT data1_tagset *data1_read_tagset(data1_handle dh, 
+                                          const char *file,
+                                          int type);
 YAZ_EXPORT data1_element *data1_getelementbytagname(data1_handle dh, 
                                                    data1_absyn *abs,
                                                    data1_element *parent,
@@ -463,7 +473,7 @@ YAZ_EXPORT Z_GenericRecord *data1_nodetogr(data1_handle dh, data1_node *n,
                                           int select, ODR o,
                                           int *len);
 YAZ_EXPORT data1_tag *data1_gettagbyname(data1_handle dh, data1_tagset *s,
-                                        char *name);
+                                        const char *name);
 YAZ_EXPORT void data1_free_tree(data1_handle dh, data1_node *t);
 YAZ_EXPORT char *data1_nodetobuf(data1_handle dh, data1_node *n,
                                 int select, int *len);
index 6b9a413..71e35de 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_absyn.c,v $
- * Revision 1.22  1998-10-13 16:09:47  adam
+ * 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.
@@ -637,14 +641,18 @@ 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",
                     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",
                     file, lineno, name);
index 38b785f..7ba2a81 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: d1_tagset.c,v $
- * Revision 1.9  1998-10-13 16:09:53  adam
+ * Revision 1.10  1998-10-15 08:29:17  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.9  1998/10/13 16:09:53  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.
@@ -80,14 +84,14 @@ data1_datatype data1_maptype (data1_handle dh, char *t)
     for (i = 0; types[i].tname; i++)
        if (!data1_matchstr(types[i].tname, t))
            return types[i].type;
-    return 0;
+    return DATA1K_unknown;
 }
 
 data1_tag *data1_gettagbynum (data1_handle dh, data1_tagset *s,
                              int type, int value)
 {
     data1_tag *r;
-
+    
     for (; s; s = s->next)
     {
        /* scan local set */
@@ -96,21 +100,22 @@ data1_tag *data1_gettagbynum (data1_handle dh, data1_tagset *s,
                if (r->which == DATA1T_numeric && r->value.numeric == value)
                    return r;
        /* scan included sets */
-       if (s->children && (r = data1_gettagbynum (dh, s->children,
-                                                  type, value)))
+       if (s->children &&
+           (r = data1_gettagbynum (dh, s->children, type, value)))
            return r;
     }
     return 0;
 }
 
-data1_tag *data1_gettagbyname (data1_handle dh, data1_tagset *s, char *name)
+data1_tag *data1_gettagbyname (data1_handle dh, data1_tagset *s,
+                              const char *name)
 {
     data1_tag *r;
 
     for (; s; s = s->next)
     {
        /* scan local set */
-       for (r = s->tags; r; r = r->next)
+       for (r = s->children->tags; r; r = r->next)
        {
            data1_name *np;
 
@@ -131,17 +136,18 @@ data1_tagset *data1_empty_tagset (data1_handle dh)
        (data1_tagset *) nmem_malloc(data1_nmem_get (dh), sizeof(*res));
     res->name = 0;
     res->reference = VAL_NONE;
-    res->type = 0;
     res->tags = 0;
+    res->type = 0;
     res->children = 0;
     res->next = 0;
     return res;
 }
 
-data1_tagset *data1_read_tagset (data1_handle dh, char *file)
+data1_tagset *data1_read_tagset (data1_handle dh, const char *file, int type)
 {
     NMEM mem = data1_nmem_get (dh);
-    data1_tagset *res = 0, **childp;
+    data1_tagset *res = 0;
+    data1_tagset **childp;
     data1_tag **tagp;
     FILE *f;
     int lineno = 0;
@@ -154,6 +160,7 @@ data1_tagset *data1_read_tagset (data1_handle dh, char *file)
        return 0;
     }
     res = data1_empty_tagset (dh);
+    res->type = type;
     childp = &res->children;
     tagp = &res->tags;
 
@@ -241,23 +248,28 @@ data1_tagset *data1_read_tagset (data1_handle dh, char *file)
        {
            if (argc != 2)
            {
-               logf(LOG_WARN, "%s:%d: Bad # args to type", file, lineno);
+               logf (LOG_WARN, "%s:%d: Bad # args to type", file, lineno);
                continue;
            }
-           res->type = atoi(argv[1]);
+           if (!res->type)
+               res->type = atoi(argv[1]);
        }
        else if (!strcmp(cmd, "include"))
        {
            char *name;
+           int type = 0;
 
-           if (argc != 2)
+           if (argc < 2)
            {
                logf(LOG_WARN, "%s:%d: Bad # args to include",
                     file, lineno);
                continue;
            }
            name = argv[1];
-           if (!(*childp = data1_read_tagset (dh, name)))
+           if (argc == 3)
+               type = atoi(argv[2]);
+           *childp = data1_read_tagset (dh, name, type);
+           if (!(*childp))
            {
                logf(LOG_WARN, "%s:%d: Inclusion failed for tagset %s",
                     file, lineno, name);