- printf("UserInformationfield:\n");
- if (!z_External(print, (Z_External**)&res-> userInformationField,
- 0))
- {
- odr_perror(print, "Printing userinfo\n");
- odr_reset(print);
- }
- if (res->userInformationField->which == Z_External_octet)
- {
- printf("Guessing visiblestring:\n");
- printf("'%s'\n", res->userInformationField->u. octet_aligned->buf);
- }
+ printf("UserInformationfield:\n");
+ if (!z_External(print, (Z_External**)&res-> userInformationField,
+ 0))
+ {
+ odr_perror(print, "Printing userinfo\n");
+ odr_reset(print);
+ }
+ if (res->userInformationField->which == Z_External_octet)
+ {
+ printf("Guessing visiblestring:\n");
+ printf("'%s'\n", res->userInformationField->u. octet_aligned->buf);
+ }
- 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");
+ 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");
- oident prefsyn;
-
- prefsyn.proto = protocol;
- prefsyn.class = CLASS_RECSYN;
- prefsyn.value = recordsyntax;
- req->preferredRecordSyntax = odr_oiddup(out, oid_getoidbyent(&prefsyn));
- req->smallSetElementSetNames =
- req->mediumSetElementSetNames = elementSetNames;
+ oident prefsyn;
+
+ prefsyn.proto = protocol;
+ prefsyn.class = CLASS_RECSYN;
+ prefsyn.value = recordsyntax;
+ req->preferredRecordSyntax = odr_oiddup(out, oid_getoidbyent(&prefsyn));
+ req->smallSetElementSetNames =
+ req->mediumSetElementSetNames = elementSetNames;
- printf("%.*s (%d)\n", t->term->u.general->len, t->term->u.general->buf,
- t->globalOccurrences ? *t->globalOccurrences : -1);
- sprintf(last_scan, "%.*s", t->term->u.general->len,
- t->term->u.general->buf);
+ printf("%.*s (%d)\n", t->term->u.general->len, t->term->u.general->buf,
+ t->globalOccurrences ? *t->globalOccurrences : -1);
+ sprintf(last_scan, "%.*s", t->term->u.general->len,
+ t->term->u.general->buf);
- Z_Entries *ent = res->entries->u.entries;
-
- for (i = 0; i < ent->num_entries; i++)
- if (ent->entries[i]->which == Z_Entry_termInfo)
- {
- printf("%c ", i + 1 == *res->positionOfTerm ? '*' : ' ');
- display_term(ent->entries[i]->u.termInfo);
- }
- else
- display_diagrec(ent->entries[i]->u.surrogateDiagnostic);
+ Z_Entries *ent = res->entries->u.entries;
+
+ for (i = 0; i < ent->num_entries; i++)
+ if (ent->entries[i]->which == Z_Entry_termInfo)
+ {
+ printf("%c ", i + 1 == *res->positionOfTerm ? '*' : ' ');
+ display_term(ent->entries[i]->u.termInfo);
+ }
+ else
+ display_diagrec(ent->entries[i]->u.surrogateDiagnostic);
- {"open", cmd_open, "('tcp'|'osi')':'[<TSEL>'/']<HOST>[':'<PORT>]"},
- {"quit", cmd_quit, ""},
- {"find", cmd_find, "<CCL-QUERY>"},
- {"base", cmd_base, "<BASE-NAME>"},
- {"show", cmd_show, "<REC#>['+'<#RECS>]"},
- {"scan", cmd_scan, "<TERM>"},
- {"authentication", cmd_authentication, "<ACCTSTRING>"},
- {"lslb", cmd_lslb, "<largeSetLowerBound>"},
- {"ssub", cmd_ssub, "<smallSetUpperBound>"},
- {"mspn", cmd_mspn, "<mediumSetPresentNumber>"},
- {"status", cmd_status, ""},
- {"setnames", cmd_setnames, ""},
- {"cancel", cmd_cancel, ""},
- {"format", cmd_format, "<recordsyntax>"},
- {"elements", cmd_elements, "<elementSetName>"},
- {"close", cmd_close, ""},
- {0,0}
+ {"open", cmd_open, "('tcp'|'osi')':'[<TSEL>'/']<HOST>[':'<PORT>]"},
+ {"quit", cmd_quit, ""},
+ {"find", cmd_find, "<CCL-QUERY>"},
+ {"base", cmd_base, "<BASE-NAME>"},
+ {"show", cmd_show, "<REC#>['+'<#RECS>]"},
+ {"scan", cmd_scan, "<TERM>"},
+ {"authentication", cmd_authentication, "<ACCTSTRING>"},
+ {"lslb", cmd_lslb, "<largeSetLowerBound>"},
+ {"ssub", cmd_ssub, "<smallSetUpperBound>"},
+ {"mspn", cmd_mspn, "<mediumSetPresentNumber>"},
+ {"status", cmd_status, ""},
+ {"setnames", cmd_setnames, ""},
+ {"cancel", cmd_cancel, ""},
+ {"format", cmd_format, "<recordsyntax>"},
+ {"elements", cmd_elements, "<elementSetName>"},
+ {"close", cmd_close, ""},
+ {0,0}
- int res;
- fd_set input;
- char line[1024], word[1024], arg[1024];
-
- FD_ZERO(&input);
- FD_SET(0, &input);
- if (conn)
- FD_SET(cs_fileno(conn), &input);
- if ((res = select(20, &input, 0, 0, 0)) < 0)
- {
- perror("select");
- exit(1);
- }
- if (!res)
- continue;
- if (FD_ISSET(0, &input))
- {
- /* quick & dirty way to get a command line. */
- if (!gets(line))
- break;
- if ((res = sscanf(line, "%s %[^;]", word, arg)) <= 0)
- {
- strcpy(word, last_cmd);
- *arg = '\0';
- }
- else if (res == 1)
- *arg = 0;
- strcpy(last_cmd, word);
- for (i = 0; cmd[i].cmd; i++)
- if (!strncmp(cmd[i].cmd, word, strlen(word)))
- {
- res = (*cmd[i].fun)(arg);
- break;
- }
- if (!cmd[i].cmd) /* dump our help-screen */
- {
- printf("Unknown command: %s.\n", word);
- printf("Currently recognized commands:\n");
- for (i = 0; cmd[i].cmd; i++)
- printf(" %s %s\n", cmd[i].cmd, cmd[i].ad);
- res = 1;
- }
- if (res < 2)
- printf(C_PROMPT);
- }
- if (conn && FD_ISSET(cs_fileno(conn), &input))
- {
- do
- {
- if ((res = cs_get(conn, &netbuffer, &netbufferlen)) < 0)
- {
- perror("cs_get");
- exit(1);
- }
- if (!res)
- {
- printf("Target closed connection.\n");
- exit(1);
- }
- odr_reset(in); /* release APDU from last round */
- odr_setbuf(in, netbuffer, res, 0);
- if (!z_APDU(in, &apdu, 0))
- {
- odr_perror(in, "Decoding incoming APDU");
- fprintf(stderr, "Packet dump:\n---------\n");
- odr_dumpBER(stderr, netbuffer, res);
- fprintf(stderr, "---------\n");
- exit(1);
- }
+ int res;
+ fd_set input;
+ char line[1024], word[1024], arg[1024];
+
+ FD_ZERO(&input);
+ FD_SET(0, &input);
+ if (conn)
+ FD_SET(cs_fileno(conn), &input);
+ if ((res = select(20, &input, 0, 0, 0)) < 0)
+ {
+ perror("select");
+ exit(1);
+ }
+ if (!res)
+ continue;
+ if (FD_ISSET(0, &input))
+ {
+ /* quick & dirty way to get a command line. */
+ if (!gets(line))
+ break;
+ if ((res = sscanf(line, "%s %[^;]", word, arg)) <= 0)
+ {
+ strcpy(word, last_cmd);
+ *arg = '\0';
+ }
+ else if (res == 1)
+ *arg = 0;
+ strcpy(last_cmd, word);
+ for (i = 0; cmd[i].cmd; i++)
+ if (!strncmp(cmd[i].cmd, word, strlen(word)))
+ {
+ res = (*cmd[i].fun)(arg);
+ break;
+ }
+ if (!cmd[i].cmd) /* dump our help-screen */
+ {
+ printf("Unknown command: %s.\n", word);
+ printf("Currently recognized commands:\n");
+ for (i = 0; cmd[i].cmd; i++)
+ printf(" %s %s\n", cmd[i].cmd, cmd[i].ad);
+ res = 1;
+ }
+ if (res < 2)
+ printf(C_PROMPT);
+ }
+ if (conn && FD_ISSET(cs_fileno(conn), &input))
+ {
+ do
+ {
+ if ((res = cs_get(conn, &netbuffer, &netbufferlen)) < 0)
+ {
+ perror("cs_get");
+ exit(1);
+ }
+ if (!res)
+ {
+ printf("Target closed connection.\n");
+ exit(1);
+ }
+ odr_reset(in); /* release APDU from last round */
+ odr_setbuf(in, netbuffer, res, 0);
+ if (!z_APDU(in, &apdu, 0))
+ {
+ odr_perror(in, "Decoding incoming APDU");
+ fprintf(stderr, "Packet dump:\n---------\n");
+ odr_dumpBER(stderr, netbuffer, res);
+ fprintf(stderr, "---------\n");
+ exit(1);
+ }
- switch(apdu->which)
- {
- case Z_APDU_initResponse:
- process_initResponse(apdu->u.initResponse);
- break;
- case Z_APDU_searchResponse:
- process_searchResponse(apdu->u.searchResponse);
- break;
- case Z_APDU_scanResponse:
- process_scanResponse(apdu->u.scanResponse);
- break;
- case Z_APDU_presentResponse:
- printf("Received presentResponse.\n");
- setno +=
- *apdu->u.presentResponse->numberOfRecordsReturned;
- if (apdu->u.presentResponse->records)
- display_records(apdu->u.presentResponse->records);
- else
- printf("No records.\n");
- break;
- case Z_APDU_close:
- printf("Target has closed the association.\n");
- process_close(apdu->u.close);
- break;
- default:
- printf("Received unknown APDU type (%d).\n",
- apdu->which);
- exit(1);
- }
- printf("Z> ");
- fflush(stdout);
- }
- while (cs_more(conn));
- }
+ switch(apdu->which)
+ {
+ case Z_APDU_initResponse:
+ process_initResponse(apdu->u.initResponse);
+ break;
+ case Z_APDU_searchResponse:
+ process_searchResponse(apdu->u.searchResponse);
+ break;
+ case Z_APDU_scanResponse:
+ process_scanResponse(apdu->u.scanResponse);
+ break;
+ case Z_APDU_presentResponse:
+ printf("Received presentResponse.\n");
+ setno +=
+ *apdu->u.presentResponse->numberOfRecordsReturned;
+ if (apdu->u.presentResponse->records)
+ display_records(apdu->u.presentResponse->records);
+ else
+ printf("No records.\n");
+ break;
+ case Z_APDU_close:
+ printf("Target has closed the association.\n");
+ process_close(apdu->u.close);
+ break;
+ default:
+ printf("Received unknown APDU type (%d).\n",
+ apdu->which);
+ exit(1);
+ }
+ printf("Z> ");
+ fflush(stdout);
+ }
+ while (cs_more(conn));
+ }