+ILL_Extension *makeoclcextension(struct prog_args *args, ODR odr) {
+ /* The oclc extension is required, but only contains optional */
+ /* fields. Here we just null them all out */
+ ODR odr_ext = odr_createmem(ODR_ENCODE);
+ ODR odr_prt = odr_createmem(ODR_PRINT);
+ ILL_Extension *e = (ILL_Extension *) odr_malloc(odr, sizeof(*e));
+ ILL_OCLCILLRequestExtension *oc = (ILL_OCLCILLRequestExtension *)
+ odr_malloc(odr_ext, sizeof(*oc));
+ char * buf;
+ int siz;
+ Z_External *ext = (Z_External *) odr_malloc(odr, sizeof(*ext));
+ oc->clientDepartment = 0;
+ oc->paymentMethod = 0;
+ oc->uniformTitle = 0;
+ oc->dissertation = 0;
+ oc->issueNumber = 0;
+ oc->volume = 0;
+ oc->affiliations = 0;
+ oc->source = 0;
+ ext->direct_reference = odr_getoidbystr(odr,"1.0.10161.13.2");
+ ext->indirect_reference=0;
+ ext->descriptor=0;
+ ext->which=Z_External_single;
+ if ( ! ill_OCLCILLRequestExtension(odr_ext, &oc, 0,0 ) ) {
+ yaz_log(YLOG_FATAL,"Encoding of ill_OCLCILLRequestExtension failed ");
+ exit (6);
+ }
+
+ printf ("OCLC: \n"); /*!*/
+ ill_OCLCILLRequestExtension(odr_prt, &oc, 0,0 ); /*!*/
+
+ buf= odr_getbuf(odr_ext,&siz,0);
+ ext->u.single_ASN1_type = (Odr_any*)
+ odr_malloc(odr,sizeof(*ext->u.single_ASN1_type));
+ ext->u.single_ASN1_type->buf = (unsigned char *) odr_malloc(odr, siz);
+ memcpy(ext->u.single_ASN1_type->buf,buf, siz );
+ ext->u.single_ASN1_type->len = ext->u.single_ASN1_type->size = siz;
+ odr_reset(odr_ext);
+ odr_reset(odr_prt); /*!*/
+
+ e->identifier = odr_intdup(odr,1);
+ e->critical = odr_booldup(odr,0);
+ e->item = (Odr_any *) odr_malloc(odr,sizeof(*e->item));
+ if ( ! z_External(odr_ext, &ext,0,0) ) {
+ yaz_log(YLOG_FATAL,"Encoding of z_External failed ");
+ exit (6);
+ }
+ printf("External: \n");
+ z_External(odr_prt, &ext,0,0); /*!*/
+ buf= odr_getbuf(odr_ext,&siz,0);
+ e->item->buf= (unsigned char *) odr_malloc(odr, siz);
+ memcpy(e->item->buf, buf, siz);
+ e->item->len = e->item->size = siz;
+
+ odr_destroy(odr_prt);
+ odr_destroy(odr_ext);
+ return e;
+
+} /* makeoclcextension */
+