* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.151 2002-05-03 13:48:27 adam Exp $
+ * $Id: client.c,v 1.152 2002-05-18 09:52:37 oleg Exp $
*/
#include <stdio.h>
#include <yaz/marcdisp.h>
#include <yaz/diagbib1.h>
#include <yaz/otherinfo.h>
+#include <yaz/charneg.h>
#include <yaz/pquery.h>
#include <yaz/sortspec.h>
static char* esPackageName = 0;
static char* yazProxy = 0;
static int kilobytes = 1024;
+static char* yazCharset = 0;
+static char* yazLang = 0;
static char last_cmd[32] = "?";
static FILE *marcdump = 0;
yaz_oi_set_string_oidval(&req->otherInfo, out, VAL_PROXY,
1, type_and_host);
+ if (yazCharset || yazLang) {
+ Z_OtherInformation **p;
+ Z_OtherInformationUnit *p0;
+
+ yaz_oi_APDU(apdu, &p);
+
+ if (p0=yaz_oi_update(p, out, NULL, 0, 0)) {
+ ODR_MASK_SET(req->options, Z_Options_negotiationModel);
+
+ p0->which = Z_OtherInfo_externallyDefinedInfo;
+ p0->information.externallyDefinedInfo =
+ yaz_set_charset_and_lang(out, CLASS_NEGOT, VAL_CHARNEG3,
+ (const char**)&yazCharset, (yazCharset)?1:0,
+ (const char**)&yazLang, (yazLang)?1:0);
+ }
+ }
+
send_apdu(apdu);
printf("Sent initrequest.\n");
}
int cmd_proxy(char* arg)
{
+ if (*arg == '\0') {
+ printf("Current proxy is `%s'\n", (yazCharset)?yazProxy:NULL);
+ return 1;
+ }
xfree (yazProxy);
yazProxy = NULL;
if (*arg)
return 1;
}
+int cmd_charset(char* arg)
+{
+ if (*arg == '\0') {
+ printf("Current character set is `%s'\n", (yazCharset)?yazCharset:NULL);
+ return 1;
+ }
+ xfree (yazCharset);
+ yazCharset = NULL;
+ if (*arg)
+ {
+ yazCharset = (char *) xmalloc (strlen(arg)+1);
+ strcpy (yazCharset, arg);
+ }
+ return 1;
+}
+
+int cmd_lang(char* arg)
+{
+ if (*arg == '\0') {
+ printf("Current language is `%s'\n", (yazLang)?yazLang:NULL);
+ return 1;
+ }
+ xfree (yazLang);
+ yazLang = NULL;
+ if (*arg)
+ {
+ yazLang = (char *) xmalloc (strlen(arg)+1);
+ strcpy (yazLang, arg);
+ }
+ return 1;
+}
+
int cmd_source(char* arg)
{
/* first should open the file and read one line at a time.. */
{"update", cmd_update, "<item>",NULL,0},
{"packagename", cmd_packagename, "<packagename>",NULL,0},
{"proxy", cmd_proxy, "[('tcp'|'ssl')]<host>[':'<port>]",NULL,0},
+ {"charset", cmd_charset, "<charset_name>",NULL,0},
+ {"lang", cmd_lang, "<language_code>",NULL,0},
{".", cmd_source, "<filename>",NULL,1},
{"!", cmd_subshell, "Subshell command",NULL,0},
{"set_apdufile", cmd_set_apdufile, "<filename>",NULL,0},
-## $Id: Makefile.am,v 1.14 2002-05-13 18:34:53 adam Exp $
+## $Id: Makefile.am,v 1.15 2002-05-18 09:52:37 oleg Exp $
pkginclude_HEADERS= backend.h ccl.h comstack.h \
d1_attset.h d1_map.h data1.h diagbib1.h sortspec.h \
z-grs.h z-opac.h z-rrf1.h z-rrf2.h z-sum.h z-sutrs.h z-uifr1.h \
z-univ.h zes-expi.h zes-exps.h zes-order.h zes-pquery.h \
zes-psched.h zes-admin.h zes-pset.h zes-update.h zes-update0.h \
- zoom.h z-charneg.h
+ zoom.h z-charneg.h charneg.h
# makefile.mak - makefile for MS NMAKE
-# $Id: makefile,v 1.37 2002-05-17 12:48:30 adam Exp $
+# $Id: makefile,v 1.38 2002-05-18 09:52:37 oleg Exp $
#
# Programmed by
# HL: Heikki Levanto, Index Data
$(OBJDIR)\yaz-ccl.obj \
$(OBJDIR)\otherinfo.obj \
$(OBJDIR)\sortspec.obj \
- $(OBJDIR)\z3950oid.obj
+ $(OBJDIR)\z3950oid.obj \
+ $(OBJDIR)\charneg.obj
YAZ_RET_OBJS= \
###########################################################
#
# $Log: makefile,v $
-# Revision 1.37 2002-05-17 12:48:30 adam
+# Revision 1.38 2002-05-18 09:52:37 oleg
+# Added support of CharacterSetandLanguageNegotiation-3
+# modele (based on Z_PrivateCharacterSet_externallySpecified) at the client
+# side.
+#
+# Revision 1.37 2002/05/17 12:48:30 adam
# Use __stdcall convention for ZOOM on WIN32
#
# Revision 1.36 2002/03/18 21:33:48 adam
/*
- * $Id: zoom-c.c,v 1.28 2002-05-17 12:48:30 adam Exp $
+ * $Id: zoom-c.c,v 1.29 2002-05-18 09:52:37 oleg Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
#include <yaz/log.h>
#include <yaz/pquery.h>
#include <yaz/diagbib1.h>
+#include <yaz/charneg.h>
#include "zoom-p.h"
c->host_port = 0;
c->proxy = 0;
+
+ c->charset = c->lang = 0;
c->cookie_out = 0;
c->cookie_in = 0;
else
c->proxy = 0;
+ val = ZOOM_options_get (c->options, "charset");
+ if (val && *val)
+ c->charset = xstrdup (val);
+ else
+ c->charset = 0;
+
+ val = ZOOM_options_get (c->options, "lang");
+ if (val && *val)
+ c->lang = xstrdup (val);
+ else
+ c->lang = 0;
+
if (portnum)
{
char hostn[128];
ZOOM_connection_remove_tasks (c);
xfree (c->host_port);
xfree (c->proxy);
+ xfree (c->charset);
+ xfree (c->lang);
xfree (c->cookie_out);
xfree (c->cookie_in);
xfree (c);
if (c->proxy)
yaz_oi_set_string_oidval(&ireq->otherInfo, c->odr_out,
VAL_PROXY, 1, c->host_port);
+ if (c->charset||c->lang)
+ {
+ Z_OtherInformation **oi;
+ Z_OtherInformationUnit *oi_unit;
+
+ yaz_oi_APDU(apdu, &oi);
+
+ if (oi_unit = yaz_oi_update(oi, c->odr_out, NULL, 0, 0))
+ {
+ ODR_MASK_SET(ireq->options, Z_Options_negotiationModel);
+
+ oi_unit->which = Z_OtherInfo_externallyDefinedInfo;
+ oi_unit->information.externallyDefinedInfo =
+ yaz_set_charset_and_lang(c->odr_out,
+ CLASS_NEGOT, VAL_CHARNEG3,
+ (const char **)&c->charset, (c->charset) ? 1:0,
+ (const char **)&c->lang, (c->lang) ? 1:0);
+ }
+ }
assert (apdu);
send_APDU (c, apdu);
{
Z_NamePlusRecord *npr;
- *len = 0; /* if return 0 */
-
+ if (len)
+ *len = 0; /* default return */
+
if (!rec)
return 0;
npr = rec->npr;
return 0;
if (!strcmp (type, "database"))
{
- *len = strlen(npr->databaseName)+1;
+ if (len) *len = strlen(npr->databaseName)+1;
return npr->databaseName;
}
else if (!strcmp (type, "syntax"))
oident *ent = oid_getentbyoid(r->direct_reference);
if (ent)
{
- *len = strlen(ent->desc)+1;
+ if (len) *len = strlen(ent->desc)+1;
return ent->desc;
}
}
if (r->which == Z_External_sutrs)
{
- *len = r->u.sutrs->len;
+ if (len) *len = r->u.sutrs->len;
return (const char *) r->u.sutrs->buf;
}
else if (r->which == Z_External_octet)
r->u.octet_aligned->len,
0) > 0)
{
- *len = wrbuf_len(rec->wrbuf_marc);
+ if (len) *len = wrbuf_len(rec->wrbuf_marc);
return wrbuf_buf(rec->wrbuf_marc);
}
}
- *len = r->u.octet_aligned->len;
+ if (len) *len = r->u.octet_aligned->len;
return (const char *) r->u.octet_aligned->buf;
}
else if (r->which == Z_External_grs1)
{
- *len = 5;
+ if (len) *len = 5;
return "GRS-1";
}
return 0;
if (r->which == Z_External_sutrs)
{
- *len = r->u.sutrs->len;
+ if (len) *len = r->u.sutrs->len;
return (const char *) r->u.sutrs->buf;
}
else if (r->which == Z_External_octet)
r->u.octet_aligned->len,
1) > 0)
{
- *len = wrbuf_len(rec->wrbuf_marc);
+ if (len) *len = wrbuf_len(rec->wrbuf_marc);
return wrbuf_buf(rec->wrbuf_marc);
}
}
- *len = r->u.octet_aligned->len;
+ if (len) *len = r->u.octet_aligned->len;
return (const char *) r->u.octet_aligned->buf;
}
else if (r->which == Z_External_grs1)
{
- *len = 5;
+ if (len) *len = 5;
return "GRS-1";
}
return 0;
if (r->which == Z_External_sutrs)
{
- *len = r->u.sutrs->len;
+ if (len) *len = r->u.sutrs->len;
return (const char *) r->u.sutrs->buf;
}
else if (r->which == Z_External_octet)
{
- *len = r->u.octet_aligned->len;
+ if (len) *len = r->u.octet_aligned->len;
return (const char *) r->u.octet_aligned->buf;
}
else /* grs-1, explain, ... */
{
- *len = -1;
+ if (len) *len = -1;
return (const char *) npr->u.databaseRecord;
}
}
/*
* Private C header for ZOOM C.
- * $Id: zoom-p.h,v 1.9 2002-05-17 12:48:30 adam Exp $
+ * $Id: zoom-p.h,v 1.10 2002-05-18 09:52:37 oleg Exp $
*/
#include <yaz/proto.h>
#include <yaz/comstack.h>
char *buf_out;
int len_out;
char *proxy;
+ char *charset;
+ char *lang;
char *cookie_out;
char *cookie_in;
int async;
/*
- * $Id: zoomsh.c,v 1.8 2002-02-20 14:40:42 adam Exp $
+ * $Id: zoomsh.c,v 1.9 2002-05-18 09:52:37 oleg Exp $
*
* ZOOM-C Shell
*/
printf (" user\n");
printf (" pass\n");
printf (" implementationName\n");
+ printf (" charset\n");
+ printf (" lang\n");
}
static void cmd_connect (ZOOM_connection *c, ZOOM_resultset *r,
-## $Id: Makefile.am,v 1.9 2002-04-15 09:44:44 adam Exp $
+## $Id: Makefile.am,v 1.10 2002-05-18 09:52:37 oleg Exp $
noinst_LTLIBRARIES = libzutil.la
AM_CPPFLAGS=-I$(top_srcdir)/include
LIBS =
libzutil_la_SOURCES = zget.c yaz-ccl.c diagbib1.c logrpn.c \
- otherinfo.c pquery.c sortspec.c z3950oid.c
+ otherinfo.c pquery.c sortspec.c z3950oid.c charneg.c