From 4a9cbf62bc7a294f1782386997e09d2dd4ba9671 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 4 Dec 2009 13:50:43 +0100 Subject: [PATCH] COMSTACK API changes: cs_stackerr, cs_addrstr. 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 | 32 ++++++++++++-------------------- include/yaz/comstack.h | 6 ++---- src/statserv.c | 4 ++-- src/tcpip.c | 10 ++++------ src/unix.c | 10 ++++------ 5 files changed, 24 insertions(+), 38 deletions(-) diff --git a/doc/comstack.xml b/doc/comstack.xml index 8538a14..65e3d1d 100644 --- a/doc/comstack.xml +++ b/doc/comstack.xml @@ -148,7 +148,7 @@ - int cs_close(COMSTACK handle); + void cs_close(COMSTACK handle); @@ -404,7 +404,7 @@ - char *cs_addrstr(COMSTACK); + const char *cs_addrstr(COMSTACK); @@ -460,7 +460,7 @@ - char *cs_addrstr(COMSTACK h); + const char *cs_addrstr(COMSTACK h); @@ -581,19 +581,18 @@ Summary and Synopsis - - #include <yaz/comstack.h> + - #include <yaz/tcpip.h> /* this is for TCP/IP and SSL support */ - #include <yaz/unix.h> /* this is for UNIX sockeL support */ + #include /* this is for TCP/IP and SSL support */ + #include /* 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_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); @@ -611,21 +610,14 @@ 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); - 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); +]]> diff --git a/include/yaz/comstack.h b/include/yaz/comstack.h index cabd27b..44ac32f 100644 --- a/include/yaz/comstack.h +++ b/include/yaz/comstack.h @@ -49,7 +49,6 @@ struct comstack { 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 */ @@ -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 (*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 */ @@ -106,7 +105,6 @@ struct comstack ((*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) diff --git a/src/statserv.c b/src/statserv.c index 2789a9b..e46b110 100644 --- a/src/statserv.c +++ b/src/statserv.c @@ -995,7 +995,7 @@ static void listener(IOCHAN h, int event) static void *new_session(void *vp) { - char *a; + const char *a; 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; - char *addr; + const char *addr; if ((line = cs_createbysocket(0, tcpip_type, 0, what))) { diff --git a/src/tcpip.c b/src/tcpip.c index cb2883c..ae1c66e 100644 --- a/src/tcpip.c +++ b/src/tcpip.c @@ -70,7 +70,7 @@ #include #include -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); @@ -90,7 +90,7 @@ static int ssl_put(COMSTACK h, char *buf, int size); #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 @@ -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->stackerr = 0; p->user = 0; #if HAVE_GNUTLS_H @@ -1346,7 +1345,7 @@ int ssl_put(COMSTACK h, char *buf, int size) } #endif -int tcpip_close(COMSTACK h) +void tcpip_close(COMSTACK h) { 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); - 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; diff --git a/src/unix.c b/src/unix.c index 5c3dce0..e37bf70 100644 --- a/src/unix.c +++ b/src/unix.c @@ -52,7 +52,7 @@ #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); @@ -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 char *unix_addrstr(COMSTACK h); +static const char *unix_addrstr(COMSTACK h); 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->stackerr = 0; p->user = 0; state->altbuf = 0; @@ -701,7 +700,7 @@ static int unix_put(COMSTACK h, char *buf, int size) return 0; } -static int unix_close(COMSTACK h) +static void unix_close(COMSTACK h) { 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); - 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; -- 1.7.10.4