* See the file LICENSE for details.
*
* $Log: client.c,v $
- * Revision 1.115 2001-03-13 18:10:58 adam
+ * Revision 1.121 2001-04-22 12:26:17 ja7
+ * if Compiled with Command line history a open command is pushed into
+ * the command history if yaz-client is startet with a server on the
+ * command line. eg
+ * yaz-clinet tcp:server:port/database
+ * hash the commend
+ * open tcp:server:port/database
+ * in the command history on startup
+ *
+ * Added the refid set with setrefid to the update APDU
+ *
+ * Revision 1.120 2001/04/06 12:26:46 adam
+ * Optional CCL module. Moved atoi_n to marcdisp.h from yaz-util.h.
+ *
+ * Revision 1.119 2001/04/05 13:08:48 adam
+ * New configure options: --enable-module.
+ *
+ * Revision 1.118 2001/03/27 14:48:06 adam
+ * Fixed scan for bad CCL.
+ *
+ * Revision 1.117 2001/03/25 21:55:12 adam
+ * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate.
+ *
+ * Revision 1.116 2001/03/21 12:43:36 adam
+ * Implemented cs_create_host. Better error reporting for SSL comstack.
+ *
+ * Revision 1.115 2001/03/13 18:10:58 adam
* Added option -c to set CCL config file.
*
* Revision 1.114 2001/02/21 13:46:53 adam
#include <yaz/pquery.h>
-#ifdef ASN_COMPILED
+#if YAZ_MODULE_ill
#include <yaz/ill.h>
#endif
-#if CCL2RPN
+#if YAZ_MODULE_ccl
#include <yaz/yaz-ccl.h>
#endif
static char last_scan_line[512] = "0";
static char last_scan_query[512] = "0";
static char ccl_fields[512] = "default.bib";
-char* esPackageName = 0;
+static char* esPackageName = 0;
static char last_cmd[100] = "?";
static FILE *marcdump = 0;
static QueryType queryType = QueryType_Prefix;
-#if CCL2RPN
+#if YAZ_MODULE_ccl
static CCL_bibset bibset; /* CCL bibset handle */
#endif
{
void *add;
char type_and_host[101], base[101];
- char *host = 0;
CS_TYPE t;
if (conn)
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);
- protocol = PROTO_Z3950;
- if (!(conn = cs_create(t, 1, protocol)))
- {
- perror("cs_create");
- return 0;
- }
- if (!(add = cs_straddr(conn, host)))
+ conn = cs_create_host(type_and_host, 1, &add);
+ if (!conn)
{
- perror(arg);
- return 0;
+ printf ("Couldn't create comstack\n");
+ return 0;
}
printf("Connecting...");
fflush(stdout);
if (cs_connect(conn, add) < 0)
{
- perror("connect");
+ printf ("error = %s\n", cs_strerror(conn));
+ if (conn->cerrno == CSYSERR)
+ perror("system");
cs_close(conn);
conn = 0;
return 0;
}
printf("Ok.\n");
send_initRequest();
+ if (*base)
+ cmd_base (base);
return 2;
}
Z_SearchRequest *req = apdu->u.searchRequest;
Z_Query query;
int oid[OID_SIZE];
-#if CCL2RPN
+#if YAZ_MODULE_ccl
struct ccl_rpn_node *rpn = NULL;
int error, pos;
#endif
Z_RPNQuery *RPNquery;
Odr_oct ccl_query;
-#if CCL2RPN
+#if YAZ_MODULE_ccl
if (queryType == QueryType_CCL2RPN)
{
rpn = ccl_find_str(bibset, arg, &error, &pos);
ccl_query.buf = (unsigned char*) arg;
ccl_query.len = strlen(arg);
break;
-#if CCL2RPN
+#if YAZ_MODULE_ccl
case QueryType_CCL2RPN:
query.which = Z_Query_type_1;
RPNquery = ccl_rpn_query(out, rpn);
}
}
-#ifdef ASN_COMPILED
+#if YAZ_MODULE_ill
const char *get_ill_element (void *clientData, const char *element)
{
}
return r;
}
-#else
-static Z_External *create_external_itemRequest()
-{
- return 0;
-}
#endif
-#ifdef ASN_COMPILED
+#ifdef YAZ_MODULE_ill
static Z_External *create_external_ILL_APDU(int which)
{
struct ill_get_ctl ctl;
}
return r;
}
-#else
-static Z_External *create_external_ILLRequest()
-{
- return 0;
-}
#endif
(int *) odr_malloc(out, sizeof(int));
*r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->item = itemno;
-#ifdef ASN_COMPILED
+#if YAZ_MODULE_ill
if (!strcmp (type, "item") || !strcmp(type, "2"))
{
printf ("using item-request\n");
r->u.itemOrder->u.esRequest->notToKeep->itemRequest =
create_external_ILL_APDU(ILL_APDU_ILL_Request);
}
+ else if (!strcmp(type, "xml") || !strcmp(type, "3"))
+ {
+ const char *xml_buf =
+ "<itemorder>\n"
+ " <type>request</type>\n"
+ " <libraryNo>000200</libraryNo>\n"
+ " <borrowerTicketNo> 1212 </borrowerTicketNo>\n"
+ "</itemorder>";
+ r->u.itemOrder->u.esRequest->notToKeep->itemRequest =
+ z_ext_record (out, VAL_TEXT_XML, xml_buf, strlen(xml_buf));
+ }
else
r->u.itemOrder->u.esRequest->notToKeep->itemRequest = 0;
oid_ent_to_oid (&update_oid, oid);
req->packageType = odr_oiddup(out,oid);
req->packageName = esPackageName;
+
+ req->referenceId = set_refid (out);
r = req->taskSpecificParameters = (Z_External *)
odr_malloc (out, sizeof(*r));
Z_APDU *apdu = zget_APDU(out, Z_APDU_scanRequest);
Z_ScanRequest *req = apdu->u.scanRequest;
int use_rpn = 1;
+#if YAZ_MODULE_ccl
int oid[OID_SIZE];
-#if CCL2RPN
if (queryType == QueryType_CCL2RPN)
{
oident bib1;
if (error)
{
printf("CCL ERROR: %s\n", ccl_err_msg(error));
- return 0;
+ return -1;
}
use_rpn = 0;
bib1.proto = PROTO_Z3950;
if (!(req->termListAndStartPoint = ccl_scan_query (out, rpn)))
{
printf("Couldn't convert CCL to Scan term\n");
- return 0;
+ return -1;
}
ccl_rpn_delete (rpn);
}
queryType = QueryType_CCL;
else if (!strcmp (arg, "prefix") || !strcmp(arg, "rpn"))
queryType = QueryType_Prefix;
-#if CCL2RPN
+#if YAZ_MODULE_ccl
else if (!strcmp (arg, "ccl2rpn") || !strcmp (arg, "cclrpn"))
queryType = QueryType_CCL2RPN;
#endif
printf ("Querytype must be one of:\n");
printf (" prefix - Prefix query\n");
printf (" ccl - CCL query\n");
-#if CCL2RPN
+#if YAZ_MODULE_ccl
printf (" ccl2rpn - CCL query converted to RPN\n");
#endif
return 0;
static void initialize(void)
{
-#if CCL2RPN
+#if YAZ_MODULE_ccl
FILE *inf;
#endif
nmem_init();
if (apdu_file)
odr_setprint(print, apdu_file);
-#if CCL2RPN
+#if YAZ_MODULE_ccl
bibset = ccl_qual_mk ();
inf = fopen (ccl_fields, "r");
if (inf)
if (!opened)
{
initialize ();
- if (cmd_open (arg) == 2)
- opened = 1;
+ if (cmd_open (arg) == 2) {
+#if HAVE_READLINE_HISTORY_H
+ char* tmp=(char*)malloc(strlen(arg)+6);
+ *tmp=0;
+ strcat(tmp,"open ");
+ strcat(tmp,arg);
+ add_history(tmp);
+ free(tmp);
+#endif
+ opened = 1;
+ };
}
break;
case 'm':