From 3576736bac485d8f04b2fc4f6b5cfcef7576d741 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 30 Nov 2007 11:44:46 +0000 Subject: [PATCH] Adjustments to make YAZ compile as C++ code. --- include/yaz/poll.h | 4 +++- src/comstack.c | 4 ++-- src/eventl.c | 12 ++++++------ src/http.c | 6 +++--- src/poll.c | 22 +++++++++++----------- src/tcpip.c | 4 ++-- src/zoom-c.c | 8 ++++---- src/zoom-socket.c | 14 +++++++------- util/yaz-illclient.c | 7 ++++--- 9 files changed, 42 insertions(+), 39 deletions(-) diff --git a/include/yaz/poll.h b/include/yaz/poll.h index f149c23..858eba9 100644 --- a/include/yaz/poll.h +++ b/include/yaz/poll.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: poll.h,v 1.3 2007-11-09 22:08:14 adam Exp $ */ +/* $Id: poll.h,v 1.4 2007-11-30 11:44:46 adam Exp $ */ /** * \file @@ -40,6 +40,7 @@ YAZ_BEGIN_CDECL /** \brief select/poll masks .. timeout is "output" only */ enum yaz_poll_mask { + yaz_poll_none = 0, yaz_poll_read = 1, yaz_poll_write = 2, yaz_poll_except = 4, @@ -72,6 +73,7 @@ struct yaz_poll_fd { */ int yaz_poll(struct yaz_poll_fd *fds, int num_fds, int sec, int nsec); +#define yaz_poll_add(var,value) var = (enum yaz_poll_mask ) ((int) var | value) YAZ_END_CDECL #endif diff --git a/src/comstack.c b/src/comstack.c index 896127b..4c8fe05 100644 --- a/src/comstack.c +++ b/src/comstack.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: comstack.c,v 1.21 2007-10-09 06:00:56 adam Exp $ + * $Id: comstack.c,v 1.22 2007-11-30 11:44:47 adam Exp $ */ /** @@ -85,7 +85,7 @@ static int cs_parse_host(const char *uri, const char **host, if (cp) { size_t len = cp - (uri + 8); - *connect_host = xmalloc(len+1); + *connect_host = (char *) xmalloc(len+1); memcpy(*connect_host, uri + 8, len); (*connect_host)[len] = '\0'; uri = cp+1; diff --git a/src/eventl.c b/src/eventl.c index 6146138..f2963a1 100644 --- a/src/eventl.c +++ b/src/eventl.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: eventl.c,v 1.16 2007-11-12 08:41:56 adam Exp $ + * $Id: eventl.c,v 1.17 2007-11-30 11:44:47 adam Exp $ */ /** @@ -96,21 +96,21 @@ int iochan_event_loop(IOCHAN *iochans) } for (p = *iochans; p; p = p->next) no_fds++; - fds = xmalloc(no_fds * sizeof(*fds)); + fds = (struct yaz_poll_fd *) xmalloc(no_fds * sizeof(*fds)); for (i = 0, p = *iochans; p; p = p->next, i++) { time_t w, ftime; - enum yaz_poll_mask input_mask = 0; + enum yaz_poll_mask input_mask = yaz_poll_none; yaz_log(log_level, "fd=%d flags=%d force_event=%d", p->fd, p->flags, p->force_event); if (p->force_event) tv_sec = 0; /* polling select */ if (p->flags & EVENT_INPUT) - input_mask += yaz_poll_read; + yaz_poll_add(input_mask, yaz_poll_read); if (p->flags & EVENT_OUTPUT) - input_mask += yaz_poll_write; + yaz_poll_add(input_mask, yaz_poll_write); if (p->flags & EVENT_EXCEPT) - input_mask += yaz_poll_except; + yaz_poll_add(input_mask, yaz_poll_except); if (p->max_idle && p->last_event) { ftime = p->last_event + p->max_idle; diff --git a/src/http.c b/src/http.c index 60cef68..3d62fcd 100644 --- a/src/http.c +++ b/src/http.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: http.c,v 1.3 2007-09-06 17:11:59 mike Exp $ + * $Id: http.c,v 1.4 2007-11-30 11:44:47 adam Exp $ */ /** @@ -234,9 +234,9 @@ void z_HTTP_header_add_basic_auth(ODR o, Z_HTTP_Header **hp, return; len = strlen(username) + strlen(password); - tmp = odr_malloc(o, len+2); + tmp = (char *) odr_malloc(o, len+2); sprintf(tmp, "%s:%s", username, password); - buf = odr_malloc(o, (len+1) * 8/6 + 12); + buf = (char *) odr_malloc(o, (len+1) * 8/6 + 12); strcpy(buf, "Basic "); yaz_base64encode(tmp, &buf[strlen(buf)]); z_HTTP_header_add(o, hp, "Authorization", buf); diff --git a/src/poll.c b/src/poll.c index 4bd35c0..a2f2c90 100644 --- a/src/poll.c +++ b/src/poll.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: poll.c,v 1.3 2007-11-10 08:59:31 adam Exp $ + * $Id: poll.c,v 1.4 2007-11-30 11:44:47 adam Exp $ */ /** * \file @@ -82,18 +82,18 @@ int yaz_poll_select(struct yaz_poll_fd *fds, int num_fds, int sec, int nsec) { for (i = 0; i < num_fds; i++) { - enum yaz_poll_mask mask = 0; + enum yaz_poll_mask mask = yaz_poll_none; int fd = fds[i].fd; if (!r) - mask += yaz_poll_timeout; + yaz_poll_add(mask, yaz_poll_timeout); else { if (FD_ISSET(fd, &input)) - mask += yaz_poll_read; + yaz_poll_add(mask, yaz_poll_read); if (FD_ISSET(fd, &output)) - mask += yaz_poll_write; + yaz_poll_add(mask, yaz_poll_write); if (FD_ISSET(fd, &except)) - mask += yaz_poll_except; + yaz_poll_add(mask, yaz_poll_except); } fds[i].output_mask = mask; } @@ -131,17 +131,17 @@ int yaz_poll_poll(struct yaz_poll_fd *fds, int num_fds, int sec, int nsec) { for (i = 0; i < num_fds; i++) { - enum yaz_poll_mask mask = 0; + enum yaz_poll_mask mask = yaz_poll_none; if (!r) - mask += yaz_poll_timeout; + yaz_poll_add(mask, yaz_poll_timeout); else { if (pollfds[i].revents & POLLIN) - mask += yaz_poll_read; + yaz_poll_add(mask, yaz_poll_read); if (pollfds[i].revents & POLLOUT) - mask += yaz_poll_write; + yaz_poll_add(mask, yaz_poll_write); if (pollfds[i].revents & POLLERR) - mask += yaz_poll_except; + yaz_poll_add(mask, yaz_poll_except); } fds[i].output_mask = mask; } diff --git a/src/tcpip.c b/src/tcpip.c index 275c10c..0e31fc6 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: tcpip.c,v 1.37 2007-11-09 21:52:38 adam Exp $ + * $Id: tcpip.c,v 1.38 2007-11-30 11:44:47 adam Exp $ */ /** * \file tcpip.c @@ -224,7 +224,7 @@ COMSTACK yaz_tcpip_create(int s, int flags, int protocol, if (connect_host) { tcpip_state *sp = (tcpip_state *) p->cprivate; - sp->connect_request_buf = xmalloc(strlen(connect_host) + 30); + sp->connect_request_buf = (char *) xmalloc(strlen(connect_host) + 30); sprintf(sp->connect_request_buf, "CONNECT %s HTTP/1.0\r\n\r\n", connect_host); sp->connect_request_len = strlen(sp->connect_request_buf); diff --git a/src/zoom-c.c b/src/zoom-c.c index 5af33a0..8befe19 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.151 2007-09-21 16:04:48 adam Exp $ + * $Id: zoom-c.c,v 1.152 2007-11-30 11:44:47 adam Exp $ */ /** * \file zoom-c.c @@ -49,7 +49,7 @@ static char *cql2pqf(ZOOM_connection c, const char *cql); * if it could cause failure when a lookup fails, but that's hard. */ static Odr_oid *zoom_yaz_str_to_z3950oid(ZOOM_connection c, - int oid_class, const char *str) { + oid_class oid_class, const char *str) { Odr_oid *res = yaz_string_to_oid_odr(yaz_oid_std(), oid_class, str, c->odr_out); if (res == 0) @@ -1356,7 +1356,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.151 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.152 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = @@ -3398,7 +3398,7 @@ static Z_APDU *create_update_package(ZOOM_package p) { Z_IUCorrelationInfo *ci; ci = notToKeep->elements[0]->correlationInfo = - odr_malloc(p->odr_out, sizeof(*ci)); + (Z_IUCorrelationInfo *) odr_malloc(p->odr_out, sizeof(*ci)); ci->note = odr_strdup_null(p->odr_out, correlationInfo_note); ci->id = correlationInfo_id ? odr_intdup(p->odr_out, atoi(correlationInfo_id)) : 0; diff --git a/src/zoom-socket.c b/src/zoom-socket.c index 9299884..2d9d686 100644 --- a/src/zoom-socket.c +++ b/src/zoom-socket.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-socket.c,v 1.7 2007-11-10 08:59:31 adam Exp $ + * $Id: zoom-socket.c,v 1.8 2007-11-30 11:44:47 adam Exp $ */ /** * \file zoom-socket.c @@ -29,7 +29,7 @@ ZOOM_API(int) ZOOM_event_sys_yaz_poll(int no, ZOOM_connection *cs) { - struct yaz_poll_fd *yp = xmalloc(sizeof(*yp) * no); + struct yaz_poll_fd *yp = (struct yaz_poll_fd *) xmalloc(sizeof(*yp) * no); int i, r; int nfds = 0; int timeout = 30; @@ -49,14 +49,14 @@ ZOOM_API(int) continue; if (mask) { - enum yaz_poll_mask input_mask = 0; + enum yaz_poll_mask input_mask = yaz_poll_none; if (mask & ZOOM_SELECT_READ) - input_mask += yaz_poll_read; + yaz_poll_add(input_mask, yaz_poll_read); if (mask & ZOOM_SELECT_WRITE) - input_mask += yaz_poll_write; + yaz_poll_add(input_mask, yaz_poll_write); if (mask & ZOOM_SELECT_EXCEPT) - input_mask += yaz_poll_except; + yaz_poll_add(input_mask, yaz_poll_except); yp[nfds].fd = fd; yp[nfds].input_mask = input_mask; yp[nfds].client_data = c; @@ -73,7 +73,7 @@ ZOOM_API(int) { for (i = 0; i < nfds; i++) { - ZOOM_connection c = yp[i].client_data; + ZOOM_connection c = (ZOOM_connection) yp[i].client_data; enum yaz_poll_mask output_mask = yp[i].output_mask; if (output_mask & yaz_poll_timeout) ZOOM_connection_fire_event_timeout(c); diff --git a/util/yaz-illclient.c b/util/yaz-illclient.c index bb62655..b65c9e6 100644 --- a/util/yaz-illclient.c +++ b/util/yaz-illclient.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: yaz-illclient.c,v 1.8 2007-06-08 10:01:07 heikki Exp $ + * $Id: yaz-illclient.c,v 1.9 2007-11-30 11:44:47 adam Exp $ */ /* WARNING - This is work in progress - not at all ready */ @@ -184,7 +184,7 @@ void parseargs( int argc, char * argv[], struct prog_args *args) { int ret; char *arg; char *prog=*argv; - char *version="$Id: yaz-illclient.c,v 1.8 2007-06-08 10:01:07 heikki Exp $"; /* from cvs */ + const char *version="$Id: yaz-illclient.c,v 1.9 2007-11-30 11:44:47 adam Exp $"; /* from cvs */ struct nameval *nv; /* default values */ @@ -462,8 +462,9 @@ ILL_APDU *createrequest( struct prog_args *args, ODR odr) { if (args->oclc_auth) { req->num_iLL_request_extensions=2; req->iLL_request_extensions= + (ILL_Extension **) odr_malloc(odr, req->num_iLL_request_extensions* - sizeof(*req->iLL_request_extensions)); + sizeof(*req->iLL_request_extensions)); req->iLL_request_extensions[0]=makepromptextension(args,odr); req->iLL_request_extensions[1]=makeoclcextension(args,odr); } -- 1.7.10.4