YAZ  5.23.1
z-charneg.c
Go to the documentation of this file.
1 
6 #if HAVE_CONFIG_H
7 #include <config.h>
8 #endif
9 
10 #include <yaz/z-charneg.h>
11 
13 {
14  static Odr_arm arm[] = {
16  (Odr_fun) z_OriginProposal, "proposal"},
18  (Odr_fun) z_TargetResponse, "response"},
19  {-1, -1, -1, -1, (Odr_fun) 0, 0}
20  };
21  if (!odr_initmember(o, p, sizeof(**p)))
22  return odr_missing(o, opt, name);
23  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
24  return 1;
25  if (o->direction == ODR_DECODE)
26  *p = 0;
27  return odr_missing(o, opt, name);
28 }
29 
30 int z_OriginProposal_0(ODR o, Z_OriginProposal_0 **p, int opt, const char *name)
31 {
32  static Odr_arm arm[] = {
34  (Odr_fun) z_Iso2022, "iso2022"},
36  (Odr_fun) z_Iso10646, "iso10646"},
38  (Odr_fun) z_PrivateCharacterSet, "zprivate"},
39  {-1, -1, -1, -1, (Odr_fun) 0, 0}
40  };
41  if (!odr_initmember(o, p, sizeof(**p)))
42  return odr_missing(o, opt, name);
43  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
44  return 1;
45  if (o->direction == ODR_DECODE)
46  *p = 0;
47  return odr_missing(o, opt, name);
48 }
49 
50 int z_OriginProposal(ODR o, Z_OriginProposal **p, int opt, const char *name)
51 {
52  if (!odr_sequence_begin(o, p, sizeof(**p), name))
53  return odr_missing(o, opt, name) && odr_ok (o);
54  return
56  (odr_sequence_of(o, (Odr_fun) z_OriginProposal_0, &(*p)->proposedCharSets,
57  &(*p)->num_proposedCharSets, "proposedCharSets") || odr_ok(o)) &&
59  (odr_sequence_of(o, (Odr_fun) z_LanguageCode, &(*p)->proposedlanguages,
60  &(*p)->num_proposedlanguages, "proposedlanguages") || odr_ok(o)) &&
62  &(*p)->recordsInSelectedCharSets, ODR_CONTEXT, 3, 1, "recordsInSelectedCharSets") &&
64 }
65 
66 int z_TargetResponse(ODR o, Z_TargetResponse **p, int opt, const char *name)
67 {
68  static Odr_arm arm[] = {
70  (Odr_fun) z_Iso2022, "iso2022"},
72  (Odr_fun) z_Iso10646, "iso10646"},
74  (Odr_fun) z_PrivateCharacterSet, "zprivate"},
76  (Odr_fun) odr_null, "none"},
77  {-1, -1, -1, -1, (Odr_fun) 0, 0}
78  };
79  if (!odr_sequence_begin(o, p, sizeof(**p), name))
80  return odr_missing(o, opt, name) && odr_ok (o);
81  return
82  ((odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 1, "selectedCharSets") &&
83  odr_choice(o, arm, &(*p)->u, &(*p)->which, 0) &&
84  odr_constructed_end(o)) || odr_ok(o)) &&
86  &(*p)->selectedLanguage, ODR_CONTEXT, 2, 1, "selectedLanguage") &&
88  &(*p)->recordsInSelectedCharSets, ODR_CONTEXT, 3, 1, "recordsInSelectedCharSets") &&
90 }
91 
93 {
94  if (!odr_initmember(o, p, sizeof(**p)))
95  return odr_missing(o, opt, name);
96  if (odr_sequence_of(o, (Odr_fun) odr_oid, &(*p)->elements,
97  &(*p)->num, name))
98  return 1;
99  if (o->direction == ODR_DECODE)
100  *p = 0;
101  return odr_missing(o, opt, name);
102 }
103 
105 {
106  static Odr_arm arm[] = {
110  (Odr_fun) z_External, "externallySpecified"},
112  (Odr_fun) odr_null, "previouslyAgreedUpon"},
113  {-1, -1, -1, -1, (Odr_fun) 0, 0}
114  };
115  if (!odr_initmember(o, p, sizeof(**p)))
116  return odr_missing(o, opt, name);
117  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
118  return 1;
119  if (o->direction == ODR_DECODE)
120  *p = 0;
121  return odr_missing(o, opt, name);
122 }
123 
125 {
126  if (!odr_sequence_begin(o, p, sizeof(**p), name))
127  return odr_missing(o, opt, name) && odr_ok (o);
128  return
130  &(*p)->proposedEnvironment, ODR_CONTEXT, 0, 1, "proposedEnvironment") &&
132  odr_sequence_of(o, (Odr_fun) odr_integer, &(*p)->proposedSets,
133  &(*p)->num_proposedSets, "proposedSets") &&
135  odr_sequence_of(o, (Odr_fun) z_InitialSet, &(*p)->proposedInitialSets,
136  &(*p)->num_proposedInitialSets, "proposedInitialSets") &&
138  &(*p)->proposedLeftAndRight, ODR_CONTEXT, 3, 0, "proposedLeftAndRight") &&
139  odr_sequence_end(o);
140 }
141 
143 {
144  if (!odr_sequence_begin(o, p, sizeof(**p), name))
145  return odr_missing(o, opt, name) && odr_ok (o);
146  return
148  &(*p)->selectedEnvironment, ODR_CONTEXT, 0, 0, "selectedEnvironment") &&
150  odr_sequence_of(o, (Odr_fun) odr_integer, &(*p)->selectedSets,
151  &(*p)->num_selectedSets, "selectedSets") &&
153  &(*p)->selectedinitialSet, ODR_CONTEXT, 2, 0, "selectedinitialSet") &&
155  &(*p)->selectedLeftAndRight, ODR_CONTEXT, 3, 0, "selectedLeftAndRight") &&
156  odr_sequence_end(o);
157 }
158 
159 int z_Iso2022(ODR o, Z_Iso2022 **p, int opt, const char *name)
160 {
161  static Odr_arm arm[] = {
163  (Odr_fun) z_Iso2022OriginProposal, "originProposal"},
165  (Odr_fun) z_Iso2022TargetResponse, "targetResponse"},
166  {-1, -1, -1, -1, (Odr_fun) 0, 0}
167  };
168  if (!odr_initmember(o, p, sizeof(**p)))
169  return odr_missing(o, opt, name);
170  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
171  return 1;
172  if (o->direction == ODR_DECODE)
173  *p = 0;
174  return odr_missing(o, opt, name);
175 }
176 
177 int z_Environment(ODR o, Z_Environment **p, int opt, const char *name)
178 {
179  static Odr_arm arm[] = {
181  (Odr_fun) odr_null, "sevenBit"},
183  (Odr_fun) odr_null, "eightBit"},
184  {-1, -1, -1, -1, (Odr_fun) 0, 0}
185  };
186  if (!odr_initmember(o, p, sizeof(**p)))
187  return odr_missing(o, opt, name);
188  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
189  return 1;
190  if (o->direction == ODR_DECODE)
191  *p = 0;
192  return odr_missing(o, opt, name);
193 }
194 
195 int z_InitialSet(ODR o, Z_InitialSet **p, int opt, const char *name)
196 {
197  if (!odr_sequence_begin(o, p, sizeof(**p), name))
198  return odr_missing(o, opt, name) && odr_ok (o);
199  return
201  &(*p)->g0, ODR_CONTEXT, 0, 1, "g0") &&
203  &(*p)->g1, ODR_CONTEXT, 1, 1, "g1") &&
205  &(*p)->g2, ODR_CONTEXT, 2, 1, "g2") &&
207  &(*p)->g3, ODR_CONTEXT, 3, 1, "g3") &&
209  &(*p)->c0, ODR_CONTEXT, 4, 0, "c0") &&
211  &(*p)->c1, ODR_CONTEXT, 5, 1, "c1") &&
212  odr_sequence_end(o);
213 }
214 
215 int z_LeftAndRight(ODR o, Z_LeftAndRight **p, int opt, const char *name)
216 {
217  if (!odr_sequence_begin(o, p, sizeof(**p), name))
218  return odr_missing(o, opt, name) && odr_ok (o);
219  return
221  &(*p)->gLeft, ODR_CONTEXT, 3, 0, "gLeft") &&
223  &(*p)->gRight, ODR_CONTEXT, 4, 1, "gRight") &&
224  odr_sequence_end(o);
225 }
226 
227 int z_Iso10646(ODR o, Z_Iso10646 **p, int opt, const char *name)
228 {
229  if (!odr_sequence_begin(o, p, sizeof(**p), name))
230  return odr_missing(o, opt, name) && odr_ok (o);
231  return
233  &(*p)->collections, ODR_CONTEXT, 1, 1, "collections") &&
235  &(*p)->encodingLevel, ODR_CONTEXT, 2, 0, "encodingLevel") &&
236  odr_sequence_end(o);
237 }
#define odr_ok(o)
Definition: odr.h:215
int z_Iso10646(ODR o, Z_Iso10646 **p, int opt, const char *name)
Definition: z-charneg.c:227
#define Z_PrivateCharacterSet_externallySpecified
Definition: z-charneg.h:118
#define odr_explicit_tag(o, t, p, cl, tg, opt, name)
Definition: odr.h:195
#define Z_OriginProposal_0_iso10646
Definition: z-charneg.h:77
int z_Iso2022(ODR o, Z_Iso2022 **p, int opt, const char *name)
Definition: z-charneg.c:159
#define Z_TargetResponse_iso2022
Definition: z-charneg.h:97
#define Z_CharSetandLanguageNegotiation_proposal
Definition: z-charneg.h:65
#define odr_implicit_tag(o, t, p, cl, tg, opt, name)
Definition: odr.h:192
int odr_sequence_begin(ODR o, void *p, int size, const char *name)
Definition: odr_seq.c:15
char * name
Definition: initopt.c:18
#define Z_Environment_eightBit
Definition: z-charneg.h:156
int z_TargetResponse(ODR o, Z_TargetResponse **p, int opt, const char *name)
Definition: z-charneg.c:66
#define Z_CharSetandLanguageNegotiation_response
Definition: z-charneg.h:66
#define Z_PrivateCharacterSet_previouslyAgreedUpon
Definition: z-charneg.h:119
int z_LeftAndRight(ODR o, Z_LeftAndRight **p, int opt, const char *name)
Definition: z-charneg.c:215
int z_External(ODR o, Z_External **p, int opt, const char *name)
codec for BER EXTERNAL
Definition: prt-ext.c:95
int odr_constructed_begin(ODR o, void *xxp, int zclass, int tag, const char *name)
Definition: odr_cons.c:24
int odr_initmember(ODR o, void *p, int size)
Definition: odr_tag.c:44
#define Z_Environment_sevenBit
Definition: z-charneg.h:155
int direction
Definition: odr.h:126
int odr_integer(ODR o, Odr_int **p, int opt, const char *name)
Definition: odr_int.c:19
int odr_bool(ODR o, Odr_bool **p, int opt, const char *name)
Definition: odr_bool.c:21
int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp, const char *name)
Definition: odr_choice.c:17
int z_OriginProposal(ODR o, Z_OriginProposal **p, int opt, const char *name)
Definition: z-charneg.c:50
#define ODR_EXPLICIT
Definition: odr.h:60
#define Z_Iso2022_originProposal
Definition: z-charneg.h:145
int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num, const char *name)
Definition: odr_seq.c:134
int(* Odr_fun)(ODR, char **, int, const char *)
Definition: odr.h:135
int z_PrivateCharacterSetViaOid(ODR o, Z_PrivateCharacterSetViaOid **p, int opt, const char *name)
Definition: z-charneg.c:92
int which
Definition: odr.h:142
Definition: odr.h:137
int z_Environment(ODR o, Z_Environment **p, int opt, const char *name)
Definition: z-charneg.c:177
int z_Iso2022OriginProposal(ODR o, Z_Iso2022OriginProposal **p, int opt, const char *name)
Definition: z-charneg.c:124
#define Z_OriginProposal_0_iso2022
Definition: z-charneg.h:76
int odr_null(ODR o, Odr_null **p, int opt, const char *name)
Definition: odr_null.c:19
int odr_missing(ODR o, int opt, const char *name)
Definition: odr_util.c:82
int z_Iso2022TargetResponse(ODR o, Z_Iso2022TargetResponse **p, int opt, const char *name)
Definition: z-charneg.c:142
ASN.1 Module NegotiationRecordDefinition-charSetandLanguageNegotiation-3.
#define Z_TargetResponse_private
Definition: z-charneg.h:99
int z_LanguageCode(ODR o, Z_LanguageCode **p, int opt, const char *name)
Definition: z-exp.c:1053
Definition: odr.h:124
#define Z_TargetResponse_none
Definition: z-charneg.h:100
int odr_sequence_end(ODR o)
Definition: odr_seq.c:61
int opt
Definition: initopt.c:19
#define ODR_IMPLICIT
Definition: odr.h:59
int odr_oid(ODR o, Odr_oid **p, int opt, const char *name)
Definition: odr_oid.c:20
int z_InitialSet(ODR o, Z_InitialSet **p, int opt, const char *name)
Definition: z-charneg.c:195
#define Z_PrivateCharacterSet_viaOid
Definition: z-charneg.h:117
int z_OriginProposal_0(ODR o, Z_OriginProposal_0 **p, int opt, const char *name)
Definition: z-charneg.c:30
#define Z_OriginProposal_0_private
Definition: z-charneg.h:78
int z_PrivateCharacterSet(ODR o, Z_PrivateCharacterSet **p, int opt, const char *name)
Definition: z-charneg.c:104
#define Z_TargetResponse_iso10646
Definition: z-charneg.h:98
int odr_constructed_end(ODR o)
Definition: odr_cons.c:148
#define ODR_CONTEXT
Definition: odr.h:67
int z_CharSetandLanguageNegotiation(ODR o, Z_CharSetandLanguageNegotiation **p, int opt, const char *name)
Definition: z-charneg.c:12
#define ODR_DECODE
Definition: odr.h:95
int odr_implicit_settag(ODR o, int zclass, int tag)
Definition: odr_tag.c:32
#define Z_Iso2022_targetResponse
Definition: z-charneg.h:146