YAZ  5.23.1
z-diag1.c
Go to the documentation of this file.
1 
6 #if HAVE_CONFIG_H
7 #include <config.h>
8 #endif
9 
10 #include <yaz/z-diag1.h>
11 
12 int z_DiagnosticFormat_s(ODR o, Z_DiagnosticFormat_s **p, int opt, const char *name)
13 {
14  static Odr_arm arm[] = {
16  (Odr_fun) z_DefaultDiagFormat, "defaultDiagRec"},
18  (Odr_fun) z_DiagFormat, "explicitDiagnostic"},
19  {-1, -1, -1, -1, (Odr_fun) 0, 0}
20  };
21  if (!odr_sequence_begin(o, p, sizeof(**p), name))
22  return odr_missing(o, opt, name) && odr_ok (o);
23  return
24  ((odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1, "diagnostic") &&
25  odr_choice(o, arm, &(*p)->u, &(*p)->which, 0) &&
26  odr_constructed_end(o)) || odr_ok(o)) &&
28  &(*p)->message, ODR_CONTEXT, 2, 1, "message") &&
30 }
31 
32 int z_DiagnosticFormat(ODR o, Z_DiagnosticFormat **p, int opt, const char *name)
33 {
34  if (!odr_initmember(o, p, sizeof(**p)))
35  return odr_missing(o, opt, name);
36  if (odr_sequence_of(o, (Odr_fun) z_DiagnosticFormat_s, &(*p)->elements,
37  &(*p)->num, name))
38  return 1;
39  if (o->direction == ODR_DECODE)
40  *p = 0;
41  return odr_missing(o, opt, name);
42 }
43 
44 int z_TooMany(ODR o, Z_TooMany **p, int opt, const char *name)
45 {
46  if (!odr_sequence_begin(o, p, sizeof(**p), name))
47  return odr_missing(o, opt, name) && odr_ok (o);
48  return
50  &(*p)->tooManyWhat, ODR_CONTEXT, 1, 0, "tooManyWhat") &&
52  &(*p)->max, ODR_CONTEXT, 2, 1, "max") &&
54 }
55 
56 int z_BadSpec(ODR o, Z_BadSpec **p, int opt, const char *name)
57 {
58  if (!odr_sequence_begin(o, p, sizeof(**p), name))
59  return odr_missing(o, opt, name) && odr_ok (o);
60  return
62  &(*p)->spec, ODR_CONTEXT, 1, 0, "spec") &&
64  &(*p)->db, ODR_CONTEXT, 2, 1, "db") &&
66  (odr_sequence_of(o, (Odr_fun) z_Specification, &(*p)->goodOnes,
67  &(*p)->num_goodOnes, "goodOnes") || odr_ok(o)) &&
69 }
70 
71 int z_DbUnavail_0(ODR o, Z_DbUnavail_0 **p, int opt, const char *name)
72 {
73  if (!odr_sequence_begin(o, p, sizeof(**p), name))
74  return odr_missing(o, opt, name) && odr_ok (o);
75  return
77  &(*p)->reasonCode, ODR_CONTEXT, 1, 1, "reasonCode") &&
79  &(*p)->message, ODR_CONTEXT, 2, 1, "message") &&
81 }
82 
83 int z_DbUnavail(ODR o, Z_DbUnavail **p, int opt, const char *name)
84 {
85  if (!odr_sequence_begin(o, p, sizeof(**p), name))
86  return odr_missing(o, opt, name) && odr_ok (o);
87  return
89  &(*p)->db, ODR_CONTEXT, 1, 0, "db") &&
91  &(*p)->why, ODR_CONTEXT, 2, 0, "why") &&
93 }
94 
95 int z_Attribute(ODR o, Z_Attribute **p, int opt, const char *name)
96 {
97  if (!odr_sequence_begin(o, p, sizeof(**p), name))
98  return odr_missing(o, opt, name) && odr_ok (o);
99  return
101  &(*p)->id, ODR_CONTEXT, 1, 0, "id") &&
103  &(*p)->type, ODR_CONTEXT, 2, 1, "type") &&
105  &(*p)->value, ODR_CONTEXT, 3, 1, "value") &&
107  &(*p)->term, ODR_CONTEXT, 4, 1, "term") &&
108  odr_sequence_end(o);
109 }
110 
111 int z_AttCombo(ODR o, Z_AttCombo **p, int opt, const char *name)
112 {
113  if (!odr_sequence_begin(o, p, sizeof(**p), name))
114  return odr_missing(o, opt, name) && odr_ok (o);
115  return
117  &(*p)->unsupportedCombination, ODR_CONTEXT, 1, 0, "unsupportedCombination") &&
119  (odr_sequence_of(o, (Odr_fun) z_AttributeList, &(*p)->recommendedAlternatives,
120  &(*p)->num_recommendedAlternatives, "recommendedAlternatives") || odr_ok(o)) &&
121  odr_sequence_end(o);
122 }
123 
124 int z_DiagTerm(ODR o, Z_DiagTerm **p, int opt, const char *name)
125 {
126  if (!odr_sequence_begin(o, p, sizeof(**p), name))
127  return odr_missing(o, opt, name) && odr_ok (o);
128  return
130  &(*p)->problem, ODR_CONTEXT, 1, 1, "problem") &&
132  &(*p)->term, ODR_CONTEXT, 2, 0, "term") &&
133  odr_sequence_end(o);
134 }
135 
136 int z_Proximity(ODR o, Z_Proximity **p, int opt, const char *name)
137 {
138  static Odr_arm arm[] = {
140  (Odr_fun) odr_null, "resultSets"},
142  (Odr_fun) z_InternationalString, "badSet"},
144  (Odr_fun) odr_integer, "relation"},
146  (Odr_fun) odr_integer, "unit"},
148  (Odr_fun) odr_integer, "distance"},
150  (Odr_fun) z_AttributeList, "attributes"},
152  (Odr_fun) odr_null, "ordered"},
154  (Odr_fun) odr_null, "exclusion"},
155  {-1, -1, -1, -1, (Odr_fun) 0, 0}
156  };
157  if (!odr_initmember(o, p, sizeof(**p)))
158  return odr_missing(o, opt, name);
159  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
160  return 1;
161  if (o->direction == ODR_DECODE)
162  *p = 0;
163  return odr_missing(o, opt, name);
164 }
165 
166 int z_AttrListList(ODR o, Z_AttrListList **p, int opt, const char *name)
167 {
168  if (!odr_initmember(o, p, sizeof(**p)))
169  return odr_missing(o, opt, name);
170  if (odr_sequence_of(o, (Odr_fun) z_AttributeList, &(*p)->elements,
171  &(*p)->num, name))
172  return 1;
173  if (o->direction == ODR_DECODE)
174  *p = 0;
175  return odr_missing(o, opt, name);
176 }
177 
178 int z_Scan(ODR o, Z_Scan **p, int opt, const char *name)
179 {
180  static Odr_arm arm[] = {
182  (Odr_fun) odr_null, "nonZeroStepSize"},
184  (Odr_fun) odr_null, "specifiedStepSize"},
186  (Odr_fun) odr_null, "termList1"},
188  (Odr_fun) z_AttrListList, "termList2"},
190  (Odr_fun) odr_integer, "posInResponse"},
192  (Odr_fun) odr_null, "resources"},
194  (Odr_fun) odr_null, "endOfList"},
195  {-1, -1, -1, -1, (Odr_fun) 0, 0}
196  };
197  if (!odr_initmember(o, p, sizeof(**p)))
198  return odr_missing(o, opt, name);
199  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
200  return 1;
201  if (o->direction == ODR_DECODE)
202  *p = 0;
203  return odr_missing(o, opt, name);
204 }
205 
206 int z_StringList(ODR o, Z_StringList **p, int opt, const char *name)
207 {
208  if (!odr_initmember(o, p, sizeof(**p)))
209  return odr_missing(o, opt, name);
210  if (odr_sequence_of(o, (Odr_fun) z_InternationalString, &(*p)->elements,
211  &(*p)->num, name))
212  return 1;
213  if (o->direction == ODR_DECODE)
214  *p = 0;
215  return odr_missing(o, opt, name);
216 }
217 
218 int z_Sort(ODR o, Z_Sort **p, int opt, const char *name)
219 {
220  static Odr_arm arm[] = {
222  (Odr_fun) odr_null, "sequence"},
224  (Odr_fun) odr_null, "noRsName"},
226  (Odr_fun) odr_integer, "tooMany"},
228  (Odr_fun) odr_null, "incompatible"},
230  (Odr_fun) odr_null, "generic"},
232  (Odr_fun) odr_null, "dbSpecific"},
234  (Odr_fun) z_SortElement, "sortElement"},
236  (Odr_fun) odr_integer, "key"},
238  (Odr_fun) odr_null, "action"},
240  (Odr_fun) odr_integer, "illegal"},
242  (Odr_fun) z_StringList, "inputTooLarge"},
244  (Odr_fun) odr_null, "aggregateTooLarge"},
245  {-1, -1, -1, -1, (Odr_fun) 0, 0}
246  };
247  if (!odr_initmember(o, p, sizeof(**p)))
248  return odr_missing(o, opt, name);
249  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
250  return 1;
251  if (o->direction == ODR_DECODE)
252  *p = 0;
253  return odr_missing(o, opt, name);
254 }
255 
256 int z_Segmentation(ODR o, Z_Segmentation **p, int opt, const char *name)
257 {
258  static Odr_arm arm[] = {
260  (Odr_fun) odr_null, "segmentCount"},
262  (Odr_fun) odr_integer, "segmentSize"},
263  {-1, -1, -1, -1, (Odr_fun) 0, 0}
264  };
265  if (!odr_initmember(o, p, sizeof(**p)))
266  return odr_missing(o, opt, name);
267  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
268  return 1;
269  if (o->direction == ODR_DECODE)
270  *p = 0;
271  return odr_missing(o, opt, name);
272 }
273 
274 int z_ExtServices(ODR o, Z_ExtServices **p, int opt, const char *name)
275 {
276  static Odr_arm arm[] = {
278  (Odr_fun) odr_integer, "req"},
280  (Odr_fun) odr_integer, "permission"},
282  (Odr_fun) odr_integer, "immediate"},
283  {-1, -1, -1, -1, (Odr_fun) 0, 0}
284  };
285  if (!odr_initmember(o, p, sizeof(**p)))
286  return odr_missing(o, opt, name);
287  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
288  return 1;
289  if (o->direction == ODR_DECODE)
290  *p = 0;
291  return odr_missing(o, opt, name);
292 }
293 
294 int z_OidList(ODR o, Z_OidList **p, int opt, const char *name)
295 {
296  if (!odr_initmember(o, p, sizeof(**p)))
297  return odr_missing(o, opt, name);
298  if (odr_sequence_of(o, (Odr_fun) odr_oid, &(*p)->elements,
299  &(*p)->num, name))
300  return 1;
301  if (o->direction == ODR_DECODE)
302  *p = 0;
303  return odr_missing(o, opt, name);
304 }
305 
306 int z_AltOidList(ODR o, Z_AltOidList **p, int opt, const char *name)
307 {
308  if (!odr_initmember(o, p, sizeof(**p)))
309  return odr_missing(o, opt, name);
310  if (odr_sequence_of(o, (Odr_fun) odr_oid, &(*p)->elements,
311  &(*p)->num, name))
312  return 1;
313  if (o->direction == ODR_DECODE)
314  *p = 0;
315  return odr_missing(o, opt, name);
316 }
317 
318 int z_AccessCtrl(ODR o, Z_AccessCtrl **p, int opt, const char *name)
319 {
320  static Odr_arm arm[] = {
322  (Odr_fun) odr_null, "noUser"},
324  (Odr_fun) odr_null, "refused"},
326  (Odr_fun) odr_null, "simple"},
328  (Odr_fun) z_OidList, "oid"},
330  (Odr_fun) z_AltOidList, "alternative"},
332  (Odr_fun) odr_null, "pwdInv"},
334  (Odr_fun) odr_null, "pwdExp"},
335  {-1, -1, -1, -1, (Odr_fun) 0, 0}
336  };
337  if (!odr_initmember(o, p, sizeof(**p)))
338  return odr_missing(o, opt, name);
339  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
340  return 1;
341  if (o->direction == ODR_DECODE)
342  *p = 0;
343  return odr_missing(o, opt, name);
344 }
345 
346 int z_RecordSyntax(ODR o, Z_RecordSyntax **p, int opt, const char *name)
347 {
348  if (!odr_sequence_begin(o, p, sizeof(**p), name))
349  return odr_missing(o, opt, name) && odr_ok (o);
350  return
352  &(*p)->unsupportedSyntax, ODR_CONTEXT, 1, 0, "unsupportedSyntax") &&
354  (odr_sequence_of(o, (Odr_fun) odr_oid, &(*p)->suggestedAlternatives,
355  &(*p)->num_suggestedAlternatives, "suggestedAlternatives") || odr_ok(o)) &&
356  odr_sequence_end(o);
357 }
358 
359 int z_DiagFormat(ODR o, Z_DiagFormat **p, int opt, const char *name)
360 {
361  static Odr_arm arm[] = {
363  (Odr_fun) z_TooMany, "tooMany"},
365  (Odr_fun) z_BadSpec, "badSpec"},
367  (Odr_fun) z_DbUnavail, "dbUnavail"},
369  (Odr_fun) odr_integer, "unSupOp"},
371  (Odr_fun) z_Attribute, "attribute"},
373  (Odr_fun) z_AttCombo, "attCombo"},
375  (Odr_fun) z_DiagTerm, "term"},
377  (Odr_fun) z_Proximity, "proximity"},
379  (Odr_fun) z_Scan, "scan"},
381  (Odr_fun) z_Sort, "sort"},
383  (Odr_fun) z_Segmentation, "segmentation"},
385  (Odr_fun) z_ExtServices, "extServices"},
387  (Odr_fun) z_AccessCtrl, "accessCtrl"},
389  (Odr_fun) z_RecordSyntax, "recordSyntax"},
390  {-1, -1, -1, -1, (Odr_fun) 0, 0}
391  };
392  if (!odr_initmember(o, p, sizeof(**p)))
393  return odr_missing(o, opt, name);
394  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
395  return 1;
396  if (o->direction == ODR_DECODE)
397  *p = 0;
398  return odr_missing(o, opt, name);
399 }
#define odr_ok(o)
Definition: odr.h:215
#define Z_Scan_nonZeroStepSize
Definition: z-diag1.h:198
#define Z_AccessCtrl_oid
Definition: z-diag1.h:303
#define Z_SortD_incompatible
Definition: z-diag1.h:237
int z_AttributeList(ODR o, Z_AttributeList **p, int opt, const char *name)
Definition: z-core.c:316
int z_ExtServices(ODR o, Z_ExtServices **p, int opt, const char *name)
Definition: z-diag1.c:274
#define odr_explicit_tag(o, t, p, cl, tg, opt, name)
Definition: odr.h:195
#define Z_Proximity_relation
Definition: z-diag1.h:170
#define Z_Proximity_attributes
Definition: z-diag1.h:173
#define Z_SortD_inputTooLarge
Definition: z-diag1.h:244
#define Z_DiagFormat_unSupOp
Definition: z-diag1.h:340
int z_DbUnavail_0(ODR o, Z_DbUnavail_0 **p, int opt, const char *name)
Definition: z-diag1.c:71
#define Z_AccessCtrl_alternative
Definition: z-diag1.h:304
int z_DiagTerm(ODR o, Z_DiagTerm **p, int opt, const char *name)
Definition: z-diag1.c:124
#define Z_DiagFormat_sort
Definition: z-diag1.h:346
#define Z_DiagFormat_scan
Definition: z-diag1.h:345
#define Z_DiagFormat_extServices
Definition: z-diag1.h:348
#define Z_DiagFormat_attribute
Definition: z-diag1.h:341
#define Z_DiagFormat_segmentation
Definition: z-diag1.h:347
int z_DiagFormat(ODR o, Z_DiagFormat **p, int opt, const char *name)
Definition: z-diag1.c:359
int z_Attribute(ODR o, Z_Attribute **p, int opt, const char *name)
Definition: z-diag1.c:95
#define odr_implicit_tag(o, t, p, cl, tg, opt, name)
Definition: odr.h:192
int odr_sequence_begin(ODR o, void *p, int size, const char *name)
Definition: odr_seq.c:15
#define Z_Scan_endOfList
Definition: z-diag1.h:204
#define Z_Proximity_unit
Definition: z-diag1.h:171
#define Z_Segmentation_segmentCount
Definition: z-diag1.h:254
#define Z_SortD_noRsName
Definition: z-diag1.h:235
#define Z_SortD_action
Definition: z-diag1.h:242
#define Z_DiagnosticFormat_s_defaultDiagRec
Definition: z-diag1.h:89
char * name
Definition: initopt.c:18
#define Z_Segmentation_segmentSize
Definition: z-diag1.h:255
#define Z_ExtServices_immediate
Definition: z-diag1.h:276
int z_AttrListList(ODR o, Z_AttrListList **p, int opt, const char *name)
Definition: z-diag1.c:166
#define Z_DiagFormat_recordSyntax
Definition: z-diag1.h:350
#define Z_DiagFormat_tooMany
Definition: z-diag1.h:337
int z_OidList(ODR o, Z_OidList **p, int opt, const char *name)
Definition: z-diag1.c:294
#define Z_SortD_aggregateTooLarge
Definition: z-diag1.h:245
int odr_constructed_begin(ODR o, void *xxp, int zclass, int tag, const char *name)
Definition: odr_cons.c:24
int z_BadSpec(ODR o, Z_BadSpec **p, int opt, const char *name)
Definition: z-diag1.c:56
#define Z_SortD_key
Definition: z-diag1.h:241
#define Z_Proximity_badSet
Definition: z-diag1.h:169
int odr_initmember(ODR o, void *p, int size)
Definition: odr_tag.c:44
#define Z_SortD_generic
Definition: z-diag1.h:238
int z_RecordSyntax(ODR o, Z_RecordSyntax **p, int opt, const char *name)
Definition: z-diag1.c:346
int z_StringList(ODR o, Z_StringList **p, int opt, const char *name)
Definition: z-diag1.c:206
int direction
Definition: odr.h:126
#define Z_SortD_illegal
Definition: z-diag1.h:243
#define Z_DiagFormat_term
Definition: z-diag1.h:343
#define Z_Scan_posInResponse
Definition: z-diag1.h:202
#define Z_AccessCtrl_pwdExp
Definition: z-diag1.h:306
int odr_integer(ODR o, Odr_int **p, int opt, const char *name)
Definition: odr_int.c:19
#define Z_DiagnosticFormat_s_explicitDiagnostic
Definition: z-diag1.h:90
int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp, const char *name)
Definition: odr_choice.c:17
#define Z_Scan_specifiedStepSize
Definition: z-diag1.h:199
#define Z_DiagFormat_accessCtrl
Definition: z-diag1.h:349
#define Z_DiagFormat_badSpec
Definition: z-diag1.h:338
#define ODR_EXPLICIT
Definition: odr.h:60
#define Z_Scan_termList1
Definition: z-diag1.h:200
int z_AccessCtrl(ODR o, Z_AccessCtrl **p, int opt, const char *name)
Definition: z-diag1.c:318
int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num, const char *name)
Definition: odr_seq.c:134
int(* Odr_fun)(ODR, char **, int, const char *)
Definition: odr.h:135
#define Z_DiagFormat_attCombo
Definition: z-diag1.h:342
#define Z_AccessCtrl_simple
Definition: z-diag1.h:302
int which
Definition: odr.h:142
Definition: odr.h:137
#define Z_SortD_dbSpecific
Definition: z-diag1.h:239
#define Z_ExtServices_permission
Definition: z-diag1.h:275
int z_TooMany(ODR o, Z_TooMany **p, int opt, const char *name)
Definition: z-diag1.c:44
int odr_null(ODR o, Odr_null **p, int opt, const char *name)
Definition: odr_null.c:19
#define Z_Proximity_distance
Definition: z-diag1.h:172
int odr_missing(ODR o, int opt, const char *name)
Definition: odr_util.c:82
int z_DiagnosticFormat(ODR o, Z_DiagnosticFormat **p, int opt, const char *name)
Definition: z-diag1.c:32
Definition: odr.h:124
ASN.1 Module DiagnosticFormatDiag1.
int z_Sort(ODR o, Z_Sort **p, int opt, const char *name)
Definition: z-diag1.c:218
int z_AttCombo(ODR o, Z_AttCombo **p, int opt, const char *name)
Definition: z-diag1.c:111
int odr_sequence_end(ODR o)
Definition: odr_seq.c:61
#define Z_Proximity_resultSets
Definition: z-diag1.h:168
#define Z_DiagFormat_proximity
Definition: z-diag1.h:344
#define Z_AccessCtrl_pwdInv
Definition: z-diag1.h:305
int opt
Definition: initopt.c:19
int z_DbUnavail(ODR o, Z_DbUnavail **p, int opt, const char *name)
Definition: z-diag1.c:83
int z_Scan(ODR o, Z_Scan **p, int opt, const char *name)
Definition: z-diag1.c:178
int z_DefaultDiagFormat(ODR o, Z_DefaultDiagFormat **p, int opt, const char *name)
Definition: z-core.c:655
#define ODR_IMPLICIT
Definition: odr.h:59
int odr_oid(ODR o, Odr_oid **p, int opt, const char *name)
Definition: odr_oid.c:20
int z_Specification(ODR o, Z_Specification **p, int opt, const char *name)
Definition: z-core.c:778
int z_DiagnosticFormat_s(ODR o, Z_DiagnosticFormat_s **p, int opt, const char *name)
Definition: z-diag1.c:12
int z_InternationalString(ODR o, Z_InternationalString **p, int opt, const char *name)
Definition: z-core.c:1598
int z_SortElement(ODR o, Z_SortElement **p, int opt, const char *name)
Definition: z-core.c:1228
#define Z_Scan_termList2
Definition: z-diag1.h:201
int z_Term(ODR o, Z_Term **p, int opt, const char *name)
Definition: z-core.c:329
int z_Proximity(ODR o, Z_Proximity **p, int opt, const char *name)
Definition: z-diag1.c:136
#define Z_SortD_sortElement
Definition: z-diag1.h:240
#define Z_Proximity_exclusion
Definition: z-diag1.h:175
#define Z_ExtServices_req
Definition: z-diag1.h:274
#define Z_DiagFormat_dbUnavail
Definition: z-diag1.h:339
#define Z_SortD_tooMany
Definition: z-diag1.h:236
int odr_constructed_end(ODR o)
Definition: odr_cons.c:148
int z_Segmentation(ODR o, Z_Segmentation **p, int opt, const char *name)
Definition: z-diag1.c:256
#define ODR_CONTEXT
Definition: odr.h:67
#define Z_AccessCtrl_noUser
Definition: z-diag1.h:300
int z_AltOidList(ODR o, Z_AltOidList **p, int opt, const char *name)
Definition: z-diag1.c:306
#define Z_Proximity_ordered
Definition: z-diag1.h:174
#define Z_Scan_resources
Definition: z-diag1.h:203
#define ODR_DECODE
Definition: odr.h:95
#define Z_SortD_sequence
Definition: z-diag1.h:234
int z_DatabaseName(ODR o, Z_DatabaseName **p, int opt, const char *name)
Definition: z-core.c:1513
int odr_implicit_settag(ODR o, int zclass, int tag)
Definition: odr_tag.c:32
#define Z_AccessCtrl_refused
Definition: z-diag1.h:301