Added Diagnostic Format
[yaz-moved-to-github.git] / include / prt-dia.h
1 /*
2  * Copyright (c) 1995, Index Data.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation, in whole or in part, for any purpose, is hereby granted,
6  * provided that:
7  *
8  * 1. This copyright and permission notice appear in all copies of the
9  * software and its documentation. Notices of copyright or attribution
10  * which appear at the beginning of any file must remain unchanged.
11  *
12  * 2. The names of Index Data or the individual authors may not be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  * IN NO EVENT SHALL INDEX DATA BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
20  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
22  * NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  *
26  */
27
28 typedef struct Z_TooMany
29 {
30     int *tooManyWhat;
31 #define Z_TooMany_argumentWords        1
32 #define Z_TooMany_truncatedWords       2
33 #define Z_TooMany_booleanOperators     3
34 #define Z_TooMany_incompleteSubfields  4
35 #define Z_TooMany_characters           5
36 #define Z_TooMany_recordsRetrieved     6
37 #define Z_TooMany_databasesSpecified   7
38 #define Z_TooMany_resultSetsCreated    8
39 #define Z_TooMany_indexTermsProcessed  9
40     int *max;                    /* OPTIONAL */
41 } Z_TooMany;
42
43 typedef struct Z_BadSpec
44 {
45     Z_Specification *spec;
46     char *db;                    /* OPTIONAL */
47     int num_goodOnes;
48     Z_Specification **goodOnes;  /* OPTIONAL */
49 } Z_BadSpec;
50
51 typedef struct Z_DbUnavailWhy
52 {
53     int *reasonCode;             /* OPTIONAL */
54 #define Z_DbUnavail_doesNotExist         0
55 #define Z_DbUnavail_existsButUnavail     1
56 #define Z_DbUnavail_locked               2
57 #define Z_DbUnavail_accessDenied         3
58     char *message;               /* OPTIONAL */
59 } Z_DbUnavailWhy;
60
61 typedef struct Z_DbUnavail
62 {
63     char *db;
64     Z_DbUnavailWhy *why;         /* OPTIONAL */
65 } Z_DbUnavail;
66
67 typedef struct Z_Attribute
68 {
69     Odr_oid *id;
70     int *type;                   /* OPTIONAL */
71     int *value;                  /* OPTIONAL */
72     Z_Term *term;                /* OPTIONAL */
73 } Z_Attribute;
74
75 typedef struct Z_AttCombo
76 {
77     Z_AttributeList *unsupportedCombination;
78     int num_alternatives;
79     Z_AttributeList **alternatives;    /* OPTIONAL */
80 } Z_AttCombo;
81
82 typedef struct Z_DiagTerm 
83 {
84     int *problem;                /* OPTIONAL */
85 #define Z_DiagtermProb_codedValue     1
86 #define Z_DiagtermProb_unparsable     2
87 #define Z_DiagtermProb_tooShort       3
88 #define Z_DiagtermProb_type           4
89     Z_Term *term;
90 } Z_DiagTerm;
91
92 typedef struct Z_Proximity
93 {
94     enum
95     {
96         Z_Proximity_resultSets,
97         Z_Proximity_badSet,
98         Z_Proximity_relation,
99         Z_Proximity_unit,
100         Z_Proximity_distance,
101         Z_Proximity_attributes,
102         Z_Proximity_ordered,
103         Z_Proximity_exclusion
104     } which;
105     union
106     {
107         Odr_null *resultSets;
108         char *badSet;
109         int *relation;
110         int *unit;
111         int *distance;
112         Z_AttributeList *attributes;
113         Odr_null *ordered;
114         Odr_null *exclusion;
115     } u;
116 } Z_Proximity;
117
118 typedef struct Z_AttrListList
119 {
120     int num_lists;
121     Z_AttributeList *lists;
122 } Z_AttrListList;
123
124 typedef struct Z_Scan
125 {
126     enum
127     {
128         Z_ScanD_nonZeroStepSize,
129         Z_ScanD_specifiedStepSize,
130         Z_ScanD_termList1,
131         Z_ScanD_termList2,
132         Z_ScanD_posInResponse,
133         Z_ScanD_resources,
134         Z_ScanD_endOfList
135     } which;
136     union
137     {
138         Odr_null *nonZeroStepSize;
139         Odr_null *specifiedStepSize;
140         Odr_null *termList1;
141         Z_AttrListList *termList2;
142         int *posInResponse;
143 #define Z_ScanPosInRsp_mustBeOne         1
144 #define Z_ScanPosInRsp_mustBePositive    2
145 #define Z_ScanPosInRsp_mustBeNonNegative 3
146 #define Z_ScanPosInRsp_other             4
147         Odr_null *resources;
148         Odr_null *endOfList;
149     } u;
150 } Z_Scan;
151
152 typedef struct Z_StringList
153 {
154     int num_strings;
155     char **strings;
156 } Z_StringList;
157
158 typedef struct Z_Sort
159 {
160     enum
161     {
162         Z_SortD_sequence,
163         Z_SortD_noRsName,
164         Z_SortD_tooMany,
165         Z_SortD_incompatible,
166         Z_SortD_generic,
167         Z_SortD_dbSpecific,
168         Z_SortD_sortElement,
169         Z_SortD_key,
170         Z_SortD_action,
171         Z_SortD_illegal,
172         Z_SortD_inputTooLarge,
173         Z_SortD_aggregateTooLarge
174     } which;
175     union
176     {
177         Odr_null *sequence;
178         Odr_null *noRsName;
179         int *tooMany;
180         Odr_null *incompatible;
181         Odr_null *generic;
182         Odr_null *dbSpecific;
183 #if 0
184         Z_SortElement *sortElement;
185 #endif
186         int *key;
187 #define Z_SortKey_tooMany       1
188 #define Z_SortKey_duplicate     2
189         Odr_null *action;
190         int *illegal;
191 #define Z_SortIllegal_relation  1
192 #define Z_SortIllegal_case      2
193 #define Z_SortIllegal_action    3
194 #define Z_SortIllegal_sort      4
195         Z_StringList *inputTooLarge;
196         Odr_null *aggregateTooLarge;
197     } u;
198 } Z_Sort;
199
200 typedef struct Z_Segmentation
201 {
202     enum
203     {
204         Z_SegmentationD_segments
205     } which;
206     union
207     {
208         Odr_null *segments;
209     } u;
210 } Z_Segmentation;
211
212 typedef struct Z_ExtServices
213 {
214     enum
215     {
216         Z_ExtServicesD_req,
217         Z_ExtServicesD_permission,
218         Z_ExtServicesD_immediate
219     } which;
220     union
221     {
222         int *req;
223 #define Z_ExtSrvReq_nameInUse           1
224 #define Z_ExtSrvReq_noSuchname          2
225 #define Z_ExtSrvReq_quota               3
226 #define Z_ExtSrvReq_type                4
227         int *permission;
228 #define Z_ExtSrvPerm_id                 1
229 #define Z_ExtSrvPerm_modifyDelete       2
230         int *immediate;
231 #define Z_ExtSrvImm_failed              1
232 #define Z_ExtSrvImm_service             2
233 #define Z_ExtSrvImm_parameters          3
234     } u;
235 } Z_ExtServices;
236
237 typedef struct Z_OidList
238 {
239     int num_oids;
240     Odr_oid **oids;
241 } Z_OidList;
242
243 typedef struct Z_AccessCtrl
244 {
245     enum
246     {
247         Z_AccessCtrlD_noUser,
248         Z_AccessCtrlD_refused,
249         Z_AccessCtrlD_simple,
250         Z_AccessCtrlD_oid,
251         Z_AccessCtrlD_alternative,
252         Z_AccessCtrlD_pwdInv,
253         Z_AccessCtrlD_pwdExp
254     } which;
255     union
256     {
257         Odr_null *noUser;
258         Odr_null *refused;
259         Odr_null *simple;
260         Z_OidList *oid;
261         Z_OidList *alternative;
262         Odr_null *pwdInv;
263         Odr_null *pwdExp;
264     } u;
265 } Z_AccessCtrl;
266
267 typedef struct Z_RecordSyntax
268 {
269     Odr_oid *unsupportedSyntax;
270     int num_suggestedAlternatives;           /* OPTIONAL */
271     Odr_oid **suggestedAlternatives;           /* OPTIONAL */
272 } Z_RecordSyntax;
273
274 typedef struct Z_DiagFormat
275 {
276     enum
277     {
278         Z_DiagFormat_tooMany,
279         Z_DiagFormat_badSpec,
280         Z_DiagFormat_dbUnavail,
281         Z_DiagFormat_unSupOp,
282         Z_DiagFormat_attribute,
283         Z_DiagFormat_attCombo,
284         Z_DiagFormat_term,
285         Z_DiagFormat_proximity,
286         Z_DiagFormat_scan,
287         Z_DiagFormat_sort,
288         Z_DiagFormat_segmentation,
289         Z_DiagFormat_extServices,
290         Z_DiagFormat_accessCtrl,
291         Z_DiagFormat_recordSyntax
292     } which;
293     union
294     {
295         Z_TooMany *tooMany;
296         Z_BadSpec *badSpec;
297         Z_DbUnavail *dbUnavail;
298         int *unSupOp;
299 #define Z_UnSupOp_and             0
300 #define Z_UnSupOp_or              1
301 #define Z_UnSupOp_and_not         2
302 #define Z_UnSupOp_prox            3
303         Z_Attribute *attribute;
304         Z_AttributeList *attCombo;
305         Z_DiagTerm *term;
306         Z_Proximity *proximity;
307         Z_Scan *scan;
308         Z_Sort *sort;
309         Z_Segmentation *segmentation;
310         Z_ExtServices *extServices;
311         Z_AccessCtrl *accessCtrl;
312         Z_RecordSyntax *recordSyntax;
313     } u;
314 } Z_DiagFormat;
315
316 typedef struct Z_Diagnostic
317 {
318     enum
319     {
320         Z_Diagnostic_defaultDiagRec,
321         Z_Diagnostic_explicitDiagnostic
322     } which;
323     union 
324     {
325         Z_DefaultDiagFormat *defaultDiagRec;
326         Z_DiagFormat *explicitDiagnostic;
327     } u;
328 } Z_Diagnostic;
329
330 typedef struct Z_DiagnosticUnit
331 {
332     Z_Diagnostic *diagnostic;                    /* OPTIONAL */
333     char *message;                               /* OPTIONAL */
334 } Z_DiagnosticUnit;
335
336 typedef struct Z_DiagnosticFormat
337 {
338     int num_diagnostics;
339     Z_DiagnosticUnit **diagnostics;
340 } Z_DiagnosticFormat;
341
342 int z_DiagnosticFormat(ODR o, Z_DiagnosticFormat **p, int opt);