27f010de224fff89eeece5236d56156193545ac4
[yaz-moved-to-github.git] / z39.50 / z-univ.c
1 /* YC 0.2 Tue Feb 29 16:45:14 CET 2000 */
2 /* Module-C: ResourceReport-Format-Universe-1 */
3
4 #include <yaz/z-univ.h>
5
6 int z_UniverseReportHits (ODR o, Z_UniverseReportHits **p, int opt, const char *name)
7 {
8         if (!odr_sequence_begin (o, p, sizeof(**p), name))
9                 return opt && odr_ok (o);
10         return
11                 z_StringOrNumeric(o, &(*p)->database, 0, "database") &&
12                 z_StringOrNumeric(o, &(*p)->hits, 0, "hits") &&
13                 odr_sequence_end (o);
14 }
15
16 int z_UniverseReportDuplicate (ODR o, Z_UniverseReportDuplicate **p, int opt, const char *name)
17 {
18         if (!odr_sequence_begin (o, p, sizeof(**p), name))
19                 return opt && odr_ok (o);
20         return
21                 z_StringOrNumeric(o, &(*p)->hitno, 0, "hitno") &&
22                 odr_sequence_end (o);
23 }
24
25 int z_UniverseReport (ODR o, Z_UniverseReport **p, int opt, const char *name)
26 {
27         static Odr_arm arm[] = {
28                 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_UniverseReport_databaseHits,
29                 (Odr_fun) z_UniverseReportHits, "databaseHits"},
30                 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_UniverseReport_duplicate,
31                 (Odr_fun) z_UniverseReportDuplicate, "duplicate"},
32                 {-1, -1, -1, -1, (Odr_fun) 0, 0}
33         };
34         if (!odr_sequence_begin (o, p, sizeof(**p), name))
35                 return opt && odr_ok (o);
36         return
37                 odr_integer(o, &(*p)->totalHits, 0, "totalHits") &&
38                 odr_choice (o, arm, &(*p)->u, &(*p)->which, 0) &&
39                 odr_sequence_end (o);
40 }