* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: comstack.c,v 1.11 2003-02-14 18:49:23 adam Exp $
+ * $Id: comstack.c,v 1.12 2003-02-21 12:08:57 adam Exp $
*/
#include <string.h>
+#include <ctype.h>
+
#include <yaz/comstack.h>
#include <yaz/tcpip.h>
#include <yaz/unix.h>
+#include <yaz/odr.h>
static const char *cs_errlist[] =
{
COMSTACK cs_create_host(const char *type_and_host, int blocking, void **vp)
{
+ enum oid_proto proto = PROTO_Z3950;
const char *host = 0;
COMSTACK cs;
CS_TYPE t;
return 0;
#endif
}
+ else if (strncmp(type_and_host, "http:", 5) == 0)
+ {
+ t = tcpip_type;
+ host = type_and_host + 5;
+ if (host[0] == '/' && host[1] == '/')
+ host = host + 2;
+ proto = PROTO_HTTP;
+ }
+ else if (strncmp(type_and_host, "https:", 6) == 0)
+ {
+#if HAVE_OPENSSL_SSL_H
+ t = ssl_type;
+ host = type_and_host + 6;
+ if (host[0] == '/' && host[1] == '/')
+ host = host + 2;
+#else
+ return 0;
+#endif
+ proto = PROTO_HTTP;
+ }
else
{
t = tcpip_type;
host = type_and_host;
-
+
}
- cs = cs_create (t, blocking, PROTO_Z3950);
+ cs = cs_create (t, blocking, proto);
if (!cs)
return 0;
{
return cs->event;
}
+
+int cs_complete_auto(const unsigned char *buf, int len)
+{
+ if (!len)
+ return 0;
+ if (!buf[0] && !buf[1])
+ return 0;
+ if (len > 5 && buf[0] >= 0x20 && buf[0] < 0x7f
+ && buf[1] >= 0x20 && buf[1] < 0x7f
+ && buf[2] >= 0x20 && buf[2] < 0x7f)
+ {
+ /* deal with HTTP request/response */
+ int i = 2, content_len = 0;
+
+ while (i <= len-4)
+ {
+ if (buf[i] == '\r' && buf[i+1] == '\n')
+ {
+ i += 2;
+ if (buf[i] == '\r' && buf[i+1] == '\n')
+ {
+ /* i += 2 seems not to work with GCC -O2 ..
+ so i+2 is used instead .. */
+ if (len >= (i+2)+ content_len)
+ return (i+2)+ content_len;
+ break;
+ }
+ if (i < len-18)
+ {
+ if (!memcmp(buf+i, "Content-Length:", 15))
+ {
+ i+= 15;
+ if (buf[i] == ' ')
+ i++;
+ content_len = 0;
+ while (i <= len-4 && isdigit(buf[i]))
+ content_len = content_len*10 + (buf[i++] - '0');
+ if (content_len < 0) /* prevent negative offsets */
+ content_len = 0;
+ }
+ }
+ }
+ else
+ i++;
+ }
+ return 0;
+ }
+ return completeBER(buf, len);
+}
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: tcpip.c,v 1.54 2003-02-20 15:10:24 adam Exp $
+ * $Id: tcpip.c,v 1.55 2003-02-21 12:08:57 adam Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
-#include <unistd.h>
#else
+#include <unistd.h>
#endif
#include <errno.h>
#include <yaz/comstack.h>
#include <yaz/tcpip.h>
#include <yaz/log.h>
+#include <yaz/nmem.h>
#ifdef WIN32
#else
#include <netinet/tcp.h>
#endif
-/* Chas added the following, so we get the definition of completeBER */
-#include <yaz/odr.h>
-
static int tcpip_close(COMSTACK h);
static int tcpip_put(COMSTACK h, char *buf, int size);
static int tcpip_get(COMSTACK h, char **buf, int *bufsize);
if (protocol == PROTO_WAIS)
state->complete = completeWAIS;
else
- state->complete = completeBER;
+ state->complete = cs_complete_auto;
p->timeout = COMSTACK_DEFAULT_TIMEOUT;
TRC(fprintf(stderr, "Created new TCPIP comstack\n"));
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: unix.c,v 1.9 2003-01-06 08:20:27 adam Exp $
+ * $Id: unix.c,v 1.10 2003-02-21 12:08:58 adam Exp $
* UNIX socket COMSTACK. By Morten Bøgeskov.
*/
#ifndef WIN32
#include <yaz/unix.h>
#include <yaz/log.h>
-/* Chas added the following, so we get the definition of completeBER */
-#include <yaz/odr.h>
-
#ifndef YAZ_SOCKLEN_T
#define YAZ_SOCKLEN_T int
#endif
if (protocol == PROTO_WAIS)
state->complete = completeWAIS;
else
- state->complete = completeBER;
+ state->complete = cs_complete_auto;
p->timeout = COMSTACK_DEFAULT_TIMEOUT;
TRC(fprintf(stderr, "Created new UNIX comstack\n"));
-## $Id: Makefile.am,v 1.20 2003-02-12 15:06:43 adam Exp $
+## $Id: Makefile.am,v 1.21 2003-02-21 12:08:58 adam Exp $
pkginclude_HEADERS= backend.h ccl.h cql.h comstack.h \
diagbib1.h sortspec.h log.h logrpn.h marcdisp.h nmem.h odr.h oid.h \
z-grs.h z-mterm2.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 charneg.h soap.h srw.h
+ zoom.h z-charneg.h charneg.h soap.h srw.h zgdu.h
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: comstack.h,v 1.7 2001-10-22 16:00:04 adam Exp $
+ * $Id: comstack.h,v 1.8 2003-02-21 12:08:58 adam Exp $
*/
#ifndef COMSTACK_H
#define CS_WANT_READ 1
#define CS_WANT_WRITE 2
+
YAZ_EXPORT int cs_look (COMSTACK);
YAZ_EXPORT const char *cs_strerror(COMSTACK h);
YAZ_EXPORT const char *cs_errmsg(int n);
YAZ_EXPORT COMSTACK cs_create_host(const char *type_and_host,
- int blocking, void **vp);
+ int blocking, void **vp);
+YAZ_EXPORT int cs_complete_auto(const unsigned char *buf, int len);
+
/*
* error management.
*/
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: oid.h,v 1.14 2003-02-14 18:49:23 adam Exp $
+ * $Id: oid.h,v 1.15 2003-02-21 12:08:58 adam Exp $
*/
#ifndef OID_H
PROTO_SR,
PROTO_GENERAL,
PROTO_WAIS,
- PROTO_SRW,
+ PROTO_HTTP,
} oid_proto;
typedef enum oid_class
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: proto.h,v 1.8 2003-02-14 18:49:23 adam Exp $
+ * $Id: proto.h,v 1.9 2003-02-21 12:08:58 adam Exp $
*/
#ifndef Z_PROTO_H
#define Z_PROTO_H
#include <yaz/z-mterm2.h>
#include <yaz/oid.h>
#include <yaz/wrbuf.h>
+#include <yaz/zgdu.h>
YAZ_BEGIN_CDECL
YAZ_EXPORT void yaz_display_grs1(WRBUF wrbuf, Z_GenericRecord *r, int flags);
-typedef struct Z_HTTP_Header Z_HTTP_Header;
-
-struct Z_HTTP_Header {
- char *name;
- char *value;
- Z_HTTP_Header *next;
-};
-
-typedef struct {
- char *method;
- char *version;
- char *path;
- Z_HTTP_Header *headers;
- char *content_buf;
- int content_len;
-} Z_HTTP_Request;
-
-typedef struct {
- int code;
- char *version;
- Z_HTTP_Header *headers;
- char *content_buf;
- int content_len;
-} Z_HTTP_Response;
-
-#define Z_GDU_Z3950 1
-#define Z_GDU_HTTP_Request 2
-#define Z_GDU_HTTP_Response 3
-typedef struct {
- int which;
- union {
- Z_APDU *z3950;
- Z_HTTP_Request *HTTP_Request;
- Z_HTTP_Response *HTTP_Response;
- } u;
-} Z_GDU ;
-YAZ_EXPORT int z_GDU (ODR o, Z_GDU **p, int opt, const char *name);
-YAZ_EXPORT void z_HTTP_header_add(ODR o, Z_HTTP_Header **hp, const char *n,
- const char *v);
-YAZ_EXPORT const char *z_HTTP_header_lookup(Z_HTTP_Header *hp, const char *n);
-
-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
--- /dev/null
+/*
+ * Copyright (c) 1998-2003, Index Data
+ * See the file LICENSE for details.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Id: zgdu.h,v 1.1 2003-02-21 12:08:58 adam Exp $
+ */
+#ifndef Z_GDU_H
+#define Z_GDU_H
+
+#include <yaz/z-core.h>
+
+typedef struct Z_HTTP_Header Z_HTTP_Header;
+
+struct Z_HTTP_Header {
+ char *name;
+ char *value;
+ Z_HTTP_Header *next;
+};
+
+typedef struct {
+ char *method;
+ char *version;
+ char *path;
+ Z_HTTP_Header *headers;
+ char *content_buf;
+ int content_len;
+} Z_HTTP_Request;
+
+typedef struct {
+ int code;
+ char *version;
+ Z_HTTP_Header *headers;
+ char *content_buf;
+ int content_len;
+} Z_HTTP_Response;
+
+#define Z_GDU_Z3950 1
+#define Z_GDU_HTTP_Request 2
+#define Z_GDU_HTTP_Response 3
+typedef struct {
+ int which;
+ union {
+ Z_APDU *z3950;
+ Z_HTTP_Request *HTTP_Request;
+ Z_HTTP_Response *HTTP_Response;
+ } u;
+} Z_GDU ;
+YAZ_EXPORT int z_GDU (ODR o, Z_GDU **p, int opt, const char *name);
+YAZ_EXPORT void z_HTTP_header_add(ODR o, Z_HTTP_Header **hp, const char *n,
+ const char *v);
+YAZ_EXPORT const char *z_HTTP_header_lookup(Z_HTTP_Header *hp, const char *n);
+
+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);
+
+#endif
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: ber_any.c,v 1.22 2003-02-14 18:49:23 adam Exp $
+ * $Id: ber_any.c,v 1.23 2003-02-21 12:08:58 adam Exp $
*/
#if HAVE_CONFIG_H
#include <config.h>
#endif
-#include <ctype.h>
#include "odr-priv.h"
return 0;
if (!buf[0] && !buf[1])
return 0;
- if (len > 5 && buf[0] >= 0x20 && buf[0] < 0x7f
- && buf[1] >= 0x20 && buf[1] < 0x7f
- && buf[2] >= 0x20 && buf[2] < 0x7f)
- {
- /* deal with HTTP request/response */
- int i = 2, content_len = 0;
-
- while (i <= len-4)
- {
- if (buf[i] == '\r' && buf[i+1] == '\n')
- {
- i += 2;
- if (buf[i] == '\r' && buf[i+1] == '\n')
- {
- /* i += 2 seems not to work with GCC -O2 ..
- so i+2 is used instead .. */
- if (len >= (i+2)+ content_len)
- return (i+2)+ content_len;
- break;
- }
- if (i < len-18)
- {
- if (!memcmp(buf+i, "Content-Length:", 15))
- {
- i+= 15;
- if (buf[i] == ' ')
- i++;
- content_len = 0;
- while (i <= len-4 && isdigit(buf[i]))
- content_len = content_len*10 + (buf[i++] - '0');
- if (content_len < 0) /* prevent negative offsets */
- content_len = 0;
- }
- }
- }
- else
- i++;
- }
- return 0;
- }
- /* BER from now on .. */
if ((res = ber_dectag(b, &zclass, &tag, &cons)) <= 0)
return 0;
if (res > len)
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: eventl.c,v 1.38 2003-02-20 15:13:28 adam Exp $
+ * $Id: eventl.c,v 1.39 2003-02-21 12:08:59 adam Exp $
*/
#include <stdio.h>
to.tv_sec = w;
}
}
- yaz_log(LOG_DEBUG, "select start %d", to.tv_sec);
+ yaz_log(LOG_DEBUG, "select start %ld", (long) to.tv_sec);
res = YAZ_EV_SELECT(max + 1, &in, &out, &except, &to);
yaz_log(LOG_DEBUG, "select end");
if (res < 0)
* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.144 2003-02-20 15:15:04 adam Exp $
+ * $Id: seshigh.c,v 1.145 2003-02-21 12:08:59 adam Exp $
*/
/*
#include <unistd.h>
#endif
#include <assert.h>
+#include <ctype.h>
#include <yaz/yconfig.h>
#include <yaz/xmalloc.h>
Z_SRW_searchRetrieveRequest *srw_req,
Z_SRW_searchRetrieveResponse *srw_res)
{
- char *base = "Default";
int srw_error = 0;
bend_search_rr rr;
Z_External *ext;
* Copyright (c) 2002-2003, Index Data.
* See the file LICENSE for details.
*
- * $Id: zgdu.c,v 1.7 2003-02-20 15:12:28 adam Exp $
+ * $Id: zgdu.c,v 1.8 2003-02-21 12:08:59 adam Exp $
*/
-#include <yaz/proto.h>
+#include <yaz/odr.h>
+#include <yaz/yaz-version.h>
+#include <yaz/zgdu.h>
static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers,
char **content_buf, int *content_len)
* Copyright (c) 2000-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.26 2003-02-20 15:11:38 adam Exp $
+ * $Id: zoom-c.c,v 1.27 2003-02-21 12:08:59 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
r->next = c->resultsets;
c->resultsets = r;
- if (c->host_port && c->proto == PROTO_SRW)
+ if (c->host_port && c->proto == PROTO_HTTP)
{
if (!c->cs)
{
if (!c)
return;
- if (c->host_port && c->proto == PROTO_SRW)
+ if (c->host_port && c->proto == PROTO_HTTP)
{
if (!c->cs)
{
{
#if HAVE_XML2
const char *path;
- c->proto = PROTO_SRW;
+ c->proto = PROTO_HTTP;
effective_host = c->host_port + 5;
if (*effective_host == '/')
effective_host++;
switch (task->which)
{
case ZOOM_TASK_SEARCH:
- if (c->proto == PROTO_SRW)
+ if (c->proto == PROTO_HTTP)
ret = ZOOM_connection_srw_send_search(c);
else
ret = ZOOM_connection_send_search(c);
break;
case ZOOM_TASK_RETRIEVE:
- if (c->proto == PROTO_SRW)
+ if (c->proto == PROTO_HTTP)
ret = ZOOM_connection_srw_send_search(c);
else
ret = send_present (c);