Fix sample PQF
[yaz-moved-to-github.git] / asn / prt-rsc.c
1 /*
2  * Copyright (c) 1995-1999, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: prt-rsc.c,v $
7  * Revision 1.8  1999-11-30 13:47:11  adam
8  * Improved installation. Moved header files to include/yaz.
9  *
10  * Revision 1.7  1999/04/20 09:56:48  adam
11  * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
12  * Modified all encoders/decoders to reflect this change.
13  *
14  * Revision 1.6  1998/02/11 11:53:32  adam
15  * Changed code so that it compiles as C++.
16  *
17  * Revision 1.5  1995/09/29 17:11:55  quinn
18  * Smallish
19  *
20  * Revision 1.4  1995/09/27  15:02:43  quinn
21  * Modified function heads & prototypes.
22  *
23  * Revision 1.3  1995/06/02  09:49:15  quinn
24  * Adding access control
25  *
26  * Revision 1.2  1995/06/01  14:34:53  quinn
27  * Work
28  *
29  * Revision 1.1  1995/06/01  11:22:17  quinn
30  * Resource control
31  *
32  *
33  */
34
35 #include <yaz/proto.h>
36
37 /* -------------------- Resource 1 ------------------------- */
38
39 int z_Estimate1(ODR o, Z_Estimate1 **p, int opt, const char *name)
40 {
41     if (!odr_sequence_begin(o, p, sizeof(**p), 0))
42         return opt && odr_ok(o);
43     return
44         odr_implicit(o, odr_integer, &(*p)->type, ODR_CONTEXT, 1, 0) &&
45         odr_implicit(o, odr_integer, &(*p)->value, ODR_CONTEXT, 2, 0) &&
46         odr_implicit(o, odr_integer, &(*p)->currencyCode, ODR_CONTEXT, 3, 1) &&
47         odr_sequence_end(o);
48 }
49
50 int z_ResourceReport1(ODR o, Z_ResourceReport1 **p, int opt, const char *name)
51 {
52     if (!odr_sequence_begin(o, p, sizeof(**p), 0))
53         return opt && odr_ok(o);
54     return
55         odr_implicit_settag(o, ODR_CONTEXT, 1) &&
56         odr_sequence_of(o, (Odr_fun)z_Estimate1, &(*p)->estimates,
57                         &(*p)->num_estimates, 0) &&
58         odr_implicit(o, odr_visiblestring, &(*p)->message,
59                      ODR_CONTEXT, 2, 0) &&
60         odr_sequence_end(o);
61 }
62
63 /* -------------------- Resource 2 ------------------------- */
64
65 /* int z_StringOrNumeric(ODR, Z_StringOrNumeric **, int); */
66 /* int z_IntUnit(ODR, Z_IntUnit **, int); */
67
68 int z_Estimate2(ODR o, Z_Estimate2 **p, int opt, const char *name)
69 {
70     if (!odr_sequence_begin(o, p, sizeof(**p), 0))
71         return opt && odr_ok(o);
72     return
73         odr_explicit(o, z_StringOrNumeric, &(*p)->type, ODR_CONTEXT, 1, 0) &&
74         odr_implicit(o, z_IntUnit, &(*p)->value, ODR_CONTEXT, 2, 0) &&
75         odr_sequence_end(o);
76 }
77
78 int z_ResourceReport2(ODR o, Z_ResourceReport2 **p, int opt, const char *name)
79 {
80     if (!odr_sequence_begin(o, p, sizeof(**p), 0))
81         return opt && odr_ok(o);
82     return
83         odr_implicit_settag(o, ODR_CONTEXT, 1) &&
84         (odr_sequence_of(o, (Odr_fun)z_Estimate2, &(*p)->estimates,
85                          &(*p)->num_estimates, 0) || odr_ok(o)) &&
86         odr_implicit(o, odr_visiblestring, &(*p)->message,
87                      ODR_CONTEXT, 2, 1) &&
88         odr_sequence_end(o);
89 }
90
91