2 * Copyright (c) 1995-1998, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.65 1998-03-31 15:13:19 adam
8 * Development towards compiled ASN.1.
10 * Revision 1.64 1998/03/31 11:07:44 adam
11 * Furhter work on UNIverse resource report.
12 * Added Extended Services handling in frontend server.
14 * Revision 1.63 1998/03/05 08:05:10 adam
15 * Added a few casts to make C++ happy.
17 * Revision 1.62 1998/02/11 11:53:33 adam
18 * Changed code so that it compiles as C++.
20 * Revision 1.61 1998/02/10 11:03:06 adam
21 * Implemented command refid. Client prints reference-ID's, when present,
24 * Revision 1.60 1998/01/29 14:08:52 adam
25 * Better sort diagnostics.
27 * Revision 1.59 1998/01/29 13:17:56 adam
30 * Revision 1.58 1998/01/07 13:51:45 adam
33 * Revision 1.57 1998/01/07 12:58:22 adam
34 * Using fgets instead of gets.
36 * Revision 1.56 1997/11/05 09:18:31 adam
37 * The client handles records with no associated syntax.
39 * Revision 1.55 1997/10/31 12:20:08 adam
40 * Improved memory debugging for xmalloc/nmem.c. References to NMEM
41 * instead of ODR in n ESPEC-1 handling in source d1_espec.c.
42 * Bug fix: missing fclose in data1_read_espec1.
44 * Revision 1.54 1997/10/27 13:52:46 adam
45 * Header yaz-util includes all YAZ utility header files.
47 * Revision 1.53 1997/09/29 13:18:59 adam
48 * Added function, oid_ent_to_oid, to replace the function
49 * oid_getoidbyent, which is not thread safe.
51 * Revision 1.52 1997/09/29 07:20:31 adam
52 * Client code uses nmem_init.
54 * Revision 1.51 1997/09/26 09:41:55 adam
55 * Updated client to handle multiple diagnostics.
57 * Revision 1.50 1997/09/17 12:10:29 adam
60 * Revision 1.49 1997/09/04 13:45:17 adam
61 * Added UNImarc to list of available syntaxes.
63 * Revision 1.48 1997/09/01 08:48:44 adam
64 * New windows NT/95 port using MSV5.0. Only a few changes made
65 * to avoid warnings. Sub project created: client.dsp.
67 * Revision 1.47 1997/07/01 13:49:56 adam
68 * Take care of case when invalid target is specified on command line.
70 * Revision 1.46 1997/06/23 10:30:18 adam
71 * Added call to ccl_rpn_delete in search. Added ODR stream "out"
72 * as parameter to ccl_rpn_query to release RPN query.
74 * Revision 1.45 1997/05/14 06:53:29 adam
77 * Revision 1.44 1997/05/05 11:20:35 adam
78 * Client uses "options" utility and marc dump filename may be specified
79 * as an option (-m <file>).
81 * Revision 1.43 1996/11/08 11:03:26 adam
82 * Client accepts multiple database names.
84 * Revision 1.42 1996/10/08 10:44:57 quinn
87 * Revision 1.41 1996/10/07 15:29:03 quinn
90 * Revision 1.40 1996/08/29 14:19:34 quinn
91 * Fixed conflict (CVS)
93 * Revision 1.39 1996/08/27 10:43:22 quinn
94 * Made select() optional
96 * Revision 1.38 1996/08/12 14:09:11 adam
97 * Default prefix query attribute set defined by using p_query_attset.
99 * Revision 1.37 1996/07/06 19:58:29 quinn
100 * System headerfiles gathered in yconfig
102 * Revision 1.36 1996/06/10 08:53:47 quinn
105 * Revision 1.35 1996/06/03 09:45:50 quinn
106 * Added display of OIDs in the GRS routine.
108 * Revision 1.34 1996/05/09 07:26:49 quinn
109 * *** empty log message ***
111 * Revision 1.33 1996/05/09 07:25:22 quinn
114 * Revision 1.32 1996/03/15 11:05:33 adam
115 * The user can set the preferred query type (prefix, ccl, ..) with the
118 * Revision 1.31 1996/02/20 12:51:54 quinn
119 * Fixed problems with EXTERNAL.
121 * Revision 1.30 1996/02/12 18:18:09 quinn
124 * Revision 1.29 1996/01/02 08:57:25 quinn
125 * Changed enums in the ASN.1 .h files to #defines. Changed oident.class to oclass
127 * Revision 1.28 1995/12/14 11:09:31 quinn
128 * Added Explain record syntax to the format command.
130 * Revision 1.27 1995/12/12 16:37:02 quinn
131 * Added destroy element to data1_node.
133 * Revision 1.26 1995/12/12 14:11:00 quinn
136 * Revision 1.25 1995/11/13 09:27:22 quinn
137 * Fiddling with the variant stuff.
139 * Revision 1.24 1995/10/30 12:41:13 quinn
140 * Added hostname lookup for server.
142 * Revision 1.23 1995/10/18 16:12:30 quinn
143 * Better diagnostics.
145 * Revision 1.22 1995/10/11 14:49:12 quinn
148 * Revision 1.21 1995/09/29 17:01:47 quinn
151 * Revision 1.20 1995/08/29 14:24:13 quinn
152 * Added second half of close-handshake
154 * Revision 1.19 1995/08/29 11:17:28 quinn
155 * Added code to receive close
157 * Revision 1.18 1995/08/28 12:21:27 quinn
158 * Client can now ask for simple element set names.
160 * Revision 1.17 1995/08/17 12:45:02 quinn
161 * Fixed minor problems with GRS-1. Added support in c&s.
163 * Revision 1.16 1995/08/15 12:00:04 quinn
166 * Revision 1.15 1995/06/22 09:28:03 quinn
167 * Fixed bug in SUTRS processing.
169 * Revision 1.14 1995/06/19 12:37:41 quinn
172 * Revision 1.13 1995/06/16 10:29:11 quinn
173 * *** empty log message ***
175 * Revision 1.12 1995/06/15 07:44:57 quinn
178 * Revision 1.11 1995/06/14 15:26:40 quinn
179 * *** empty log message ***
181 * Revision 1.10 1995/06/06 14:56:58 quinn
182 * Better diagnostics.
184 * Revision 1.9 1995/06/06 08:15:19 quinn
187 * Revision 1.8 1995/06/05 10:52:22 quinn
190 * Revision 1.7 1995/06/02 09:50:09 quinn
193 * Revision 1.6 1995/05/31 08:29:21 quinn
194 * Nothing significant.
196 * Revision 1.5 1995/05/29 08:10:47 quinn
197 * Moved oid.c to util.
199 * Revision 1.4 1995/05/22 15:30:13 adam
200 * Client uses prefix query notation.
202 * Revision 1.3 1995/05/22 15:06:53 quinn
203 * *** empty log message ***
205 * Revision 1.2 1995/05/22 14:56:40 quinn
206 * *** empty log message ***
208 * Revision 1.1 1995/05/22 11:30:31 quinn
209 * Added prettier client.
215 * This is the obligatory little toy client, whose primary purpose is
216 * to illustrate the use of the YAZ service-level API.
224 #include <yaz-util.h>
226 #include <comstack.h>
233 #include <marcdisp.h>
234 #include <diagbib1.h>
242 #define C_PROMPT "Z> "
244 static ODR out, in, print; /* encoding and decoding streams */
245 static COMSTACK conn = 0; /* our z-association */
246 static Z_IdAuthentication *auth = 0; /* our current auth definition */
247 static char *databaseNames[128];
248 static int num_databaseNames = 0;
249 static int setnumber = 0; /* current result set number */
250 static int smallSetUpperBound = 0;
251 static int largeSetLowerBound = 1;
252 static int mediumSetPresentNumber = 0;
253 static Z_ElementSetNames *elementSetNames = 0;
254 static int setno = 1; /* current set offset */
255 static int protocol = PROTO_Z3950; /* current app protocol */
256 static int recordsyntax = VAL_USMARC;
257 static int sent_close = 0;
258 static ODR_MEM session_mem; /* memory handle for init-response */
259 static Z_InitResponse *session = 0; /* session parameters */
260 static char last_scan[512] = "0";
261 static char last_cmd[100] = "?";
262 static FILE *marcdump = 0;
263 static char *refid = NULL;
271 static QueryType queryType = QueryType_Prefix;
274 static CCL_bibset bibset; /* CCL bibset handle */
277 static void send_apdu(Z_APDU *a)
282 if (!z_APDU(out, &a, 0))
284 odr_perror(out, "Encoding APDU");
287 buf = odr_getbuf(out, &len, 0);
288 if (cs_put(conn, buf, len) < 0)
290 fprintf(stderr, "cs_put: %s", cs_errmsg(cs_errno(conn)));
293 odr_reset(out); /* release the APDU structure */
296 static void print_refid (Z_ReferenceId *id)
300 printf ("ReferenceId: '%.*s'\n", id->len, id->buf);
304 static Z_ReferenceId *set_refid (ODR out)
309 id = (Z_ReferenceId *) odr_malloc (out, sizeof(*id));
310 id->size = id->len = strlen(refid);
311 id->buf = (unsigned char *) odr_malloc (out, id->len);
312 memcpy (id->buf, refid, id->len);
316 /* INIT SERVICE ------------------------------- */
318 static void send_initRequest()
320 Z_APDU *apdu = zget_APDU(out, Z_APDU_initRequest);
321 Z_InitRequest *req = apdu->u.initRequest;
323 ODR_MASK_SET(req->options, Z_Options_search);
324 ODR_MASK_SET(req->options, Z_Options_present);
325 ODR_MASK_SET(req->options, Z_Options_namedResultSets);
326 ODR_MASK_SET(req->options, Z_Options_triggerResourceCtrl);
327 ODR_MASK_SET(req->options, Z_Options_scan);
328 ODR_MASK_SET(req->options, Z_Options_sort);
329 ODR_MASK_SET(req->options, Z_Options_extendedServices);
331 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1);
332 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2);
333 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3);
335 *req->maximumRecordSize = 1024*1024;
337 req->idAuthentication = auth;
340 printf("Sent initrequest.\n");
343 static int process_initResponse(Z_InitResponse *res)
345 /* save session parameters for later use */
346 session_mem = odr_extract_mem(in);
350 printf("Connection rejected by target.\n");
352 printf("Connection accepted by target.\n");
353 if (res->implementationId)
354 printf("ID : %s\n", res->implementationId);
355 if (res->implementationName)
356 printf("Name : %s\n", res->implementationName);
357 if (res->implementationVersion)
358 printf("Version: %s\n", res->implementationVersion);
359 if (res->userInformationField)
361 printf("UserInformationfield:\n");
362 if (!z_External(print, (Z_External**)&res-> userInformationField,
365 odr_perror(print, "Printing userinfo\n");
368 if (res->userInformationField->which == Z_External_octet)
370 printf("Guessing visiblestring:\n");
371 printf("'%s'\n", res->userInformationField->u. octet_aligned->buf);
377 int cmd_open(char *arg)
380 char type[100], addr[100];
385 printf("Already connected.\n");
388 if (!*arg || sscanf(arg, "%[^:]:%s", type, addr) < 2)
390 fprintf(stderr, "Usage: open (osi|tcp) ':' [tsel '/']host[':'port]\n");
393 if (!strcmp(type, "tcp"))
396 protocol = PROTO_Z3950;
400 if (!strcmp(type, "osi"))
408 fprintf(stderr, "Bad type: %s\n", type);
411 if (!(conn = cs_create(t, 1, protocol)))
416 if (!(add = cs_straddr(conn, addr)))
421 printf("Connecting...");
423 if (cs_connect(conn, add) < 0)
435 int cmd_authentication(char *arg)
437 static Z_IdAuthentication au;
438 static char open[256];
442 printf("Auth field set to null\n");
447 au.which = Z_IdAuthentication_open;
453 /* SEARCH SERVICE ------------------------------ */
455 static void display_variant(Z_Variant *v, int level)
459 for (i = 0; i < v->num_triples; i++)
461 printf("%*sclass=%d,type=%d", level * 4, "", *v->triples[i]->zclass,
462 *v->triples[i]->type);
463 if (v->triples[i]->which == Z_Triple_internationalString)
464 printf(",value=%s\n", v->triples[i]->value.internationalString);
470 static void display_grs1(Z_GenericRecord *r, int level)
476 for (i = 0; i < r->num_elements; i++)
480 printf("%*s", level * 4, "");
484 printf("%d,", *t->tagType);
487 if (t->tagValue->which == Z_StringOrNumeric_numeric)
488 printf("%d) ", *t->tagValue->u.numeric);
490 printf("%s) ", t->tagValue->u.string);
491 if (t->content->which == Z_ElementData_subtree)
494 display_grs1(t->content->u.subtree, level+1);
496 else if (t->content->which == Z_ElementData_string)
497 printf("%s\n", t->content->u.string);
498 else if (t->content->which == Z_ElementData_numeric)
499 printf("%d\n", *t->content->u.numeric);
500 else if (t->content->which == Z_ElementData_oid)
502 int *ip = t->content->u.oid;
505 if ((oent = oid_getentbyoid(t->content->u.oid)))
506 printf("OID: %s\n", oent->desc);
510 while (ip && *ip >= 0)
511 printf(" %d", *(ip++));
515 else if (t->content->which == Z_ElementData_noDataRequested)
516 printf("[No data requested]\n");
517 else if (t->content->which == Z_ElementData_elementEmpty)
518 printf("[Element empty]\n");
519 else if (t->content->which == Z_ElementData_elementNotThere)
520 printf("[Element not there]\n");
523 if (t->appliedVariant)
524 display_variant(t->appliedVariant, level+1);
525 if (t->metaData && t->metaData->supportedVariants)
529 printf("%*s---- variant list\n", (level+1)*4, "");
530 for (c = 0; c < t->metaData->num_supportedVariants; c++)
532 printf("%*svariant #%d\n", (level+1)*4, "", c);
533 display_variant(t->metaData->supportedVariants[c], level + 2);
539 static void display_record(Z_DatabaseRecord *p)
541 Z_External *r = (Z_External*) p;
542 oident *ent = oid_getentbyoid(r->direct_reference);
545 * Tell the user what we got.
547 if (r->direct_reference)
549 printf("Record type: ");
551 printf("%s\n", ent->desc);
552 else if (!odr_oid(print, &r->direct_reference, 0))
554 odr_perror(print, "print oid");
558 /* Check if this is a known, ASN.1 type tucked away in an octet string */
559 if (ent && r->which == Z_External_octet)
561 Z_ext_typeent *type = z_ext_getentbyref(ent->value);
567 * Call the given decoder to process the record.
569 odr_setbuf(in, (char*)p->u.octet_aligned->buf,
570 p->u.octet_aligned->len, 0);
571 if (!(*type->fun)(in, (char **)&rr, 0))
573 odr_perror(in, "Decoding constructed record.");
574 fprintf(stderr, "[Near %d]\n", odr_offset(in));
575 fprintf(stderr, "Packet dump:\n---------\n");
576 odr_dumpBER(stderr, (char*)p->u.octet_aligned->buf,
577 p->u.octet_aligned->len);
578 fprintf(stderr, "---------\n");
582 * Note: we throw away the original, BER-encoded record here.
583 * Do something else with it if you want to keep it.
585 r->u.sutrs = (Z_SUTRS *) rr; /* we don't actually check the type here. */
586 r->which = type->what;
589 if (ent && ent->value == VAL_SOIF)
590 printf("%.*s", r->u.octet_aligned->len, r->u.octet_aligned->buf);
591 else if (r->which == Z_External_octet && p->u.octet_aligned->len)
593 const char *marc_buf = (char*)p->u.octet_aligned->buf;
594 marc_display (marc_buf, NULL);
596 fwrite (marc_buf, strlen (marc_buf), 1, marcdump);
598 else if (ent && ent->value == VAL_SUTRS)
600 if (r->which != Z_External_sutrs)
602 printf("Expecting single SUTRS type for SUTRS.\n");
605 printf("%.*s", r->u.sutrs->len, r->u.sutrs->buf);
607 else if (ent && ent->value == VAL_GRS1)
609 if (r->which != Z_External_grs1)
611 printf("Expecting single GRS type for GRS.\n");
614 display_grs1(r->u.grs1, 0);
618 printf("Unknown record representation.\n");
619 if (!z_External(print, &r, 0))
621 odr_perror(print, "Printing external");
628 static void display_diagrecs(Z_DiagRec **pp, int num)
632 Z_DefaultDiagFormat *r;
634 printf("Diagnostic message(s) from database:\n");
635 for (i = 0; i<num; i++)
637 Z_DiagRec *p = pp[i];
638 if (p->which != Z_DiagRec_defaultFormat)
640 printf("Diagnostic record not in default format.\n");
644 r = p->u.defaultFormat;
645 if (!(ent = oid_getentbyoid(r->diagnosticSetId)) ||
646 ent->oclass != CLASS_DIAGSET || ent->value != VAL_BIB1)
647 printf("Missing or unknown diagset\n");
648 printf(" [%d] %s", *r->condition, diagbib1_str(*r->condition));
652 case Z_DefaultDiagFormat_v2Addinfo:
653 printf (" -- v2 addinfo '%s'\n", r->u.v2Addinfo);
655 case Z_DefaultDiagFormat_v3Addinfo:
656 printf (" -- v3 addinfo '%s'\n", r->u.v3Addinfo);
660 if (r->addinfo && *r->addinfo)
661 printf(" -- '%s'\n", r->addinfo);
669 static void display_nameplusrecord(Z_NamePlusRecord *p)
672 printf("[%s]", p->databaseName);
673 if (p->which == Z_NamePlusRecord_surrogateDiagnostic)
674 display_diagrecs(&p->u.surrogateDiagnostic, 1);
676 display_record(p->u.databaseRecord);
679 static void display_records(Z_Records *p)
683 if (p->which == Z_Records_NSD)
686 Z_DiagRec dr, *dr_p = &dr;
687 dr.which = Z_DiagRec_defaultFormat;
688 dr.u.defaultFormat = p->u.nonSurrogateDiagnostic;
689 display_diagrecs (&dr_p, 1);
691 display_diagrecs (&p->u.nonSurrogateDiagnostic, 1);
694 else if (p->which == Z_Records_multipleNSD)
695 display_diagrecs (p->u.multipleNonSurDiagnostics->diagRecs,
696 p->u.multipleNonSurDiagnostics->num_diagRecs);
699 printf("Records: %d\n", p->u.databaseOrSurDiagnostics->num_records);
700 for (i = 0; i < p->u.databaseOrSurDiagnostics->num_records; i++)
701 display_nameplusrecord(p->u.databaseOrSurDiagnostics->records[i]);
705 static int send_searchRequest(char *arg)
707 Z_APDU *apdu = zget_APDU(out, Z_APDU_searchRequest);
708 Z_SearchRequest *req = apdu->u.searchRequest;
712 struct ccl_rpn_node *rpn;
717 Z_RPNQuery *RPNquery;
721 if (queryType == QueryType_CCL2RPN)
723 rpn = ccl_find_str(bibset, arg, &error, &pos);
726 printf("CCL ERROR: %s\n", ccl_err_msg(error));
731 req->referenceId = set_refid (out);
732 if (!strcmp(arg, "@big")) /* strictly for troublemaking */
734 static unsigned char big[2100];
737 /* send a very big referenceid to test transport stack etc. */
738 memset(big, 'A', 2100);
739 bigo.len = bigo.size = 2100;
741 req->referenceId = &bigo;
746 sprintf(setstring, "%d", ++setnumber);
747 req->resultSetName = setstring;
749 *req->smallSetUpperBound = smallSetUpperBound;
750 *req->largeSetLowerBound = largeSetLowerBound;
751 *req->mediumSetPresentNumber = mediumSetPresentNumber;
752 if (smallSetUpperBound > 0 || (largeSetLowerBound > 1 &&
753 mediumSetPresentNumber > 0))
757 prefsyn.proto = protocol;
758 prefsyn.oclass = CLASS_RECSYN;
759 prefsyn.value = recordsyntax;
760 req->preferredRecordSyntax =
761 odr_oiddup(out, oid_ent_to_oid(&prefsyn, oid));
762 req->smallSetElementSetNames =
763 req->mediumSetElementSetNames = elementSetNames;
765 req->num_databaseNames = num_databaseNames;
766 req->databaseNames = databaseNames;
772 case QueryType_Prefix:
773 query.which = Z_Query_type_1;
774 RPNquery = p_query_rpn (out, protocol, arg);
777 printf("Prefix query error\n");
780 query.u.type_1 = RPNquery;
783 query.which = Z_Query_type_2;
784 query.u.type_2 = &ccl_query;
785 ccl_query.buf = (unsigned char*) arg;
786 ccl_query.len = strlen(arg);
789 case QueryType_CCL2RPN:
790 query.which = Z_Query_type_1;
791 assert((RPNquery = ccl_rpn_query(out, rpn)));
792 bib1.proto = protocol;
793 bib1.oclass = CLASS_ATTSET;
794 bib1.value = VAL_BIB1;
795 RPNquery->attributeSetId = oid_ent_to_oid(&bib1, oid);
796 query.u.type_1 = RPNquery;
797 ccl_rpn_delete (rpn);
801 printf ("Unsupported query type\n");
806 printf("Sent searchRequest.\n");
810 static int process_searchResponse(Z_SearchResponse *res)
812 printf ("Received SearchResponse.\n");
813 print_refid (res->referenceId);
814 if (*res->searchStatus)
815 printf("Search was a success.\n");
817 printf("Search was a bloomin' failure.\n");
818 printf("Number of hits: %d, setno %d\n",
819 *res->resultCount, setnumber);
820 printf("records returned: %d\n",
821 *res->numberOfRecordsReturned);
822 setno += *res->numberOfRecordsReturned;
824 display_records(res->records);
828 static void print_level(int iLevel)
831 for (i = 0; i < iLevel * 4; i++)
835 static void print_int(int iLevel, const char *pTag, int *pInt)
840 printf("%s: %d\n", pTag, *pInt);
844 static void print_string(int iLevel, const char *pTag, const char *pString)
849 printf("%s: %s\n", pTag, pString);
853 static void print_oid(int iLevel, const char *pTag, Odr_oid *pOid)
861 for (; *pInt != -1; pInt++)
862 printf(" %d", *pInt);
867 static void print_referenceId(int iLevel, Z_ReferenceId *referenceId)
869 if (referenceId != NULL)
874 printf("Ref Id (%d, %d): ", referenceId->len, referenceId->size);
875 for (i = 0; i < referenceId->len; i++)
876 printf("%c", referenceId->buf[i]);
881 static void print_string_or_numeric(int iLevel, const char *pTag, Z_StringOrNumeric *pStringNumeric)
883 if (pStringNumeric != NULL)
885 switch (pStringNumeric->which)
887 case Z_StringOrNumeric_string:
888 print_string(iLevel, pTag, pStringNumeric->u.string);
891 case Z_StringOrNumeric_numeric:
892 print_int(iLevel, pTag, pStringNumeric->u.numeric);
897 printf("%s: valid type for Z_StringOrNumeric\n", pTag);
903 static void print_universe_report_duplicate(int iLevel, Z_UniverseReportDuplicate *pUniverseReportDuplicate)
905 if (pUniverseReportDuplicate != NULL)
908 printf("Universe Report Duplicate: \n");
910 print_string_or_numeric(iLevel, "Hit No", pUniverseReportDuplicate->hitno);
914 static void print_universe_report_hits(int iLevel, Z_UniverseReportHits *pUniverseReportHits)
916 if (pUniverseReportHits != NULL)
919 printf("Universe Report Hits: \n");
921 print_string_or_numeric(iLevel, "Database", pUniverseReportHits->database);
922 print_string_or_numeric(iLevel, "Hits", pUniverseReportHits->hits);
926 static void print_universe_report(int iLevel, Z_UniverseReport *pUniverseReport)
928 if (pUniverseReport != NULL)
931 printf("Universe Report: \n");
933 print_int(iLevel, "Total Hits", pUniverseReport->totalHits);
934 switch (pUniverseReport->which)
936 case Z_UniverseReport_databaseHits:
937 print_universe_report_hits(iLevel, pUniverseReport->u.databaseHits);
940 case Z_UniverseReport_duplicate:
941 print_universe_report_duplicate(iLevel, pUniverseReport->u.duplicate);
946 printf("Type: %d\n", pUniverseReport->which);
952 static void print_external(int iLevel, Z_External *pExternal)
954 if (pExternal != NULL)
957 printf("External: \n");
959 print_oid(iLevel, "Direct Reference", pExternal->direct_reference);
960 print_int(iLevel, "InDirect Reference", pExternal->indirect_reference);
961 print_string(iLevel, "Descriptor", pExternal->descriptor);
962 switch (pExternal->which)
964 case Z_External_universeReport:
965 print_universe_report(iLevel, pExternal->u.universeReport);
970 printf("Type: %d\n", pExternal->which);
976 static int process_resourceControlRequest (Z_ResourceControlRequest *req)
978 printf ("Received ResourceControlRequest.\n");
979 print_referenceId(1, req->referenceId);
980 print_int(1, "Suspended Flag", req->suspendedFlag);
981 print_int(1, "Partial Results Available", req->partialResultsAvailable);
982 print_int(1, "Response Required", req->responseRequired);
983 print_int(1, "Triggered Request Flag", req->triggeredRequestFlag);
984 print_external(1, req->resourceReport);
988 void process_ESResponse(Z_ExtendedServicesResponse *res)
990 printf("process_ESResponse\n");
993 static Z_External *CreateItemOrderExternal(int itemno)
995 Z_External *r = odr_malloc(out, sizeof(Z_External));
996 oident ItemOrderRequest;
998 ItemOrderRequest.proto = PROTO_Z3950;
999 ItemOrderRequest.oclass = CLASS_EXTSERV;
1000 ItemOrderRequest.value = VAL_ITEMORDER;
1002 r->direct_reference = odr_oiddup(out,oid_getoidbyent(&ItemOrderRequest));
1003 r->indirect_reference = odr_malloc(out,sizeof(int));
1004 *r->indirect_reference = 0;
1006 r->descriptor = "Extended services item order";
1008 r->which = Z_External_itemOrder;
1010 r->u.itemOrder = odr_malloc(out,sizeof(Z_ItemOrder));
1011 memset(r->u.itemOrder, 0, sizeof(Z_ItemOrder));
1013 r->u.itemOrder->which=Z_IOItemOrder_esRequest;
1015 r->u.itemOrder->which=Z_ItemOrder_esRequest;
1018 r->u.itemOrder->u.esRequest = odr_malloc(out,sizeof(Z_IORequest));
1019 memset(r->u.itemOrder->u.esRequest, 0, sizeof(Z_IORequest));
1021 r->u.itemOrder->u.esRequest->toKeep = odr_malloc(out,sizeof(Z_IOOriginPartToKeep));
1022 memset(r->u.itemOrder->u.esRequest->toKeep, 0, sizeof(Z_IOOriginPartToKeep));
1023 r->u.itemOrder->u.esRequest->notToKeep = odr_malloc(out,sizeof(Z_IOOriginPartNotToKeep));
1024 memset(r->u.itemOrder->u.esRequest->notToKeep, 0, sizeof(Z_IOOriginPartNotToKeep));
1026 r->u.itemOrder->u.esRequest->toKeep->supplDescription = NULL;
1027 r->u.itemOrder->u.esRequest->toKeep->contact = NULL;
1028 r->u.itemOrder->u.esRequest->toKeep->addlBilling = NULL;
1030 r->u.itemOrder->u.esRequest->notToKeep->resultSetItem = odr_malloc(out, sizeof(Z_IOResultSetItem));
1031 memset(r->u.itemOrder->u.esRequest->notToKeep->resultSetItem, 0, sizeof(Z_IOResultSetItem));
1032 r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->resultSetId = "1";
1034 r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->item = odr_malloc(out, sizeof(int));
1035 *r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->item = itemno;
1037 r->u.itemOrder->u.esRequest->notToKeep->itemRequest = NULL;
1041 /* II : Added to do DALI Item Order Extended services request */
1042 static int send_itemorder(char *arg)
1045 Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest );
1046 Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
1047 oident ItemOrderRequest;
1052 /* Set up item order request */
1054 /* Function being performed by this extended services request */
1055 req->function = odr_malloc(out, sizeof(int));
1056 *req->function = Z_ExtendedServicesRequest_create;
1058 /* Package type, Using protocol ILL ( But that's not in the oid.h file yet */
1059 /* create an object of class Extended Service, value Item Order */
1060 ItemOrderRequest.proto = PROTO_Z3950;
1061 ItemOrderRequest.oclass = CLASS_EXTSERV;
1062 ItemOrderRequest.value = VAL_ITEMORDER;
1063 req->packageType = odr_oiddup(out,oid_getoidbyent(&ItemOrderRequest));
1064 req->packageName = "1.Extendedserveq";
1066 /* ** taskSpecificParameters ** */
1067 req->taskSpecificParameters = CreateItemOrderExternal(itemno);
1069 /* waitAction - Create the ILL request and that's it */
1070 *req->waitAction = Z_ExtendedServicesRequest_wait;
1076 /* II : Added to do DALI Item Order Extended services request */
1077 static int cmd_itemorder(char *arg)
1079 printf("Item order request\n");
1082 send_itemorder(arg);
1086 static int cmd_find(char *arg)
1090 printf("Find what?\n");
1095 printf("Not connected yet\n");
1098 if (!send_searchRequest(arg))
1103 static int cmd_ssub(char *arg)
1105 if (!(smallSetUpperBound = atoi(arg)))
1110 static int cmd_lslb(char *arg)
1112 if (!(largeSetLowerBound = atoi(arg)))
1117 static int cmd_mspn(char *arg)
1119 if (!(mediumSetPresentNumber = atoi(arg)))
1124 static int cmd_status(char *arg)
1126 printf("smallSetUpperBound: %d\n", smallSetUpperBound);
1127 printf("largeSetLowerBound: %d\n", largeSetLowerBound);
1128 printf("mediumSetPresentNumber: %d\n", mediumSetPresentNumber);
1132 static int cmd_base(char *arg)
1139 printf("Usage: base <database> <database> ...\n");
1142 for (i = 0; i<num_databaseNames; i++)
1143 xfree (databaseNames[i]);
1144 num_databaseNames = 0;
1147 if (!(cp = strchr(arg, ' ')))
1148 cp = arg + strlen(arg);
1151 databaseNames[num_databaseNames] = (char *)xmalloc (1 + cp - arg);
1152 memcpy (databaseNames[num_databaseNames], arg, cp - arg);
1153 databaseNames[num_databaseNames++][cp - arg] = '\0';
1161 static int cmd_setnames(char *arg)
1165 printf("Set numbering enabled.\n");
1170 printf("Set numbering disabled.\n");
1176 /* PRESENT SERVICE ----------------------------- */
1178 static int send_presentRequest(char *arg)
1180 Z_APDU *apdu = zget_APDU(out, Z_APDU_presentRequest);
1181 Z_PresentRequest *req = apdu->u.presentRequest;
1182 Z_RecordComposition compo;
1187 char setstring[100];
1189 req->referenceId = set_refid (out);
1190 if ((p = strchr(arg, '+')))
1197 if (p && (p=strchr(p+1, '+')))
1199 strcpy (setstring, p+1);
1200 req->resultSetId = setstring;
1202 else if (setnumber >= 0)
1204 sprintf(setstring, "%d", setnumber);
1205 req->resultSetId = setstring;
1210 static Z_Range range;
1211 static Z_Range *rangep = ⦥
1212 req->num_ranges = 1;
1214 req->resultSetStartPoint = &setno;
1215 req->numberOfRecordsRequested = &nos;
1216 prefsyn.proto = protocol;
1217 prefsyn.oclass = CLASS_RECSYN;
1218 prefsyn.value = recordsyntax;
1219 req->preferredRecordSyntax = oid_ent_to_oid(&prefsyn, oid);
1221 if (elementSetNames)
1223 req->recordComposition = &compo;
1224 compo.which = Z_RecordComp_simple;
1225 compo.u.simple = elementSetNames;
1228 printf("Sent presentRequest (%d+%d).\n", setno, nos);
1232 void process_close(Z_Close *req)
1234 Z_APDU *apdu = zget_APDU(out, Z_APDU_close);
1235 Z_Close *res = apdu->u.close;
1237 static char *reasons[] =
1242 "cost limit reached",
1244 "security violation",
1251 printf("Reason: %s, message: %s\n", reasons[*req->closeReason],
1252 req->diagnosticInformation ? req->diagnosticInformation : "NULL");
1255 printf("Goodbye.\n");
1258 *res->closeReason = Z_Close_finished;
1260 printf("Sent response.\n");
1264 static int cmd_show(char *arg)
1266 if (!send_presentRequest(arg))
1271 int cmd_quit(char *arg)
1273 printf("See you later, alligator.\n");
1278 int cmd_cancel(char *arg)
1280 Z_APDU *apdu = zget_APDU(out, Z_APDU_triggerResourceControlRequest);
1281 Z_TriggerResourceControlRequest *req =
1282 apdu->u.triggerResourceControlRequest;
1287 printf("Session not initialized yet\n");
1290 if (!ODR_MASK_GET(session->options, Z_Options_triggerResourceCtrl))
1292 printf("Target doesn't support cancel (trigger resource ctrl)\n");
1295 *req->requestedAction = Z_TriggerResourceCtrl_cancel;
1296 req->resultSetWanted = &rfalse;
1299 printf("Sent cancel request\n");
1303 int send_scanrequest(char *string, int pp, int num)
1305 Z_APDU *apdu = zget_APDU(out, Z_APDU_scanRequest);
1306 Z_ScanRequest *req = apdu->u.scanRequest;
1308 req->referenceId = set_refid (out);
1309 req->num_databaseNames = num_databaseNames;
1310 req->databaseNames = databaseNames;
1311 req->termListAndStartPoint = p_query_scan(out, protocol,
1312 &req->attributeSet, string);
1313 req->numberOfTermsRequested = #
1314 req->preferredPositionInResponse = &pp;
1319 int send_sortrequest(char *arg, int newset)
1321 Z_APDU *apdu = zget_APDU(out, Z_APDU_sortRequest);
1322 Z_SortRequest *req = apdu->u.sortRequest;
1323 Z_SortKeySpecList *sksl = (Z_SortKeySpecList *)odr_malloc (out, sizeof(*sksl));
1325 char sort_string[32], sort_flags[32];
1331 sprintf (setstring, "%d", setnumber);
1333 sprintf (setstring, "default");
1335 req->referenceId = set_refid (out);
1338 req->num_inputResultSetNames = 1;
1339 req->inputResultSetNames = (Z_InternationalString **)
1340 odr_malloc (out, sizeof(*req->inputResultSetNames));
1341 req->inputResultSetNames[0] = (char *)
1342 odr_malloc (out, strlen(setstring)+1);
1343 strcpy (req->inputResultSetNames[0], setstring);
1345 req->inputResultSetNames =
1346 (Z_StringList *)odr_malloc (out, sizeof(*req->inputResultSetNames));
1347 req->inputResultSetNames->num_strings = 1;
1348 req->inputResultSetNames->strings =
1349 (char **)odr_malloc (out, sizeof(*req->inputResultSetNames->strings));
1350 req->inputResultSetNames->strings[0] =
1351 (char *)odr_malloc (out, strlen(setstring)+1);
1352 strcpy (req->inputResultSetNames->strings[0], setstring);
1355 if (newset && setnumber >= 0)
1356 sprintf (setstring, "%d", ++setnumber);
1358 req->sortedResultSetName = (char *)odr_malloc (out, strlen(setstring)+1);
1359 strcpy (req->sortedResultSetName, setstring);
1361 req->sortSequence = sksl;
1362 sksl->num_specs = 0;
1363 sksl->specs = (Z_SortKeySpec **)odr_malloc (out, sizeof(sksl->specs) * 20);
1365 bib1.proto = protocol;
1366 bib1.oclass = CLASS_ATTSET;
1367 bib1.value = VAL_BIB1;
1368 while ((sscanf (arg, "%31s %31s%n", sort_string, sort_flags, &off)) == 2
1372 char *sort_string_sep;
1373 Z_SortKeySpec *sks = (Z_SortKeySpec *)odr_malloc (out, sizeof(*sks));
1374 Z_SortKey *sk = (Z_SortKey *)odr_malloc (out, sizeof(*sk));
1377 sksl->specs[sksl->num_specs++] = sks;
1378 sks->sortElement = (Z_SortElement *)odr_malloc (out, sizeof(*sks->sortElement));
1379 sks->sortElement->which = Z_SortElement_generic;
1380 sks->sortElement->u.generic = sk;
1382 if ((sort_string_sep = strchr (sort_string, '=')))
1384 Z_AttributeElement *el = (Z_AttributeElement *)odr_malloc (out, sizeof(*el));
1385 sk->which = Z_SortKey_sortAttributes;
1386 sk->u.sortAttributes =
1387 (Z_SortAttributes *)odr_malloc (out, sizeof(*sk->u.sortAttributes));
1388 sk->u.sortAttributes->id = oid_ent_to_oid(&bib1, oid);
1389 sk->u.sortAttributes->list =
1390 (Z_AttributeList *)odr_malloc (out, sizeof(*sk->u.sortAttributes->list));
1391 sk->u.sortAttributes->list->num_attributes = 1;
1392 sk->u.sortAttributes->list->attributes =
1393 (Z_AttributeElement **)odr_malloc (out,
1394 sizeof(*sk->u.sortAttributes->list->attributes));
1395 sk->u.sortAttributes->list->attributes[0] = el;
1396 el->attributeSet = 0;
1397 el->attributeType = (int *)odr_malloc (out, sizeof(*el->attributeType));
1398 *el->attributeType = atoi (sort_string);
1399 el->which = Z_AttributeValue_numeric;
1400 el->value.numeric = (int *)odr_malloc (out, sizeof(*el->value.numeric));
1401 *el->value.numeric = atoi (sort_string_sep + 1);
1405 sk->which = Z_SortKey_sortField;
1406 sk->u.sortField = (char *)odr_malloc (out, strlen(sort_string)+1);
1407 strcpy (sk->u.sortField, sort_string);
1409 sks->sortRelation = (int *)odr_malloc (out, sizeof(*sks->sortRelation));
1410 *sks->sortRelation = Z_SortRelation_ascending;
1411 sks->caseSensitivity = (int *)odr_malloc (out, sizeof(*sks->caseSensitivity));
1412 *sks->caseSensitivity = Z_SortCase_caseSensitive;
1415 sks->which = Z_SortKeySpec_null;
1416 sks->u.null = odr_nullval ();
1418 sks->missingValueAction = NULL;
1421 for (i = 0; sort_flags[i]; i++)
1423 switch (sort_flags[i])
1428 *sks->sortRelation = Z_SortRelation_ascending;
1433 *sks->sortRelation = Z_SortRelation_descending;
1437 *sks->caseSensitivity = Z_SortCase_caseInsensitive;
1441 *sks->caseSensitivity = Z_SortCase_caseSensitive;
1446 if (!sksl->num_specs)
1448 printf ("Missing sort specifications\n");
1455 void display_term(Z_TermInfo *t)
1457 if (t->term->which == Z_Term_general)
1459 printf("%.*s (%d)\n", t->term->u.general->len, t->term->u.general->buf,
1460 t->globalOccurrences ? *t->globalOccurrences : -1);
1461 sprintf(last_scan, "%.*s", t->term->u.general->len,
1462 t->term->u.general->buf);
1465 printf("Term type not general.\n");
1468 void process_scanResponse(Z_ScanResponse *res)
1471 Z_Entry **entries = NULL;
1472 int num_entries = 0;
1474 printf("Received ScanResponse\n");
1475 print_refid (res->referenceId);
1476 printf("%d entries", *res->numberOfEntriesReturned);
1477 if (res->positionOfTerm)
1478 printf (", position=%d", *res->positionOfTerm);
1480 if (*res->scanStatus != Z_Scan_success)
1481 printf("Scan returned code %d\n", *res->scanStatus);
1485 if ((entries = res->entries->entries))
1486 num_entries = res->entries->num_entries;
1488 if (res->entries->which == Z_ListEntries_entries)
1490 entries = res->entries->u.entries->entries;
1491 num_entries = res->entries->u.entries->num_entries;
1494 for (i = 0; i < num_entries; i++)
1495 if (entries[i]->which == Z_Entry_termInfo)
1497 printf("%c ", i + 1 == *res->positionOfTerm ? '*' : ' ');
1498 display_term(entries[i]->u.termInfo);
1501 display_diagrecs(&entries[i]->u.surrogateDiagnostic, 1);
1503 if (res->entries->nonsurrogateDiagnostics)
1504 display_diagrecs (res->entries->nonsurrogateDiagnostics,
1505 res->entries->num_nonsurrogateDiagnostics);
1507 if (res->entries->which == Z_ListEntries_nonSurrogateDiagnostics)
1508 display_diagrecs(&res->entries->
1509 u.nonSurrogateDiagnostics->diagRecs[0], 1);
1513 void process_sortResponse(Z_SortResponse *res)
1515 printf("Received SortResponse: status=");
1516 switch (*res->sortStatus)
1518 case Z_SortStatus_success:
1519 printf ("success"); break;
1520 case Z_SortStatus_partial_1:
1521 printf ("partial"); break;
1522 case Z_SortStatus_failure:
1523 printf ("failure"); break;
1525 printf ("unknown (%d)", *res->sortStatus);
1528 print_refid (res->referenceId);
1530 if (res->diagnostics)
1531 display_diagrecs(res->diagnostics,
1532 res->num_diagnostics);
1534 if (res->diagnostics)
1535 display_diagrecs(res->diagnostics->diagRecs,
1536 res->diagnostics->num_diagRecs);
1540 int cmd_sort_generic(char *arg, int newset)
1544 printf("Session not initialized yet\n");
1547 if (!ODR_MASK_GET(session->options, Z_Options_sort))
1549 printf("Target doesn't support sort\n");
1554 if (send_sortrequest(arg, newset) < 0)
1561 int cmd_sort(char *arg)
1563 return cmd_sort_generic (arg, 0);
1566 int cmd_sort_newset (char *arg)
1568 return cmd_sort_generic (arg, 1);
1571 int cmd_scan(char *arg)
1575 printf("Session not initialized yet\n");
1578 if (!ODR_MASK_GET(session->options, Z_Options_scan))
1580 printf("Target doesn't support scan\n");
1585 if (send_scanrequest(arg, 5, 20) < 0)
1589 if (send_scanrequest(last_scan, 1, 20) < 0)
1594 int cmd_format(char *arg)
1598 printf("Usage: format <recordsyntax>\n");
1601 recordsyntax = oid_getvalbyname (arg);
1602 if (recordsyntax == VAL_NONE)
1604 printf ("unknown record syntax\n");
1610 int cmd_elements(char *arg)
1612 static Z_ElementSetNames esn;
1613 static char what[100];
1617 printf("Usage: elements <esn>\n");
1621 esn.which = Z_ElementSetNames_generic;
1622 esn.u.generic = what;
1623 elementSetNames = &esn;
1627 int cmd_attributeset(char *arg)
1633 printf("Usage: attributeset <setname>\n");
1636 sscanf(arg, "%s", what);
1637 if (p_query_attset (what))
1639 printf("Unknown attribute set name\n");
1645 int cmd_querytype (char *arg)
1647 if (!strcmp (arg, "ccl"))
1648 queryType = QueryType_CCL;
1649 else if (!strcmp (arg, "prefix"))
1650 queryType = QueryType_Prefix;
1652 else if (!strcmp (arg, "ccl2rpn") || !strcmp (arg, "cclrpn"))
1653 queryType = QueryType_CCL2RPN;
1657 printf ("Querytype must be one of:\n");
1658 printf (" prefix - Prefix query\n");
1659 printf (" ccl - CCL query\n");
1661 printf (" ccl2rpn - CCL query converted to RPN\n");
1668 int cmd_refid (char *arg)
1674 refid = (char *) xmalloc (strlen(arg)+1);
1675 strcpy (refid, arg);
1680 int cmd_close(char *arg)
1682 Z_APDU *apdu = zget_APDU(out, Z_APDU_close);
1683 Z_Close *req = apdu->u.close;
1685 *req->closeReason = Z_Close_finished;
1687 printf("Sent close request.\n");
1692 static void initialize(void)
1698 if (!(out = odr_createmem(ODR_ENCODE)) ||
1699 !(in = odr_createmem(ODR_DECODE)) ||
1700 !(print = odr_createmem(ODR_PRINT)))
1702 fprintf(stderr, "failed to allocate ODR streams\n");
1705 setvbuf(stdout, 0, _IONBF, 0);
1708 bibset = ccl_qual_mk ();
1709 inf = fopen ("default.bib", "r");
1712 ccl_qual_file (bibset, inf);
1718 static int client(int wait)
1722 int (*fun)(char *arg);
1725 {"open", cmd_open, "('tcp'|'osi')':'[<tsel>'/']<host>[':'<port>]"},
1726 {"quit", cmd_quit, ""},
1727 {"find", cmd_find, "<query>"},
1728 {"base", cmd_base, "<base-name>"},
1729 {"show", cmd_show, "<rec#>['+'<#recs>['+'<setname>]]"},
1730 {"scan", cmd_scan, "<term>"},
1731 {"sort", cmd_sort, "<sortkey> <flag> <sortkey> <flag> ..."},
1732 {"sort+", cmd_sort_newset, "<sortkey> <flag> <sortkey> <flag> ..."},
1733 {"authentication", cmd_authentication, "<acctstring>"},
1734 {"lslb", cmd_lslb, "<largeSetLowerBound>"},
1735 {"ssub", cmd_ssub, "<smallSetUpperBound>"},
1736 {"mspn", cmd_mspn, "<mediumSetPresentNumber>"},
1737 {"status", cmd_status, ""},
1738 {"setnames", cmd_setnames, ""},
1739 {"cancel", cmd_cancel, ""},
1740 {"format", cmd_format, "<recordsyntax>"},
1741 {"elements", cmd_elements, "<elementSetName>"},
1742 {"close", cmd_close, ""},
1743 {"attributeset", cmd_attributeset, "<attrset>"},
1744 {"querytype", cmd_querytype, "<type>"},
1745 {"refid", cmd_refid, "<id>"},
1746 {"itemorder", cmd_itemorder, "<item>"},
1750 int netbufferlen = 0;
1760 char line[1024], word[1024], arg[1024];
1766 FD_SET(cs_fileno(conn), &input);
1767 if ((res = select(20, &input, 0, 0, 0)) < 0)
1774 if (!wait && FD_ISSET(0, &input))
1779 /* quick & dirty way to get a command line. */
1781 if (!fgets(line, 1023, stdin))
1783 if ((end_p = strchr (line, '\n')))
1785 if ((res = sscanf(line, "%s %[^;]", word, arg)) <= 0)
1787 strcpy(word, last_cmd);
1792 strcpy(last_cmd, word);
1793 for (i = 0; cmd[i].cmd; i++)
1794 if (!strncmp(cmd[i].cmd, word, strlen(word)))
1796 res = (*cmd[i].fun)(arg);
1799 if (!cmd[i].cmd) /* dump our help-screen */
1801 printf("Unknown command: %s.\n", word);
1802 printf("Currently recognized commands:\n");
1803 for (i = 0; cmd[i].cmd; i++)
1804 printf(" %s %s\n", cmd[i].cmd, cmd[i].ad);
1815 if (conn && FD_ISSET(cs_fileno(conn), &input))
1820 if ((res = cs_get(conn, &netbuffer, &netbufferlen)) < 0)
1827 printf("Target closed connection.\n");
1830 odr_reset(in); /* release APDU from last round */
1831 odr_setbuf(in, netbuffer, res, 0);
1832 if (!z_APDU(in, &apdu, 0))
1834 odr_perror(in, "Decoding incoming APDU");
1835 fprintf(stderr, "[Near %d]\n", odr_offset(in));
1836 fprintf(stderr, "Packet dump:\n---------\n");
1837 odr_dumpBER(stderr, netbuffer, res);
1838 fprintf(stderr, "---------\n");
1842 if (!z_APDU(print, &apdu, 0))
1844 odr_perror(print, "Failed to print incoming APDU");
1851 case Z_APDU_initResponse:
1852 process_initResponse(apdu->u.initResponse);
1854 case Z_APDU_searchResponse:
1855 process_searchResponse(apdu->u.searchResponse);
1857 case Z_APDU_scanResponse:
1858 process_scanResponse(apdu->u.scanResponse);
1860 case Z_APDU_presentResponse:
1861 print_refid (apdu->u.presentResponse->referenceId);
1863 *apdu->u.presentResponse->numberOfRecordsReturned;
1864 if (apdu->u.presentResponse->records)
1865 display_records(apdu->u.presentResponse->records);
1867 printf("No records.\n");
1869 case Z_APDU_sortResponse:
1870 process_sortResponse(apdu->u.sortResponse);
1872 case Z_APDU_extendedServicesResponse:
1873 printf("Got extended services response\n");
1874 process_ESResponse(apdu->u.extendedServicesResponse);
1877 printf("Target has closed the association.\n");
1878 process_close(apdu->u.close);
1880 case Z_APDU_resourceControlRequest:
1881 process_resourceControlRequest
1882 (apdu->u.resourceControlRequest);
1885 printf("Received unknown APDU type (%d).\n",
1890 while (cs_more(conn));
1898 int main(int argc, char **argv)
1906 cmd_base("Default");
1908 while ((ret = options("m:", argv, argc, &arg)) != -2)
1913 if (cmd_open (arg) == 2)
1917 if (!(marcdump = fopen (arg, "a")))
1924 fprintf (stderr, "Usage: %s [-m <marclog>] [<server-addr>]\n",
1931 return client (opened);