Definitions in zebramap.h are private. ZebraMaps no longer used in
[idzebra-moved-to-github.git] / include / idzebra / recctrl.h
1 /* $Id: recctrl.h,v 1.27 2006-08-15 14:28:33 adam Exp $
2    Copyright (C) 1995-2006
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
21 */
22
23 #ifndef IDZEBRA_RECCTRL_H
24 #define IDZEBRA_RECCTRL_H
25
26 #include <sys/types.h>
27 #include <yaz/proto.h>
28 #include <yaz/oid.h>
29 #include <yaz/odr.h>
30 #include <idzebra/res.h>
31 #include <idzebra/data1.h>
32 #include <idzebra/snippet.h>
33
34 YAZ_BEGIN_CDECL
35
36 /* 1 */
37 #define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN"
38
39 /* 2 */
40 #define ZEBRA_XPATH_ELM_END   "_XPATH_END"
41
42 /* 1016 */
43 #define ZEBRA_XPATH_CDATA     "_XPATH_CDATA"
44
45 /* 3 */
46 #define ZEBRA_XPATH_ATTR_NAME       "_XPATH_ATTR_NAME"
47
48 /* 1015 */
49 #define ZEBRA_XPATH_ATTR_CDATA      "_XPATH_ATTR_CDATA"
50
51 /* single word entity */
52 typedef struct {
53     unsigned index_type;
54     const char *index_name;
55     const char *term_buf;
56     int  term_len;
57     zint seqno;
58     zint record_id;
59     zint section_id;
60     struct recExtractCtrl *extractCtrl;
61 } RecWord;
62
63 /* Extract record control */
64 struct recExtractCtrl {
65     void      *fh;                    /* File handle and read function     */
66     int       (*readf)(void *fh, char *buf, size_t count);
67     off_t     (*seekf)(void *fh, off_t offset);  /* seek function          */
68     off_t     (*tellf)(void *fh);                /* tell function          */
69     void      (*endf)(void *fh, off_t offset);   /* end of record position */
70     off_t     offset;                            /* start offset           */
71     void      (*init)(struct recExtractCtrl *p, RecWord *w);
72     void      *clientData;
73     void      (*tokenAdd)(RecWord *w);
74     void      (*setStoreData)(struct recExtractCtrl *p, void *buf, size_t size);
75     int       first_record;
76     int       flagShowRecords;
77     int       seqno[256];
78     char      match_criteria[256];
79     zint      staticrank;
80     void      (*schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid);
81     data1_handle dh;
82     void      *handle;
83 };
84
85 /* Retrieve record control */
86 struct recRetrieveCtrl {
87     /* Input parameters ... */
88     Res       res;                    /* Resource pool                     */
89     ODR       odr;                    /* ODR used to create response       */
90     void     *fh;                     /* File descriptor and read function */
91     int       (*readf)(void *fh, char *buf, size_t count);
92     off_t     (*seekf)(void *fh, off_t offset);
93     off_t     (*tellf)(void *fh);
94     oid_value input_format;           /* Preferred record syntax           */
95     Z_RecordComposition *comp;        /* formatting instructions           */
96     char      *encoding;              /* preferred character encoding      */
97     zint      localno;                /* local id of record                */
98     int       score;                  /* score 0-1000 or -1 if none        */
99     zint      staticrank;             /* static rank >= 0,  0 if none */
100     int       recordSize;             /* size of record in bytes */
101     char      *fname;                 /* name of file (or NULL if internal) */
102     data1_handle dh;
103     zebra_snippets *hit_snippet;
104     zebra_snippets *doc_snippet;
105     
106     /* response */
107     oid_value  output_format;
108     void       *rec_buf;
109     int        rec_len;
110     int        diagnostic;
111     char       *addinfo;
112 };
113
114 typedef struct recType *RecType;
115
116 struct recType
117 {
118     int version;
119     char *name;                           /* Name of record type */
120     void *(*init)(Res res, RecType recType);  /* Init function - called once */
121     ZEBRA_RES (*config)(void *clientData, Res res, const char *args); /* Config */
122     void (*destroy)(void *clientData);    /* Destroy function */
123     int  (*extract)(void *clientData,
124                     struct recExtractCtrl *ctrl);   /* Extract proc */
125     int  (*retrieve)(void *clientData,
126                      struct recRetrieveCtrl *ctrl); /* Retrieve proc */
127 };
128
129 #define RECCTRL_EXTRACT_OK    0
130 #define RECCTRL_EXTRACT_EOF   1
131 #define RECCTRL_EXTRACT_ERROR_GENERIC 2
132 #define RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER 3
133
134 typedef struct recTypeClass *RecTypeClass;
135 typedef struct recTypes *RecTypes;
136
137 YAZ_EXPORT
138 RecTypeClass recTypeClass_create (Res res, NMEM nmem);
139
140 YAZ_EXPORT
141 void recTypeClass_load_modules(RecTypeClass *rts, NMEM nmem,
142                                const char *module_path);
143
144 YAZ_EXPORT
145 RecTypeClass recTypeClass_add_modules(Res res, NMEM nmem,
146                                       const char *module_path);
147
148 YAZ_EXPORT
149 void recTypeClass_destroy(RecTypeClass rtc);
150
151 YAZ_EXPORT
152 void recTypeClass_info(RecTypeClass rtc, void *cd,
153                        void (*cb)(void *cd, const char *s));
154
155 YAZ_EXPORT
156 RecTypes recTypes_init(RecTypeClass rtc, data1_handle dh);
157
158 YAZ_EXPORT
159 void recTypes_destroy(RecTypes recTypes);
160
161 YAZ_EXPORT
162 void recTypes_default_handlers(RecTypes recTypes, Res res);
163
164 YAZ_EXPORT
165 RecType recType_byName(RecTypes rts, Res res, const char *name,
166                        void **clientDataP);
167
168
169 #define KEY_SEGMENT_SIZE 1024
170
171 YAZ_END_CDECL
172
173 #endif
174 /*
175  * Local variables:
176  * c-basic-offset: 4
177  * indent-tabs-mode: nil
178  * End:
179  * vim: shiftwidth=4 tabstop=8 expandtab
180  */
181