IDZEBRA  2.2.7
recctrl.h
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 #ifndef IDZEBRA_RECCTRL_H
21 #define IDZEBRA_RECCTRL_H
22 
23 #include <sys/types.h>
24 #include <yaz/proto.h>
25 #include <yaz/odr.h>
26 #include <idzebra/res.h>
27 #include <idzebra/data1.h>
28 #include <idzebra/snippet.h>
29 
30 YAZ_BEGIN_CDECL
31 
32 /* 1 */
33 #define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN"
34 
35 /* 2 */
36 #define ZEBRA_XPATH_ELM_END "_XPATH_END"
37 
38 /* 1016 */
39 #define ZEBRA_XPATH_CDATA "_XPATH_CDATA"
40 
41 /* 3 */
42 #define ZEBRA_XPATH_ATTR_NAME "_XPATH_ATTR_NAME"
43 
44 /* 1015 */
45 #define ZEBRA_XPATH_ATTR_CDATA "_XPATH_ATTR_CDATA"
46 
47 #define ZEBRA_GROUP_INDEX_NAME "_GROUP_"
48 
50 typedef struct {
52  const char *index_type;
54  const char *index_name;
56  const char *term_buf;
58  int term_len;
68 } RecWord;
69 
73  void *fh;
75  int (*readf)(struct ZebraRecStream *s, char *buf, size_t count);
77  off_t (*seekf)(struct ZebraRecStream *s, off_t offset);
79  off_t (*tellf)(struct ZebraRecStream *s);
81  off_t (*endf)(struct ZebraRecStream *s, off_t *offset);
83  void (*destroy)(struct ZebraRecStream *s);
84 };
85 
98 };
99 
103  void (*init)(struct recExtractCtrl *p, RecWord *w);
104  void *clientData;
105  void (*tokenAdd)(RecWord *w);
106  void (*setStoreData)(struct recExtractCtrl *p, void *buf, size_t size);
109  char match_criteria[256];
111  void (*schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid);
113  void *handle;
115 };
116 
117 /* Retrieve record control */
120  /* Input parameters ... */
121  Res res; /* Resource pool */
122  ODR odr; /* ODR used to create response */
123  const Odr_oid * input_format; /* Preferred record syntax OID */
124  Z_RecordComposition *comp; /* formatting instructions */
125  char *encoding; /* preferred character encoding */
126  zint localno; /* local id of record */
127  int score; /* score 0-1000 or -1 if none */
128  zint staticrank; /* static rank >= 0, 0 if none */
129  int recordSize; /* size of record in bytes */
130  char *fname; /* name of file (or NULL if internal) */
132 
133  /* response */
134  const Odr_oid * output_format; /* output format OID */
135  void * rec_buf;
136  int rec_len;
138  char * addinfo;
139 
140  /* special fetch to be included in retrieved response (say snippets) */
141  void *handle;
142  int (*special_fetch)(void *handle, const char *esn,
143  const Odr_oid *input_format,
144  const Odr_oid **output_format,
145  WRBUF result, WRBUF addinfo);
146 };
147 
148 typedef struct recType *RecType;
149 
150 struct recType
151 {
152  int version;
153  char *name; /* Name of record type */
154  void *(*init)(Res res, RecType recType); /* Init function - called once */
155  ZEBRA_RES (*config)(void *clientData, Res res, const char *args); /* Config */
156  void (*destroy)(void *clientData); /* Destroy function */
157  int (*extract)(void *clientData,
158  struct recExtractCtrl *ctrl); /* Extract proc */
159  int (*retrieve)(void *clientData,
160  struct recRetrieveCtrl *ctrl); /* Retrieve proc */
161 };
162 
163 #define RECCTRL_EXTRACT_OK 0
164 #define RECCTRL_EXTRACT_EOF 1
165 #define RECCTRL_EXTRACT_ERROR_GENERIC 2
166 #define RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER 3
167 #define RECCTRL_EXTRACT_SKIP 4
168 
169 typedef struct recTypeClass *RecTypeClass;
170 typedef struct recTypes *RecTypes;
171 
172 YAZ_EXPORT
173 RecTypeClass recTypeClass_create (Res res, NMEM nmem);
174 
175 YAZ_EXPORT
176 void recTypeClass_load_modules(RecTypeClass *rts, NMEM nmem,
177  const char *module_path);
178 
179 YAZ_EXPORT
181  const char *module_path);
182 
183 YAZ_EXPORT
185 
186 YAZ_EXPORT
187 void recTypeClass_info(RecTypeClass rtc, void *cd,
188  void (*cb)(void *cd, const char *s));
189 
190 YAZ_EXPORT
192 
193 YAZ_EXPORT
195 
196 YAZ_EXPORT
198 
199 YAZ_EXPORT
200 RecType recType_byName(RecTypes rts, Res res, const char *name,
201  void **clientDataP);
202 
203 YAZ_END_CDECL
204 
205 #endif
206 /*
207  * Local variables:
208  * c-basic-offset: 4
209  * c-file-style: "Stroustrup"
210  * indent-tabs-mode: nil
211  * End:
212  * vim: shiftwidth=4 tabstop=8 expandtab
213  */
214 
void recTypeClass_load_modules(RecTypeClass *rts, NMEM nmem, const char *module_path)
Definition: recctrl.c:177
RecTypeClass recTypeClass_add_modules(Res res, NMEM nmem, const char *module_path)
struct recType * RecType
Definition: recctrl.h:148
void recTypeClass_destroy(RecTypeClass rtc)
Definition: recctrl.c:223
zebra_recctrl_action_t
Definition: recctrl.h:87
@ action_a_delete
Definition: recctrl.h:97
@ action_delete
Definition: recctrl.h:93
@ action_insert
Definition: recctrl.h:89
@ action_update
Definition: recctrl.h:95
@ action_replace
Definition: recctrl.h:91
struct recTypes * RecTypes
Definition: recctrl.h:170
RecTypeClass recTypeClass_create(Res res, NMEM nmem)
Definition: recctrl.c:58
void recTypes_destroy(RecTypes recTypes)
Definition: recctrl.c:253
struct recTypeClass * RecTypeClass
Definition: recctrl.h:169
void recTypeClass_info(RecTypeClass rtc, void *cd, void(*cb)(void *cd, const char *s))
Definition: recctrl.c:216
RecTypes recTypes_init(RecTypeClass rtc, data1_handle dh)
Definition: recctrl.c:234
RecType recType_byName(RecTypes rts, Res res, const char *name, void **clientDataP)
Definition: recctrl.c:264
void recTypes_default_handlers(RecTypes recTypes, Res res)
const char * term_buf
Definition: recctrl.h:56
zint record_id
Definition: recctrl.h:64
const char * index_type
Definition: recctrl.h:52
struct recExtractCtrl * extractCtrl
Definition: recctrl.h:67
zint seqno
Definition: recctrl.h:60
int term_len
Definition: recctrl.h:58
zint section_id
Definition: recctrl.h:66
zint segment
Definition: recctrl.h:62
const char * index_name
Definition: recctrl.h:54
record reader stream
Definition: recctrl.h:71
void(* destroy)(struct ZebraRecStream *s)
close and destroy stream
Definition: recctrl.h:83
off_t(* seekf)(struct ZebraRecStream *s, off_t offset)
seek function
Definition: recctrl.h:77
off_t(* endf)(struct ZebraRecStream *s, off_t *offset)
set and get of record position
Definition: recctrl.h:81
int(* readf)(struct ZebraRecStream *s, char *buf, size_t count)
read function
Definition: recctrl.h:75
void * fh
Definition: recctrl.h:73
off_t(* tellf)(struct ZebraRecStream *s)
tell function
Definition: recctrl.h:79
record extract for indexing
Definition: recctrl.h:101
void * clientData
Definition: recctrl.h:104
int flagShowRecords
Definition: recctrl.h:108
void(* init)(struct recExtractCtrl *p, RecWord *w)
Definition: recctrl.h:103
enum zebra_recctrl_action_t action
Definition: recctrl.h:114
char match_criteria[256]
Definition: recctrl.h:109
void(* tokenAdd)(RecWord *w)
Definition: recctrl.h:105
zint staticrank
Definition: recctrl.h:110
void * handle
Definition: recctrl.h:113
void(* setStoreData)(struct recExtractCtrl *p, void *buf, size_t size)
Definition: recctrl.h:106
int first_record
Definition: recctrl.h:107
void(* schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid)
Definition: recctrl.h:111
data1_handle dh
Definition: recctrl.h:112
struct ZebraRecStream * stream
Definition: recctrl.h:102
const Odr_oid * input_format
Definition: recctrl.h:123
data1_handle dh
Definition: recctrl.h:131
int(* special_fetch)(void *handle, const char *esn, const Odr_oid *input_format, const Odr_oid **output_format, WRBUF result, WRBUF addinfo)
Definition: recctrl.h:142
char * addinfo
Definition: recctrl.h:138
Z_RecordComposition * comp
Definition: recctrl.h:124
struct ZebraRecStream * stream
Definition: recctrl.h:119
const Odr_oid * output_format
Definition: recctrl.h:134
void * handle
Definition: recctrl.h:141
zint staticrank
Definition: recctrl.h:128
char * encoding
Definition: recctrl.h:125
char * fname
Definition: recctrl.h:130
void * rec_buf
Definition: recctrl.h:135
int(* retrieve)(void *clientData, struct recRetrieveCtrl *ctrl)
Definition: recctrl.h:159
void(* destroy)(void *clientData)
Definition: recctrl.h:156
int(* extract)(void *clientData, struct recExtractCtrl *ctrl)
Definition: recctrl.h:157
int version
Definition: recctrl.h:152
char * name
Definition: recctrl.h:153
ZEBRA_RES(* config)(void *clientData, Res res, const char *args)
Definition: recctrl.h:155
data1_handle dh
Definition: recctrl.c:50
Definition: res.c:46
long zint
Zebra integer.
Definition: util.h:66
short ZEBRA_RES
Common return type for Zebra API.
Definition: util.h:80