Added new function nmem_print_list_l (variant of nmem_print_list).
Added new yaz-client command zversion that sets Z39.50 option bits -
using yaz_init_opt_encode.
Possible compatibility problems with earlier versions marked with '*'.
+Fixed a bug in Generic Frontend Server that could make it crash if a
+client sets characterSetNegotation bit, but didn't pass negotiation stuff
+in InitRequest.
+
+New YAZ client command, zversion, that sets Z39.50 version (1,2,3..).
+Must be issued before open, in order to be in effect.
+
--- 2.0.9-6 2004/01/12 Debian/Windows
Make the SRU server more picky WRT unknown params, etc.
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.225 2004-01-13 11:19:24 adam Exp $
+ * $Id: client.c,v 1.226 2004-01-15 10:16:26 adam Exp $
*/
#include <stdio.h>
static char *last_open_command = NULL;
static int auto_reconnect = 0;
static Odr_bitmask z3950_options;
+static int z3950_version = 3;
static char cur_host[200];
{
Z_APDU *apdu = zget_APDU(out, Z_APDU_initRequest);
Z_InitRequest *req = apdu->u.initRequest;
+ int i;
req->options = &z3950_options;
- ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1);
- ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2);
- ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3);
+ ODR_MASK_ZERO(req->protocolVersion);
+ for (i = 0; i<z3950_version; i++)
+ ODR_MASK_SET(req->protocolVersion, i);
*req->maximumRecordSize = 1024*kilobytes;
*req->preferredMessageSize = 1024*kilobytes;
static void render_initUserInfo(Z_OtherInformation *ui1);
static void render_diag(Z_DiagnosticFormat *diag);
-static void pr_opt(const char *opt)
+static void pr_opt(const char *opt, void *clientData)
{
printf (" %s", opt);
}
session_mem = odr_extract_mem(in);
session = res;
- for (ver = 0; ver<5; ver++)
+ for (ver = 0; ver < 8; ver++)
if (!ODR_MASK_GET(res->protocolVersion, ver))
break;
}
}
printf ("Options:");
- yaz_init_opt_decode(res->options, pr_opt);
+ yaz_init_opt_decode(res->options, pr_opt, 0);
printf ("\n");
if (ODR_MASK_GET(res->options, Z_Options_namedResultSets))
return 2;
}
-static void show_opt(const char *arg)
+static void show_opt(const char *arg, void *clientData)
{
printf ("%s ", arg);
}
+static int cmd_zversion(const char *arg)
+{
+ if (*arg && arg)
+ z3950_version = atoi(arg);
+ else
+ printf ("version is %d\n", z3950_version);
+ return 0;
+}
+
static int cmd_options(const char *arg)
{
if (*arg)
}
else
{
- yaz_init_opt_decode(&z3950_options, show_opt);
+ yaz_init_opt_decode(&z3950_options, show_opt, 0);
printf ("\n");
}
return 0;
{"adm-startup", cmd_adm_startup, "",NULL,0,NULL},
{"explain", cmd_explain, "", NULL, 0, NULL},
{"options", cmd_options, "", NULL, 0, NULL},
+ {"zversion", cmd_zversion, "", NULL, 0, NULL},
{"help", cmd_help, "", NULL,0,NULL},
{0,0,0,0,0,0}
};
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: nmem.h,v 1.11 2003-03-18 13:34:35 adam Exp $
+ * $Id: nmem.h,v 1.12 2004-01-15 10:16:26 adam Exp $
*/
#ifndef NMEM_H
#define nmem_malloc(x, y) nmem_malloc_f(__FILE__, __LINE__, (x), (y))
YAZ_EXPORT void nmem_print_list (void);
+YAZ_EXPORT void nmem_print_list_l (int level);
#else
* Copyright (c) 1998-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: proto.h,v 1.12 2004-01-12 12:11:57 adam Exp $
+ * $Id: proto.h,v 1.13 2004-01-15 10:16:26 adam Exp $
*/
#ifndef Z_PROTO_H
#define Z_PROTO_H
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));
+ void (*pr)(const char *name,
+ void *clientData),
+ void *clientData);
YAZ_END_CDECL
#include <yaz/prt-ext.h>
* 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 $
+ * $Id: initopt.c,v 1.2 2004-01-15 10:16:27 adam Exp $
*/
#if HAVE_CONFIG_H
return 0;
}
-void yaz_init_opt_decode(Z_Options *opt, void (*pr)(const char *name))
+void yaz_init_opt_decode(Z_Options *opt, void (*pr)(const char *name,
+ void *clientData),
+ void *clientData)
{
int i;
for (i = 0; opt_array[i].name; i++)
if (ODR_MASK_GET(opt, opt_array[i].opt))
- (*pr)(opt_array[i].name);
+ (*pr)(opt_array[i].name, clientData);
}
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: nmem.c,v 1.2 2003-12-04 11:47:50 adam Exp $
+ * $Id: nmem.c,v 1.3 2004-01-15 10:16:27 adam Exp $
*/
/*
#if NMEM_DEBUG
void nmem_print_list (void)
{
+ nmem_print_list_l(LOG_DEBUG);
+}
+
+void nmem_print_list_l (int level)
+{
struct nmem_debug_info *p;
- yaz_log (LOG_DEBUG, "nmem print list");
+ yaz_log (level, "nmem print list");
NMEM_ENTER;
for (p = nmem_debug_list; p; p = p->next)
- yaz_log (LOG_DEBUG, " %s:%d p=%p size=%d", p->file, p->line, p->p,
+ yaz_log (level, " %s:%d p=%p size=%d", p->file, p->line, p->p,
nmem_total(p->p));
NMEM_LEAVE;
}
* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.16 2004-01-09 18:10:31 adam Exp $
+ * $Id: seshigh.c,v 1.17 2004-01-15 10:16:27 adam Exp $
*/
/*
{
Z_HTTP_Request *hreq = req->gdu_request->u.HTTP_Request;
ODR o = assoc->encode;
- int r;
+ int r = 2; /* 2=NOT TAKEN, 1=TAKEN, 0=SOAP TAKEN */
Z_SRW_PDU *sr = 0;
Z_SOAP *soap_package = 0;
Z_GDU *p = 0;
char *charset = 0;
- Z_HTTP_Response *hres;
+ Z_HTTP_Response *hres = 0;
int keepalive = 1;
char *stylesheet = 0;
Z_SRW_diagnostic *diagnostic = 0;
int num_diagnostic = 0;
- r = yaz_srw_decode(hreq, &sr, &soap_package, assoc->decode, &charset);
+ if (!strcmp(hreq->path, "/test"))
+ {
+ p = z_get_HTTP_Response(o, 200);
+ hres = p->u.HTTP_Response;
+ hres->content_buf = "1234567890\n";
+ hres->content_len = strlen(hres->content_buf);
+ r = 1;
+ }
+ if (r == 2)
+ {
+ r = yaz_srw_decode(hreq, &sr, &soap_package, assoc->decode, &charset);
+ yaz_log(LOG_DEBUG, "yaz_srw_decode returned %d", r);
+ }
if (r == 2) /* not taken */
+ {
r = yaz_sru_decode(hreq, &sr, &soap_package, assoc->decode, &charset,
&diagnostic, &num_diagnostic);
+ yaz_log(LOG_DEBUG, "yaz_sru_decode returned %d", r);
+ }
if (r == 0) /* decode SRW/SRU OK .. */
{
int http_code = 200;
else
p = z_get_HTTP_Response(o, http_code);
}
- else
+
+ if (p == 0)
p = z_get_HTTP_Response(o, 500);
hres = p->u.HTTP_Response;
if (!strcmp(hreq->version, "1.0"))
{
Z_CharSetandLanguageNegotiation *negotiation =
yaz_get_charneg_record (req->otherInfo);
- if (negotiation->which == Z_CharSetandLanguageNegotiation_proposal)
+ if (negotiation &&
+ negotiation->which == Z_CharSetandLanguageNegotiation_proposal)
assoc->init->charneg_request = negotiation;
}
if (ODR_MASK_GET(req->protocolVersion, Z_ProtocolVersion_1))
{
ODR_MASK_SET(resp->protocolVersion, Z_ProtocolVersion_1);
- assoc->version = 2; /* 1 & 2 are equivalent */
+ assoc->version = 1; /* 1 & 2 are equivalent */
}
if (ODR_MASK_GET(req->protocolVersion, Z_ProtocolVersion_2))
{
assoc->init->implementation_name,
odr_prepend(assoc->encode, "GFS", resp->implementationName));
- version = odr_strdup(assoc->encode, "$Revision: 1.16 $");
+ version = odr_strdup(assoc->encode, "$Revision: 1.17 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
resp->implementationVersion = odr_prepend(assoc->encode,