X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=client%2Fclient.c;h=e874e31ced5f12241ca757ef6e85b13040595e58;hp=c23dcfede68f059ccd12969a68f940e8aa7d708a;hb=9f6bbd483ea92b4a5ae114a36bfebd942e138460;hpb=37b3d8433b89248def810d7cfa9b110893519f65 diff --git a/client/client.c b/client/client.c index c23dcfe..e874e31 100644 --- a/client/client.c +++ b/client/client.c @@ -1,10 +1,25 @@ /* - * Copyright (c) 1995-2000, Index Data + * Copyright (c) 1995-2001, Index Data * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * $Log: client.c,v $ - * Revision 1.107 2000-11-16 13:11:07 adam + * Revision 1.112 2001-02-20 11:25:32 adam + * Added ill_get_APDU and ill_get_Cancel. + * + * Revision 1.111 2001/01/30 15:52:48 ja7 + * added command for setting packageName in ES packages! + * command is named packagename default is NULL for server suplyed package name + * + * Revision 1.110 2001/01/29 11:19:05 adam + * Clients prints options in InitResponse. + * + * Revision 1.109 2001/01/22 10:41:47 adam + * Multiple attribute may be specified for sorging. + * + * Revision 1.108 2000/11/23 10:58:32 adam + * SSL comstack support. Separate POSIX thread support library. + * + * Revision 1.107 2000/11/16 13:11:07 adam * Changed because ccl_rpn_query sets attribute set. * * Revision 1.106 2000/11/13 09:44:59 adam @@ -408,6 +423,7 @@ static NMEM session_mem = NULL; /* memory handle for init-response */ static Z_InitResponse *session = 0; /* session parameters */ static char last_scan_line[512] = "0"; static char last_scan_query[512] = "0"; +char* esPackageName = 0; static char last_cmd[100] = "?"; static FILE *marcdump = 0; @@ -536,6 +552,35 @@ static int process_initResponse(Z_InitResponse *res) } odr_reset (print); } + printf ("Options:"); + if (ODR_MASK_GET(res->options, Z_Options_search)) + printf (" search"); + if (ODR_MASK_GET(res->options, Z_Options_present)) + printf (" present"); + if (ODR_MASK_GET(res->options, Z_Options_delSet)) + printf (" delSet"); + if (ODR_MASK_GET(res->options, Z_Options_resourceReport)) + printf (" resourceReport"); + if (ODR_MASK_GET(res->options, Z_Options_resourceCtrl)) + printf (" resourceCtrl"); + if (ODR_MASK_GET(res->options, Z_Options_accessCtrl)) + printf (" accessCtrl"); + if (ODR_MASK_GET(res->options, Z_Options_scan)) + printf (" scan"); + if (ODR_MASK_GET(res->options, Z_Options_sort)) + printf (" sort"); + if (ODR_MASK_GET(res->options, Z_Options_extendedServices)) + printf (" extendedServices"); + if (ODR_MASK_GET(res->options, Z_Options_level_1Segmentation)) + printf (" level1Segmentation"); + if (ODR_MASK_GET(res->options, Z_Options_level_2Segmentation)) + printf (" level2Segmentation"); + if (ODR_MASK_GET(res->options, Z_Options_concurrentOperations)) + printf (" concurrentOperations"); + if (ODR_MASK_GET(res->options, Z_Options_namedResultSets)) + printf (" namedResultSets"); + printf ("\n"); + fflush (stdout); return 0; } @@ -588,16 +633,25 @@ int cmd_open(char *arg) session_mem = NULL; } } + t = tcpip_type; base[0] = '\0'; if (sscanf (arg, "%100[^/]/%100s", type_and_host, base) < 1) return 0; if (strncmp (type_and_host, "tcp:", 4) == 0) host = type_and_host + 4; + else if (strncmp (type_and_host, "ssl:", 4) == 0) + { +#if HAVE_OPENSSL_SSL_H + t = ssl_type; +#else + printf ("SSL not supported\n"); +#endif + host = type_and_host + 4; + } else host = type_and_host; if (*base) cmd_base (base); - t = tcpip_type; protocol = PROTO_Z3950; if (!(conn = cs_create(t, 1, protocol))) @@ -1329,10 +1383,10 @@ static Z_External *create_external_itemRequest() #endif #ifdef ASN_COMPILED -static Z_External *create_external_ILLRequest() +static Z_External *create_external_ILL_APDU(int which) { struct ill_get_ctl ctl; - ILL_Request *req; + ILL_APDU *ill_apdu; Z_External *r = 0; int ill_request_size = 0; char *ill_request_buf = 0; @@ -1341,14 +1395,14 @@ static Z_External *create_external_ILLRequest() ctl.clientData = 0; ctl.f = get_ill_element; - req = ill_get_ILLRequest(&ctl, "ill", 0); + ill_apdu = ill_get_APDU(&ctl, "ill", 0); - if (!ill_Request (out, &req, 0, 0)) + if (!ill_APDU (out, &ill_apdu, 0, 0)) { if (apdu_file) { printf ("-------------------\n"); - ill_Request(print, &req, 0, 0); + ill_APDU(print, &ill_apdu, 0, 0); odr_reset(print); printf ("-------------------\n"); } @@ -1448,7 +1502,7 @@ static Z_External *create_ItemOrderExternal(const char *type, int itemno) { printf ("using ILL-request\n"); r->u.itemOrder->u.esRequest->notToKeep->itemRequest = - create_external_ILLRequest(); + create_external_ILL_APDU(ILL_APDU_ILL_Request); } else r->u.itemOrder->u.esRequest->notToKeep->itemRequest = 0; @@ -1465,7 +1519,7 @@ static int send_itemorder(const char *type, int itemno) ItemOrderRequest.oclass = CLASS_EXTSERV; ItemOrderRequest.value = VAL_ITEMORDER; req->packageType = odr_oiddup(out,oid_getoidbyent(&ItemOrderRequest)); - req->packageName = "1.Extendedserveq"; + req->packageName = esPackageName; req->taskSpecificParameters = create_ItemOrderExternal(type, itemno); @@ -1492,7 +1546,7 @@ static int cmd_update(char *arg) update_oid.value = VAL_DBUPDATE; oid_ent_to_oid (&update_oid, oid); req->packageType = odr_oiddup(out,oid); - req->packageName = "1.Extendedserveq"; + req->packageName = esPackageName; r = req->taskSpecificParameters = (Z_External *) odr_malloc (out, sizeof(*r)); @@ -1871,7 +1925,7 @@ int send_sortrequest(char *arg, int newset) Z_SortKeySpecList *sksl = (Z_SortKeySpecList *) odr_malloc (out, sizeof(*sksl)); char setstring[32]; - char sort_string[32], sort_flags[32]; + char sort_string_buf[32], sort_flags[32]; int off; int oid[OID_SIZE]; oident bib1; @@ -1910,11 +1964,12 @@ int send_sortrequest(char *arg, int newset) bib1.proto = protocol; bib1.oclass = CLASS_ATTSET; bib1.value = VAL_BIB1; - while ((sscanf (arg, "%31s %31s%n", sort_string, sort_flags, &off)) == 2 + while ((sscanf (arg, "%31s %31s%n", sort_string_buf, sort_flags, &off)) == 2 && off > 1) { int i; char *sort_string_sep; + char *sort_string = sort_string_buf; Z_SortKeySpec *sks = (Z_SortKeySpec *)odr_malloc (out, sizeof(*sks)); Z_SortKey *sk = (Z_SortKey *)odr_malloc (out, sizeof(*sk)); @@ -1926,24 +1981,37 @@ int send_sortrequest(char *arg, int newset) if ((sort_string_sep = strchr (sort_string, '='))) { - Z_AttributeElement *el = (Z_AttributeElement *)odr_malloc (out, sizeof(*el)); + int i = 0; sk->which = Z_SortKey_sortAttributes; sk->u.sortAttributes = (Z_SortAttributes *)odr_malloc (out, sizeof(*sk->u.sortAttributes)); sk->u.sortAttributes->id = oid_ent_to_oid(&bib1, oid); sk->u.sortAttributes->list = (Z_AttributeList *)odr_malloc (out, sizeof(*sk->u.sortAttributes->list)); - sk->u.sortAttributes->list->num_attributes = 1; sk->u.sortAttributes->list->attributes = - (Z_AttributeElement **)odr_malloc (out, - sizeof(*sk->u.sortAttributes->list->attributes)); - sk->u.sortAttributes->list->attributes[0] = el; - el->attributeSet = 0; - el->attributeType = (int *)odr_malloc (out, sizeof(*el->attributeType)); - *el->attributeType = atoi (sort_string); - el->which = Z_AttributeValue_numeric; - el->value.numeric = (int *)odr_malloc (out, sizeof(*el->value.numeric)); - *el->value.numeric = atoi (sort_string_sep + 1); + (Z_AttributeElement **) + odr_malloc (out, 10 * + sizeof(*sk->u.sortAttributes->list->attributes)); + while (i < 10 && sort_string && sort_string_sep) + { + Z_AttributeElement *el = (Z_AttributeElement *) + odr_malloc (out, sizeof(*el)); + sk->u.sortAttributes->list->attributes[i] = el; + el->attributeSet = 0; + el->attributeType = (int *)odr_malloc (out, sizeof(*el->attributeType)); + *el->attributeType = atoi (sort_string); + el->which = Z_AttributeValue_numeric; + el->value.numeric = (int *)odr_malloc (out, sizeof(*el->value.numeric)); + *el->value.numeric = atoi (sort_string_sep + 1); + i++; + sort_string = strchr(sort_string, ','); + if (sort_string) + { + sort_string++; + sort_string_sep = strchr (sort_string, '='); + } + } + sk->u.sortAttributes->list->num_attributes = i; } else { @@ -2263,6 +2331,17 @@ int cmd_close(char *arg) return 2; } +int cmd_packagename(char* arg) { + xfree (esPackageName); + esPackageName = NULL; + if (*arg) + { + esPackageName = (char *) xmalloc (strlen(arg)+1); + strcpy (esPackageName, arg); + } + return 1; +}; + static void initialize(void) { #if CCL2RPN @@ -2324,6 +2403,7 @@ static int client(int wait) {"refid", cmd_refid, ""}, {"itemorder", cmd_itemorder, "ill|item "}, {"update", cmd_update, ""}, + {"packagename", cmd_packagename, ""}, #ifdef ASN_COMPILED /* Server Admin Functions */ {"adm-reindex", cmd_adm_reindex, ""},