COMSTACK API changes: cs_stackerr, cs_addrstr.
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 4 Dec 2009 12:50:43 +0000 (13:50 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 4 Dec 2009 12:50:43 +0000 (13:50 +0100)
COMSTACK method cs_stackerr removed. It is not implemented by tcpip or
unix COMSTACK, perhaps for ISO SR which was removed 7 years ago.
COMSTACK macro / method cs_addrstr now returns 'const char *'
rather than 'char *. The returned string is read-only and should not
be modified by applications. COMSTACK cs_close is now a void function
- it no longer returns int. No applications check for the value and
the implementations has always returned 0.

doc/comstack.xml
include/yaz/comstack.h
src/statserv.c
src/tcpip.c
src/unix.c

index 8538a14..65e3d1d 100644 (file)
     </para>
 
     <synopsis>
     </para>
 
     <synopsis>
-     int cs_close(COMSTACK handle);
+     void cs_close(COMSTACK handle);
     </synopsis>
 
     <para>
     </synopsis>
 
     <para>
    </para>
 
    <synopsis>
    </para>
 
    <synopsis>
-    char *cs_addrstr(COMSTACK);
+    const char *cs_addrstr(COMSTACK);
    </synopsis>
 
    <para>
    </synopsis>
 
    <para>
    </para>
 
    <synopsis>
    </para>
 
    <synopsis>
-    char *cs_addrstr(COMSTACK h);
+    const char *cs_addrstr(COMSTACK h);
    </synopsis>
 
    <para>
    </synopsis>
 
    <para>
   </sect1>
   <sect1 id="comstack.summary"><title>Summary and Synopsis</title>
 
   </sect1>
   <sect1 id="comstack.summary"><title>Summary and Synopsis</title>
 
-   <synopsis>
-    #include &lt;yaz/comstack.h>
+   <synopsis><![CDATA[
+    #include <yaz/comstack.h>
     
     
-    #include &lt;yaz/tcpip.h>  /* this is for TCP/IP and SSL support */
-    #include &lt;yaz/unix.h>   /* this is for UNIX sockeL support */
+    #include <yaz/tcpip.h>  /* this is for TCP/IP and SSL support */
+    #include <yaz/unix.h>   /* this is for UNIX socket support */
     
     
-     
     COMSTACK cs_create(CS_TYPE type, int blocking, int protocol);
      
     COMSTACK cs_createbysocket(int s, CS_TYPE type, int blocking,
                                int protocol);
     COMSTACK cs_create(CS_TYPE type, int blocking, int protocol);
      
     COMSTACK cs_createbysocket(int s, CS_TYPE type, int blocking,
                                int protocol);
-    COMSTACK cs_create_host (const char *str, int blocking,
-                             void **vp);
+    COMSTACK cs_create_host(const char *str, int blocking,
+                            void **vp);
      
     int cs_bind(COMSTACK handle, int mode);
      
      
     int cs_bind(COMSTACK handle, int mode);
      
 
     int cs_more(COMSTACK handle);
 
 
     int cs_more(COMSTACK handle);
 
-    int cs_close(COMSTACK handle);
+    void cs_close(COMSTACK handle);
 
     int cs_look(COMSTACK handle);
 
     void *cs_straddr(COMSTACK handle, const char *str);
 
 
     int cs_look(COMSTACK handle);
 
     void *cs_straddr(COMSTACK handle, const char *str);
 
-    char *cs_addrstr(COMSTACK h);
-
-    extern int cs_errno;
-
-    void cs_perror(COMSTACK handle char *message);
-
-    const char *cs_stackerr(COMSTACK handle);
-
-    extern const char *cs_errlist[];
+    const char *cs_addrstr(COMSTACK h);
+]]>
    </synopsis>
   </sect1>
 
    </synopsis>
   </sect1>
 
index cabd27b..44ac32f 100644 (file)
@@ -49,7 +49,6 @@ struct comstack
 {
     CS_TYPE type;
     int cerrno;     /* current error code of this stack */
 {
     CS_TYPE type;
     int cerrno;     /* current error code of this stack */
-    char *stackerr;/* current lower-layer error string, or null if none */
     int iofile;    /* UNIX file descriptor for iochannel */
     int timeout;   /* how long to wait for trailing blocks (ignored for now) */
     void *cprivate;/* state info for lower stack */
     int iofile;    /* UNIX file descriptor for iochannel */
     int timeout;   /* how long to wait for trailing blocks (ignored for now) */
     void *cprivate;/* state info for lower stack */
@@ -84,8 +83,8 @@ struct comstack
                    int (*check_ip)(void *cd, const char *a, int len, int type),
                    void *cd);
     COMSTACK (*f_accept)(COMSTACK handle);
                    int (*check_ip)(void *cd, const char *a, int len, int type),
                    void *cd);
     COMSTACK (*f_accept)(COMSTACK handle);
-    int (*f_close)(COMSTACK handle);
-    char *(*f_addrstr)(COMSTACK handle);
+    void (*f_close)(COMSTACK handle);
+    const char *(*f_addrstr)(COMSTACK handle);
     void *(*f_straddr)(COMSTACK handle, const char *str);
     int (*f_set_blocking)(COMSTACK handle, int blocking);
     void *user;       /* user defined data associated with COMSTACK */
     void *(*f_straddr)(COMSTACK handle, const char *str);
     int (*f_set_blocking)(COMSTACK handle, int blocking);
     void *user;       /* user defined data associated with COMSTACK */
@@ -106,7 +105,6 @@ struct comstack
         ((*type)(sock, blocking, proto, 0))
 #define cs_type(handle) ((handle)->type)
 #define cs_fileno(handle) ((handle)->iofile)
         ((*type)(sock, blocking, proto, 0))
 #define cs_type(handle) ((handle)->type)
 #define cs_fileno(handle) ((handle)->iofile)
-#define cs_stackerr(handle) ((handle)->stackerr)
 #define cs_getstate(handle) ((handle)->getstate)
 #define cs_errno(handle) ((handle)->cerrno)
 #define cs_getproto(handle) ((handle)->protocol)
 #define cs_getstate(handle) ((handle)->getstate)
 #define cs_errno(handle) ((handle)->cerrno)
 #define cs_getproto(handle) ((handle)->protocol)
index 2789a9b..e46b110 100644 (file)
@@ -995,7 +995,7 @@ static void listener(IOCHAN h, int event)
 
 static void *new_session(void *vp)
 {
 
 static void *new_session(void *vp)
 {
-    char *a;
+    const char *a;
     association *newas;
     IOCHAN new_chan;
     COMSTACK new_line = (COMSTACK) vp;
     association *newas;
     IOCHAN new_chan;
     COMSTACK new_line = (COMSTACK) vp;
@@ -1063,7 +1063,7 @@ static void inetd_connection(int what)
     COMSTACK line;
     IOCHAN chan;
     association *assoc;
     COMSTACK line;
     IOCHAN chan;
     association *assoc;
-    char *addr;
+    const char *addr;
 
     if ((line = cs_createbysocket(0, tcpip_type, 0, what)))
     {
 
     if ((line = cs_createbysocket(0, tcpip_type, 0, what)))
     {
index cb2883c..ae1c66e 100644 (file)
@@ -70,7 +70,7 @@
 #include <yaz/tcpip.h>
 #include <yaz/errno.h>
 
 #include <yaz/tcpip.h>
 #include <yaz/errno.h>
 
-static int tcpip_close(COMSTACK h);
+static void tcpip_close(COMSTACK h);
 static int tcpip_put(COMSTACK h, char *buf, int size);
 static int tcpip_get(COMSTACK h, char **buf, int *bufsize);
 static int tcpip_put_connect(COMSTACK h, char *buf, int size);
 static int tcpip_put(COMSTACK h, char *buf, int size);
 static int tcpip_get(COMSTACK h, char **buf, int *bufsize);
 static int tcpip_put_connect(COMSTACK h, char *buf, int size);
@@ -90,7 +90,7 @@ static int ssl_put(COMSTACK h, char *buf, int size);
 #endif
 
 static COMSTACK tcpip_accept(COMSTACK h);
 #endif
 
 static COMSTACK tcpip_accept(COMSTACK h);
-static char *tcpip_addrstr(COMSTACK h);
+static const char *tcpip_addrstr(COMSTACK h);
 static void *tcpip_straddr(COMSTACK h, const char *str);
 
 #if 0
 static void *tcpip_straddr(COMSTACK h, const char *str);
 
 #if 0
@@ -206,7 +206,6 @@ COMSTACK tcpip_type(int s, int flags, int protocol, void *vp)
     p->state = s < 0 ? CS_ST_UNBND : CS_ST_IDLE; /* state of line */
     p->event = CS_NONE;
     p->cerrno = 0;
     p->state = s < 0 ? CS_ST_UNBND : CS_ST_IDLE; /* state of line */
     p->event = CS_NONE;
     p->cerrno = 0;
-    p->stackerr = 0;
     p->user = 0;
 
 #if HAVE_GNUTLS_H
     p->user = 0;
 
 #if HAVE_GNUTLS_H
@@ -1346,7 +1345,7 @@ int ssl_put(COMSTACK h, char *buf, int size)
 }
 #endif
 
 }
 #endif
 
-int tcpip_close(COMSTACK h)
+void tcpip_close(COMSTACK h)
 {
     tcpip_state *sp = (struct tcpip_state *)h->cprivate;
 
 {
     tcpip_state *sp = (struct tcpip_state *)h->cprivate;
 
@@ -1406,10 +1405,9 @@ int tcpip_close(COMSTACK h)
     xfree(sp->connect_response_buf);
     xfree(sp);
     xfree(h);
     xfree(sp->connect_response_buf);
     xfree(sp);
     xfree(h);
-    return 0;
 }
 
 }
 
-char *tcpip_addrstr(COMSTACK h)
+const char *tcpip_addrstr(COMSTACK h)
 {
     tcpip_state *sp = (struct tcpip_state *)h->cprivate;
     char *r = 0, *buf = sp->buf;
 {
     tcpip_state *sp = (struct tcpip_state *)h->cprivate;
     char *r = 0, *buf = sp->buf;
index 5c3dce0..e37bf70 100644 (file)
@@ -52,7 +52,7 @@
 #endif
 #endif
 
 #endif
 #endif
 
-static int unix_close(COMSTACK h);
+static void unix_close(COMSTACK h);
 static int unix_put(COMSTACK h, char *buf, int size);
 static int unix_get(COMSTACK h, char **buf, int *bufsize);
 static int unix_connect(COMSTACK h, void *address);
 static int unix_put(COMSTACK h, char *buf, int size);
 static int unix_get(COMSTACK h, char **buf, int *bufsize);
 static int unix_connect(COMSTACK h, void *address);
@@ -65,7 +65,7 @@ static int unix_listen(COMSTACK h, char *raddr, int *addrlen,
 static int unix_set_blocking(COMSTACK p, int blocking);
 
 static COMSTACK unix_accept(COMSTACK h);
 static int unix_set_blocking(COMSTACK p, int blocking);
 
 static COMSTACK unix_accept(COMSTACK h);
-static char *unix_addrstr(COMSTACK h);
+static const char *unix_addrstr(COMSTACK h);
 static void *unix_straddr(COMSTACK h, const char *str);
 
 #ifndef SUN_LEN
 static void *unix_straddr(COMSTACK h, const char *str);
 
 #ifndef SUN_LEN
@@ -157,7 +157,6 @@ COMSTACK unix_type(int s, int flags, int protocol, void *vp)
     p->state = new_socket ? CS_ST_UNBND : CS_ST_IDLE; /* state of line */
     p->event = CS_NONE;
     p->cerrno = 0;
     p->state = new_socket ? CS_ST_UNBND : CS_ST_IDLE; /* state of line */
     p->event = CS_NONE;
     p->cerrno = 0;
-    p->stackerr = 0;
     p->user = 0;
 
     state->altbuf = 0;
     p->user = 0;
 
     state->altbuf = 0;
@@ -701,7 +700,7 @@ static int unix_put(COMSTACK h, char *buf, int size)
     return 0;
 }
 
     return 0;
 }
 
-static int unix_close(COMSTACK h)
+static void unix_close(COMSTACK h)
 {
     unix_state *sp = (struct unix_state *)h->cprivate;
 
 {
     unix_state *sp = (struct unix_state *)h->cprivate;
 
@@ -714,10 +713,9 @@ static int unix_close(COMSTACK h)
         xfree(sp->altbuf);
     xfree(sp);
     xfree(h);
         xfree(sp->altbuf);
     xfree(sp);
     xfree(h);
-    return 0;
 }
 
 }
 
-static char *unix_addrstr(COMSTACK h)
+static const char *unix_addrstr(COMSTACK h)
 {
     unix_state *sp = (struct unix_state *)h->cprivate;
     char *buf = sp->buf;
 {
     unix_state *sp = (struct unix_state *)h->cprivate;
     char *buf = sp->buf;