1 /* $Id: recctrl.h,v 1.32 2007-03-14 11:48:31 adam Exp $
2 Copyright (C) 1995-2007
5 This file is part of the Zebra server.
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
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
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
23 #ifndef IDZEBRA_RECCTRL_H
24 #define IDZEBRA_RECCTRL_H
26 #include <sys/types.h>
27 #include <yaz/proto.h>
30 #include <idzebra/res.h>
31 #include <idzebra/data1.h>
32 #include <idzebra/snippet.h>
37 #define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN"
40 #define ZEBRA_XPATH_ELM_END "_XPATH_END"
43 #define ZEBRA_XPATH_CDATA "_XPATH_CDATA"
46 #define ZEBRA_XPATH_ATTR_NAME "_XPATH_ATTR_NAME"
49 #define ZEBRA_XPATH_ATTR_CDATA "_XPATH_ATTR_CDATA"
53 /** index type ('w', 'p', .. */
55 /** index name, e.g. "title" */
56 const char *index_name;
57 /** token char data */
59 /** length of term_buf */
61 /** sequence number */
69 struct recExtractCtrl *extractCtrl;
72 /** \brief record reader stream */
73 struct ZebraRecStream {
76 /** \brief read function */
77 int (*readf)(struct ZebraRecStream *s, char *buf, size_t count);
78 /** \brief seek function */
79 off_t (*seekf)(struct ZebraRecStream *s, off_t offset);
80 /** \brief tell function */
81 off_t (*tellf)(struct ZebraRecStream *s);
82 /** \brief set and get of record position */
83 off_t (*endf)(struct ZebraRecStream *s, off_t *offset);
84 /** \brief close and destroy stream */
85 void (*destroy)(struct ZebraRecStream *s);
88 enum zebra_recctrl_action_t {
92 action_update /* insert or replace as needed */
95 /** \brief record extract for indexing */
96 struct recExtractCtrl {
97 struct ZebraRecStream *stream;
98 void (*init)(struct recExtractCtrl *p, RecWord *w);
100 void (*tokenAdd)(RecWord *w);
101 void (*setStoreData)(struct recExtractCtrl *p, void *buf, size_t size);
105 char match_criteria[256];
107 void (*schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid);
112 /* Retrieve record control */
113 struct recRetrieveCtrl {
114 struct ZebraRecStream *stream;
115 /* Input parameters ... */
116 Res res; /* Resource pool */
117 ODR odr; /* ODR used to create response */
118 oid_value input_format; /* Preferred record syntax */
119 Z_RecordComposition *comp; /* formatting instructions */
120 char *encoding; /* preferred character encoding */
121 zint localno; /* local id of record */
122 int score; /* score 0-1000 or -1 if none */
123 zint staticrank; /* static rank >= 0, 0 if none */
124 int recordSize; /* size of record in bytes */
125 char *fname; /* name of file (or NULL if internal) */
127 zebra_snippets *hit_snippet;
128 zebra_snippets *doc_snippet;
131 oid_value output_format;
138 typedef struct recType *RecType;
143 char *name; /* Name of record type */
144 void *(*init)(Res res, RecType recType); /* Init function - called once */
145 ZEBRA_RES (*config)(void *clientData, Res res, const char *args); /* Config */
146 void (*destroy)(void *clientData); /* Destroy function */
147 int (*extract)(void *clientData,
148 struct recExtractCtrl *ctrl); /* Extract proc */
149 int (*retrieve)(void *clientData,
150 struct recRetrieveCtrl *ctrl); /* Retrieve proc */
153 #define RECCTRL_EXTRACT_OK 0
154 #define RECCTRL_EXTRACT_EOF 1
155 #define RECCTRL_EXTRACT_ERROR_GENERIC 2
156 #define RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER 3
157 #define RECCTRL_EXTRACT_SKIP 4
159 typedef struct recTypeClass *RecTypeClass;
160 typedef struct recTypes *RecTypes;
163 RecTypeClass recTypeClass_create (Res res, NMEM nmem);
166 void recTypeClass_load_modules(RecTypeClass *rts, NMEM nmem,
167 const char *module_path);
170 RecTypeClass recTypeClass_add_modules(Res res, NMEM nmem,
171 const char *module_path);
174 void recTypeClass_destroy(RecTypeClass rtc);
177 void recTypeClass_info(RecTypeClass rtc, void *cd,
178 void (*cb)(void *cd, const char *s));
181 RecTypes recTypes_init(RecTypeClass rtc, data1_handle dh);
184 void recTypes_destroy(RecTypes recTypes);
187 void recTypes_default_handlers(RecTypes recTypes, Res res);
190 RecType recType_byName(RecTypes rts, Res res, const char *name,
199 * indent-tabs-mode: nil
201 * vim: shiftwidth=4 tabstop=8 expandtab