YAZ  5.23.1
z-accform1.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-accform1.h>
11 
12 int z_PromptObject1(ODR o, Z_PromptObject1 **p, int opt, const char *name)
13 {
14  static Odr_arm arm[] = {
16  (Odr_fun) z_Challenge1, "challenge"},
18  (Odr_fun) z_Response1, "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_ChallengeUnit1(ODR o, Z_ChallengeUnit1 **p, int opt, const char *name)
31 {
32  static Odr_arm arm[] = {
34  (Odr_fun) z_InternationalString, "character"},
36  (Odr_fun) z_Encryption, "encrypted"},
37  {-1, -1, -1, -1, (Odr_fun) 0, 0}
38  };
39  if (!odr_sequence_begin(o, p, sizeof(**p), name))
40  return odr_missing(o, opt, name) && odr_ok (o);
41  return
43  &(*p)->promptId, ODR_CONTEXT, 1, 0, "promptId") &&
45  &(*p)->defaultResponse, ODR_CONTEXT, 2, 1, "defaultResponse") &&
46  ((odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 3, "promptInfo") &&
47  odr_choice(o, arm, &(*p)->u, &(*p)->which, 0) &&
48  odr_constructed_end(o)) || odr_ok(o)) &&
50  &(*p)->regExpr, ODR_CONTEXT, 4, 1, "regExpr") &&
52  &(*p)->responseRequired, ODR_CONTEXT, 5, 1, "responseRequired") &&
54  (odr_sequence_of(o, (Odr_fun) z_InternationalString, &(*p)->allowedValues,
55  &(*p)->num_allowedValues, "allowedValues") || odr_ok(o)) &&
57  &(*p)->shouldSave, ODR_CONTEXT, 7, 1, "shouldSave") &&
59  &(*p)->dataType, ODR_CONTEXT, 8, 1, "dataType") &&
61  &(*p)->diagnostic, ODR_CONTEXT, 9, 1, "diagnostic") &&
63 }
64 
65 int z_Challenge1(ODR o, Z_Challenge1 **p, int opt, const char *name)
66 {
67  if (!odr_initmember(o, p, sizeof(**p)))
68  return odr_missing(o, opt, name);
69  if (odr_sequence_of(o, (Odr_fun) z_ChallengeUnit1, &(*p)->elements,
70  &(*p)->num, name))
71  return 1;
72  if (o->direction == ODR_DECODE)
73  *p = 0;
74  return odr_missing(o, opt, name);
75 }
76 
77 int z_ResponseUnit1(ODR o, Z_ResponseUnit1 **p, int opt, const char *name)
78 {
79  static Odr_arm arm[] = {
81  (Odr_fun) z_InternationalString, "string"},
83  (Odr_fun) odr_bool, "accept"},
85  (Odr_fun) odr_null, "acknowledge"},
87  (Odr_fun) z_DiagRec, "diagnostic"},
89  (Odr_fun) z_Encryption, "encrypted"},
90  {-1, -1, -1, -1, (Odr_fun) 0, 0}
91  };
92  if (!odr_sequence_begin(o, p, sizeof(**p), name))
93  return odr_missing(o, opt, name) && odr_ok (o);
94  return
96  &(*p)->promptId, ODR_CONTEXT, 1, 0, "promptId") &&
97  odr_constructed_begin(o, &(*p)->u, ODR_CONTEXT, 2, "promptResponse") &&
98  odr_choice(o, arm, &(*p)->u, &(*p)->which, 0) &&
100  odr_sequence_end(o);
101 }
102 
103 int z_Response1(ODR o, Z_Response1 **p, int opt, const char *name)
104 {
105  if (!odr_initmember(o, p, sizeof(**p)))
106  return odr_missing(o, opt, name);
107  if (odr_sequence_of(o, (Odr_fun) z_ResponseUnit1, &(*p)->elements,
108  &(*p)->num, name))
109  return 1;
110  if (o->direction == ODR_DECODE)
111  *p = 0;
112  return odr_missing(o, opt, name);
113 }
114 
116 {
117  if (!odr_sequence_begin(o, p, sizeof(**p), name))
118  return odr_missing(o, opt, name) && odr_ok (o);
119  return
121  &(*p)->type, ODR_CONTEXT, 1, 0, "type") &&
123  &(*p)->suggestedString, ODR_CONTEXT, 2, 1, "suggestedString") &&
124  odr_sequence_end(o);
125 }
126 
127 int z_PromptId(ODR o, Z_PromptId **p, int opt, const char *name)
128 {
129  static Odr_arm arm[] = {
131  (Odr_fun) z_PromptIdEnumeratedPrompt, "enumeratedPrompt"},
133  (Odr_fun) z_InternationalString, "nonEnumeratedPrompt"},
134  {-1, -1, -1, -1, (Odr_fun) 0, 0}
135  };
136  if (!odr_initmember(o, p, sizeof(**p)))
137  return odr_missing(o, opt, name);
138  if (odr_choice(o, arm, &(*p)->u, &(*p)->which, name))
139  return 1;
140  if (o->direction == ODR_DECODE)
141  *p = 0;
142  return odr_missing(o, opt, name);
143 }
144 
145 int z_Encryption(ODR o, Z_Encryption **p, int opt, const char *name)
146 {
147  if (!odr_sequence_begin(o, p, sizeof(**p), name))
148  return odr_missing(o, opt, name) && odr_ok (o);
149  return
151  &(*p)->cryptType, ODR_CONTEXT, 1, 1, "cryptType") &&
153  &(*p)->credential, ODR_CONTEXT, 2, 1, "credential") &&
155  &(*p)->data, ODR_CONTEXT, 3, 0, "data") &&
156  odr_sequence_end(o);
157 }
#define odr_ok(o)
Definition: odr.h:215
int z_PromptObject1(ODR o, Z_PromptObject1 **p, int opt, const char *name)
Definition: z-accform1.c:12
int z_Challenge1(ODR o, Z_Challenge1 **p, int opt, const char *name)
Definition: z-accform1.c:65
#define odr_explicit_tag(o, t, p, cl, tg, opt, name)
Definition: odr.h:195
#define Z_ResponseUnit1_acknowledge
Definition: z-accform1.h:96
#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
int z_PromptIdEnumeratedPrompt(ODR o, Z_PromptIdEnumeratedPrompt **p, int opt, const char *name)
Definition: z-accform1.c:115
char * name
Definition: initopt.c:18
#define Z_ResponseUnit1_diagnostic
Definition: z-accform1.h:97
#define Z_PromptId_nonEnumeratedPrompt
Definition: z-accform1.h:124
int z_ChallengeUnit1(ODR o, Z_ChallengeUnit1 **p, int opt, const char *name)
Definition: z-accform1.c:30
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
#define Z_ChallengeUnit1_character
Definition: z-accform1.h:62
int odr_initmember(ODR o, void *p, int size)
Definition: odr_tag.c:44
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 z_PromptId(ODR o, Z_PromptId **p, int opt, const char *name)
Definition: z-accform1.c:127
#define Z_ResponseUnit1_string
Definition: z-accform1.h:94
int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp, const char *name)
Definition: odr_choice.c:17
#define Z_PromptObject1_response
Definition: z-accform1.h:51
#define ODR_EXPLICIT
Definition: odr.h:60
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 which
Definition: odr.h:142
Definition: odr.h:137
int odr_null(ODR o, Odr_null **p, int opt, const char *name)
Definition: odr_null.c:19
int z_DiagRec(ODR o, Z_DiagRec **p, int opt, const char *name)
Definition: z-core.c:637
int odr_missing(ODR o, int opt, const char *name)
Definition: odr_util.c:82
int z_ResponseUnit1(ODR o, Z_ResponseUnit1 **p, int opt, const char *name)
Definition: z-accform1.c:77
Definition: odr.h:124
#define Z_ResponseUnit1_encrypted
Definition: z-accform1.h:98
#define Z_ChallengeUnit1_encrypted
Definition: z-accform1.h:63
int odr_sequence_end(ODR o)
Definition: odr_seq.c:61
ASN.1 Module AccessControlFormat-prompt-1.
int opt
Definition: initopt.c:19
#define Z_PromptObject1_challenge
Definition: z-accform1.h:50
#define ODR_IMPLICIT
Definition: odr.h:59
int z_InternationalString(ODR o, Z_InternationalString **p, int opt, const char *name)
Definition: z-core.c:1598
int z_Response1(ODR o, Z_Response1 **p, int opt, const char *name)
Definition: z-accform1.c:103
int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name)
Definition: odr_oct.c:19
#define Z_ResponseUnit1_accept
Definition: z-accform1.h:95
int z_Encryption(ODR o, Z_Encryption **p, int opt, const char *name)
Definition: z-accform1.c:145
int odr_constructed_end(ODR o)
Definition: odr_cons.c:148
#define ODR_CONTEXT
Definition: odr.h:67
#define ODR_DECODE
Definition: odr.h:95
int odr_implicit_settag(ODR o, int zclass, int tag)
Definition: odr_tag.c:32
#define Z_PromptId_enumeratedPrompt
Definition: z-accform1.h:123