6 typedef Odr_bitmask Z_ReferenceId;
8 typedef struct Z_InitRequest
10 Z_ReferenceId *referenceId; /* OPTIONAL */
12 Odr_bitmask *protocolVersion;
13 int *preferredMessageSize;
14 int *maximumRecordSize;
15 char *idAuthentication; /* OPTIONAL */
16 char *implementationId; /* OPTIONAL */
17 char *implementationName; /* OPTIONAL */
18 char *implementationVersion; /* OPTIONAL */
21 int z_ReferenceId(ODR o, Z_ReferenceId **p, int opt)
23 return odr_implicit(o, odr_octetstring, (Odr_oct**) p, ODR_CONTEXT, 2, opt);
26 int z_InitRequest(ODR o, Z_InitRequest **p, int opt)
30 if (!odr_sequence_begin(o, p, sizeof(Z_InitRequest)))
34 z_ReferenceId(o, &pp->referenceId, 1) &&
35 odr_implicit(o, odr_bitstring, &pp->protocolVersion, ODR_CONTEXT,
37 odr_implicit(o, odr_bitstring, &pp->options, ODR_CONTEXT, 4, 0) &&
38 odr_implicit(o, odr_integer, &pp->preferredMessageSize, ODR_CONTEXT,
40 odr_implicit(o, odr_integer, &pp->maximumRecordSize, ODR_CONTEXT,
42 odr_implicit(o, odr_visiblestring, &pp->idAuthentication, ODR_CONTEXT,
44 odr_implicit(o, odr_visiblestring, &pp->implementationId, ODR_CONTEXT,
46 odr_implicit(o, odr_visiblestring, &pp->implementationName, ODR_CONTEXT,
48 odr_implicit(o, odr_visiblestring, &pp->implementationVersion,
49 ODR_CONTEXT, 112, 1) &&
59 char *c; /* visstring */
63 int f_A(ODR o, struct A **p, int opt)
68 { -1, -1, -1, 0, (Odr_fun) odr_integer },
69 { ODR_IMPLICIT, ODR_CONTEXT, 200, 1, (Odr_fun) odr_visiblestring },
73 if (o->direction == ODR_DECODE && !*p)
74 *p = odr_malloc(o, sizeof(**p));
75 res = odr_choice(o, arm, &(*p)->u, &(*p)->which);
88 unsigned char buf[4048];
90 Z_InitRequest ireq, *ireqp, *ireq2p;
91 Odr_bitmask options, protocolVersion;
92 char *iId = "YAZ", *iName = "Yet Another Z39.50 Implementation",
94 int maximumRS = 4096, preferredMS = 2048;
95 static Odr_oid oid[] = {1, 2, 3, 4, -1}, *oidp1, *oidp2;
99 ODR_MASK_ZERO(&protocolVersion);
100 ODR_MASK_SET(&protocolVersion, 0);
101 ODR_MASK_SET(&protocolVersion, 1);
103 ODR_MASK_ZERO(&options);
104 ODR_MASK_SET(&options, 0);
105 ODR_MASK_SET(&options, 1);
106 ODR_MASK_SET(&options, 2);
108 ireq.referenceId = 0;
109 ireq.protocolVersion = &protocolVersion;
110 ireq.options = &options;
111 ireq.preferredMessageSize = &preferredMS;
112 ireq.maximumRecordSize = &maximumRS;
113 ireq.idAuthentication = 0;
114 ireq.implementationId = iId;
115 ireq.implementationName = iName;
116 ireq.implementationVersion = iVersion;
121 o.left = o.buflen = 1024;
122 o.direction = ODR_PRINT;
126 odr_oid(&o, &oidp1, 0);
130 o.direction = ODR_DECODE;
133 odr_oid(&o, &oidp2, 0);
151 sscanf(line, "%c %d", &command, &val);
154 case 's': ODR_MASK_SET(&a, val); break;
155 case 'c': ODR_MASK_CLEAR(&a, val); break;
156 case 'g': printf("%d\n", ODR_MASK_GET(&a, val)); break;
158 default: printf("enter c <v> or s <v> or l\n"); continue;
160 printf("top is %d\n", a.top);
161 for (i = 0; i <= a.top; i++)
162 printf("%2.2x ", a.bits[i] );