Added --with-yc option to configure. For the data1_node in data1.h:
[yaz-moved-to-github.git] / include / data1.h
index 14de485..dce4698 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-1998, Index Data.
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation, in whole or in part, for any purpose, is hereby granted,
  * OF THIS SOFTWARE.
  *
  * $Log: data1.h,v $
- * Revision 1.12  1996-01-18 09:46:34  adam
+ * Revision 1.39  1998-10-28 15:10:06  adam
+ * Added --with-yc option to configure. For the data1_node in data1.h:
+ * decreased size of localdata and removed member "line" which wasn't useful.
+ *
+ * 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.
+ * Fixed many bad logs-calls in routines that read the various
+ * specifications regarding data1 (*.abs,*.att,...) and made the messages
+ * consistent whenever possible.
+ * Added extra 'lineno' argument to function readconf_line.
+ *
+ * Revision 1.36  1998/05/18 13:06:57  adam
+ * Changed the way attribute sets are handled by the retriaval module.
+ * Extended Explain conversion / schema.
+ * Modified server and client to work with ASN.1 compiled protocol handlers.
+ *
+ * Revision 1.35  1998/03/05 08:15:32  adam
+ * Implemented data1_add_insert_taggeddata utility which is more flexible
+ * than data1_insert_taggeddata.
+ *
+ * Revision 1.34  1998/02/27 14:08:04  adam
+ * Added const to some char pointer arguments.
+ * Reworked data1_read_node so that it doesn't create a tree with
+ * pointers to original "SGML"-buffer.
+ *
+ * Revision 1.33  1997/12/18 10:51:30  adam
+ * Implemented sub-trees feature for schemas - including forward
+ * references.
+ *
+ * Revision 1.32  1997/12/09 16:18:16  adam
+ * Work on EXPLAIN schema. First implementation of sub-schema facility
+ * in the *.abs files.
+ *
+ * Revision 1.31  1997/11/18 09:51:08  adam
+ * Removed element num_children from data1_node. Minor changes in
+ * data1 to Explain.
+ *
+ * Revision 1.30  1997/10/31 12:20:07  adam
+ * Improved memory debugging for xmalloc/nmem.c. References to NMEM
+ * instead of ODR in n ESPEC-1 handling in source d1_espec.c.
+ * Bug fix: missing fclose in data1_read_espec1.
+ *
+ * Revision 1.29  1997/10/27 13:54:18  adam
+ * Changed structure field in data1 node to be simple string which
+ * is "unknown" to the retrieval system itself.
+ *
+ * Revision 1.28  1997/10/06 09:37:53  adam
+ * Added prototype for data1_get_map_buf.
+ *
+ * Revision 1.27  1997/09/24 13:35:44  adam
+ * Added two members to data1_marctab to ease reading of weird MARC records.
+ *
+ * Revision 1.26  1997/09/17 12:10:32  adam
+ * YAZ version 1.4.
+ *
+ * Revision 1.25  1997/09/05 09:50:55  adam
+ * Removed global data1_tabpath - uses data1_get_tabpath() instead.
+ *
+ * Revision 1.24  1997/09/01 09:30:39  adam
+ * Added include of yaz-util.h.
+ *
+ * Revision 1.23  1997/09/01 08:58:04  adam
+ * Removed declaration of data1_matchstr since it's a macro.
+ *
+ * Revision 1.22  1997/09/01 08:49:48  adam
+ * New windows NT/95 port using MSV5.0. To export DLL functions the
+ * YAZ_EXPORT modifier was added. Defined in yconfig.h.
+ *
+ * Revision 1.21  1997/05/14 06:53:38  adam
+ * C++ support.
+ *
+ * Revision 1.20  1996/10/29 13:34:39  adam
+ * New functions to get/set data1_tabpath.
+ *
+ * Revision 1.19  1996/10/11 11:57:16  quinn
+ * Smallish
+ *
+ * Revision 1.18  1996/10/07  15:29:16  quinn
+ * Added SOIF support
+ *
+ * Revision 1.17  1996/07/06  19:58:32  quinn
+ * System headerfiles gathered in yconfig
+ *
+ * Revision 1.16  1996/06/10  08:55:34  quinn
+ * Added Summary. Unfinished work
+ *
+ * Revision 1.15  1996/06/03  09:46:03  quinn
+ * Added OID type.
+ *
+ * Revision 1.14  1996/05/09  07:27:11  quinn
+ * Multiple local values supported.
+ *
+ * Revision 1.13  1996/02/20  16:32:48  quinn
+ * Created util file.
+ *
+ * Revision 1.12  1996/01/18  09:46:34  adam
  * Changed prototype for reader function parsed to data1_read_record.
  *
  * Revision 1.11  1995/12/15  16:19:45  quinn
 
 #include <d1_attset.h>
 #include <d1_map.h>
