1 /* $Id: recctrl.h,v 1.40.2.2 2006-08-14 10:38:56 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
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
26 #include <sys/types.h>
27 #include <yaz/proto.h>
37 /* single word entity */
46 struct recExtractCtrl *extractCtrl;
49 /* Extract record control */
50 struct recExtractCtrl {
51 void *fh; /* File handle and read function */
52 int (*readf)(void *fh, char *buf, size_t count);
53 off_t (*seekf)(void *fh, off_t offset); /* seek function */
54 off_t (*tellf)(void *fh); /* tell function */
55 void (*endf)(void *fh, off_t offset); /* end of record position */
56 off_t offset; /* start offset */
58 void (*init)(struct recExtractCtrl *p, RecWord *w);
60 void (*tokenAdd)(RecWord *w);
64 void (*schemaAdd)(struct recExtractCtrl *p, Odr_oid *oid);
69 /* Retrieve record control */
70 struct recRetrieveCtrl {
71 /* Input parameters ... */
72 Res res; /* Resource pool */
73 ODR odr; /* ODR used to create response */
74 void *fh; /* File descriptor and read function */
75 int (*readf)(void *fh, char *buf, size_t count);
76 off_t (*seekf)(void *fh, off_t offset);
77 off_t (*tellf)(void *fh);
78 oid_value input_format; /* Preferred record syntax */
79 Z_RecordComposition *comp; /* formatting instructions */
80 char *encoding; /* preferred character encoding */
81 int localno; /* local id of record */
82 int score; /* score 0-1000 or -1 if none */
83 int recordSize; /* size of record in bytes */
84 char *fname; /* name of file (or NULL if internal) */
89 oid_value output_format;
96 typedef struct recType *RecType;
100 char *name; /* Name of record type */
101 void *(*init)(RecType recType); /* Init function - called once */
102 void (*destroy)(void *clientData); /* Destroy function */
103 int (*extract)(void *clientData,
104 struct recExtractCtrl *ctrl); /* Extract proc */
105 int (*retrieve)(void *clientData,
106 struct recRetrieveCtrl *ctrl); /* Retrieve proc */
109 #define RECCTRL_EXTRACT_OK 0
110 #define RECCTRL_EXTRACT_EOF 1
111 #define RECCTRL_EXTRACT_ERROR_GENERIC 2
112 #define RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER 3
114 typedef struct recTypes *RecTypes;
116 RecTypes recTypes_init (data1_handle dh);
117 void recTypes_destroy (RecTypes recTypes);
118 void recTypes_default_handlers (RecTypes recTypes);
120 RecType recType_byName (RecTypes rts, const char *name, char *subType,
123 int grs_extract_tree(struct recExtractCtrl *p, data1_node *n);