* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.223 2004-01-07 21:02:42 adam Exp $
+ * $Id: client.c,v 1.224 2004-01-12 12:11:57 adam Exp $
*/
#include <stdio.h>
static char *refid = NULL;
static char *last_open_command = NULL;
static int auto_reconnect = 0;
+static Odr_bitmask z3950_options;
static char cur_host[200];
Z_APDU *apdu = zget_APDU(out, Z_APDU_initRequest);
Z_InitRequest *req = apdu->u.initRequest;
- ODR_MASK_SET(req->options, Z_Options_search);
- ODR_MASK_SET(req->options, Z_Options_present);
- ODR_MASK_SET(req->options, Z_Options_namedResultSets);
- ODR_MASK_SET(req->options, Z_Options_triggerResourceCtrl);
- ODR_MASK_SET(req->options, Z_Options_scan);
- ODR_MASK_SET(req->options, Z_Options_sort);
- ODR_MASK_SET(req->options, Z_Options_extendedServices);
- ODR_MASK_SET(req->options, Z_Options_delSet);
+ req->options = &z3950_options;
ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1);
ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2);
return 2;
}
+static void show_opt(const char *arg)
+{
+ printf ("%s ", arg);
+}
+
+static int cmd_options(const char *arg)
+{
+ if (*arg)
+ {
+ int r;
+ int pos;
+ r = yaz_init_opt_encode(&z3950_options, arg, &pos);
+ }
+ else
+ {
+ yaz_init_opt_decode(&z3950_options, show_opt);
+ printf ("\n");
+ }
+ return 0;
+}
+
static int cmd_explain(const char *arg)
{
if (protocol != PROTO_HTTP)
{"adm-shutdown", cmd_adm_shutdown, "",NULL,0,NULL},
{"adm-startup", cmd_adm_startup, "",NULL,0,NULL},
{"explain", cmd_explain, "", NULL, 0, NULL},
+ {"options", cmd_options, "", NULL, 0, NULL},
{"help", cmd_help, "", NULL,0,NULL},
{0,0,0,0,0,0}
};
#endif
if (codeset)
outputCharset = xstrdup(codeset);
+
+ ODR_MASK_SET(&z3950_options, Z_Options_search);
+ ODR_MASK_SET(&z3950_options, Z_Options_present);
+ ODR_MASK_SET(&z3950_options, Z_Options_namedResultSets);
+ ODR_MASK_SET(&z3950_options, Z_Options_triggerResourceCtrl);
+ ODR_MASK_SET(&z3950_options, Z_Options_scan);
+ ODR_MASK_SET(&z3950_options, Z_Options_sort);
+ ODR_MASK_SET(&z3950_options, Z_Options_extendedServices);
+ ODR_MASK_SET(&z3950_options, Z_Options_delSet);
while ((ret = options("k:c:q:a:b:m:v:p:u:t:Vxd:", argv, argc, &arg)) != -2)
{
/*
- * Copyright (c) 1998-2003, Index Data
+ * Copyright (c) 1998-2004, Index Data
* See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
*
- * $Id: proto.h,v 1.11 2003-07-18 19:54:30 mike Exp $
+ * $Id: proto.h,v 1.12 2004-01-12 12:11:57 adam Exp $
*/
#ifndef Z_PROTO_H
#define Z_PROTO_H
YAZ_EXPORT void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *r, int flags);
+YAZ_EXPORT int yaz_init_opt_encode(Z_Options *opt, const char *opt_str,
+ int *error_pos);
+YAZ_EXPORT void yaz_init_opt_decode(Z_Options *opt,
+ void (*pr)(const char *name));
YAZ_END_CDECL
#include <yaz/prt-ext.h>
## Copyright (C) 1994-2003, Index Data
## All rights reserved.
-## $Id: Makefile.am,v 1.4 2004-01-05 09:41:31 adam Exp $
+## $Id: Makefile.am,v 1.5 2004-01-12 12:11:57 adam Exp $
if ISTHR
thrlib=libyazthread.la
prt-ext.c \
ill-core.c item-req.c ill-get.c \
zget.c yaz-ccl.c diagbib1.c logrpn.c \
- otherinfo.c pquery.c sortspec.c z3950oid.c charneg.c \
+ otherinfo.c pquery.c sortspec.c z3950oid.c charneg.c initopt.c \
zoom-c.c zoom-opt.c zoom-p.h grs1disp.c zgdu.c soap.c srw.c srwutil.c \
opacdisp.c cclfind.c ccltoken.c cclerrms.c cclqual.c cclptree.c \
cclqfile.c cclstr.c \
--- /dev/null
+/*
+ * Copyright (c) 1995-2004, Index Data
+ * See the file LICENSE for details.
+ *
+ * $Id: initopt.c,v 1.1 2004-01-12 12:11:57 adam Exp $
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <yaz/proto.h>
+
+static struct {
+ char *name;
+ int opt;
+} opt_array[] = {
+ {"search", Z_Options_search},
+ {"present", Z_Options_present},
+ {"delSet", Z_Options_delSet},
+ {"resourceReport", Z_Options_resourceReport},
+ {"triggerResourceCtrl", Z_Options_triggerResourceCtrl},
+ {"resourceCtrl", Z_Options_resourceCtrl},
+ {"accessCtrl", Z_Options_accessCtrl},
+ {"scan", Z_Options_scan},
+ {"sort", Z_Options_sort},
+ {"extendedServices", Z_Options_extendedServices},
+ {"level_1Segmentation", Z_Options_level_1Segmentation},
+ {"level_2Segmentation", Z_Options_level_2Segmentation},
+ {"concurrentOperations", Z_Options_concurrentOperations},
+ {"namedResultSets", Z_Options_namedResultSets},
+ {"encapsulation", Z_Options_encapsulation},
+ {"resultCount", Z_Options_resultCount},
+ {"negotiationModel", Z_Options_negotiationModel},
+ {"duplicationDetection", Z_Options_duplicateDetection},
+ {"queryType104", Z_Options_queryType104},
+ {"pQESCorrection", Z_Options_pQESCorrection},
+ {"stringSchema", Z_Options_stringSchema},
+ {0, 0}
+};
+
+int yaz_init_opt_encode(Z_Options *opt, const char *opt_str, int *error_pos)
+{
+ const char *cp = opt_str;
+
+ ODR_MASK_ZERO(opt);
+ while (*cp)
+ {
+ char this_opt[20];
+ int i, j;
+ if (*cp == ' ' || *cp == ',')
+ {
+ cp++;
+ continue;
+ }
+ for (i = 0; i < (sizeof(this_opt)-1) &&
+ cp[i] && cp[i] != ' ' && cp[i] != ','; i++)
+ this_opt[i] = cp[i];
+ this_opt[i] = 0;
+ for (j = 0; opt_array[j].name; j++)
+ {
+ if (yaz_matchstr(this_opt, opt_array[j].name) == 0)
+ {
+ ODR_MASK_SET(opt, opt_array[j].opt);
+ break;
+ }
+ }
+ if (!opt_array[j].name)
+ {
+ if (error_pos)
+ {
+ *error_pos = cp - opt_str;
+ return -1;
+ }
+ }
+ cp += i;
+ }
+ return 0;
+}
+
+void yaz_init_opt_decode(Z_Options *opt, void (*pr)(const char *name))
+{
+ int i;
+ for (i = 0; opt_array[i].name; i++)
+ if (ODR_MASK_GET(opt, opt_array[i].opt))
+ (*pr)(opt_array[i].name);
+}
# Copyright (C) 1994-2003, Index Data
# All rights reserved.
-# $Id: makefile,v 1.68 2003-12-30 00:23:28 adam Exp $
+# $Id: makefile,v 1.69 2004-01-12 12:11:58 adam Exp $
#
# Programmed by
# HL: Heikki Levanto, Index Data
$(OBJDIR)\srw.obj \
$(OBJDIR)\srwutil.obj \
$(OBJDIR)\zoom-c.obj \
- $(OBJDIR)\zoom-opt.obj
+ $(OBJDIR)\zoom-opt.obj \
+ $(OBJDIR)\initopt.obj
Z3950_OBJS= \
$(OBJDIR)\z-date.obj\