1 /* $Id: recctrl.h,v 1.11 2005-06-07 11:36:38 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>
37 /* single word entity */
49 struct recExtractCtrl *extractCtrl;
52 /* Extract record control */
53 struct recExtractCtrl {
54 void *fh; /* File handle and read function */
55 int (*readf)(void *fh, char *buf, size_t count);
56 off_t (*seekf)(void *fh, off_t offset); /* seek function */
57 off_t (*tellf)(void *fh); /* tell function */
58 void (*endf)(void *fh, off_t offset); /* end of record position */
59 off_t offset; /* start offset */
60 void (*init)(struct recExtractCtrl *p, RecWord *w);
62 void (*tokenAdd)(RecWord *w);
63 void (*setStoreData)(struct recExtractCtrl *p, void *buf, size_t size);
68 char match_criteria[256];
69 void (*schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid);
74 /* Retrieve record control */
75 struct recRetrieveCtrl {
76 /* Input parameters ... */
77 Res res; /* Resource pool */
78 ODR odr; /* ODR used to create response */
79 void *fh; /* File descriptor and read function */
80 int (*readf)(void *fh, char *buf, size_t count);
81 off_t (*seekf)(void *fh, off_t offset);
82 off_t (*tellf)(void *fh);
83 oid_value input_format; /* Preferred record syntax */
84 Z_RecordComposition *comp; /* formatting instructions */
85 char *encoding; /* preferred character encoding */
86 zint localno; /* local id of record */
87 int score; /* score 0-1000 or -1 if none */
88 int recordSize; /* size of record in bytes */
89 char *fname; /* name of file (or NULL if internal) */
91 zebra_snippets *hit_snippet;
92 zebra_snippets *doc_snippet;
95 oid_value output_format;
102 typedef struct recType *RecType;
107 char *name; /* Name of record type */
108 void *(*init)(Res res, RecType recType); /* Init function - called once */
109 void (*config)(void *clientData, Res res, const char *args); /* Config */
110 void (*destroy)(void *clientData); /* Destroy function */
111 int (*extract)(void *clientData,
112 struct recExtractCtrl *ctrl); /* Extract proc */
113 int (*retrieve)(void *clientData,
114 struct recRetrieveCtrl *ctrl); /* Retrieve proc */
117 #define RECCTRL_EXTRACT_OK 0
118 #define RECCTRL_EXTRACT_EOF 1
119 #define RECCTRL_EXTRACT_ERROR_GENERIC 2
120 #define RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER 3
122 typedef struct recTypeClass *RecTypeClass;
123 typedef struct recTypes *RecTypes;
126 RecTypeClass recTypeClass_create (Res res, NMEM nmem);
129 void recTypeClass_destroy(RecTypeClass rtc);
132 void recTypeClass_info(RecTypeClass rtc, void *cd,
133 void (*cb)(void *cd, const char *s));
136 RecTypes recTypes_init(RecTypeClass rtc, data1_handle dh);
139 void recTypes_destroy(RecTypes recTypes);
142 void recTypes_default_handlers(RecTypes recTypes, Res res);
145 RecType recType_byName(RecTypes rts, Res res, const char *name,