12ed4941d06f002c0c47384fc3d38c906ec2e704
[yaz-moved-to-github.git] / asn / prt-add.c
1 /*
2  * Copyright (c) 1995, Index Data
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: prt-add.c,v $
7  * Revision 1.1  1996-10-10 11:52:18  quinn
8  * Added SearchResult additionalInfo
9  *
10  *
11  */
12
13 #include <proto.h>
14
15 int z_ResultsByDBList (ODR o, Z_ResultsByDBList **p, int opt)
16 {
17     if (odr_initmember (o, p, sizeof(**p)))
18         return opt && odr_ok(o);
19     if (odr_sequence_of (o, z_DatabaseName, &(*p)->elements,
20         &(*p)->num))
21         return 1;
22     *p = 0;
23     return opt && odr_ok(o);
24 }
25
26 int z_ResultsByDB_elem (ODR o, Z_ResultsByDB_elem **p, int opt)
27 {
28     static Odr_arm arm[] = {
29         {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ResultsByDB_all, odr_null},
30         {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ResultsByDB_list, z_ResultsByDBList},
31         {-1, -1, -1, -1, 0}
32     };
33     if (!odr_sequence_begin (o, p, sizeof(**p)))
34         return opt && odr_ok (o);
35     return
36         odr_constructed_begin (o, &(*p)->u, ODR_CONTEXT, 1) &&
37         odr_choice (o, arm, &(*p)->u, &(*p)->which) &&
38         odr_constructed_end (o) &&
39         odr_implicit (o, odr_integer,
40             &(*p)->count, ODR_CONTEXT, 2, 1) &&
41         odr_implicit (o, z_InternationalString,
42             &(*p)->resultSetName, ODR_CONTEXT, 3, 1) &&
43         odr_sequence_end (o);
44 }
45
46 int z_ResultsByDB (ODR o, Z_ResultsByDB **p, int opt)
47 {
48     if (odr_initmember (o, p, sizeof(**p)))
49         return opt && odr_ok(o);
50     if (odr_sequence_of (o, z_ResultsByDB_elem, &(*p)->elements,
51         &(*p)->num))
52         return 1;
53     *p = 0;
54     return opt && odr_ok(o);
55 }
56
57 int z_QueryExpressionTerm (ODR o, Z_QueryExpressionTerm **p, int opt)
58 {
59     if (!odr_sequence_begin (o, p, sizeof(**p)))
60         return opt && odr_ok (o);
61     return
62         odr_explicit (o, z_Term,
63             &(*p)->queryTerm, ODR_CONTEXT, 1, 0) &&
64         odr_implicit (o, z_InternationalString,
65             &(*p)->termComment, ODR_CONTEXT, 2, 1) &&
66         odr_sequence_end (o);
67 }
68
69 int z_QueryExpression (ODR o, Z_QueryExpression **p, int opt)
70 {
71     static Odr_arm arm[] = {
72         {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_QueryExpression_term,
73          z_QueryExpressionTerm},
74         {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_QueryExpression_query, z_Query},
75         {-1, -1, -1, -1, 0}
76     };
77     if (!odr_initmember(o, p, sizeof(**p)))
78         return opt && odr_ok(o);
79     if (odr_choice(o, arm, &(*p)->u, &(*p)->which))
80         return 1;
81     *p = 0;
82     return opt && odr_ok(o);
83 }
84
85 int z_SearchInfoReport_elem (ODR o, Z_SearchInfoReport_elem **p, int opt)
86 {
87     if (!odr_sequence_begin (o, p, sizeof(**p)))
88         return opt && odr_ok (o);
89     return
90         odr_implicit (o, z_InternationalString,
91             &(*p)->subqueryId, ODR_CONTEXT, 1, 1) &&
92         odr_implicit (o, odr_bool,
93             &(*p)->fullQuery, ODR_CONTEXT, 2, 0) &&
94         odr_explicit (o, z_QueryExpression,
95             &(*p)->subqueryExpression, ODR_CONTEXT, 3, 1) &&
96         odr_explicit (o, z_QueryExpression,
97             &(*p)->subqueryInterpretation, ODR_CONTEXT, 4, 1) &&
98         odr_explicit (o, z_QueryExpression,
99             &(*p)->subqueryRecommendation, ODR_CONTEXT, 5, 1) &&
100         odr_implicit (o, odr_integer,
101             &(*p)->subqueryCount, ODR_CONTEXT, 6, 1) &&
102         odr_implicit (o, z_IntUnit,
103             &(*p)->subqueryWeight, ODR_CONTEXT, 7, 1) &&
104         odr_implicit (o, z_ResultsByDB,
105             &(*p)->resultsByDB, ODR_CONTEXT, 8, 1) &&
106         odr_sequence_end (o);
107 }
108
109 int z_SearchInfoReport (ODR o, Z_SearchInfoReport **p, int opt)
110 {
111     if (odr_initmember (o, p, sizeof(**p)))
112         return opt && odr_ok(o);
113     if (odr_sequence_of (o, z_SearchInfoReport_elem, &(*p)->elements,
114         &(*p)->num))
115         return 1;
116     *p = 0;
117     return opt && odr_ok(o);
118 }