1 /* $Id: recctrl.h,v 1.39 2007-11-30 12:19:08 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>
29 #include <idzebra/res.h>
30 #include <idzebra/data1.h>
31 #include <idzebra/snippet.h>
36 #define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN"
39 #define ZEBRA_XPATH_ELM_END "_XPATH_END"
42 #define ZEBRA_XPATH_CDATA "_XPATH_CDATA"
45 #define ZEBRA_XPATH_ATTR_NAME "_XPATH_ATTR_NAME"
48 #define ZEBRA_XPATH_ATTR_CDATA "_XPATH_ATTR_CDATA"
52 /** index type, e.g. "w", "p", .. */
53 const char *index_type;
54 /** index name, e.g. "title" */
55 const char *index_name;
56 /** token char data */
58 /** length of term_buf */
60 /** sequence number */
68 struct recExtractCtrl *extractCtrl;
71 /** \brief record reader stream */
72 struct ZebraRecStream {
75 /** \brief read function */
76 int (*readf)(struct ZebraRecStream *s, char *buf, size_t count);
77 /** \brief seek function */
78 off_t (*seekf)(struct ZebraRecStream *s, off_t offset);
79 /** \brief tell function */
80 off_t (*tellf)(struct ZebraRecStream *s);
81 /** \brief set and get of record position */
82 off_t (*endf)(struct ZebraRecStream *s, off_t *offset);
83 /** \brief close and destroy stream */
84 void (*destroy)(struct ZebraRecStream *s);
87 enum zebra_recctrl_action_t {
91 action_update /* insert or replace as needed */
94 /** \brief record extract for indexing */
95 struct recExtractCtrl {
96 struct ZebraRecStream *stream;
97 void (*init)(struct recExtractCtrl *p, RecWord *w);
99 void (*tokenAdd)(RecWord *w);
100 void (*setStoreData)(struct recExtractCtrl *p, void *buf, size_t size);
103 char match_criteria[256];
105 void (*schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid);
108 enum zebra_recctrl_action_t action;
111 /* Retrieve record control */
112 struct recRetrieveCtrl {
113 struct ZebraRecStream *stream;
114 /* Input parameters ... */
115 Res res; /* Resource pool */
116 ODR odr; /* ODR used to create response */
117 const Odr_oid * input_format; /* Preferred record syntax OID */
118 Z_RecordComposition *comp; /* formatting instructions */
119 char *encoding; /* preferred character encoding */
120 zint localno; /* local id of record */
121 int score; /* score 0-1000 or -1 if none */
122 zint staticrank; /* static rank >= 0, 0 if none */
123 int recordSize; /* size of record in bytes */
124 char *fname; /* name of file (or NULL if internal) */
128 const Odr_oid * output_format; /* output format OID */
135 typedef struct recType *RecType;
140 char *name; /* Name of record type */
141 void *(*init)(Res res, RecType recType); /* Init function - called once */
142 ZEBRA_RES (*config)(void *clientData, Res res, const char *args); /* Config */
143 void (*destroy)(void *clientData); /* Destroy function */
144 int (*extract)(void *clientData,
145 struct recExtractCtrl *ctrl); /* Extract proc */
146 int (*retrieve)(void *clientData,
147 struct recRetrieveCtrl *ctrl); /* Retrieve proc */
150 #define RECCTRL_EXTRACT_OK 0
151 #define RECCTRL_EXTRACT_EOF 1
152 #define RECCTRL_EXTRACT_ERROR_GENERIC 2
153 #define RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER 3
154 #define RECCTRL_EXTRACT_SKIP 4
156 typedef struct recTypeClass *RecTypeClass;
157 typedef struct recTypes *RecTypes;
160 RecTypeClass recTypeClass_create (Res res, NMEM nmem);
163 void recTypeClass_load_modules(RecTypeClass *rts, NMEM nmem,
164 const char *module_path);
167 RecTypeClass recTypeClass_add_modules(Res res, NMEM nmem,
168 const char *module_path);
171 void recTypeClass_destroy(RecTypeClass rtc);
174 void recTypeClass_info(RecTypeClass rtc, void *cd,
175 void (*cb)(void *cd, const char *s));
178 RecTypes recTypes_init(RecTypeClass rtc, data1_handle dh);
181 void recTypes_destroy(RecTypes recTypes);
184 void recTypes_default_handlers(RecTypes recTypes, Res res);
187 RecType recType_byName(RecTypes rts, Res res, const char *name,
196 * indent-tabs-mode: nil
198 * vim: shiftwidth=4 tabstop=8 expandtab