X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Ftcpip.c;h=97449bf4fe0634663b76e50089ebf0653799dd64;hb=31e3a0ef5a0866477a3b54dc6ffbeb0aca4e0029;hp=54d8dbaaa1174241fd419b3151427f76039b52cb;hpb=7bb5e2926727e963de8411dbba9cc18df967bfbb;p=yaz-moved-to-github.git diff --git a/src/tcpip.c b/src/tcpip.c index 54d8dba..97449bf 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -1,22 +1,49 @@ /* - * Copyright (c) 1995-2004, Index Data + * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: tcpip.c,v 1.6 2004-04-30 19:10:35 adam Exp $ + * $Id: tcpip.c,v 1.15 2005-02-01 14:37:47 adam Exp $ + */ +/** + * \file tcpip.c + * \brief Implements TCP/IP + SSL COMSTACK. */ #include #include #include +#include +#include +#include +#if HAVE_SYS_TYPES_H +#include +#endif +#if HAVE_SYS_TIME_H +#include +#endif +#if HAVE_UNISTD_H +#include +#endif #ifdef WIN32 +#include #else -#include +#include +#include +#include +#include +#endif + +#if HAVE_SYS_SOCKET_H +#include +#endif +#if HAVE_SYS_SELECT_H +#include +#endif +#if HAVE_SYS_WAIT_H +#include #endif -#include -#include -#include #if HAVE_OPENSSL_SSL_H #include #include @@ -24,14 +51,8 @@ #include #include -#include #include -#ifdef WIN32 -#else -#include -#endif - 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); @@ -171,6 +192,7 @@ COMSTACK tcpip_type(int s, int blocking, int protocol, void *vp) p->event = CS_NONE; p->cerrno = 0; p->stackerr = 0; + p->user = 0; #if HAVE_OPENSSL_SSL_H sp->ctx = sp->ctx_alloc = 0; @@ -207,7 +229,7 @@ COMSTACK ssl_type(int s, int blocking, int protocol, void *vp) p->type = ssl_type; sp = (tcpip_state *) p->cprivate; - sp->ctx = vp; /* may be NULL */ + sp->ctx = (SSL_CTX *) vp; /* may be NULL */ /* note: we don't handle already opened socket in SSL mode - yet */ return p; @@ -776,7 +798,7 @@ int tcpip_get(COMSTACK h, char **buf, int *bufsize) #endif } else if (!res) - return 0; + return hasread; hasread += res; } TRC (fprintf (stderr, " Out of read loop with hasread=%d, berlen=%d\n", @@ -1118,7 +1140,7 @@ int cs_set_ssl_ctx(COMSTACK cs, void *ctx) sp = (struct tcpip_state *) cs->cprivate; if (sp->ctx_alloc) return 0; - sp->ctx = ctx; + sp->ctx = (SSL_CTX *) ctx; return 1; } @@ -1131,7 +1153,7 @@ void *cs_get_ssl(COMSTACK cs) return sp->ssl; } -int cs_set_ssl_certf(COMSTACK cs, const char *fname) +int cs_set_ssl_certificate_file(COMSTACK cs, const char *fname) { struct tcpip_state *sp; if (!cs || cs->type != ssl_type) @@ -1144,7 +1166,7 @@ int cs_set_ssl_certf(COMSTACK cs, const char *fname) int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len) { - SSL *ssl = cs_get_ssl(cs); + SSL *ssl = (SSL *) cs_get_ssl(cs); if (ssl) { X509 *server_cert = SSL_get_peer_certificate (ssl); @@ -1155,7 +1177,7 @@ int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len) /* get PEM buffer in memory */ PEM_write_bio_X509(bio, server_cert); *len = BIO_get_mem_data(bio, &pem_buf); - *buf = xmalloc(*len); + *buf = (char *) xmalloc(*len); memcpy(*buf, pem_buf, *len); BIO_free(bio); return 1; @@ -1179,7 +1201,7 @@ int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len) return 0; } -int cs_set_ssl_certf(COMSTACK cs, const char *fname) +int cs_set_ssl_certificate_file(COMSTACK cs, const char *fname) { return 0; }