7d18e580316d9e1670a7ae90d034daf0cf82cd25
[yaz-moved-to-github.git] / asn / prt-univ.c
1 /*
2  * Copyright (c) 1998-1999, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: prt-univ.c,v $
7  * Revision 1.2  1999-04-20 09:56:48  adam
8  * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
9  * Modified all encoders/decoders to reflect this change.
10  *
11  * Revision 1.1  1998/03/20 14:46:06  adam
12  * Added UNIverse Resource Reports.
13  *
14  */
15
16 #include <proto.h>
17
18 int z_UniverseReportHits (ODR o, Z_UniverseReportHits **p, int opt,
19                           const char *name)
20 {
21     if (!odr_sequence_begin (o, p, sizeof(**p), 0))
22         return opt && odr_ok (o);
23     return
24         z_StringOrNumeric(o, &(*p)->database, 0, 0) &&
25         z_StringOrNumeric(o, &(*p)->hits, 0, 0) &&
26         odr_sequence_end (o);
27 }
28
29 int z_UniverseReportDuplicate (ODR o, Z_UniverseReportDuplicate **p, int opt,
30                                const char *name)
31 {
32     if (!odr_sequence_begin (o, p, sizeof(**p), 0))
33         return opt && odr_ok (o);
34     return
35         z_StringOrNumeric(o, &(*p)->hitno, 0, 0) &&
36         odr_sequence_end (o);
37 }
38
39 int z_UniverseReport (ODR o, Z_UniverseReport **p, int opt, const char *name)
40 {
41     static Odr_arm arm[] = {
42         {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_UniverseReport_databaseHits,
43          (Odr_fun) z_UniverseReportHits, 0},
44         {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_UniverseReport_duplicate,
45          (Odr_fun) z_UniverseReportDuplicate, 0},
46         {-1, -1, -1, -1, (Odr_fun) 0, 0}
47     };
48     if (!odr_sequence_begin (o, p, sizeof(**p), 0))
49         return opt && odr_ok (o);
50     return
51         odr_integer(o, &(*p)->totalHits, 0, 0) &&
52         odr_choice (o, arm, &(*p)->u, &(*p)->which, 0) &&
53         odr_sequence_end (o);
54 }
55