+ Z_External *r = (Z_External*) record;
+ oident *ent = oid_getentbyoid(r->direct_reference);
+
+ /*
+ * Tell the user what we got.
+ */
+ if (r->direct_reference)
+ {
+ printf("Record type: ");
+ if (ent)
+ printf("%s\n", ent->desc);
+ }
+ /* Check if this is a known, ASN.1 type tucked away in an octet string */
+ Z_ext_typeent *etype = z_ext_getentbyref(ent->value);
+ if (ent && (r->which == Z_External_octet || r->which == Z_External_single)
+ && (etype = z_ext_getentbyref(ent->value)))
+
+ {
+ void *rr;
+ /*
+ * Call the given decoder to process the record.
+ */
+ odr_setbuf(odr_decode(), (char*)record->u.octet_aligned->buf,
+ record->u.octet_aligned->len, 0);
+ if (!(*etype->fun)(odr_decode(), (char **)&rr, 0, 0))
+ {
+ odr_perror(odr_decode(), "Decoding constructed record.");
+ fprintf(stderr, "[Near %d]\n", odr_offset(odr_decode()));
+ fprintf(stderr, "Packet dump:\n---------\n");
+ odr_dumpBER(stderr, (char*)record->u.octet_aligned->buf,
+ record->u.octet_aligned->len);
+ fprintf(stderr, "---------\n");
+ }
+ if (etype->what == Z_External_sutrs)
+ {
+ Z_SUTRS *sutrs = (Z_SUTRS *) rr;
+ recv_textRecord ((int) VAL_SUTRS, (const char *) sutrs->buf,
+ (size_t) sutrs->len);
+ }
+ return;
+ }
+ if (r->which == Z_External_octet && record->u.octet_aligned->len)
+ {
+ recv_textRecord((int) ent->value,
+ (const char *) record->u.octet_aligned->buf,
+ (size_t) record->u.octet_aligned->len);
+ }
+ else if (ent && ent->value == VAL_SUTRS && r->which == Z_External_sutrs)
+ recv_textRecord((int) VAL_SUTRS, (const char *) r->u.sutrs->buf,
+ (size_t) r->u.sutrs->len);
+ else if (ent && ent->value == VAL_GRS1 && r->which == Z_External_grs1)
+ recv_genericRecord(r->u.grs1);
+ else
+ {
+ printf("Unknown record representation.\n");
+ if (!z_External(odr_print(), &r, 0, 0))
+ {
+ odr_perror(odr_print(), "Printing external");
+ odr_reset(odr_print());
+ }
+ }
+}