2 * Copyright (c) 1995, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.28 1995-12-14 11:09:31 quinn
8 * Added Explain record syntax to the format command.
10 * Revision 1.27 1995/12/12 16:37:02 quinn
11 * Added destroy element to data1_node.
13 * Revision 1.26 1995/12/12 14:11:00 quinn
16 * Revision 1.25 1995/11/13 09:27:22 quinn
17 * Fiddling with the variant stuff.
19 * Revision 1.24 1995/10/30 12:41:13 quinn
20 * Added hostname lookup for server.
22 * Revision 1.23 1995/10/18 16:12:30 quinn
25 * Revision 1.22 1995/10/11 14:49:12 quinn
28 * Revision 1.21 1995/09/29 17:01:47 quinn
31 * Revision 1.20 1995/08/29 14:24:13 quinn
32 * Added second half of close-handshake
34 * Revision 1.19 1995/08/29 11:17:28 quinn
35 * Added code to receive close
37 * Revision 1.18 1995/08/28 12:21:27 quinn
38 * Client can now ask for simple element set names.
40 * Revision 1.17 1995/08/17 12:45:02 quinn
41 * Fixed minor problems with GRS-1. Added support in c&s.
43 * Revision 1.16 1995/08/15 12:00:04 quinn
46 * Revision 1.15 1995/06/22 09:28:03 quinn
47 * Fixed bug in SUTRS processing.
49 * Revision 1.14 1995/06/19 12:37:41 quinn
52 * Revision 1.13 1995/06/16 10:29:11 quinn
53 * *** empty log message ***
55 * Revision 1.12 1995/06/15 07:44:57 quinn
58 * Revision 1.11 1995/06/14 15:26:40 quinn
59 * *** empty log message ***
61 * Revision 1.10 1995/06/06 14:56:58 quinn
64 * Revision 1.9 1995/06/06 08:15:19 quinn
67 * Revision 1.8 1995/06/05 10:52:22 quinn
70 * Revision 1.7 1995/06/02 09:50:09 quinn
73 * Revision 1.6 1995/05/31 08:29:21 quinn
74 * Nothing significant.
76 * Revision 1.5 1995/05/29 08:10:47 quinn
77 * Moved oid.c to util.
79 * Revision 1.4 1995/05/22 15:30:13 adam
80 * Client uses prefix query notation.
82 * Revision 1.3 1995/05/22 15:06:53 quinn
83 * *** empty log message ***
85 * Revision 1.2 1995/05/22 14:56:40 quinn
86 * *** empty log message ***
88 * Revision 1.1 1995/05/22 11:30:31 quinn
89 * Added prettier client.
95 * This is the obligatory little toy client, whose primary purpose is
96 * to illustrate the use of the YAZ service-level API.
104 #include <sys/time.h>
108 #include <sys/select.h>
111 #include <comstack.h>
118 #include <marcdisp.h>
119 #include <diagbib1.h>
129 #define C_PROMPT "Z> "
131 static ODR out, in, print; /* encoding and decoding streams */
132 static COMSTACK conn = 0; /* our z-association */
133 static Z_IdAuthentication *auth = 0; /* our current auth definition */
134 static char database[512] = "Default"; /* Database name */
135 static int setnumber = 0; /* current result set number */
136 static int smallSetUpperBound = 0;
137 static int largeSetLowerBound = 1;
138 static int mediumSetPresentNumber = 0;
139 static Z_ElementSetNames *elementSetNames = 0;
140 static int setno = 1; /* current set offset */
141 static int protocol = PROTO_Z3950; /* current app protocol */
142 static int recordsyntax = VAL_USMARC;
143 static int sent_close = 0;
144 static ODR_MEM session_mem; /* memory handle for init-response */
145 static Z_InitResponse *session = 0; /* session parameters */
146 static char last_scan[512] = "0";
147 static char last_cmd[100] = "?";
150 static CCL_bibset bibset; /* CCL bibset handle */
154 static void send_apdu(Z_APDU *a)
159 if (!z_APDU(out, &a, 0))
161 odr_perror(out, "Encoding APDU");
164 buf = odr_getbuf(out, &len, 0);
165 odr_reset(out); /* release the APDU */
166 if (cs_put(conn, buf, len) < 0)
168 fprintf(stderr, "cs_put: %s", cs_errmsg(cs_errno(conn)));
173 /* INIT SERVICE ------------------------------- */
175 static void send_initRequest()
177 Z_APDU *apdu = zget_APDU(out, Z_APDU_initRequest);
178 Z_InitRequest *req = apdu->u.initRequest;
180 ODR_MASK_SET(req->options, Z_Options_search);
181 ODR_MASK_SET(req->options, Z_Options_present);
182 ODR_MASK_SET(req->options, Z_Options_namedResultSets);
183 ODR_MASK_SET(req->options, Z_Options_triggerResourceCtrl);
184 ODR_MASK_SET(req->options, Z_Options_scan);
186 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1);
187 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2);
188 ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3);
190 *req->maximumRecordSize = 1024*1024;
192 req->idAuthentication = auth;
195 printf("Sent initrequest.\n");
198 static int process_initResponse(Z_InitResponse *res)
200 /* save session parameters for later use */
201 session_mem = odr_extract_mem(in);
205 printf("Connection rejected by target.\n");
207 printf("Connection accepted by target.\n");
208 if (res->implementationId)
209 printf("ID : %s\n", res->implementationId);
210 if (res->implementationName)
211 printf("Name : %s\n", res->implementationName);
212 if (res->implementationVersion)
213 printf("Version: %s\n", res->implementationVersion);
214 if (res->userInformationField)
216 printf("UserInformationfield:\n");
217 if (!z_External(print, (Z_External**)&res-> userInformationField,
220 odr_perror(print, "Printing userinfo\n");
223 if (res->userInformationField->which == Z_External_octet)
225 printf("Guessing visiblestring:\n");
226 printf("'%s'\n", res->userInformationField->u. octet_aligned->buf);
232 int cmd_open(char *arg)
235 char type[100], addr[100];
240 printf("Already connected.\n");
243 if (!*arg || sscanf(arg, "%[^:]:%s", type, addr) < 2)
245 fprintf(stderr, "Usage: open (osi|tcp) ':' [tsel '/']host[':'port]\n");
249 if (!strcmp(type, "osi"))
251 if (!(add = mosi_strtoaddr(addr)))
261 if (!strcmp(type, "tcp"))
263 if (!(add = tcpip_strtoaddr(addr)))
269 protocol = PROTO_Z3950;
273 fprintf(stderr, "Bad type: %s\n", type);
276 if (!(conn = cs_create(t, 1, protocol)))
281 printf("Connecting...");
283 if (cs_connect(conn, add) < 0)
295 int cmd_authentication(char *arg)
297 static Z_IdAuthentication au;
298 static char open[256];
302 printf("Auth field set to null\n");
307 au.which = Z_IdAuthentication_open;
313 /* SEARCH SERVICE ------------------------------ */
315 static void display_variant(Z_Variant *v, int level)
319 for (i = 0; i < v->num_triples; i++)
321 printf("%*sclass=%d,type=%d", level * 4, "", *v->triples[i]->class,
322 *v->triples[i]->type);
323 if (v->triples[i]->which == Z_Triple_internationalString)
324 printf(",value=%s\n", v->triples[i]->value.internationalString);
330 static void display_grs1(Z_GenericRecord *r, int level)
336 for (i = 0; i < r->num_elements; i++)
340 printf("%*s", level * 4, "");
344 printf("%d,", *t->tagType);
347 if (t->tagValue->which == Z_StringOrNumeric_numeric)
348 printf("%d) ", *t->tagValue->u.numeric);
350 printf("%s) ", t->tagValue->u.string);
351 if (t->content->which == Z_ElementData_subtree)
354 display_grs1(t->content->u.subtree, level+1);
356 else if (t->content->which == Z_ElementData_string)
357 printf("%s\n", t->content->u.string);
358 else if (t->content->which == Z_ElementData_numeric)
359 printf("%d\n", *t->content->u.numeric);
360 else if (t->content->which == Z_ElementData_noDataRequested)
361 printf("[No data requested]\n");
362 else if (t->content->which == Z_ElementData_elementEmpty)
363 printf("[Element empty]\n");
364 else if (t->content->which == Z_ElementData_elementNotThere)
365 printf("[Element not there]\n");
368 if (t->appliedVariant)
369 display_variant(t->appliedVariant, level+1);
370 if (t->metaData && t->metaData->supportedVariants)
374 printf("%*s---- variant list\n", (level+1)*4, "");
375 for (c = 0; c < t->metaData->num_supportedVariants; c++)
377 printf("%*svariant #%d\n", (level+1)*4, "", c);
378 display_variant(t->metaData->supportedVariants[c], level + 2);
384 static void display_record(Z_DatabaseRecord *p)
386 Z_External *r = (Z_External*) p;
387 oident *ent = oid_getentbyoid(r->direct_reference);
389 if (r->direct_reference)
391 printf("Record type: ");
393 printf("%s\n", ent->desc);
394 else if (!odr_oid(print, &r->direct_reference, 0))
396 odr_perror(print, "print oid");
400 if (r->which == Z_External_octet && p->u.octet_aligned->len)
401 marc_display ((char*)p->u.octet_aligned->buf, stdout);
402 else if (ent->value == VAL_SUTRS)
404 if (r->which != Z_External_sutrs)
406 printf("Expecting single SUTRS type for SUTRS.\n");
409 printf("%.*s", r->u.sutrs->len, r->u.sutrs->buf);
411 else if (ent->value == VAL_GRS1)
413 if (r->which != Z_External_grs1)
415 printf("Expecting single GRS type for GRS.\n");
418 display_grs1(r->u.grs1, 0);
422 printf("Unknown record representation.\n");
423 if (!z_External(print, &r, 0))
425 odr_perror(print, "Printing external");
431 static void display_diagrec(Z_DiagRec *p)
435 Z_DefaultDiagFormat *r;
440 printf("Diagnostic message from database:\n");
442 if (p->which != Z_DiagRec_defaultFormat)
444 printf("Diagnostic record not in default format.\n");
448 r = p->u.defaultFormat;
450 if (!(ent = oid_getentbyoid(r->diagnosticSetId)) ||
451 ent->class != CLASS_DIAGSET || ent->value != VAL_BIB1)
452 printf("Missing or unknown diagset\n");
453 printf(" [%d] %s", *r->condition, diagbib1_str(*r->condition));
454 if (r->addinfo && *r->addinfo)
455 printf(" -- %s\n", r->addinfo);
460 static void display_nameplusrecord(Z_NamePlusRecord *p)
463 printf("[%s]", p->databaseName);
464 if (p->which == Z_NamePlusRecord_surrogateDiagnostic)
465 display_diagrec(p->u.surrogateDiagnostic);
467 display_record(p->u.databaseRecord);
470 static void display_records(Z_Records *p)
474 if (p->which == Z_Records_NSD)
475 display_diagrec(p->u.nonSurrogateDiagnostic);
478 printf("Records: %d\n", p->u.databaseOrSurDiagnostics->num_records);
479 for (i = 0; i < p->u.databaseOrSurDiagnostics->num_records; i++)
480 display_nameplusrecord(p->u.databaseOrSurDiagnostics->records[i]);
484 static int send_searchRequest(char *arg)
486 Z_APDU *apdu = zget_APDU(out, Z_APDU_searchRequest);
487 Z_SearchRequest *req = apdu->u.searchRequest;
488 char *databaseNames = database;
492 struct ccl_rpn_node *rpn;
498 Z_RPNQuery *RPNquery;
506 rpn = ccl_find_str(bibset, arg, &error, &pos);
509 printf("CCL ERROR: %s\n", ccl_err_msg(error));
515 if (!strcmp(arg, "@big")) /* strictly for troublemaking */
517 static unsigned char big[2100];
520 /* send a very big referenceid to test transport stack etc. */
521 memset(big, 'A', 2100);
522 bigo.len = bigo.size = 2100;
524 req->referenceId = &bigo;
529 sprintf(setstring, "%d", ++setnumber);
530 req->resultSetName = setstring;
532 *req->smallSetUpperBound = smallSetUpperBound;
533 *req->largeSetLowerBound = largeSetLowerBound;
534 *req->mediumSetPresentNumber = mediumSetPresentNumber;
535 if (smallSetUpperBound > 0 || (largeSetLowerBound > 1 &&
536 mediumSetPresentNumber > 0))
540 prefsyn.proto = protocol;
541 prefsyn.class = CLASS_RECSYN;
542 prefsyn.value = recordsyntax;
543 req->preferredRecordSyntax = odr_oiddup(out, oid_getoidbyent(&prefsyn));
544 req->smallSetElementSetNames =
545 req->mediumSetElementSetNames = elementSetNames;
547 req->num_databaseNames = 1;
548 req->databaseNames = &databaseNames;
553 query.which = Z_Query_type_1;
556 assert((RPNquery = ccl_rpn_query(rpn)));
558 RPNquery = p_query_rpn (out, arg);
561 printf("Prefix query error\n");
565 bib1.proto = protocol;
566 bib1.class = CLASS_ATTSET;
567 bib1.value = VAL_BIB1;
568 RPNquery->attributeSetId = oid_getoidbyent(&bib1);
569 query.u.type_1 = RPNquery;
571 query.which = Z_Query_type_2;
572 query.u.type_2 = &ccl_query;
573 ccl_query.buf = (unsigned char*) arg;
574 ccl_query.len = strlen(arg);
579 printf("Sent searchRequest.\n");
583 static int process_searchResponse(Z_SearchResponse *res)
585 if (*res->searchStatus)
586 printf("Search was a success.\n");
588 printf("Search was a bloomin' failure.\n");
589 printf("Number of hits: %d, setno %d\n",
590 *res->resultCount, setnumber);
591 printf("records returned: %d\n",
592 *res->numberOfRecordsReturned);
593 setno += *res->numberOfRecordsReturned;
595 display_records(res->records);
599 static int cmd_find(char *arg)
603 printf("Find what?\n");
608 printf("Not connected yet\n");
611 if (!send_searchRequest(arg))
616 static int cmd_ssub(char *arg)
618 if (!(smallSetUpperBound = atoi(arg)))
623 static int cmd_lslb(char *arg)
625 if (!(largeSetLowerBound = atoi(arg)))
630 static int cmd_mspn(char *arg)
632 if (!(mediumSetPresentNumber = atoi(arg)))
637 static int cmd_status(char *arg)
639 printf("smallSetUpperBound: %d\n", smallSetUpperBound);
640 printf("largeSetLowerBound: %d\n", largeSetLowerBound);
641 printf("mediumSetPresentNumber: %d\n", mediumSetPresentNumber);
645 static int cmd_base(char *arg)
649 printf("Usage: base <database>\n");
652 strcpy(database, arg);
656 static int cmd_setnames(char *arg)
660 printf("Set numbering enabled.\n");
665 printf("Set numbering disabled.\n");
671 /* PRESENT SERVICE ----------------------------- */
673 static int send_presentRequest(char *arg)
675 Z_APDU *apdu = zget_APDU(out, Z_APDU_presentRequest);
676 Z_PresentRequest *req = apdu->u.presentRequest;
677 Z_RecordComposition compo;
683 if ((p = strchr(arg, '+')))
693 sprintf(setstring, "%d", setnumber);
694 req->resultSetId = setstring;
696 req->resultSetStartPoint = &setno;
697 req->numberOfRecordsRequested = &nos;
698 prefsyn.proto = protocol;
699 prefsyn.class = CLASS_RECSYN;
700 prefsyn.value = recordsyntax;
701 req->preferredRecordSyntax = oid_getoidbyent(&prefsyn);
704 req->recordComposition = &compo;
705 compo.which = Z_RecordComp_simple;
706 compo.u.simple = elementSetNames;
709 printf("Sent presentRequest (%d+%d).\n", setno, nos);
713 void process_close(Z_Close *req)
715 Z_APDU *apdu = zget_APDU(out, Z_APDU_close);
716 Z_Close *res = apdu->u.close;
718 static char *reasons[] =
723 "cost limit reached",
725 "security violation",
732 printf("Reason: %s, message: %s\n", reasons[*req->closeReason],
733 req->diagnosticInformation ? req->diagnosticInformation : "NULL");
736 printf("Goodbye.\n");
739 *res->closeReason = Z_Close_finished;
741 printf("Sent response.\n");
745 static int cmd_show(char *arg)
747 if (!send_presentRequest(arg))
752 int cmd_quit(char *arg)
754 printf("See you later, alligator.\n");
758 int cmd_cancel(char *arg)
760 Z_APDU *apdu = zget_APDU(out, Z_APDU_triggerResourceControlRequest);
761 Z_TriggerResourceControlRequest *req =
762 apdu->u.triggerResourceControlRequest;
767 printf("Session not initialized yet\n");
770 if (!ODR_MASK_GET(session->options, Z_Options_triggerResourceCtrl))
772 printf("Target doesn't support cancel (trigger resource ctrl)\n");
775 *req->requestedAction = Z_TriggerResourceCtrl_cancel;
776 req->resultSetWanted = &false;
779 printf("Sent cancel request\n");
783 int send_scanrequest(char *string, int pp, int num)
785 Z_APDU *apdu = zget_APDU(out, Z_APDU_scanRequest);
786 Z_ScanRequest *req = apdu->u.scanRequest;
790 req->num_databaseNames = 1;
791 req->databaseNames = &db;
792 attset.proto = protocol;
793 attset.class = CLASS_ATTSET;
794 attset.value = VAL_BIB1;
795 req->attributeSet = oid_getoidbyent(&attset);
796 req->termListAndStartPoint = p_query_scan(out, string);
797 req->numberOfTermsRequested = #
798 req->preferredPositionInResponse = &pp;
803 void display_term(Z_TermInfo *t)
805 if (t->term->which == Z_Term_general)
807 printf("%.*s (%d)\n", t->term->u.general->len, t->term->u.general->buf,
808 t->globalOccurrences ? *t->globalOccurrences : -1);
809 sprintf(last_scan, "%.*s", t->term->u.general->len,
810 t->term->u.general->buf);
813 printf("Term type not general.\n");
816 void process_scanResponse(Z_ScanResponse *res)
820 printf("SCAN: %d entries, position=%d\n", *res->numberOfEntriesReturned,
821 *res->positionOfTerm);
822 if (*res->scanStatus != Z_Scan_success)
823 printf("Scan returned code %d\n", *res->scanStatus);
826 if (res->entries->which == Z_ListEntries_entries)
828 Z_Entries *ent = res->entries->u.entries;
830 for (i = 0; i < ent->num_entries; i++)
831 if (ent->entries[i]->which == Z_Entry_termInfo)
833 printf("%c ", i + 1 == *res->positionOfTerm ? '*' : ' ');
834 display_term(ent->entries[i]->u.termInfo);
837 display_diagrec(ent->entries[i]->u.surrogateDiagnostic);
840 display_diagrec(res->entries->u.nonSurrogateDiagnostics->diagRecs[0]);
843 int cmd_scan(char *arg)
847 printf("Session not initialized yet\n");
850 if (!ODR_MASK_GET(session->options, Z_Options_scan))
852 printf("Target doesn't support scan\n");
857 if (send_scanrequest(arg, 5, 20) < 0)
861 if (send_scanrequest(last_scan, 1, 20) < 0)
866 int cmd_format(char *arg)
870 printf("Usage: format <recordsyntax>\n");
873 if (!strcmp(arg, "sutrs"))
875 printf("Preferred format is SUTRS.\n");
876 recordsyntax = VAL_SUTRS;
879 else if (!strcmp(arg, "usmarc"))
881 printf("Preferred format is USMARC\n");
882 recordsyntax = VAL_USMARC;
885 else if (!strcmp(arg, "danmarc"))
887 printf("Preferred format is DANMARC\n");
888 recordsyntax = VAL_DANMARC;
891 else if (!strcmp(arg, "grs1"))
893 printf("Preferred format is GRS1\n");
894 recordsyntax = VAL_GRS1;
897 else if (!strcmp(arg, "explain"))
899 printf("Preferred format is Explain\n");
900 recordsyntax = VAL_EXPLAIN;
905 printf("Specify one of {sutrs,usmarc,danmarc,grs1}.\n");
910 int cmd_elements(char *arg)
912 static Z_ElementSetNames esn;
913 static char what[100];
917 printf("Usage: elements <esn>\n");
921 esn.which = Z_ElementSetNames_generic;
922 esn.u.generic = what;
923 elementSetNames = &esn;
927 int cmd_close(char *arg)
929 Z_APDU *apdu = zget_APDU(out, Z_APDU_close);
930 Z_Close *req = apdu->u.close;
932 *req->closeReason = Z_Close_finished;
934 printf("Sent close request.\n");
939 static void initialize(void)
947 if (!(out = odr_createmem(ODR_ENCODE)) ||
948 !(in = odr_createmem(ODR_DECODE)) ||
949 !(print = odr_createmem(ODR_PRINT)))
951 fprintf(stderr, "failed to allocate ODR streams\n");
954 setvbuf(stdout, 0, _IONBF, 0);
958 bibset = ccl_qual_mk ();
959 inf = fopen ("default.bib", "r");
962 ccl_qual_file (bibset, inf);
969 static int client(void)
973 int (*fun)(char *arg);
976 {"open", cmd_open, "('tcp'|'osi')':'[<TSEL>'/']<HOST>[':'<PORT>]"},
977 {"quit", cmd_quit, ""},
978 {"find", cmd_find, "<CCL-QUERY>"},
979 {"base", cmd_base, "<BASE-NAME>"},
980 {"show", cmd_show, "<REC#>['+'<#RECS>]"},
981 {"scan", cmd_scan, "<TERM>"},
982 {"authentication", cmd_authentication, "<ACCTSTRING>"},
983 {"lslb", cmd_lslb, "<largeSetLowerBound>"},
984 {"ssub", cmd_ssub, "<smallSetUpperBound>"},
985 {"mspn", cmd_mspn, "<mediumSetPresentNumber>"},
986 {"status", cmd_status, ""},
987 {"setnames", cmd_setnames, ""},
988 {"cancel", cmd_cancel, ""},
989 {"format", cmd_format, "<recordsyntax>"},
990 {"elements", cmd_elements, "<elementSetName>"},
991 {"close", cmd_close, ""},
995 int netbufferlen = 0;
1003 char line[1024], word[1024], arg[1024];
1008 FD_SET(cs_fileno(conn), &input);
1009 if ((res = select(20, &input, 0, 0, 0)) < 0)
1016 if (FD_ISSET(0, &input))
1018 /* quick & dirty way to get a command line. */
1021 if ((res = sscanf(line, "%s %[^;]", word, arg)) <= 0)
1023 strcpy(word, last_cmd);
1028 strcpy(last_cmd, word);
1029 for (i = 0; cmd[i].cmd; i++)
1030 if (!strncmp(cmd[i].cmd, word, strlen(word)))
1032 res = (*cmd[i].fun)(arg);
1035 if (!cmd[i].cmd) /* dump our help-screen */
1037 printf("Unknown command: %s.\n", word);
1038 printf("Currently recognized commands:\n");
1039 for (i = 0; cmd[i].cmd; i++)
1040 printf(" %s %s\n", cmd[i].cmd, cmd[i].ad);
1046 if (conn && FD_ISSET(cs_fileno(conn), &input))
1050 if ((res = cs_get(conn, &netbuffer, &netbufferlen)) < 0)
1057 printf("Target closed connection.\n");
1060 odr_reset(in); /* release APDU from last round */
1061 odr_setbuf(in, netbuffer, res, 0);
1062 if (!z_APDU(in, &apdu, 0))
1064 odr_perror(in, "Decoding incoming APDU");
1065 fprintf(stderr, "[Near %d]\n", odr_offset(in));
1066 fprintf(stderr, "Packet dump:\n---------\n");
1067 odr_dumpBER(stderr, netbuffer, res);
1068 fprintf(stderr, "---------\n");
1072 if (!z_APDU(print, &apdu, 0))
1074 odr_perror(print, "Failed to print incoming APDU");
1081 case Z_APDU_initResponse:
1082 process_initResponse(apdu->u.initResponse);
1084 case Z_APDU_searchResponse:
1085 process_searchResponse(apdu->u.searchResponse);
1087 case Z_APDU_scanResponse:
1088 process_scanResponse(apdu->u.scanResponse);
1090 case Z_APDU_presentResponse:
1091 printf("Received presentResponse.\n");
1093 *apdu->u.presentResponse->numberOfRecordsReturned;
1094 if (apdu->u.presentResponse->records)
1095 display_records(apdu->u.presentResponse->records);
1097 printf("No records.\n");
1100 printf("Target has closed the association.\n");
1101 process_close(apdu->u.close);
1104 printf("Received unknown APDU type (%d).\n",
1111 while (cs_more(conn));
1117 int main(int argc, char **argv)