+#include <yaz-util.h>
+#include <wrbuf.h>
 
-extern char *data1_tabpath; /* global path for tables */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define data1_matchstr(s1, s2) yaz_matchstr(s1, s2)
 
 #define DATA1_MAX_SYMBOL 31
 
@@ -124,9 +231,13 @@ typedef struct data1_name
     struct data1_name *next;
 } data1_name;
 
+typedef struct data1_absyn_cache_info *data1_absyn_cache;
+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,
@@ -154,6 +265,8 @@ typedef struct data1_marctab
     int  length_implementation;
     char future_use[2];
 
+    int  force_indicator_length;
+    int  force_identifier_length;
     struct data1_marctab *next;
 } data1_marctab;
 
@@ -171,7 +284,7 @@ typedef struct data1_esetname
 typedef struct data1_vartype
 {
     char *name;
-    struct data1_varclass *class;
+    struct data1_varclass *zclass;
     int type;
     data1_datatype datatype;
     struct data1_vartype *next;
@@ -181,7 +294,7 @@ typedef struct data1_varclass
 {
     char *name;
     struct data1_varset *set;
-    int class;
+    int zclass;
     data1_vartype *types;
     struct data1_varclass *next;
 } data1_varclass;
@@ -202,11 +315,9 @@ struct data1_tagset;
 typedef struct data1_tag
 {
     data1_name *names;
-    enum
-    {
-       DATA1T_numeric,
-       DATA1T_string
-    } which;
+#define DATA1T_numeric 1
+#define DATA1T_string 2
+    int which;
     union
     {
        int numeric;
@@ -218,15 +329,24 @@ 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
+{
+    data1_att *att;
+    char *structure;
+    struct data1_termlist *next;
+} data1_termlist;
 
 /*
  * abstract syntax specification
@@ -236,11 +356,18 @@ typedef struct data1_element
 {
     char *name;
     data1_tag *tag;
-    data1_att *att;
+    data1_termlist *termlists;
+    char *sub_name;
     struct data1_element *children;
     struct data1_element *next;
 } data1_element;
 
+typedef struct data1_sub_elements {
+    char *name;
+    struct data1_sub_elements *next;
+    data1_element *elements;
+} data1_sub_elements;
+
 typedef struct data1_absyn
 {
     char *name;
@@ -251,7 +378,8 @@ typedef struct data1_absyn
     data1_esetname *esetnames;
     data1_maptab *maptabs;
     data1_marctab *marc;
-    data1_element *elements;
+    data1_sub_elements *sub_elements;
+    data1_element *main_elements;
 } data1_absyn;
 
 /*
@@ -260,14 +388,15 @@ typedef struct data1_absyn
 
 typedef struct data1_node
 {
-    enum 
-    {
-       DATA1N_root,        /* the root of a record (containing global data) */
-       DATA1N_tag,         /* a tag */
-       DATA1N_data,        /* some data under a leaf tag or variant */
-       DATA1N_variant,     /* variant specification (a triple, actually) */
-       DATA1N_indicator    /* ISO2709 indicator */
-    } which;
+    /* the root of a record (containing global data) */
+#define DATA1N_root 1 
+    /* a tag */
+#define DATA1N_tag  2       
+    /* some data under a leaf tag or variant */
+#define DATA1N_data 3
+    /* variant specification (a triple, actually) */
+#define DATA1N_variant 4
+    int which;
 
     union
     {
@@ -284,22 +413,25 @@ typedef struct data1_node
            int node_selected;
            int make_variantlist;
            int no_data_requested;
+           int get_bytes;
        } tag;
 
        struct
        {
-           enum
-           {
-               DATA1I_inctxt,      /* text inclusion */
-               DATA1I_incbin,      /* binary data inclusion */
-               DATA1I_text,        /* text data */
-               DATA1I_num          /* numerical data */
-           } what;
+        /* text inclusion */
+#define DATA1I_inctxt 1
+        /* binary data inclusion */
+#define DATA1I_incbin 2
+        /* text data */
+#define DATA1I_text 3 
+        /* numerical data */
+#define DATA1I_num 4
+        /* object identifier */
+#define DATA1I_oid 5         
+            int what;
            int formatted_text;     /* newlines are significant */
            int len;
            char *data;      /* filename or data */
-#define DATA1_LOCALDATA 40
-           char lbuf[DATA1_LOCALDATA]; /* small buffer for local data */
        } data;
 
        struct
@@ -307,17 +439,11 @@ typedef struct data1_node
            data1_vartype *type;
            char *value;
        } variant;
-
-       struct
-       {
-           char *ind;
-       } indicator;
     } u;
 
     void (*destroy)(struct data1_node *n);
