Adjustments to make YAZ compile as C++ code.
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 30 Nov 2007 11:44:46 +0000 (11:44 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 30 Nov 2007 11:44:46 +0000 (11:44 +0000)
include/yaz/poll.h
src/comstack.c
src/eventl.c
src/http.c
src/poll.c
src/tcpip.c
src/zoom-c.c
src/zoom-socket.c
util/yaz-illclient.c

index f149c23..858eba9 100644 (file)
@@ -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.
  */
  * (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
 
 /**
  * \file
@@ -40,6 +40,7 @@ YAZ_BEGIN_CDECL
 
 /** \brief select/poll masks .. timeout is "output" only */
 enum yaz_poll_mask {
 
 /** \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,
     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);
 
 */
 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
 YAZ_END_CDECL
 
 #endif
index 896127b..4c8fe05 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * 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);
         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;
             memcpy(*connect_host, uri + 8, len);
             (*connect_host)[len] = '\0';
             uri = cp+1;
index 6146138..f2963a1 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * 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++;
         }
         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;
         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)
             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)
             if (p->flags & EVENT_OUTPUT)
-                input_mask += yaz_poll_write;
+                yaz_poll_add(input_mask, yaz_poll_write);
             if (p->flags & EVENT_EXCEPT)
             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;
             if (p->max_idle && p->last_event)
             {
                 ftime = p->last_event + p->max_idle;
index 60cef68..3d62fcd 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * 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);
         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);
     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);
     strcpy(buf, "Basic ");
     yaz_base64encode(tmp, &buf[strlen(buf)]);
     z_HTTP_header_add(o, hp, "Authorization", buf);
index 4bd35c0..a2f2c90 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * 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 
  */
 /**
  * \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++)
         {
     {
         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)
             int fd = fds[i].fd;
             if (!r)
-                mask += yaz_poll_timeout;
+                yaz_poll_add(mask, yaz_poll_timeout);
             else
             {
                 if (FD_ISSET(fd, &input))
             else
             {
                 if (FD_ISSET(fd, &input))
-                    mask += yaz_poll_read;
+                    yaz_poll_add(mask, yaz_poll_read);
                 if (FD_ISSET(fd, &output))
                 if (FD_ISSET(fd, &output))
-                    mask += yaz_poll_write;
+                    yaz_poll_add(mask, yaz_poll_write);
                 if (FD_ISSET(fd, &except))
                 if (FD_ISSET(fd, &except))
-                    mask += yaz_poll_except;
+                    yaz_poll_add(mask, yaz_poll_except);
             }
             fds[i].output_mask = mask;
         }
             }
             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++)
         {
     {
         for (i = 0; i < num_fds; i++)
         {
-            enum yaz_poll_mask mask = 0;
+            enum yaz_poll_mask mask = yaz_poll_none;
             if (!r)
             if (!r)
-                mask += yaz_poll_timeout;
+                yaz_poll_add(mask, yaz_poll_timeout);
             else
             {
                 if (pollfds[i].revents & POLLIN)
             else
             {
                 if (pollfds[i].revents & POLLIN)
-                    mask += yaz_poll_read;
+                    yaz_poll_add(mask, yaz_poll_read);
                 if (pollfds[i].revents & POLLOUT)
                 if (pollfds[i].revents & POLLOUT)
-                    mask += yaz_poll_write;
+                    yaz_poll_add(mask, yaz_poll_write);
                 if (pollfds[i].revents & POLLERR)
                 if (pollfds[i].revents & POLLERR)
-                    mask += yaz_poll_except;
+                    yaz_poll_add(mask, yaz_poll_except);
             }
             fds[i].output_mask = mask;
         }
             }
             fds[i].output_mask = mask;
         }
index 275c10c..0e31fc6 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * 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
  */
 /**
  * \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;
     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);
         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);
index 5af33a0..8befe19 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * 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
  */
 /**
  * \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,
  * 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)
     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));
     
                     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 = 
     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 =
         {
             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;
             ci->note = odr_strdup_null(p->odr_out, correlationInfo_note);
             ci->id = correlationInfo_id ?
                 odr_intdup(p->odr_out, atoi(correlationInfo_id)) : 0;
index 9299884..2d9d686 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * 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
  */
 /**
  * \file zoom-socket.c
@@ -29,7 +29,7 @@
 ZOOM_API(int)
     ZOOM_event_sys_yaz_poll(int no, ZOOM_connection *cs)
 {
 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;
     int i, r;
     int nfds = 0;
     int timeout = 30;
@@ -49,14 +49,14 @@ ZOOM_API(int)
             continue;
         if (mask)
         {
             continue;
         if (mask)
         {
-            enum yaz_poll_mask input_mask = 0;
+            enum yaz_poll_mask input_mask = yaz_poll_none;
 
             if (mask & ZOOM_SELECT_READ)
 
             if (mask & ZOOM_SELECT_READ)
-                input_mask += yaz_poll_read;
+                yaz_poll_add(input_mask, yaz_poll_read);
             if (mask & ZOOM_SELECT_WRITE)
             if (mask & ZOOM_SELECT_WRITE)
-                input_mask += yaz_poll_write;
+                yaz_poll_add(input_mask, yaz_poll_write);
             if (mask & ZOOM_SELECT_EXCEPT)
             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;
             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++)
         {
     {
         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);
             enum yaz_poll_mask output_mask = yp[i].output_mask;
             if (output_mask & yaz_poll_timeout)
                 ZOOM_connection_fire_event_timeout(c);
index bb62655..b65c9e6 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2006, Index Data ApS
  * See the file LICENSE for details.
  *
  * 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 */
  */
 
 /* 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;
     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 */
     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=
     if (args->oclc_auth) {
         req->num_iLL_request_extensions=2;
         req->iLL_request_extensions=
+            (ILL_Extension **)
             odr_malloc(odr, req->num_iLL_request_extensions*
             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);
     }
         req->iLL_request_extensions[0]=makepromptextension(args,odr);
         req->iLL_request_extensions[1]=makeoclcextension(args,odr);
     }