* Sebastian Hammer, Adam Dickmeiss
*
* $Log: client.c,v $
- * Revision 1.29 1996-01-02 08:57:25 quinn
+ * Revision 1.31 1996-02-20 12:51:54 quinn
+ * Fixed problems with EXTERNAL.
+ *
+ * Revision 1.30 1996/02/12 18:18:09 quinn
+ * Fidgeting.
+ *
+ * Revision 1.29 1996/01/02 08:57:25 quinn
* Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
*
* Revision 1.28 1995/12/14 11:09:31 quinn
static char last_scan[512] = "0";
static char last_cmd[100] = "?";
static oid_value attributeset = VAL_BIB1;
+static FILE *marcdump = 0;
+static char marcdump_file[512] = "marc.out";
#ifdef RPN_QUERY
#ifndef PREFIX_QUERY
exit(1);
}
buf = odr_getbuf(out, &len, 0);
- odr_reset(out); /* release the APDU */
+ odr_reset(out); /* release the APDU structure */
if (cs_put(conn, buf, len) < 0)
{
fprintf(stderr, "cs_put: %s", cs_errmsg(cs_errno(conn)));
Z_External *r = (Z_External*) p;
oident *ent = oid_getentbyoid(r->direct_reference);
+ /*
+ * Tell the user what we got.
+ */
if (r->direct_reference)
{
printf("Record type: ");
odr_reset(print);
}
}
+
+ /* Check if this is a known, ASN.1 type tucked away in an octet string */
+ if (ent && r->which == Z_External_octet)
+ {
+ Z_ext_typeent *type = z_ext_getentbyref(ent->value);
+ void *rr;
+
+ if (type)
+ {
+ /*
+ * Call the given decoder to process the record.
+ */
+ odr_setbuf(in, (char*)p->u.octet_aligned->buf,
+ p->u.octet_aligned->len, 0);
+ if (!(*type->fun)(in, &rr, 0))
+ {
+ odr_perror(in, "Decoding constructed record.");
+ fprintf(stderr, "[Near %d]\n", odr_offset(in));
+ fprintf(stderr, "Packet dump:\n---------\n");
+ odr_dumpBER(stderr, (char*)p->u.octet_aligned->buf,
+ p->u.octet_aligned->len);
+ fprintf(stderr, "---------\n");
+ exit(1);
+ }
+ /*
+ * Note: we throw away the original, BER-encoded record here.
+ * Do something else with it if you want to keep it.
+ */
+ r->u.sutrs = rr; /* we don't actually check the type here. */
+ r->which = type->what;
+ }
+ }
if (r->which == Z_External_octet && p->u.octet_aligned->len)
marc_display ((char*)p->u.octet_aligned->buf, stdout);
else if (ent->value == VAL_SUTRS)
cmd_open(argv[1]);
else
printf(C_PROMPT);
+ if (*marcdump_file && !(marcdump = fopen(marcdump_file, "a")))
+ {
+ perror(marcdump_file);
+ exit(1);
+ }
return client();
}