+#define DATA1_LOCALDATA 20
     char lbuf[DATA1_LOCALDATA]; /* small buffer for local data */
-    int line;
-    int num_children;
     struct data1_node *next;
     struct data1_node *child;
     struct data1_node *last_child;
@@ -325,37 +451,101 @@ typedef struct data1_node
     struct data1_node *root;
 } data1_node;
 
-data1_node *get_parent_tag(data1_node *n);
-data1_node *data1_read_node(char **buf, data1_node *parent, int *line,
-    data1_absyn *absyn, NMEM m);
-data1_node *data1_read_record(int (*rf)(void *, char *, size_t),
-    void *fh, NMEM m);
-data1_absyn *data1_read_absyn(char *file);
-data1_tag *data1_gettagbynum(data1_tagset *s, int type, int value);
-data1_tagset *data1_read_tagset(char *file);
-data1_element *data1_getelementbytagname(data1_absyn *abs,
-    data1_element *parent, char *tagname);
-Z_GenericRecord *data1_nodetogr(data1_node *n, int select, ODR o);
-int data1_matchstr(char *s1, char *s2);
-data1_tag *data1_gettagbyname(data1_tagset *s, char *name);
-void data1_free_tree(data1_node *t);
-char *data1_nodetobuf(data1_node *n, int select, int *len);
-data1_node *data1_insert_taggeddata(data1_node *root, data1_node *at,
-    char *tagname, NMEM m);
-data1_datatype data1_maptype(char *t);
-data1_varset *data1_read_varset(char *file);
-data1_vartype *data1_getvartypebyct(data1_varset *set, char *class, char *type);
-Z_Espec1 *data1_read_espec1(char *file, ODR o);
-int data1_doespec1(data1_node *n, Z_Espec1 *e);
-data1_esetname *data1_getesetbyname(data1_absyn *a, char *name);
-data1_element *data1_getelementbyname(data1_absyn *absyn, char *name);
-data1_node *data1_mk_node(NMEM m);
-data1_absyn *data1_get_absyn(char *name);
-data1_maptab *data1_read_maptab(char *file);
-data1_node *data1_map_record(data1_node *n, data1_maptab *map, NMEM m);
-data1_marctab *data1_read_marctab(char *file);
-char *data1_nodetomarc(data1_marctab *p, data1_node *n, int selected, int *len);
-char *data1_nodetoidsgml(data1_node *n, int select, int *len);
-Z_ExplainRecord *data1_nodetoexplain(data1_node *n, int select, ODR o);
+YAZ_EXPORT data1_handle data1_create (void);
+YAZ_EXPORT void data1_destroy(data1_handle dh);
+YAZ_EXPORT data1_node *get_parent_tag(data1_handle dh, data1_node *n);
+YAZ_EXPORT data1_node *data1_read_node(data1_handle dh, const char **buf,
+                                      data1_node *parent,
+                                      int *line, data1_absyn *absyn, NMEM m);
+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,
+                                       int type, int value);
+YAZ_EXPORT data1_tagset *data1_empty_tagset (data1_handle dh);
+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,
+                                                   const char *tagname);
+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,
+                                        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);
+YAZ_EXPORT data1_node *data1_insert_taggeddata(data1_handle dh,
+                                              data1_node *root,
+                                              data1_node *at,
+                                              const char *tagname, NMEM m);
+YAZ_EXPORT data1_node *data1_add_taggeddata(data1_handle dh, data1_node *root,
+                                           data1_node *at,
+                                           const char *tagname, NMEM m);
+YAZ_EXPORT data1_datatype data1_maptype(data1_handle dh, char *t);
+YAZ_EXPORT data1_varset *data1_read_varset(data1_handle dh, const char *file);
+YAZ_EXPORT data1_vartype *data1_getvartypebyct(data1_handle dh,
+                                              data1_varset *set,
+                                              char *zclass, char *type);
+YAZ_EXPORT Z_Espec1 *data1_read_espec1(data1_handle dh, const char *file);
+YAZ_EXPORT int data1_doespec1(data1_handle dh, data1_node *n, Z_Espec1 *e);
+YAZ_EXPORT data1_esetname *data1_getesetbyname(data1_handle dh, 
+                                              data1_absyn *a,
+                                              const char *name);
+YAZ_EXPORT data1_element *data1_getelementbyname(data1_handle dh,
+                                                data1_absyn *absyn,
+                                                const char *name);
+YAZ_EXPORT data1_node *data1_mk_node(data1_handle dh, NMEM m);
+YAZ_EXPORT data1_absyn *data1_get_absyn(data1_handle dh, const char *name);
+YAZ_EXPORT data1_attset *data1_get_attset (data1_handle dh, const char *name);
+YAZ_EXPORT data1_maptab *data1_read_maptab(data1_handle dh, const char *file);
+YAZ_EXPORT data1_node *data1_map_record(data1_handle dh, data1_node *n,
+                                       data1_maptab *map, NMEM m);
+YAZ_EXPORT data1_marctab *data1_read_marctab (data1_handle dh,
+                                             const char *file);
+YAZ_EXPORT char *data1_nodetomarc(data1_handle dh, data1_marctab *p,
+                                 data1_node *n, int selected, int *len);
+YAZ_EXPORT char *data1_nodetoidsgml(data1_handle dh, data1_node *n,
+                                   int select, int *len);
+YAZ_EXPORT Z_ExplainRecord *data1_nodetoexplain(data1_handle dh,
+                                               data1_node *n, int select,
+                                               ODR o);
+YAZ_EXPORT Z_BriefBib *data1_nodetosummary(data1_handle dh, 
+                                          data1_node *n, int select,
+                                          ODR o);
+YAZ_EXPORT char *data1_nodetosoif(data1_handle dh, data1_node *n, int select,
+                                 int *len);
+YAZ_EXPORT void data1_set_tabpath(data1_handle dh, const char *path);
+YAZ_EXPORT const char *data1_get_tabpath(data1_handle dh);
+
+YAZ_EXPORT WRBUF data1_get_wrbuf (data1_handle dp);
+YAZ_EXPORT char **data1_get_read_buf (data1_handle dp, int **lenp);
+YAZ_EXPORT char **data1_get_map_buf (data1_handle dp, int **lenp);
+YAZ_EXPORT data1_absyn_cache *data1_absyn_cache_get (data1_handle dh);
+YAZ_EXPORT data1_attset_cache *data1_attset_cache_get (data1_handle dh);
+YAZ_EXPORT NMEM data1_nmem_get (data1_handle dh);
+YAZ_EXPORT void data1_pr_tree (data1_handle dh, data1_node *n, FILE *out);
+YAZ_EXPORT char *data1_insert_string (data1_handle dh, data1_node *res,
+                                     NMEM m, const char *str);
+YAZ_EXPORT data1_node *data1_read_sgml (data1_handle dh, NMEM m,
+                                       const char *buf);
+YAZ_EXPORT void data1_absyn_trav (data1_handle dh, void *handle,
+                                 void (*fh)(data1_handle dh,
+                                            void *h, data1_absyn *a));
+
+YAZ_EXPORT data1_attset *data1_attset_search_id (data1_handle dh, int id);
+
+YAZ_EXPORT data1_node 
+*data1_add_insert_taggeddata(data1_handle dh, data1_node *root,
+                             data1_node *at, const char *tagname, NMEM m,
+                             int first_flag, int local_allowed);
+#ifdef __cplusplus
+}
+#endif
 
 #endif