X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=client%2Fclient.c;h=46368143247af8c19c29312821714d549b751308;hb=abaa7e4d8d4d9ad4a5a33e55895055a9975895aa;hp=cabebb9e63f1f8d5c493f1b87e813996a0162553;hpb=fca985d5c2944fa01270d363190264e4ee36ec93;p=yaz-moved-to-github.git diff --git a/client/client.c b/client/client.c index cabebb9..4636814 100644 --- a/client/client.c +++ b/client/client.c @@ -4,7 +4,13 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: client.c,v $ - * Revision 1.15 1995-06-22 09:28:03 quinn + * Revision 1.17 1995-08-17 12:45:02 quinn + * Fixed minor problems with GRS-1. Added support in c&s. + * + * Revision 1.16 1995/08/15 12:00:04 quinn + * Updated External + * + * Revision 1.15 1995/06/22 09:28:03 quinn * Fixed bug in SUTRS processing. * * Revision 1.14 1995/06/19 12:37:41 quinn @@ -166,7 +172,7 @@ static int process_initResponse(Z_InitResponse *res) if (res->userInformationField) { printf("UserInformationfield:\n"); - if (!odr_external(print, (Odr_external**)&res-> userInformationField, + if (!z_External(print, (Z_External**)&res-> userInformationField, 0)) { odr_perror(print, "Printing userinfo\n"); @@ -264,9 +270,42 @@ int cmd_authentication(char *arg) /* SEARCH SERVICE ------------------------------ */ +void display_grs1(Z_GenericRecord *r, int level) +{ + int i; + + if (!r) + return; + for (i = 0; i < r->num_elements; i++) + { + Z_TaggedElement *t; + + printf("%*s", level * 4, ""); + t = r->elements[i]; + printf("("); + if (t->tagType) + printf("%d,", *t->tagType); + else + printf("?,"); + if (t->tagValue->which == Z_StringOrNumeric_numeric) + printf("%d) ", *t->tagValue->u.numeric); + else + printf("%s) ", t->tagValue->u.string); + if (t->content->which == Z_ElementData_subtree) + { + printf("\n"); + display_grs1(t->content->u.subtree, level+1); + } + else if (t->content->which == Z_ElementData_string) + printf("%s\n", t->content->u.string); + else + printf("??????\n"); + } +} + void display_record(Z_DatabaseRecord *p) { - Odr_external *r = (Odr_external*) p; + Z_External *r = (Z_External*) p; oident *ent = oid_getentbyoid(r->direct_reference); if (r->direct_reference) @@ -284,27 +323,26 @@ void display_record(Z_DatabaseRecord *p) marc_display ((char*)p->u.octet_aligned->buf, stdout); else if (ent->value == VAL_SUTRS) { - Odr_oct *rc; - - if (r->which != ODR_EXTERNAL_single) + if (r->which != Z_External_sutrs) { - printf("Expecting single ASN.1 type for SUTRS.\n"); + printf("Expecting single SUTRS type for SUTRS.\n"); return; } - odr_setbuf(in, (char*)r->u.single_ASN1_type->buf, - r->u.single_ASN1_type->len, 0); - if (!z_SUTRS(in, &rc, 0)) + printf("%.*s", r->u.sutrs->len, r->u.sutrs->buf); + } + else if (ent->value == VAL_GRS1) + { + if (r->which != Z_External_grs1) { - odr_perror(in, "decoding SUTRS"); - odr_reset(in); + printf("Expecting single GRS type for GRS.\n"); + return; } - else - printf("%.*s", rc->len, rc->buf); + display_grs1(r->u.grs1, 0); } else { printf("Unknown record representation.\n"); - if (!odr_external(print, &r, 0)) + if (!z_External(print, &r, 0)) { odr_perror(print, "Printing external"); odr_reset(print); @@ -731,9 +769,15 @@ int cmd_format(char *arg) recordsyntax = VAL_DANMARC; return 1; } + else if (!strcmp(arg, "grs1")) + { + printf("Preferred format is GRS1\n"); + recordsyntax = VAL_GRS1; + return 1; + } else { - printf("Specify one of {sutrs,usmarc,danmarc}.\n"); + printf("Specify one of {sutrs,usmarc,danmarc,grs1}.\n"); return 0; } }