2007.
[idzebra-moved-to-github.git] / include / idzebra / data1.h
index 81c579a..f41a770 100644 (file)
@@ -1,6 +1,6 @@
-/* $Id: data1.h,v 1.1 2004-09-28 10:15:03 adam Exp $
-   Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
-   Index Data Aps
+/* $Id: data1.h,v 1.21 2007-01-15 20:08:24 adam Exp $
+   Copyright (C) 1995-2007
+   Index Data ApS
 
 This file is part of the Zebra server.
 
@@ -15,9 +15,9 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra.  If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
 */
 
 #ifndef DATA1_H
@@ -28,12 +28,9 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <yaz/nmem.h>
 #include <yaz/oid.h>
 #include <yaz/proto.h>
-
-#include <idzebra/version.h>
-#include <d1_attset.h>
-#include <d1_map.h>
 #include <yaz/yaz-util.h>
-#include <yaz/wrbuf.h>
+
+#include <idzebra/util.h>
 
 #define d1_isspace(c) strchr(" \r\n\t\f", c)
 #define d1_isdigit(c) ((c) <= '9' && (c) >= '0')
@@ -44,6 +41,83 @@ YAZ_BEGIN_CDECL
 
 #define DATA1_MAX_SYMBOL 31
 
+/*
+ * This structure describes a attset, perhaps made up by inclusion
+ * (supersetting) of other attribute sets. When indexing and searching,
+ * we perform a normalisation, where we associate a given tag with
+ * the set that originally defined it, rather than the superset. This
+ * allows the most flexible access. Eg, the tags common to GILS and BIB-1
+ * should be searchable by both names.
+ */
+
+struct data1_attset;
+
+typedef struct data1_attset data1_attset;    
+typedef struct data1_att data1_att;
+typedef struct data1_attset_child data1_attset_child;
+
+struct data1_att
+{
+    data1_attset *parent;          /* attribute set */
+    char *name;                    /* symbolic name of this attribute */
+    int value;                     /* attribute value */
+    data1_att *next;
+};
+
+struct data1_attset_child {
+    data1_attset *child;
+    data1_attset_child *next;
+};
+
+struct data1_attset
+{
+    char *name;          /* symbolic name */
+    oid_value reference;   /* external ID of attset */
+    data1_att *atts;          /* attributes */
+    data1_attset_child *children;  /* included attset */
+    data1_attset *next;       /* next in cache */
+};
+
+typedef struct data1_handle_info *data1_handle;
+
+YAZ_EXPORT data1_att *data1_getattbyname(data1_handle dh, data1_attset *s,
+                                        const char *name);
+YAZ_EXPORT data1_attset *data1_read_attset(data1_handle dh, const char *file);
+
+YAZ_EXPORT data1_attset *data1_empty_attset(data1_handle dh);
+
+typedef struct data1_maptag
+{
+    int new_field;
+    int type;
+#define D1_MAPTAG_numeric 1
+#define D1_MAPTAG_string 2
+    int which;
+    union
+    {
+       int numeric;
+       char *string;
+    } value;
+    struct data1_maptag *next;
+} data1_maptag;
+
+typedef struct data1_mapunit
+{
+    int no_data;
+    char *source_element_name;
+    data1_maptag *target_path;
+    struct data1_mapunit *next;
+} data1_mapunit;
+
+typedef struct data1_maptab
+{
+    char *name;
+    oid_value target_absyn_ref;
+    char *target_absyn_name;
+    data1_mapunit *map;
+    struct data1_maptab *next;
+} data1_maptab;
+
 typedef struct data1_name
 {
     char *name;
@@ -164,7 +238,7 @@ struct data1_tagset
 
 typedef struct data1_termlist
 {
-    data1_att *att;
+    char *index_name;
     char *structure;
     char *source;
     struct data1_termlist *next;
@@ -182,6 +256,7 @@ typedef struct data1_element
     char *sub_name;
     struct data1_element *children;
     struct data1_element *next;
+    struct data1_hash_table *hash;
 } data1_element;
 
 typedef struct data1_sub_elements {
@@ -269,7 +344,6 @@ typedef struct data1_node
         } preprocess;
     } u;
 
-    void (*destroy)(struct data1_node *n);
 #define DATA1_LOCALDATA 12
     char lbuf[DATA1_LOCALDATA]; /* small buffer for local data */
     struct data1_node *next;
@@ -279,10 +353,13 @@ typedef struct data1_node
     struct data1_node *root;
 } data1_node;
 
+enum DATA1_XPATH_INDEXING {
+    DATA1_XPATH_INDEXING_DISABLE,
+    DATA1_XPATH_INDEXING_ENABLE
+};
+
 YAZ_EXPORT data1_handle data1_create (void);
 
-#define DATA1_FLAG_XML  1
-YAZ_EXPORT data1_handle data1_createx (int flags);
 
 YAZ_EXPORT void data1_destroy(data1_handle dh);
 YAZ_EXPORT data1_node *get_parent_tag(data1_handle dh, data1_node *n);
@@ -294,8 +371,9 @@ YAZ_EXPORT data1_node *data1_read_nodex (data1_handle dh, 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,
-                                         int file_must_exist);
+
+YAZ_EXPORT void data1_remove_node (data1_handle dh, data1_node *n);
+YAZ_EXPORT void data1_remove_idzebra_subtree (data1_handle dh, data1_node *n);
 YAZ_EXPORT data1_tag *data1_gettagbynum(data1_handle dh,
                                        data1_tagset *s,
                                        int type, int value);
@@ -312,7 +390,6 @@ YAZ_EXPORT Z_GenericRecord *data1_nodetogr(data1_handle dh, data1_node *n,
                                           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_mk_tag_data_wd(data1_handle dh,
@@ -324,7 +401,8 @@ 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);
+                                              const char *zclass,
+                                              const char *type);
 YAZ_EXPORT data1_vartype *data1_getvartypeby_absyn(data1_handle dh,
                                                   data1_absyn *absyn,
                                                   char *zclass, char *type);
@@ -410,7 +488,8 @@ YAZ_EXPORT data1_node *data1_mk_tag_data_text_uni (data1_handle dh,
                                                    const char *str,
                                                    NMEM nmem);
 
-YAZ_EXPORT data1_absyn *data1_get_absyn (data1_handle dh, const char *name);
+YAZ_EXPORT data1_absyn *data1_get_absyn (data1_handle dh, const char *name,
+                                         enum DATA1_XPATH_INDEXING en);
 
 YAZ_EXPORT data1_node *data1_search_tag (data1_handle dh, data1_node *n,
                                          const char *tag);
@@ -423,9 +502,9 @@ YAZ_EXPORT data1_node *data1_map_record(data1_handle dh, data1_node *n,
 YAZ_EXPORT data1_marctab *data1_read_marctab (data1_handle dh,
                                              const char *file);
 YAZ_EXPORT data1_marctab *data1_absyn_getmarctab(data1_handle dh,
-                                                data1_absyn *absyn);
+                                                data1_node *root);
 YAZ_EXPORT data1_element *data1_absyn_getelements(data1_handle dh,
-                                                data1_absyn *absyn);
+                                                data1_node *root);
 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,
@@ -502,6 +581,16 @@ YAZ_EXPORT void data1_concat_text(data1_handle dh, NMEM m, data1_node *n);
 
 YAZ_EXPORT void data1_absyn_destroy(data1_handle dh);
 
+YAZ_EXPORT const char *data1_absyn_get_staticrank(data1_absyn *absyn);
+
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+