1 | /*
|
---|
2 | * Copyright (c) 1995-1999, Index Data
|
---|
3 | * See the file LICENSE for details.
|
---|
4 | * Sebastian Hammer, Adam Dickmeiss
|
---|
5 | *
|
---|
6 | * $Log$
|
---|
7 | * Revision 1.1 2000/08/03 03:09:47 johnmcp
|
---|
8 | * Added the YAZ toolkit source to the packages directory (for z39.50 stuff)
|
---|
9 | *
|
---|
10 | * Revision 1.6 1999/11/30 13:47:11 adam
|
---|
11 | * Improved installation. Moved header files to include/yaz.
|
---|
12 | *
|
---|
13 | * Revision 1.5 1999/04/20 09:56:47 adam
|
---|
14 | * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
|
---|
15 | * Modified all encoders/decoders to reflect this change.
|
---|
16 | *
|
---|
17 | * Revision 1.4 1998/02/11 11:53:32 adam
|
---|
18 | * Changed code so that it compiles as C++.
|
---|
19 | *
|
---|
20 | * Revision 1.3 1998/01/05 09:04:57 adam
|
---|
21 | * Fixed bugs in encoders/decoders - Not operator (!) missing.
|
---|
22 | *
|
---|
23 | * Revision 1.2 1997/04/30 08:52:02 quinn
|
---|
24 | * Null
|
---|
25 | *
|
---|
26 | * Revision 1.1 1996/10/10 11:52:18 quinn
|
---|
27 | * Added SearchResult additionalInfo
|
---|
28 | *
|
---|
29 | *
|
---|
30 | */
|
---|
31 |
|
---|
32 | #include <yaz/proto.h>
|
---|
33 |
|
---|
34 | int z_ResultsByDBList (ODR o, Z_ResultsByDBList **p, int opt, const char *name)
|
---|
35 | {
|
---|
36 | if (!odr_initmember (o, p, sizeof(**p)))
|
---|
37 | return opt && odr_ok(o);
|
---|
38 | if (odr_sequence_of (o, z_DatabaseName, &(*p)->elements,
|
---|
39 | &(*p)->num, 0))
|
---|
40 | return 1;
|
---|
41 | *p = 0;
|
---|
42 | return opt && odr_ok(o);
|
---|
43 | }
|
---|
44 |
|
---|
45 | int z_ResultsByDB_elem (ODR o, Z_ResultsByDB_elem **p, int opt,
|
---|
46 | const char *name)
|
---|
47 | {
|
---|
48 | static Odr_arm arm[] = {
|
---|
49 | {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ResultsByDB_all,
|
---|
50 | (Odr_fun)odr_null, 0},
|
---|
51 | {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ResultsByDB_list,
|
---|
52 | (Odr_fun)z_ResultsByDBList, 0},
|
---|
53 | {-1, -1, -1, -1, 0, 0}
|
---|
54 | };
|
---|
55 | if (!odr_sequence_begin (o, p, sizeof(**p), 0))
|
---|
56 | return opt && odr_ok (o);
|
---|
57 | return
|
---|
58 | odr_constructed_begin (o, &(*p)->u, ODR_CONTEXT, 1, 0) &&
|
---|
59 | odr_choice (o, arm, &(*p)->u, &(*p)->which, 0) &&
|
---|
60 | odr_constructed_end (o) &&
|
---|
61 | odr_implicit (o, odr_integer,
|
---|
62 | &(*p)->count, ODR_CONTEXT, 2, 1) &&
|
---|
63 | odr_implicit (o, z_InternationalString,
|
---|
64 | &(*p)->resultSetName, ODR_CONTEXT, 3, 1) &&
|
---|
65 | odr_sequence_end (o);
|
---|
66 | }
|
---|
67 |
|
---|
68 | int z_ResultsByDB (ODR o, Z_ResultsByDB **p, int opt, const char *name)
|
---|
69 | {
|
---|
70 | if (!odr_initmember (o, p, sizeof(**p)))
|
---|
71 | return opt && odr_ok(o);
|
---|
72 | if (odr_sequence_of (o, (Odr_fun)z_ResultsByDB_elem, &(*p)->elements,
|
---|
73 | &(*p)->num, 0))
|
---|
74 | return 1;
|
---|
75 | *p = 0;
|
---|
76 | return opt && odr_ok(o);
|
---|
77 | }
|
---|
78 |
|
---|
79 | int z_QueryExpressionTerm (ODR o, Z_QueryExpressionTerm **p, int opt,
|
---|
80 | const char *name)
|
---|
81 | {
|
---|
82 | if (!odr_sequence_begin (o, p, sizeof(**p), 0))
|
---|
83 | return opt && odr_ok (o);
|
---|
84 | return
|
---|
85 | odr_explicit (o, z_Term,
|
---|
86 | &(*p)->queryTerm, ODR_CONTEXT, 1, 0) &&
|
---|
87 | odr_implicit (o, z_InternationalString,
|
---|
88 | &(*p)->termComment, ODR_CONTEXT, 2, 1) &&
|
---|
89 | odr_sequence_end (o);
|
---|
90 | }
|
---|
91 |
|
---|
92 | int z_QueryExpression (ODR o, Z_QueryExpression **p, int opt,
|
---|
93 | const char *name)
|
---|
94 | {
|
---|
95 | static Odr_arm arm[] = {
|
---|
96 | {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_QueryExpression_term,
|
---|
97 | (Odr_fun)z_QueryExpressionTerm, 0},
|
---|
98 | {ODR_EXPLICIT, ODR_CONTEXT, 2, Z_QueryExpression_query,
|
---|
99 | (Odr_fun)z_Query, 0},
|
---|
100 | {-1, -1, -1, -1, 0, 0}
|
---|
101 | };
|
---|
102 | if (!odr_initmember(o, p, sizeof(**p)))
|
---|
103 | return opt && odr_ok(o);
|
---|
104 | if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
|
---|
105 | return 1;
|
---|
106 | *p = 0;
|
---|
107 | return opt && odr_ok(o);
|
---|
108 | }
|
---|
109 |
|
---|
110 | int z_SearchInfoReport_elem (ODR o, Z_SearchInfoReport_elem **p, int opt,
|
---|
111 | const char *name)
|
---|
112 | {
|
---|
113 | if (!odr_sequence_begin (o, p, sizeof(**p), 0))
|
---|
114 | return opt && odr_ok (o);
|
---|
115 | return
|
---|
116 | odr_implicit (o, z_InternationalString,
|
---|
117 | &(*p)->subqueryId, ODR_CONTEXT, 1, 1) &&
|
---|
118 | odr_implicit (o, odr_bool,
|
---|
119 | &(*p)->fullQuery, ODR_CONTEXT, 2, 0) &&
|
---|
120 | odr_explicit (o, z_QueryExpression,
|
---|
121 | &(*p)->subqueryExpression, ODR_CONTEXT, 3, 1) &&
|
---|
122 | odr_explicit (o, z_QueryExpression,
|
---|
123 | &(*p)->subqueryInterpretation, ODR_CONTEXT, 4, 1) &&
|
---|
124 | odr_explicit (o, z_QueryExpression,
|
---|
125 | &(*p)->subqueryRecommendation, ODR_CONTEXT, 5, 1) &&
|
---|
126 | odr_implicit (o, odr_integer,
|
---|
127 | &(*p)->subqueryCount, ODR_CONTEXT, 6, 1) &&
|
---|
128 | odr_implicit (o, z_IntUnit,
|
---|
129 | &(*p)->subqueryWeight, ODR_CONTEXT, 7, 1) &&
|
---|
130 | odr_implicit (o, z_ResultsByDB,
|
---|
131 | &(*p)->resultsByDB, ODR_CONTEXT, 8, 1) &&
|
---|
132 | odr_sequence_end (o);
|
---|
133 | }
|
---|
134 |
|
---|
135 | int z_SearchInfoReport (ODR o, Z_SearchInfoReport **p, int opt,
|
---|
136 | const char *name)
|
---|
137 | {
|
---|
138 | if (!odr_initmember (o, p, sizeof(**p)))
|
---|
139 | return opt && odr_ok(o);
|
---|
140 | if (odr_sequence_of (o, (Odr_fun)z_SearchInfoReport_elem, &(*p)->elements,
|
---|
141 | &(*p)->num, 0))
|
---|
142 | return 1;
|
---|
143 | *p = 0;
|
---|
144 | return opt && odr_ok(o);
|
---|
145 | }
|
---|