Using YAZ SOAP instead of gSOAP for ZOOM client (still incomplete).
-YAZ TODO $Id: TODO,v 1.7 2002-08-20 12:03:34 adam Exp $
+YAZ TODO $Id: TODO,v 1.8 2003-02-14 18:49:22 adam Exp $
-Complete EXPLAIN support in retrieval module.
+Improve timeouts in GFS.
+
+Database in URL for GFS.
+
+SRW support for ZOOM.
+
+Complete ODR print.
Versions to be put automatically in
configure.in
/* CCL find (to rpn conversion)
* Europagate, 1995
*
- * $Id: cclfind.c,v 1.32 2002-12-28 12:13:03 adam Exp $
+ * $Id: cclfind.c,v 1.33 2003-02-14 18:49:22 adam Exp $
*
* Old Europagate log:
*
/* ! word order specified */
/* % word order not specified */
p_prox = mk_node(CCL_RPN_TERM);
- p_prox->u.t.term = xmalloc(cclp->look_token->len);
+ p_prox->u.t.term = (char *) xmalloc(cclp->look_token->len);
memcpy(p_prox->u.t.term, cclp->look_token->name,
cclp->look_token->len);
p_prox->u.t.term[cclp->look_token->len] = 0;
/* CCL print rpn tree - infix notation
* Europagate, 1995
*
- * $Id: cclptree.c,v 1.11 2002-12-28 12:13:03 adam Exp $
+ * $Id: cclptree.c,v 1.12 2003-02-14 18:49:23 adam Exp $
*
* Old Europagate Log:
*
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#include <yaz/ccl.h>
/* CCL - lexical analysis
* Europagate, 1995
*
- * $Id: ccltoken.c,v 1.21 2002-12-28 12:13:03 adam Exp $
+ * $Id: ccltoken.c,v 1.22 2003-02-14 18:49:23 adam Exp $
*
* Old Europagate Log:
*
#include <string.h>
#include <stdlib.h>
+#include <ctype.h>
#include <yaz/ccl.h>
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.180 2003-02-12 15:06:43 adam Exp $
+ * $Id: client.c,v 1.181 2003-02-14 18:49:23 adam Exp $
*/
#include <stdio.h>
break;
case QueryType_CQL:
query.which = Z_Query_type_104;
- ext = odr_malloc(out, sizeof(*ext));
+ ext = (Z_External *) odr_malloc(out, sizeof(*ext));
ext->direct_reference = odr_getoidbystr(out, "1.2.840.10003.16.2");
ext->indirect_reference = 0;
ext->descriptor = 0;
/*
- * Copyright (c) 1995-2001, Index Data
+ * Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Log: comstack.c,v $
- * Revision 1.10 2002-06-04 11:36:10 adam
- * New COMSTACK: UNIX socket
- *
- * Revision 1.9 2001/10/22 13:57:24 adam
- * Implemented cs_rcvconnect and cs_look as described in the documentation.
- *
- * Revision 1.8 2001/07/19 19:49:02 adam
- * Added include of string.h.
- *
- * Revision 1.7 2001/03/21 12:43:36 adam
- * Implemented cs_create_host. Better error reporting for SSL comstack.
- *
- * Revision 1.6 1999/11/30 13:47:11 adam
- * Improved installation. Moved header files to include/yaz.
- *
- * Revision 1.5 1998/06/22 11:32:35 adam
- * Added 'conditional cs_listen' feature.
- *
- * Revision 1.4 1997/09/29 07:16:14 adam
- * Array cs_errlist no longer global.
- *
- * Revision 1.3 1997/09/01 08:49:14 adam
- * New windows NT/95 port using MSV5.0. Minor changes only.
- *
- * Revision 1.2 1995/09/29 17:01:48 quinn
- * More Windows work
- *
- * Revision 1.1 1995/06/14 09:58:20 quinn
- * Renamed yazlib to comstack.
- *
- * Revision 1.2 1995/05/16 08:51:15 quinn
- * License, documentation, and memory fixes
- *
- * Revision 1.1 1995/03/14 10:28:34 quinn
- * Adding server-side support to tcpip.c and fixing bugs in nonblocking I/O
- *
- *
+ * $Id: comstack.c,v 1.11 2003-02-14 18:49:23 adam Exp $
*/
#include <string.h>
dnl YAZ Toolkit, Index Data 1994-2003
dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.103 2003-02-12 15:06:42 adam Exp $
+dnl $Id: configure.in,v 1.104 2003-02-14 18:49:22 adam Exp $
AC_INIT(include/yaz/yaz-version.h)
AM_INIT_AUTOMAKE(yaz, 1.9.3)
dnl
fi
AM_CONDITIONAL(ISTHR, test $HAVETHREADS = "1")
dnl
-dnl ----- XML/XSLT
+dnl ----- libXML2/XSLT
AC_SUBST(XSLT_LIB)
AC_SUBST(XSLT_CFLAGS)
-xsltdir=NONE
+xsltdir=no
AC_ARG_WITH(xslt, [ --with-xslt[=PREFIX] Use libxslt in PREFIX/{lib,include}],[xsltdir=$withval])
-if test "x$xsltdir" = "xNONE"; then
+if test "$xsltdir" = "yes"; then
for d in /usr /usr/local; do
if test -x $d/bin/xslt-config; then
xsltdir=$d
fi
done
fi
-if true; then
+if test "$xsltdir" != "no"; then
AC_MSG_CHECKING(for XSLT)
if test -x $xsltdir/bin/xslt-config; then
XSLT_LIB=`$xsltdir/bin/xslt-config --libs`
-/* $Id: cql.y,v 1.2 2003-01-11 03:18:53 adam Exp $
+/* $Id: cql.y,v 1.3 2003-02-14 18:49:23 adam Exp $
Copyright (C) 2002-2003
Index Data Aps
} searchClause {
struct cql_node *cn = cql_node_mk_boolean($2.buf);
- cn->u.bool.modifiers = $2.rel;
- cn->u.bool.left = $1.cql;
- cn->u.bool.right = $4.cql;
+ cn->u.boolean.modifiers = $2.rel;
+ cn->u.boolean.left = $1.cql;
+ cn->u.boolean.right = $4.cql;
$$.cql = cn;
}
CQL_parser cql_parser_create(void)
{
- CQL_parser cp = malloc (sizeof(*cp));
+ CQL_parser cp = (CQL_parser) malloc (sizeof(*cp));
return cp;
}
-/* $Id: cqlstring.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+/* $Id: cqlstring.c,v 1.2 2003-02-14 18:49:23 adam Exp $
Copyright (C) 2002-2003
Index Data Aps
int getbuf(void *vp)
{
- struct cql_buf_info *bi = vp;
+ struct cql_buf_info *bi = (struct cql_buf_info *) vp;
if (bi->str[bi->off] == 0)
return 0;
return bi->str[bi->off++];
void ungetbuf(int b, void *vp)
{
- struct cql_buf_info *bi = vp;
+ struct cql_buf_info *bi = (struct cql_buf_info *) vp;
if (b)
(bi->off--);
}
-/* $Id: cqltransform.c,v 1.2 2003-01-11 03:18:53 adam Exp $
+/* $Id: cqltransform.c,v 1.3 2003-02-14 18:49:23 adam Exp $
Copyright (C) 2002-2003
Index Data Aps
cql_transform_t cql_transform_open_FILE(FILE *f)
{
char line[1024];
- cql_transform_t ct = malloc (sizeof(*ct));
+ cql_transform_t ct = (cql_transform_t) malloc (sizeof(*ct));
struct cql_prop_entry **pp = &ct->entry;
ct->error = 0;
if (cp_value_end != cp_value_start &&
strchr(" \t\r\n", cp_value_end[-1]))
cp_value_end--;
- *pp = malloc (sizeof(**pp));
- (*pp)->pattern = malloc (cp_pattern_end - line + 1);
+ *pp = (struct cql_prop_entry *) malloc (sizeof(**pp));
+ (*pp)->pattern = (char *) malloc (cp_pattern_end - line + 1);
memcpy ((*pp)->pattern, line, cp_pattern_end - line);
(*pp)->pattern[cp_pattern_end-line] = 0;
- (*pp)->value = malloc (cp_value_end - cp_value_start + 1);
+ (*pp)->value = (char *) malloc (cp_value_end - cp_value_start + 1);
if (cp_value_start != cp_value_end)
memcpy ((*pp)->value, cp_value_start, cp_value_end-cp_value_start);
(*pp)->value[cp_value_end - cp_value_start] = 0;
}
break;
case CQL_NODE_BOOL:
- if (cn->u.bool.prefixes && prefix_level < 20)
- prefix_ar[prefix_level++] = cn->u.bool.prefixes;
+ if (cn->u.boolean.prefixes && prefix_level < 20)
+ prefix_ar[prefix_level++] = cn->u.boolean.prefixes;
(*pr)("@", client_data);
- (*pr)(cn->u.bool.value, client_data);
+ (*pr)(cn->u.boolean.value, client_data);
(*pr)(" ", client_data);
- cql_transform_r(ct, cn->u.bool.left, pr, client_data,
+ cql_transform_r(ct, cn->u.boolean.left, pr, client_data,
prefix_ar, prefix_level);
- cql_transform_r(ct, cn->u.bool.right, pr, client_data,
+ cql_transform_r(ct, cn->u.boolean.right, pr, client_data,
prefix_ar, prefix_level);
}
}
-/* $Id: cqlutil.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+/* $Id: cqlutil.c,v 1.2 2003-02-14 18:49:23 adam Exp $
Copyright (C) 2002-2003
Index Data Aps
void cql_fputs(const char *buf, void *client_data)
{
- FILE *f = client_data;
+ FILE *f = (FILE *) client_data;
fputs(buf, f);
}
cn->u.mod.next = cql_node_dup(cp->u.mod.next);
break;
case CQL_NODE_BOOL:
- cn = cql_node_mk_boolean(cp->u.bool.value);
- cn->u.bool.left = cql_node_dup(cp->u.bool.left);
- cn->u.bool.right = cql_node_dup(cp->u.bool.right);
- cn->u.bool.prefixes = cql_node_dup(cp->u.bool.prefixes);
+ cn = cql_node_mk_boolean(cp->u.boolean.value);
+ cn->u.boolean.left = cql_node_dup(cp->u.boolean.left);
+ cn->u.boolean.right = cql_node_dup(cp->u.boolean.right);
+ cn->u.boolean.prefixes = cql_node_dup(cp->u.boolean.prefixes);
}
return cn;
}
const char *relation,
const char *term)
{
- struct cql_node *p = malloc(sizeof(*p));
+ struct cql_node *p = (struct cql_node *) malloc(sizeof(*p));
p->which = CQL_NODE_ST;
p->u.st.index = 0;
if (index)
struct cql_node *cql_node_mk_mod(const char *name,
const char *value)
{
- struct cql_node *p = malloc(sizeof(*p));
+ struct cql_node *p = (struct cql_node *) malloc(sizeof(*p));
p->which = CQL_NODE_MOD;
p->u.mod.name = 0;
struct cql_node *cql_node_mk_boolean(const char *op)
{
- struct cql_node *p = malloc(sizeof(*p));
+ struct cql_node *p = (struct cql_node *) malloc(sizeof(*p));
p->which = CQL_NODE_BOOL;
- p->u.bool.value = 0;
+ p->u.boolean.value = 0;
if (op)
- p->u.bool.value = strdup(op);
- p->u.bool.left = 0;
- p->u.bool.right = 0;
- p->u.bool.modifiers = 0;
- p->u.bool.prefixes = 0;
+ p->u.boolean.value = strdup(op);
+ p->u.boolean.left = 0;
+ p->u.boolean.right = 0;
+ p->u.boolean.modifiers = 0;
+ p->u.boolean.prefixes = 0;
return p;
}
}
else if (n->which == CQL_NODE_BOOL)
{
- cpp = &n->u.bool.prefixes;
+ cpp = &n->u.boolean.prefixes;
}
if (cpp)
{
cql_node_destroy(cn->u.mod.next);
break;
case CQL_NODE_BOOL:
- free (cn->u.bool.value);
- cql_node_destroy(cn->u.bool.left);
- cql_node_destroy(cn->u.bool.right);
- cql_node_destroy(cn->u.bool.prefixes);
+ free (cn->u.boolean.value);
+ cql_node_destroy(cn->u.boolean.left);
+ cql_node_destroy(cn->u.boolean.right);
+ cql_node_destroy(cn->u.boolean.prefixes);
}
free (cn);
}
-/* $Id: xcqlutil.c,v 1.1 2003-01-06 08:20:27 adam Exp $
+/* $Id: xcqlutil.c,v 1.2 2003-02-14 18:49:23 adam Exp $
Copyright (C) 2002-2003
Index Data Aps
case CQL_NODE_BOOL:
pr_n("<triple>\n", pr, client_data, level);
prefixes(cn->u.st.prefixes, pr, client_data, level+2);
- if (cn->u.bool.value)
+ if (cn->u.boolean.value)
{
- struct cql_node *m = cn->u.bool.modifiers;
+ struct cql_node *m = cn->u.boolean.modifiers;
pr_n("<boolean>\n", pr, client_data, level+2);
pr_n("<value>", pr, client_data, level+4);
- pr_cdata(cn->u.bool.value, pr, client_data);
+ pr_cdata(cn->u.boolean.value, pr, client_data);
pr_n("</value>\n", pr, client_data, 0);
if (m)
}
pr_n("</boolean>\n", pr, client_data, level+2);
}
- if (cn->u.bool.left)
+ if (cn->u.boolean.left)
{
printf ("%*s<leftOperand>\n", level+2, "");
- cql_to_xml_r(cn->u.bool.left, pr, client_data, level+4);
+ cql_to_xml_r(cn->u.boolean.left, pr, client_data, level+4);
printf ("%*s</leftOperand>\n", level+2, "");
}
- if (cn->u.bool.right)
+ if (cn->u.boolean.right)
{
printf ("%*s<rightOperand>\n", level+2, "");
- cql_to_xml_r(cn->u.bool.right, pr, client_data, level+4);
+ cql_to_xml_r(cn->u.boolean.right, pr, client_data, level+4);
printf ("%*s</rightOperand>\n", level+2, "");
}
pr_n("</triple>\n", pr, client_data, level);
void cql_buf_write_handler (const char *b, void *client_data)
{
- struct cql_buf_write_info *info = client_data;
+ struct cql_buf_write_info *info = (struct cql_buf_write_info *)client_data;
int l = strlen(b);
if (info->off < 0 || (info->off + l >= info->max))
{
-<!-- $Id: tools.xml,v 1.18 2003-01-28 22:34:17 adam Exp $ -->
+<!-- $Id: tools.xml,v 1.19 2003-02-14 18:49:23 adam Exp $ -->
<chapter id="tools"><title>Supporting Tools</title>
<para>
struct cql_node *right;
struct cql_node *modifiers;
struct cql_node *prefixes;
- } bool;
+ } boolean;
struct {
char *name;
char *value;
-/* $Id: cql.h,v 1.1 2003-01-06 08:20:27 adam Exp $
+/* $Id: cql.h,v 1.2 2003-02-14 18:49:23 adam Exp $
Copyright (C) 2002-2003
Index Data Aps
struct cql_node *right;
struct cql_node *modifiers;
struct cql_node *prefixes;
- } bool;
+ } boolean;
struct {
char *name;
char *value;
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: oid.h,v 1.13 2003-01-06 08:20:27 adam Exp $
+ * $Id: oid.h,v 1.14 2003-02-14 18:49:23 adam Exp $
*/
#ifndef OID_H
PROTO_Z3950,
PROTO_SR,
PROTO_GENERAL,
- PROTO_WAIS
+ PROTO_WAIS,
+ PROTO_SRW,
} oid_proto;
typedef enum oid_class
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: proto.h,v 1.7 2003-02-12 15:06:43 adam Exp $
+ * $Id: proto.h,v 1.8 2003-02-14 18:49:23 adam Exp $
*/
#ifndef Z_PROTO_H
#define Z_PROTO_H
YAZ_EXPORT const char *z_HTTP_errmsg(int code);
YAZ_EXPORT Z_GDU *z_get_HTTP_Response(ODR o, int code);
+YAZ_EXPORT Z_GDU *z_get_HTTP_Request(ODR o);
YAZ_END_CDECL
* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: soap.h,v 1.1 2003-02-12 15:06:43 adam Exp $
+ * $Id: soap.h,v 1.2 2003-02-14 18:49:23 adam Exp $
*/
#ifndef YAZ_SOAP_H
#include <yaz/odr.h>
-#if HAVE_XSLT
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#endif
-
typedef struct {
char *fault_code;
char *fault_string;
const char *ns;
} Z_SOAP;
+typedef int (*Z_SOAP_fun)(ODR o, void * ptr, void **handler_data,
+ void *client_data, const char *ns);
typedef struct {
char *ns;
void *client_data;
- int (*f)(ODR o, xmlNodePtr ptr, void **handler_data,
- void *client_data, const char *ns);
+ Z_SOAP_fun f;
} Z_SOAP_Handler;
YAZ_EXPORT int z_soap_codec(ODR o, Z_SOAP **pp,
* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: srw.h,v 1.1 2003-02-12 15:06:43 adam Exp $
+ * $Id: srw.h,v 1.2 2003-02-14 18:49:23 adam Exp $
*/
#ifndef YAZ_SRW_H
} u;
} Z_SRW_searchRetrieve;
+#if 1
+YAZ_EXPORT int yaz_srw_codec(ODR o, void * pptr,
+ Z_SRW_searchRetrieve **handler_data,
+ void *client_data, const char *ns);
+#else
YAZ_EXPORT int yaz_srw_codec(ODR o, xmlNodePtr pptr,
Z_SRW_searchRetrieve **handler_data,
void *client_data, const char *ns);
+#endif
YAZ_EXPORT Z_SRW_searchRetrieve *yaz_srw_get(ODR o, int which);
#endif
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: ber_any.c,v 1.21 2003-02-12 15:06:43 adam Exp $
+ * $Id: ber_any.c,v 1.22 2003-02-14 18:49:23 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
+#include <ctype.h>
+
#include "odr-priv.h"
int ber_any(ODR o, Odr_any **p)
-## $Id: Makefile.am,v 1.8 2003-02-12 15:06:43 adam Exp $
+
noinst_LTLIBRARIES=libserver.la
EXTRA_DIST=service.c
-AM_CPPFLAGS=-I$(top_srcdir)/include $(XSLT_CFLAGS)
+AM_CPPFLAGS=-I$(top_srcdir)/include $(XSLT_CFLAGS) -DDOCDIR=\"$(datadir)/doc/$(PACKAGE)\"
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.134 2003-02-12 15:06:43 adam Exp $
+ * $Id: seshigh.c,v 1.135 2003-02-14 18:49:24 adam Exp $
*/
/*
#include <stdlib.h>
#include <stdio.h>
+#include <sys/types.h>
#ifdef WIN32
+#include <io.h>
+#define S_ISREG(x) (x & _S_IFREG)
#include <process.h>
#else
+#include <sys/stat.h>
#include <unistd.h>
#endif
#include <assert.h>
rr.request_format_raw = yaz_oidval_to_z3950oid(assoc->decode,
CLASS_TRANSYN,
VAL_TEXT_XML);
- rr.comp = odr_malloc(assoc->decode, sizeof(*rr.comp));
+ rr.comp = (Z_RecordComposition *)
+ odr_malloc(assoc->decode, sizeof(*rr.comp));
rr.comp->which = Z_RecordComp_complex;
- rr.comp->u.complex = odr_malloc(assoc->decode, sizeof(Z_CompSpec));
+ rr.comp->u.complex = (Z_CompSpec *)
+ odr_malloc(assoc->decode, sizeof(Z_CompSpec));
rr.comp->u.complex->selectAlternativeSyntax = (bool_t *)
odr_malloc(assoc->encode, sizeof(bool_t));
*rr.comp->u.complex->selectAlternativeSyntax = 0;
rr.comp->u.complex->num_recordSyntax = 0;
rr.comp->u.complex->recordSyntax = 0;
- rr.comp->u.complex->generic = odr_malloc(assoc->decode,
- sizeof(Z_Specification));
+ rr.comp->u.complex->generic = (Z_Specification *)
+ odr_malloc(assoc->decode, sizeof(Z_Specification));
rr.comp->u.complex->generic->which = Z_Specification_uri;
rr.comp->u.complex->generic->u.uri = srw_req->recordSchema;
rr.comp->u.complex->generic->elementSpec = 0;
if (rr.errcode)
{
srw_res->num_diagnostics = 1;
- srw_res->diagnostics =
- odr_malloc(assoc->encode, sizeof(*srw_res->diagnostics));
+ srw_res->diagnostics = (Z_SRW_diagnostic *)
+ odr_malloc(assoc->encode, sizeof(*srw_res->diagnostics));
srw_res->diagnostics[0].code =
odr_intdup(assoc->encode, rr.errcode);
}
int j = 0;
if (start + number > rr.hits)
number = rr.hits - start + 1;
- srw_res->records =
+ srw_res->records = (Z_SRW_record *)
odr_malloc(assoc->encode,
number * sizeof(*srw_res->records));
for (i = 0; i<number; i++)
static void process_http_request(association *assoc, request *req)
{
Z_HTTP_Request *hreq = req->gdu_request->u.HTTP_Request;
- Z_HTTP_Header *hp;
ODR o = assoc->encode;
- Z_GDU *p;
+ Z_GDU *p = 0;
Z_HTTP_Response *hres = 0;
int keepalive = 1;
-#if 0
- yaz_log(LOG_LOG, "HTTP Request. method=%s Version=%s Path=%s",
- hreq->method, hreq->version, hreq->path);
-
- for (hp = hreq->headers; hp; hp = hp->next)
- yaz_log(LOG_LOG, "%s: %s", hp->name, hp->value);
-#endif
-
if (!strcmp(hreq->method, "GET"))
{
- if (!strcmp(hreq->path, "/"))
+#ifdef DOCDIR
+ if (strlen(hreq->path) >= 5 && strlen(hreq->path) < 80 &&
+ !memcmp(hreq->path, "/doc/", 5))
+ {
+ FILE *f;
+ char fpath[120];
+
+ strcpy(fpath, DOCDIR);
+ strcat(fpath, hreq->path+4);
+ f = fopen(fpath, "rb");
+ if (f) {
+ struct stat sbuf;
+ if (fstat(fileno(f), &sbuf) || !S_ISREG(sbuf.st_mode))
+ {
+ fclose(f);
+ f = 0;
+ }
+ }
+ if (f)
+ {
+ long sz;
+ fseek(f, 0L, SEEK_END);
+ sz = ftell(f);
+ if (sz >= 0 && sz < 500000)
+ {
+ const char *ctype = "application/octet-stream";
+ const char *cp;
+
+ p = z_get_HTTP_Response(o, 200);
+ hres = p->u.HTTP_Response;
+ hres->content_buf = (char *) odr_malloc(o, sz + 1);
+ hres->content_len = sz;
+ fseek(f, 0L, SEEK_SET);
+ fread(hres->content_buf, 1, sz, f);
+ if ((cp = strrchr(fpath, '.'))) {
+ cp++;
+ if (!strcmp(cp, "png"))
+ ctype = "image/png";
+ else if (!strcmp(cp, "gif"))
+ ctype = "image/gif";
+ else if (!strcmp(cp, "xml"))
+ ctype = "text/xml";
+ else if (!strcmp(cp, "html"))
+ ctype = "text/html";
+ }
+ z_HTTP_header_add(o, &hres->headers, "Content-Type", ctype);
+ yaz_log(LOG_LOG, "OK send page %s size=%ld", fpath, sz);
+ }
+ fclose(f);
+ }
+ }
+#endif
+ if (!strcmp(hreq->path, "/"))
{
+ struct stat sbuf;
+ const char *doclink = "";
p = z_get_HTTP_Response(o, 200);
hres = p->u.HTTP_Response;
- hres->content_buf = odr_malloc(o, 400);
+ hres->content_buf = (char *) odr_malloc(o, 400);
+#ifdef DOCDIR
+ if (stat(DOCDIR "/yaz.html", &sbuf) == 0 && S_ISREG(sbuf.st_mode))
+ doclink = "<P><A HREF=\"/doc/yaz.html\">Documentation</A></P>";
+#endif
sprintf (hres->content_buf,
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
"<HTML>\n"
" <BODY>\n"
" <P><A HREF=\"http://www.indexdata.dk/yaz/\">YAZ</A> "
YAZ_VERSION "</P>\n"
+ "%s"
" </BODY>\n"
- "</HTML>\n");
+ "</HTML>\n", doclink);
hres->content_len = strlen(hres->content_buf);
z_HTTP_header_add(o, &hres->headers, "Content-Type", "text/html");
}
- else
+ if (!p)
{
p = z_get_HTTP_Response(o, 404);
}
}
else if (!strcmp(hreq->method, "POST"))
{
+#if HAVE_XSLT
const char *content_type = z_HTTP_header_lookup(hreq->headers,
"Content-Type");
const char *soap_action = z_HTTP_header_lookup(hreq->headers,
"SOAPAction");
- p = 0; /* no response yet */
if (content_type && soap_action &&
!yaz_strcmp_del("text/xml", content_type, "; "))
{
int http_code = 500;
static Z_SOAP_Handler soap_handlers[2] = {
- {"http://www.loc.gov/zing/srw/v1.0/", 0, yaz_srw_codec},
+ {"http://www.loc.gov/zing/srw/v1.0/", 0,
+ (Z_SOAP_fun) yaz_srw_codec},
{0, 0, 0}
};
soap_handlers);
hres->code = http_code;
}
+#endif
if (!p) /* still no response ? */
p = z_get_HTTP_Response(o, 500);
}
* NT threaded server code by
* Chas Woodfield, Fretwell Downing Informatics.
*
- * $Id: statserv.c,v 1.91 2003-02-12 15:06:43 adam Exp $
+ * $Id: statserv.c,v 1.92 2003-02-14 18:49:24 adam Exp $
*/
#include <stdio.h>
void statserv_add_soap_handler(int (*h)(struct bend_soap_rr *rr),
const char *ns)
{
- struct bend_soap_handler *sh = xmalloc(sizeof(*sh));
+ struct bend_soap_handler *sh = (struct bend_soap_handler *)
+ xmalloc(sizeof(*sh));
sh->handler = h;
sh->ns = xstrdup(ns);
/*
- * $Id: zoomsh.c,v 1.12 2003-01-06 08:20:28 adam Exp $
+ * $Id: zoomsh.c,v 1.13 2003-02-14 18:49:24 adam Exp $
*
* ZOOM-C Shell
*/
int i, res;
ZOOM_connection z39_con[MAX_CON];
ZOOM_resultset z39_res[MAX_CON];
+
for (i = 0; i<MAX_CON; i++)
{
z39_con[i] = 0;
* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: soap.c,v 1.1 2003-02-12 15:06:44 adam Exp $
+ * $Id: soap.c,v 1.2 2003-02-14 18:49:24 adam Exp $
*/
#include <yaz/soap.h>
+#if HAVE_XSLT
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
static const char *soap_v1_1 = "http://schemas.xmlsoap.org/soap/envelope/";
static const char *soap_v1_2 = "http://www.w3.org/2001/06/soap-envelope";
const char *details)
{
p->which = Z_SOAP_error;
- p->u.soap_error = odr_malloc(o, sizeof(*p->u.soap_error));
+ p->u.soap_error = (Z_SOAP_Fault *)
+ odr_malloc(o, sizeof(*p->u.soap_error));
p->u.soap_error->fault_code = odr_strdup(o, fault_code);
p->u.soap_error->fault_string = odr_strdup(o, fault_string);
if (details)
if (!content_buf || !*content_buf || !content_len)
return -1;
- *pp = p = odr_malloc(o, sizeof(*p));
+ *pp = p = (Z_SOAP *) odr_malloc(o, sizeof(*p));
p->ns = soap_v1_1;
doc = xmlParseMemory(*content_buf, *content_len);
return ret;
}
xmlDocDumpMemory(doc, &buf_out, &len_out);
- *content_buf = odr_malloc(o, len_out);
+ *content_buf = (char *) odr_malloc(o, len_out);
*content_len = len_out;
memcpy(*content_buf, buf_out, len_out);
xmlFree(buf_out);
}
return 0;
}
+#endif
* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: srw.c,v 1.1 2003-02-12 15:06:44 adam Exp $
+ * $Id: srw.c,v 1.2 2003-02-14 18:49:24 adam Exp $
*/
#include <yaz/srw.h>
+#if HAVE_XSLT
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
static void add_xsd_string_n(xmlNodePtr ptr, const char *elem, char *val,
int len)
{
}
-int yaz_srw_codec(ODR o, xmlNodePtr pptr, Z_SRW_searchRetrieve **handler_data,
+int yaz_srw_codec(ODR o, void * vptr, Z_SRW_searchRetrieve **handler_data,
void *client_data, const char *ns)
{
+ xmlNodePtr pptr = vptr;
if (o->direction == ODR_DECODE)
{
xmlNodePtr method = pptr->children;
sr->u.request = odr_malloc(o, sizeof(*sr->u.request));
sr->u.request->query = 0;
sr->u.request->xQuery = 0;
+ sr->u.request->pQuery = 0;
sr->u.request->sortKeys = 0;
sr->u.request->xSortKeys = 0;
sr->u.request->startRecord = 0;
}
return sr;
}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2002-2003, Index Data.
+ * See the file LICENSE for details.
+ *
+ * $Id: srwtst.c,v 1.1 2003-02-14 18:49:24 adam Exp $
+ */
+
+#include <yaz/srw.h>
+
+#if HAVE_XSLT
+Z_SOAP_Handler h[2] = {
+ {"http://www.loc.gov/zing/srw/v1.0/", 0, (Z_SOAP_fun) yaz_srw_codec},
+ {0, 0, 0}
+};
+
+int main(int argc, char **argv)
+{
+ char buf[163840];
+ char *content_buf = buf;
+ int content_len;
+ int ret;
+ size_t no;
+ Z_SOAP *soap_package = 0;
+ ODR decode, encode;
+ int debug = 0;
+
+ if (argc == 2 && !strcmp(argv[1], "debug"))
+ debug = 1;
+ no = fread(buf, 1, sizeof(buf), stdin);
+ if (no < 1 || no == sizeof(buf))
+ {
+ fprintf(stderr, "Bad file or too big\n");
+ exit (1);
+ }
+ decode = odr_createmem(ODR_DECODE);
+ encode = odr_createmem(ODR_ENCODE);
+ content_len = no;
+ ret = z_soap_codec(decode, &soap_package,
+ &content_buf, &content_len, h);
+ if (!soap_package)
+ {
+ fprintf(stderr, "Decoding seriously failed\n");
+ exit(1);
+ }
+ if (debug)
+ {
+ fprintf(stderr, "got NS = %s\n", soap_package->ns);
+ if (soap_package->which == Z_SOAP_generic &&
+ soap_package->u.generic->no == 0)
+ {
+ Z_SRW_searchRetrieve *sr = soap_package->u.generic->p;
+ if (sr->which == Z_SRW_searchRetrieve_request)
+ {
+ Z_SRW_searchRetrieveRequest *req = sr->u.request;
+ }
+ else if (sr->which == Z_SRW_searchRetrieve_response)
+ {
+ Z_SRW_searchRetrieveResponse *res = sr->u.response;
+ if (res->records && res->num_records)
+ {
+ int i;
+ for (i = 0; i<res->num_records; i++)
+ {
+ fprintf (stderr, "%d\n", i);
+ if (res->records[i].recordData_buf)
+ fwrite(res->records[i].recordData_buf, 1,
+ res->records[i].recordData_len, stderr);
+ }
+ }
+ }
+
+ }
+ }
+ ret = z_soap_codec(encode, &soap_package,
+ &content_buf, &content_len, h);
+ if (content_buf && content_len)
+ fwrite (content_buf, content_len, 1, stdout);
+ else
+ {
+ fprintf(stderr, "No output!\n");
+ exit(1);
+ }
+ exit(0);
+}
+#else
+int main(int argc, char **argv)
+{
+ fprintf(stderr, "SOAP disabled\n");
+ exit(1);
+}
+#endif
* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: zgdu.c,v 1.1 2003-02-12 15:06:44 adam Exp $
+ * $Id: zgdu.c,v 1.2 2003-02-14 18:49:24 adam Exp $
*/
#include <yaz/proto.h>
else if (o->buf[i] == ':')
break;
}
- *headers = odr_malloc(o, sizeof(**headers));
- (*headers)->name = odr_malloc(o, i - po + 1);
+ *headers = (Z_HTTP_Header *) odr_malloc(o, sizeof(**headers));
+ (*headers)->name = (char*) odr_malloc(o, i - po + 1);
memcpy ((*headers)->name, o->buf + po, i - po);
(*headers)->name[i - po] = '\0';
i++;
for (po = i; i < o->size-1 && o->buf[i] != '\r' ; i++)
;
- (*headers)->value = odr_malloc(o, i - po + 1);
+ (*headers)->value = (char*) odr_malloc(o, i - po + 1);
memcpy ((*headers)->value, o->buf + po, i - po);
(*headers)->value[i - po] = '\0';
else
{
*content_len = o->size - i;
- *content_buf = odr_malloc(o, *content_len + 1);
+ *content_buf = (char*) odr_malloc(o, *content_len + 1);
memcpy(*content_buf, o->buf + i, *content_len);
(*content_buf)[*content_len] = '\0';
}
{
while (*hp)
hp = &(*hp)->next;
- *hp = odr_malloc(o, sizeof(**hp));
+ *hp = (Z_HTTP_Header *) odr_malloc(o, sizeof(**hp));
(*hp)->name = odr_strdup(o, n);
(*hp)->value = odr_strdup(o, v);
(*hp)->next = 0;
}
+Z_GDU *z_get_HTTP_Request(ODR o)
+{
+ Z_GDU *p = (Z_GDU *) odr_malloc(o, sizeof(*p));
+ Z_HTTP_Request *hreq;
+
+ p->which = Z_GDU_HTTP_Request;
+ p->u.HTTP_Request = (Z_HTTP_Request *) odr_malloc(o, sizeof(*hreq));
+ hreq = p->u.HTTP_Request;
+ hreq->headers = 0;
+ hreq->content_len = 0;
+ hreq->content_buf = 0;
+ hreq->version = "1.1";
+ hreq->method = "POST";
+ hreq->path = "/";
+ z_HTTP_header_add(o, &hreq->headers, "User-Agent",
+ "YAZ/" YAZ_VERSION);
+ return p;
+}
+
Z_GDU *z_get_HTTP_Response(ODR o, int code)
{
- Z_GDU *p = odr_malloc(o, sizeof(*p));
+ Z_GDU *p = (Z_GDU *) odr_malloc(o, sizeof(*p));
Z_HTTP_Response *hres;
p->which = Z_GDU_HTTP_Response;
- hres = p->u.HTTP_Response = odr_malloc(o, sizeof(*hres));
+ p->u.HTTP_Response = (Z_HTTP_Response *) odr_malloc(o, sizeof(*hres));
+ hres = p->u.HTTP_Response;
hres->headers = 0;
hres->content_len = 0;
hres->content_buf = 0;
"YAZ/" YAZ_VERSION);
if (code != 200)
{
- hres->content_buf = odr_malloc(o, 400);
+ hres->content_buf = (char*) odr_malloc(o, 400);
sprintf (hres->content_buf,
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
"<HTML>\n"
int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
{
if (o->direction == ODR_DECODE) {
- *p = odr_malloc(o, sizeof(**p));
+ *p = (Z_GDU *) odr_malloc(o, sizeof(**p));
if (o->size > 10 && !memcmp(o->buf, "HTTP/", 5))
{
int i, po;
Z_HTTP_Response *hr;
(*p)->which = Z_GDU_HTTP_Response;
- hr = (*p)->u.HTTP_Response = odr_malloc(o, sizeof(*hr));
-
+#if HTTP_DEBUG
+ fprintf(stderr, "-- HTTP decode:\n%.*s\n", o->size, o->buf);
+#endif
+ hr = (*p)->u.HTTP_Response = (Z_HTTP_Response *)
+ odr_malloc(o, sizeof(*hr));
po = i = 5;
while (i < o->size-2 && o->buf[i] != ' ' && o->buf[i] != '\r')
i++;
- hr->version = odr_malloc(o, i - po + 1);
+ hr->version = (char *) odr_malloc(o, i - po + 1);
if (i - po)
memcpy(hr->version, o->buf + po, i - po);
hr->version[i-po] = 0;
Z_HTTP_Request *hr;
#if HTTP_DEBUG
- fprintf(stderr, "HTTP decode:\n%.*s\n", o->size, o->buf);
+ fprintf(stderr, "-- HTTP decode:\n%.*s\n", o->size, o->buf);
#endif
(*p)->which = Z_GDU_HTTP_Request;
- hr = (*p)->u.HTTP_Request = odr_malloc(o, sizeof(*hr));
+ hr = (*p)->u.HTTP_Request =
+ (Z_HTTP_Request *) odr_malloc(o, sizeof(*hr));
/* method .. */
for (i = 0; o->buf[i] != ' '; i++)
o->error = OHTTP;
return 0;
}
- hr->method = odr_malloc(o, i+1);
+ hr->method = (char *) odr_malloc(o, i+1);
memcpy (hr->method, o->buf, i);
hr->method[i] = '\0';
/* path */
o->error = OHTTP;
return 0;
}
- hr->path = odr_malloc(o, i - po + 1);
+ hr->path = (char *) odr_malloc(o, i - po + 1);
memcpy (hr->path, o->buf+po, i - po);
hr->path[i - po] = '\0';
/* HTTP version */
}
i++;
}
- hr->version = odr_malloc(o, i - po + 1);
+ hr->version = (char *) odr_malloc(o, i - po + 1);
memcpy(hr->version, o->buf + po, i - po);
hr->version[i - po] = '\0';
/* headers */
sprintf(sbuf, "HTTP/%s %d %s\r\n", (*p)->u.HTTP_Response->version,
(*p)->u.HTTP_Response->code,
z_HTTP_errmsg((*p)->u.HTTP_Response->code));
- odr_write(o, sbuf, strlen(sbuf));
+ odr_write(o, (unsigned char *) sbuf, strlen(sbuf));
/* apply Content-Length if not already applied */
if (!z_HTTP_header_lookup((*p)->u.HTTP_Response->headers,
"Content-Length"))
}
for (h = (*p)->u.HTTP_Response->headers; h; h = h->next)
{
- odr_write(o, h->name, strlen(h->name));
- odr_write(o, ": ", 2);
- odr_write(o, h->value, strlen(h->value));
- odr_write(o, "\r\n", 2);
+ odr_write(o, (unsigned char *) h->name, strlen(h->name));
+ odr_write(o, (unsigned char *) ": ", 2);
+ odr_write(o, (unsigned char *) h->value, strlen(h->value));
+ odr_write(o, (unsigned char *) "\r\n", 2);
}
- odr_write(o, "\r\n", 2);
+ odr_write(o, (unsigned char *) "\r\n", 2);
if ((*p)->u.HTTP_Response->content_buf)
- odr_write(o, (*p)->u.HTTP_Response->content_buf,
+ odr_write(o, (unsigned char *)
+ (*p)->u.HTTP_Response->content_buf,
(*p)->u.HTTP_Response->content_len);
#if HTTP_DEBUG
- fprintf(stderr, "HTTP response:\n%.*s\n", o->top, o->buf);
+ fprintf(stderr, "-- HTTP response:\n%.*s\n", o->top, o->buf);
#endif
break;
case Z_GDU_HTTP_Request:
- odr_write(o, (*p)->u.HTTP_Request->method,
+ odr_write(o, (unsigned char *) (*p)->u.HTTP_Request->method,
strlen((*p)->u.HTTP_Request->method));
- odr_write(o, " ", 1);
- odr_write(o, (*p)->u.HTTP_Request->path,
+ odr_write(o, (unsigned char *) " ", 1);
+ odr_write(o, (unsigned char *) (*p)->u.HTTP_Request->path,
strlen((*p)->u.HTTP_Request->path));
- odr_write(o, " HTTP/", 6);
- odr_write(o, (*p)->u.HTTP_Request->version,
+ odr_write(o, (unsigned char *) " HTTP/", 6);
+ odr_write(o, (unsigned char *) (*p)->u.HTTP_Request->version,
strlen((*p)->u.HTTP_Request->version));
- odr_write(o, "\r\n", 2);
+ odr_write(o, (unsigned char *) "\r\n", 2);
+ if ((*p)->u.HTTP_Request->content_len &&
+ !z_HTTP_header_lookup((*p)->u.HTTP_Request->headers,
+ "Content-Length"))
+ {
+ char lstr[20];
+ sprintf(lstr, "%d", (*p)->u.HTTP_Request->content_len);
+ z_HTTP_header_add(o,
+ &(*p)->u.HTTP_Request->headers,
+ "Content-Length", lstr);
+ }
for (h = (*p)->u.HTTP_Request->headers; h; h = h->next)
{
- odr_write(o, h->name, strlen(h->name));
- odr_write(o, ": ", 2);
- odr_write(o, h->value, strlen(h->value));
- odr_write(o, "\r\n", 2);
+ odr_write(o, (unsigned char *) h->name, strlen(h->name));
+ odr_write(o, (unsigned char *) ": ", 2);
+ odr_write(o, (unsigned char *) h->value, strlen(h->value));
+ odr_write(o, (unsigned char *) "\r\n", 2);
}
- odr_write(o, "\r\n", 2);
+ odr_write(o, (unsigned char *) "\r\n", 2);
if ((*p)->u.HTTP_Request->content_buf)
- odr_write(o, (*p)->u.HTTP_Request->content_buf,
+ odr_write(o, (unsigned char *)
+ (*p)->u.HTTP_Request->content_buf,
(*p)->u.HTTP_Request->content_len);
#if HTTP_DEBUG
- fprintf(stderr, "HTTP request:\n%.*s\n", o->top, o->buf);
+ fprintf(stderr, "-- HTTP request:\n%.*s\n", o->top, o->buf);
#endif
break;
case Z_GDU_Z3950:
* Copyright (c) 2000-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.17 2003-02-12 15:06:44 adam Exp $
+ * $Id: zoom-c.c,v 1.18 2003-02-14 18:49:24 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
#include <yaz/diagbib1.h>
#include <yaz/charneg.h>
#include <yaz/ill.h>
-
+#include <yaz/srw.h>
#if HAVE_SYS_POLL_H
#include <sys/poll.h>
}
}
+static int ZOOM_connection_exec_task (ZOOM_connection c);
+
void ZOOM_connection_remove_tasks (ZOOM_connection c)
{
while (c->tasks)
{
ZOOM_connection c = (ZOOM_connection) xmalloc (sizeof(*c));
- c->soap = 0;
+ c->proto = PROTO_Z3950;
c->cs = 0;
c->mask = 0;
c->reconnect_ok = 0;
c->options = ZOOM_options_create_with_parent(options);
c->host_port = 0;
+ c->path = 0;
c->proxy = 0;
c->charset = c->lang = 0;
c->lang = 0;
xfree (c->host_port);
+ xfree (c->path);
if (portnum)
{
char hostn[128];
ZOOM_resultset r;
if (!c)
return;
-#if HAVE_GSOAP
- if (c->soap)
- soap_end(c->soap);
-#endif
if (c->cs)
cs_close (c->cs);
for (r = c->resultsets; r; r = r->next)
if (memcmp(c->host_port, "http:", 5) == 0)
{
-#if HAVE_GSOAP
- c->soap = soap_new();
- c->soap->namespaces = srw_namespaces;
+#if HAVE_XSLT
+ const char *path;
+ c->proto = PROTO_SRW;
+ effective_host = c->host_port + 5;
+ if (*effective_host == '/')
+ effective_host++;
+ if (*effective_host == '/')
+ effective_host++;
+ if (!(path = strchr(effective_host, '/')))
+ path = "/";
+ xfree(c->path);
+ c->path = xstrdup(path);
#else
c->state = STATE_IDLE;
set_ZOOM_error(c, ZOOM_ERROR_UNSUPPORTED_PROTOCOL, "SRW");
+ return zoom_complete;
#endif
}
- else
+ c->cs = cs_create_host (effective_host, 0, &add);
+
+ if (c->cs)
{
- c->cs = cs_create_host (effective_host, 0, &add);
-
- if (c->cs)
+ int ret = cs_connect (c->cs, add);
+ if (ret == 0)
{
- int ret = cs_connect (c->cs, add);
- if (ret == 0)
- {
- ZOOM_Event event = ZOOM_Event_create(ZOOM_EVENT_CONNECT);
- ZOOM_connection_put_event(c, event);
+ ZOOM_Event event = ZOOM_Event_create(ZOOM_EVENT_CONNECT);
+ ZOOM_connection_put_event(c, event);
+ if (c->proto == PROTO_Z3950)
ZOOM_connection_send_init(c);
- c->state = STATE_ESTABLISHED;
- return zoom_pending;
- }
- else if (ret > 0)
+ else
{
- c->state = STATE_CONNECTING;
- c->mask = ZOOM_SELECT_EXCEPT;
- if (c->cs->io_pending & CS_WANT_WRITE)
- c->mask += ZOOM_SELECT_WRITE;
- if (c->cs->io_pending & CS_WANT_READ)
- c->mask += ZOOM_SELECT_READ;
- return zoom_pending;
+ /* no init request for SRW .. */
+ assert (c->tasks->which == ZOOM_TASK_CONNECT);
+ ZOOM_connection_remove_task (c);
+ c->mask = 0;
+ ZOOM_connection_exec_task (c);
}
+ c->state = STATE_ESTABLISHED;
+ return zoom_pending;
+ }
+ else if (ret > 0)
+ {
+ c->state = STATE_CONNECTING;
+ c->mask = ZOOM_SELECT_EXCEPT;
+ if (c->cs->io_pending & CS_WANT_WRITE)
+ c->mask += ZOOM_SELECT_WRITE;
+ if (c->cs->io_pending & CS_WANT_READ)
+ c->mask += ZOOM_SELECT_READ;
+ return zoom_pending;
}
- c->state = STATE_IDLE;
- set_ZOOM_error(c, ZOOM_ERROR_CONNECT, effective_host);
}
+ c->state = STATE_IDLE;
+ set_ZOOM_error(c, ZOOM_ERROR_CONNECT, effective_host);
return zoom_complete;
}
return send_APDU (c, apdu);
}
+static zoom_ret send_srw (ZOOM_connection c, Z_SRW_searchRetrieve *sr)
+{
+ Z_SOAP_Handler h[2] = {
+ {"http://www.loc.gov/zing/srw/v1.0/", 0, (Z_SOAP_fun) yaz_srw_codec},
+ {0, 0, 0}
+ };
+ ODR o = odr_createmem(ODR_ENCODE);
+ int ret;
+ Z_SOAP *p = odr_malloc(o, sizeof(*p));
+ Z_GDU *gdu;
+ ZOOM_Event event;
+
+ gdu = z_get_HTTP_Request(c->odr_out);
+ gdu->u.HTTP_Request->path = c->path;
+ z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers,
+ "Content-Type", "text/xml");
+ z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers,
+ "SOAPAction", "\"\"");
+ p->which = Z_SOAP_generic;
+ p->u.generic = odr_malloc(o, sizeof(*p->u.generic));
+ p->u.generic->no = 0;
+ p->u.generic->ns = 0;
+ p->u.generic->p = sr;
+ p->ns = "http://schemas.xmlsoap.org/soap/envelope/";
+
+ ret = z_soap_codec(o, &p,
+ &gdu->u.HTTP_Request->content_buf,
+ &gdu->u.HTTP_Request->content_len, h);
+
+ if (!z_GDU(c->odr_out, &gdu, 0, 0))
+ return zoom_complete;
+ c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0);
+
+ odr_destroy(o);
+
+ event = ZOOM_Event_create (ZOOM_EVENT_SEND_APDU);
+ ZOOM_connection_put_event (c, event);
+ odr_reset(c->odr_out);
+ return do_write (c);
+}
+
+static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
+{
+ ZOOM_resultset resultset;
+ Z_SRW_searchRetrieve *sr = yaz_srw_get(c->odr_out,
+ Z_SRW_searchRetrieve_request);
+
+ assert (c->tasks);
+ assert (c->tasks->which == ZOOM_TASK_SEARCH);
+
+ resultset = c->tasks->u.search.resultset;
+ assert(resultset);
+ assert (resultset->z_query);
+
+ if (resultset->z_query->which == Z_Query_type_104
+ && resultset->z_query->u.type_104->which == Z_External_CQL)
+ sr->u.request->query = resultset->z_query->u.type_104->u.cql;
+ else
+ sr->u.request->query = "dc.title = computer";
+
+ sr->u.request->startRecord = odr_intdup (c->odr_out, resultset->start + 1);
+ sr->u.request->maximumRecords = odr_intdup (c->odr_out, resultset->count);
+
+ return send_srw(c, sr);
+}
+
static zoom_ret ZOOM_connection_send_search (ZOOM_connection c)
{
ZOOM_resultset r;
}
task->running = 1;
ret = zoom_complete;
- if (c->soap)
+#if 0
+ if (c->proto == PROTO_SRW)
{
-#if HAVE_GSOAP
ZOOM_resultset resultset;
switch (task->which)
{
resultset->z_query->u.type_104->u.cql);
break;
}
-#else
- ;
#endif
- }
- else if (c->cs || task->which == ZOOM_TASK_CONNECT)
+ if (c->cs || task->which == ZOOM_TASK_CONNECT)
{
switch (task->which)
{
case ZOOM_TASK_SEARCH:
- ret = ZOOM_connection_send_search(c);
+ if (c->proto == PROTO_SRW)
+ ret = ZOOM_connection_srw_send_search(c);
+ else
+ ret = ZOOM_connection_send_search(c);
break;
case ZOOM_TASK_RETRIEVE:
ret = send_present (c);
}
}
+static void handle_http(ZOOM_connection c, Z_HTTP_Response *hres)
+{
+ c->mask = 0;
+ yaz_log (LOG_DEBUG, "handle_http");
+ ZOOM_connection_remove_task(c);
+}
+
static int do_read (ZOOM_connection c)
{
int r;
- Z_APDU *apdu;
ZOOM_Event event;
event = ZOOM_Event_create (ZOOM_EVENT_RECV_DATA);
}
else
{
+ Z_GDU *gdu;
ZOOM_Event event;
odr_reset (c->odr_in);
odr_setbuf (c->odr_in, c->buf_in, r, 0);
event = ZOOM_Event_create (ZOOM_EVENT_RECV_APDU);
ZOOM_connection_put_event (c, event);
- if (!z_APDU (c->odr_in, &apdu, 0, 0))
+
+ if (!z_GDU (c->odr_in, &gdu, 0, 0))
{
set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0);
do_close (c);
}
- else
- handle_apdu (c, apdu);
+ else if (gdu->which == Z_GDU_Z3950)
+ handle_apdu (c, gdu->u.z3950);
+ else if (gdu->which == Z_GDU_HTTP_Response)
+ handle_http (c, gdu->u.HTTP_Response);
c->reconnect_ok = 0;
}
return 1;
else if (ret == 0)
{
ZOOM_connection_put_event (c, event);
- ZOOM_connection_send_init (c);
+ if (c->proto == PROTO_Z3950)
+ ZOOM_connection_send_init(c);
+ else
+ {
+ /* no init request for SRW .. */
+ assert (c->tasks->which == ZOOM_TASK_CONNECT);
+ ZOOM_connection_remove_task (c);
+ c->mask = 0;
+ ZOOM_connection_exec_task (c);
+ }
c->state = STATE_ESTABLISHED;
}
else
/*
* Private C header for ZOOM C.
- * $Id: zoom-p.h,v 1.3 2003-01-06 08:20:29 adam Exp $
+ * $Id: zoom-p.h,v 1.4 2003-02-14 18:49:24 adam Exp $
*/
-#if HAVE_GSOAP
-#include <yaz/srw-util.h>
-#else
-struct soap {
- int dummy;
-};
+#if HAVE_XSLT
+#include <yaz/srw.h>
#endif
#include <yaz/proto.h>
#define ZOOM_SELECT_EXCEPT 4
struct ZOOM_connection_p {
- struct soap *soap;
+ enum oid_proto proto;
COMSTACK cs;
char *host_port;
+ char *path;
int error;
char *addinfo;
const char *diagset;