1 /* $Id: recctrl.h,v 1.14 2005-08-22 08:19:51 adam Exp $
2 Copyright (C) 1995-2005
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 Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
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>
33 #include <idzebra/zebramap.h>
38 #define ZEBRA_XPATH_ELM_BEGIN "_XPATH_BEGIN"
39 #define ZEBRA_XPATH_ELM_END "_XPATH_END"
40 #define ZEBRA_XPATH_CDATA "_XPATH_CDATA"
41 #define ZEBRA_XPATH_ATTR "_XPATH_ATTR"
44 /* single word entity */
52 const char *index_name;
59 struct recExtractCtrl *extractCtrl;
62 /* Extract record control */
63 struct recExtractCtrl {
64 void *fh; /* File handle and read function */
65 int (*readf)(void *fh, char *buf, size_t count);
66 off_t (*seekf)(void *fh, off_t offset); /* seek function */
67 off_t (*tellf)(void *fh); /* tell function */
68 void (*endf)(void *fh, off_t offset); /* end of record position */
69 off_t offset; /* start offset */
70 void (*init)(struct recExtractCtrl *p, RecWord *w);
72 void (*tokenAdd)(RecWord *w);
73 void (*setStoreData)(struct recExtractCtrl *p, void *buf, size_t size);
78 char match_criteria[256];
80 void (*schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid);
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 int recordSize; /* size of record in bytes */
100 char *fname; /* name of file (or NULL if internal) */
102 zebra_snippets *hit_snippet;
103 zebra_snippets *doc_snippet;
106 oid_value output_format;
113 typedef struct recType *RecType;
118 char *name; /* Name of record type */
119 void *(*init)(Res res, RecType recType); /* Init function - called once */
120 void (*config)(void *clientData, Res res, const char *args); /* Config */
121 void (*destroy)(void *clientData); /* Destroy function */
122 int (*extract)(void *clientData,
123 struct recExtractCtrl *ctrl); /* Extract proc */
124 int (*retrieve)(void *clientData,
125 struct recRetrieveCtrl *ctrl); /* Retrieve proc */
128 #define RECCTRL_EXTRACT_OK 0
129 #define RECCTRL_EXTRACT_EOF 1
130 #define RECCTRL_EXTRACT_ERROR_GENERIC 2
131 #define RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER 3
133 typedef struct recTypeClass *RecTypeClass;
134 typedef struct recTypes *RecTypes;
137 RecTypeClass recTypeClass_create (Res res, NMEM nmem);
140 void recTypeClass_destroy(RecTypeClass rtc);
143 void recTypeClass_info(RecTypeClass rtc, void *cd,
144 void (*cb)(void *cd, const char *s));
147 RecTypes recTypes_init(RecTypeClass rtc, data1_handle dh);
150 void recTypes_destroy(RecTypes recTypes);
153 void recTypes_default_handlers(RecTypes recTypes, Res res);
156 RecType recType_byName(RecTypes rts, Res res, const char *name,