diff options
Diffstat (limited to 'X11')
-rw-r--r-- | X11/xtrans/Xtrans.c | 135 | ||||
-rw-r--r-- | X11/xtrans/Xtrans.h | 20 | ||||
-rw-r--r-- | X11/xtrans/Xtransint.h | 115 | ||||
-rw-r--r-- | X11/xtrans/Xtranslcl.c | 369 | ||||
-rw-r--r-- | X11/xtrans/Xtranssock.c | 336 | ||||
-rw-r--r-- | X11/xtrans/Xtranstli.c | 283 | ||||
-rw-r--r-- | X11/xtrans/Xtransutil.c | 59 | ||||
-rw-r--r-- | X11/xtrans/doc/xtrans.xml | 28 | ||||
-rw-r--r-- | X11/xtrans/transport.c | 3 |
9 files changed, 664 insertions, 684 deletions
diff --git a/X11/xtrans/Xtrans.c b/X11/xtrans/Xtrans.c index 948e2831c..f90bd47e8 100644 --- a/X11/xtrans/Xtrans.c +++ b/X11/xtrans/Xtrans.c @@ -137,7 +137,7 @@ void TRANS(FreeConnInfo) (XtransConnInfo ciptr) { - PRMSG (3,"FreeConnInfo(%p)\n", ciptr, 0, 0); + prmsg (3,"FreeConnInfo(%p)\n", ciptr); if (ciptr->addr) xfree (ciptr->addr); @@ -155,13 +155,13 @@ TRANS(FreeConnInfo) (XtransConnInfo ciptr) #define PROTOBUFSIZE 20 static Xtransport * -TRANS(SelectTransport) (char *protocol) +TRANS(SelectTransport) (const char *protocol) { char protobuf[PROTOBUFSIZE]; int i; - PRMSG (3,"SelectTransport(%s)\n", protocol, 0, 0); + prmsg (3,"SelectTransport(%s)\n", protocol); /* * Force Protocol to be lowercase as a way of doing @@ -208,11 +208,12 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) */ char *mybuf, *tmpptr; - char *_protocol, *_host, *_port; + const char *_protocol; + char *_host, *_port; char hostnamebuf[256]; int _host_len; - PRMSG (3,"ParseAddress(%s)\n", address, 0, 0); + prmsg (3,"ParseAddress(%s)\n", address); /* Copy the string so it can be changed */ @@ -409,12 +410,12 @@ TRANS(Open) (int type, char *address) XtransConnInfo ciptr = NULL; Xtransport *thistrans; - PRMSG (2,"Open(%d,%s)\n", type, address, 0); + prmsg (2,"Open(%d,%s)\n", type, address); #if defined(WIN32) && defined(TCPCONN) if (TRANS(WSAStartup)()) { - PRMSG (1,"Open: WSAStartup failed\n", 0, 0, 0); + prmsg (1,"Open: WSAStartup failed\n"); return NULL; } #endif @@ -423,7 +424,7 @@ TRANS(Open) (int type, char *address) if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0) { - PRMSG (1,"Open: Unable to Parse address %s\n", address, 0, 0); + prmsg (1,"Open: Unable to Parse address %s\n", address); return NULL; } @@ -431,8 +432,8 @@ TRANS(Open) (int type, char *address) if ((thistrans = TRANS(SelectTransport) (protocol)) == NULL) { - PRMSG (1,"Open: Unable to find transport for %s\n", - protocol, 0, 0); + prmsg (1,"Open: Unable to find transport for %s\n", + protocol); xfree (protocol); xfree (host); @@ -465,14 +466,14 @@ TRANS(Open) (int type, char *address) #endif /* TRANS_SERVER */ break; default: - PRMSG (1,"Open: Unknown Open type %d\n", type, 0, 0); + prmsg (1,"Open: Unknown Open type %d\n", type); } if (ciptr == NULL) { if (!(thistrans->flags & TRANS_DISABLED)) { - PRMSG (1,"Open: transport open failed for %s/%s:%s\n", + prmsg (1,"Open: transport open failed for %s/%s:%s\n", protocol, host, port); } xfree (protocol); @@ -508,7 +509,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) char *save_port; int i; - PRMSG (2,"Reopen(%d,%d,%s)\n", trans_id, fd, port); + prmsg (2,"Reopen(%d,%d,%s)\n", trans_id, fd, port); /* Determine the transport type */ @@ -521,15 +522,15 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) if (thistrans == NULL) { - PRMSG (1,"Reopen: Unable to find transport id %d\n", - trans_id, 0, 0); + prmsg (1,"Reopen: Unable to find transport id %d\n", + trans_id); return NULL; } if ((save_port = (char *) xalloc (strlen (port) + 1)) == NULL) { - PRMSG (1,"Reopen: Unable to malloc port string\n", 0, 0, 0); + prmsg (1,"Reopen: Unable to malloc port string\n"); return NULL; } @@ -547,12 +548,12 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) ciptr = thistrans->ReopenCLTSServer(thistrans, fd, port); break; default: - PRMSG (1,"Reopen: Bad Open type %d\n", type, 0, 0); + prmsg (1,"Reopen: Bad Open type %d\n", type); } if (ciptr == NULL) { - PRMSG (1,"Reopen: transport open failed\n", 0, 0, 0); + prmsg (1,"Reopen: transport open failed\n"); return NULL; } @@ -578,7 +579,7 @@ XtransConnInfo TRANS(OpenCOTSClient) (char *address) { - PRMSG (2,"OpenCOTSClient(%s)\n", address, 0, 0); + prmsg (2,"OpenCOTSClient(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_COTS_CLIENT, address); } @@ -591,7 +592,7 @@ XtransConnInfo TRANS(OpenCOTSServer) (char *address) { - PRMSG (2,"OpenCOTSServer(%s)\n", address, 0, 0); + prmsg (2,"OpenCOTSServer(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_COTS_SERVER, address); } @@ -604,7 +605,7 @@ XtransConnInfo TRANS(OpenCLTSClient) (char *address) { - PRMSG (2,"OpenCLTSClient(%s)\n", address, 0, 0); + prmsg (2,"OpenCLTSClient(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_CLTS_CLIENT, address); } @@ -617,7 +618,7 @@ XtransConnInfo TRANS(OpenCLTSServer) (char *address) { - PRMSG (2,"OpenCLTSServer(%s)\n", address, 0, 0); + prmsg (2,"OpenCLTSServer(%s)\n", address); return TRANS(Open) (XTRANS_OPEN_CLTS_SERVER, address); } @@ -630,7 +631,7 @@ XtransConnInfo TRANS(ReopenCOTSServer) (int trans_id, int fd, char *port) { - PRMSG (2,"ReopenCOTSServer(%d, %d, %s)\n", trans_id, fd, port); + prmsg (2,"ReopenCOTSServer(%d, %d, %s)\n", trans_id, fd, port); return TRANS(Reopen) (XTRANS_OPEN_COTS_SERVER, trans_id, fd, port); } @@ -638,7 +639,7 @@ XtransConnInfo TRANS(ReopenCLTSServer) (int trans_id, int fd, char *port) { - PRMSG (2,"ReopenCLTSServer(%d, %d, %s)\n", trans_id, fd, port); + prmsg (2,"ReopenCLTSServer(%d, %d, %s)\n", trans_id, fd, port); return TRANS(Reopen) (XTRANS_OPEN_CLTS_SERVER, trans_id, fd, port); } @@ -678,7 +679,7 @@ TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg) int fd = ciptr->fd; int ret = 0; - PRMSG (2,"SetOption(%d,%d,%d)\n", fd, option, arg); + prmsg (2,"SetOption(%d,%d,%d)\n", fd, option, arg); /* * For now, all transport type use the same stuff for setting options. @@ -764,7 +765,7 @@ TRANS(CreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags) } int -TRANS(NoListen) (char * protocol) +TRANS(NoListen) (const char * protocol) { Xtransport *trans; @@ -772,8 +773,8 @@ TRANS(NoListen) (char * protocol) if ((trans = TRANS(SelectTransport)(protocol)) == NULL) { - PRMSG (1,"TransNoListen: unable to find transport: %s\n", - protocol, 0, 0); + prmsg (1,"TransNoListen: unable to find transport: %s\n", + protocol); return -1; } @@ -806,7 +807,7 @@ TRANS(Accept) (XtransConnInfo ciptr, int *status) { XtransConnInfo newciptr; - PRMSG (2,"Accept(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"Accept(%d)\n", ciptr->fd); newciptr = ciptr->transptr->Accept (ciptr, status); @@ -830,12 +831,12 @@ TRANS(Connect) (XtransConnInfo ciptr, char *address) char *port; int ret; - PRMSG (2,"Connect(%d,%s)\n", ciptr->fd, address, 0); + prmsg (2,"Connect(%d,%s)\n", ciptr->fd, address); if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0) { - PRMSG (1,"Connect: Unable to Parse address %s\n", - address, 0, 0); + prmsg (1,"Connect: Unable to Parse address %s\n", + address); return -1; } @@ -845,8 +846,8 @@ TRANS(Connect) (XtransConnInfo ciptr, char *address) if (!port || !*port) { - PRMSG (1,"Connect: Missing port specification in %s\n", - address, 0, 0); + prmsg (1,"Connect: Missing port specification in %s\n", + address); if (protocol) xfree (protocol); if (host) xfree (host); return -1; @@ -912,7 +913,7 @@ TRANS(Close) (XtransConnInfo ciptr) { int ret; - PRMSG (2,"Close(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"Close(%d)\n", ciptr->fd); ret = ciptr->transptr->Close (ciptr); @@ -927,7 +928,7 @@ TRANS(CloseForCloning) (XtransConnInfo ciptr) { int ret; - PRMSG (2,"CloseForCloning(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"CloseForCloning(%d)\n", ciptr->fd); ret = ciptr->transptr->CloseForCloning (ciptr); @@ -949,14 +950,14 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, Xtransaddr **addrp) { - PRMSG (2,"GetMyAddr(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"GetMyAddr(%d)\n", ciptr->fd); *familyp = ciptr->family; *addrlenp = ciptr->addrlen; if ((*addrp = (Xtransaddr *) xalloc (ciptr->addrlen)) == NULL) { - PRMSG (1,"GetMyAddr: malloc failed\n", 0, 0, 0); + prmsg (1,"GetMyAddr: malloc failed\n"); return -1; } memcpy(*addrp, ciptr->addr, ciptr->addrlen); @@ -969,14 +970,14 @@ TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, Xtransaddr **addrp) { - PRMSG (2,"GetPeerAddr(%d)\n", ciptr->fd, 0, 0); + prmsg (2,"GetPeerAddr(%d)\n", ciptr->fd); *familyp = ciptr->family; *addrlenp = ciptr->peeraddrlen; if ((*addrp = (Xtransaddr *) xalloc (ciptr->peeraddrlen)) == NULL) { - PRMSG (1,"GetPeerAddr: malloc failed\n", 0, 0, 0); + prmsg (1,"GetPeerAddr: malloc failed\n"); return -1; } memcpy(*addrp, ciptr->peeraddr, ciptr->peeraddrlen); @@ -1045,8 +1046,8 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, #if defined(IPv6) && defined(AF_INET6) int ipv6_succ = 0; #endif - PRMSG (2,"MakeAllCOTSServerListeners(%s,%p)\n", - port ? port : "NULL", ciptrs_ret, 0); + prmsg (2,"MakeAllCOTSServerListeners(%s,%p)\n", + port ? port : "NULL", ciptrs_ret); *count_ret = 0; @@ -1072,17 +1073,17 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, snprintf(buffer, sizeof(buffer), "%s/:%s", trans->TransName, port ? port : ""); - PRMSG (5,"MakeAllCOTSServerListeners: opening %s\n", - buffer, 0, 0); + prmsg (5,"MakeAllCOTSServerListeners: opening %s\n", + buffer); if ((ciptr = TRANS(OpenCOTSServer(buffer))) == NULL) { if (trans->flags & TRANS_DISABLED) continue; - PRMSG (1, + prmsg (1, "MakeAllCOTSServerListeners: failed to open listener for %s\n", - trans->TransName, 0, 0); + trans->TransName); continue; } #if defined(IPv6) && defined(AF_INET6) @@ -1101,9 +1102,8 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, * running at this address, and this function should fail. */ - PRMSG (1, - "MakeAllCOTSServerListeners: server already running\n", - 0, 0, 0); + prmsg (1, + "MakeAllCOTSServerListeners: server already running\n"); for (j = 0; j < *count_ret; j++) TRANS(Close) (temp_ciptrs[j]); @@ -1115,9 +1115,9 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, } else { - PRMSG (1, + prmsg (1, "MakeAllCOTSServerListeners: failed to create listener for %s\n", - trans->TransName, 0, 0); + trans->TransName); continue; } @@ -1128,9 +1128,9 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, ipv6_succ = 1; #endif - PRMSG (5, + prmsg (5, "MakeAllCOTSServerListeners: opened listener for %s, %d\n", - trans->TransName, ciptr->fd, 0); + trans->TransName, ciptr->fd); temp_ciptrs[*count_ret] = ciptr; (*count_ret)++; @@ -1138,7 +1138,7 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, *partial = (*count_ret < complete_network_count()); - PRMSG (5, + prmsg (5, "MakeAllCOTSServerListeners: partial=%d, actual=%d, complete=%d \n", *partial, *count_ret, complete_network_count()); @@ -1170,8 +1170,8 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, XtransConnInfo ciptr, temp_ciptrs[NUMTRANS]; int status, i, j; - PRMSG (2,"MakeAllCLTSServerListeners(%s,%p)\n", - port ? port : "NULL", ciptrs_ret, 0); + prmsg (2,"MakeAllCLTSServerListeners(%s,%p)\n", + port ? port : "NULL", ciptrs_ret); *count_ret = 0; @@ -1185,14 +1185,14 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, snprintf(buffer, sizeof(buffer), "%s/:%s", trans->TransName, port ? port : ""); - PRMSG (5,"MakeAllCLTSServerListeners: opening %s\n", - buffer, 0, 0); + prmsg (5,"MakeAllCLTSServerListeners: opening %s\n", + buffer); if ((ciptr = TRANS(OpenCLTSServer (buffer))) == NULL) { - PRMSG (1, + prmsg (1, "MakeAllCLTSServerListeners: failed to open listener for %s\n", - trans->TransName, 0, 0); + trans->TransName); continue; } @@ -1206,9 +1206,8 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, * running at this address, and this function should fail. */ - PRMSG (1, - "MakeAllCLTSServerListeners: server already running\n", - 0, 0, 0); + prmsg (1, + "MakeAllCLTSServerListeners: server already running\n"); for (j = 0; j < *count_ret; j++) TRANS(Close) (temp_ciptrs[j]); @@ -1220,24 +1219,24 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, } else { - PRMSG (1, + prmsg (1, "MakeAllCLTSServerListeners: failed to create listener for %s\n", - trans->TransName, 0, 0); + trans->TransName); continue; } } - PRMSG (5, + prmsg (5, "MakeAllCLTSServerListeners: opened listener for %s, %d\n", - trans->TransName, ciptr->fd, 0); + trans->TransName, ciptr->fd); temp_ciptrs[*count_ret] = ciptr; (*count_ret)++; } *partial = (*count_ret < complete_network_count()); - PRMSG (5, + prmsg (5, "MakeAllCLTSServerListeners: partial=%d, actual=%d, complete=%d \n", *partial, *count_ret, complete_network_count()); diff --git a/X11/xtrans/Xtrans.h b/X11/xtrans/Xtrans.h index 6f8f909c8..2945b2aba 100644 --- a/X11/xtrans/Xtrans.h +++ b/X11/xtrans/Xtrans.h @@ -70,14 +70,14 @@ from The Open Group. #ifdef X11_t #define TRANS(func) _X11Trans##func #ifdef XTRANSDEBUG -static char* __xtransname = "_X11Trans"; +static const char *__xtransname = "_X11Trans"; #endif #endif /* X11_t */ #ifdef XSERV_t #define TRANS(func) _XSERVTrans##func #ifdef XTRANSDEBUG -static char* __xtransname = "_XSERVTrans"; +static const char *__xtransname = "_XSERVTrans"; #endif #define X11_t #endif /* XSERV_t */ @@ -85,35 +85,35 @@ static char* __xtransname = "_XSERVTrans"; #ifdef XIM_t #define TRANS(func) _XimXTrans##func #ifdef XTRANSDEBUG -static char* __xtransname = "_XimTrans"; +static const char *__xtransname = "_XimTrans"; #endif #endif /* XIM_t */ #ifdef FS_t #define TRANS(func) _FSTrans##func #ifdef XTRANSDEBUG -static char* __xtransname = "_FSTrans"; +static const char *__xtransname = "_FSTrans"; #endif #endif /* FS_t */ #ifdef FONT_t #define TRANS(func) _FontTrans##func #ifdef XTRANSDEBUG -static char* __xtransname = "_FontTrans"; +static const char *__xtransname = "_FontTrans"; #endif #endif /* FONT_t */ #ifdef ICE_t #define TRANS(func) _IceTrans##func #ifdef XTRANSDEBUG -static char* __xtransname = "_IceTrans"; +static const char *__xtransname = "_IceTrans"; #endif #endif /* ICE_t */ #ifdef TEST_t #define TRANS(func) _TESTTrans##func #ifdef XTRANSDEBUG -static char* __xtransname = "_TESTTrans"; +static const char *__xtransname = "_TESTTrans"; #endif #endif /* TEST_t */ @@ -121,14 +121,14 @@ static char* __xtransname = "_TESTTrans"; #define TRANS(func) _LBXPROXYTrans##func #define X11_t /* The server defines this - so should the LBX proxy */ #ifdef XTRANSDEBUG -static char* __xtransname = "_LBXPROXYTrans"; +static const char *__xtransname = "_LBXPROXYTrans"; #endif #endif /* LBXPROXY_t */ #if !defined(TRANS) #define TRANS(func) _XTrans##func #ifdef XTRANSDEBUG -static char* __xtransname = "_XTrans"; +static const char *__xtransname = "_XTrans"; #endif #endif /* !TRANS */ @@ -304,7 +304,7 @@ int TRANS(CreateListener)( ); int TRANS(NoListen) ( - char* /* protocol*/ + const char* /* protocol*/ ); int TRANS(ResetListener)( diff --git a/X11/xtrans/Xtransint.h b/X11/xtrans/Xtransint.h index 787d72124..3bce8dc6b 100644 --- a/X11/xtrans/Xtransint.h +++ b/X11/xtrans/Xtransint.h @@ -68,7 +68,7 @@ from The Open Group. * message. */ -#ifndef XTRANSDEBUG +#if !defined(XTRANSDEBUG) && defined(XTRANS_TRANSPORT_C) # define XTRANSDEBUG 1 #endif @@ -78,6 +78,10 @@ from The Open Group. #include "Xtrans.h" +#ifndef _X_UNUSED /* Defined in Xfuncproto.h in xproto >= 7.0.22 */ +# define _X_UNUSED /* */ +#endif + #ifdef XTRANSDEBUG # include <stdio.h> #endif /* XTRANSDEBUG */ @@ -140,7 +144,7 @@ struct _XtransConnInfo { typedef struct _Xtransport { - char *TransName; + const char *TransName; int flags; #ifdef TRANS_CLIENT @@ -155,7 +159,7 @@ typedef struct _Xtransport { #endif /* TRANS_CLIENT */ #ifdef TRANS_SERVER - char ** nolisten; + const char ** nolisten; XtransConnInfo (*OpenCOTSServer)( struct _Xtransport *, /* transport */ char *, /* protocol */ @@ -307,6 +311,9 @@ typedef struct _Xtransport_table { /* Flags to preserve when setting others */ #define TRANS_KEEPFLAGS (TRANS_NOUNLINK|TRANS_ABSTRACT) +#ifdef XTRANS_TRANSPORT_C /* only provide static function prototypes when + building the transport.c file that has them in */ + #ifdef __clang__ /* Not all clients make use of all provided statics */ #pragma clang diagnostic push @@ -371,54 +378,62 @@ static int trans_mkdir ( * Some XTRANSDEBUG stuff */ -#if defined(XTRANSDEBUG) -/* add hack to the format string to avoid warnings about extra arguments - * to fprintf. +#ifdef XTRANSDEBUG +#include <stdarg.h> + +/* + * The X server provides ErrorF() & VErrorF(), for other software that uses + * xtrans, we provide our own simple versions. */ -#ifdef XTRANSDEBUGTIMESTAMP -#if defined(XSERV_t) && defined(TRANS_SERVER) -/* Use ErrorF() for the X server */ -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - struct timeval tp;\ - gettimeofday(&tp,0); \ - ErrorF("%s",__xtransname); \ - ErrorF(x+hack,a,b,c); \ - ErrorF("timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \ - errno=saveerrno; \ - } else ((void)0) -#else -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - struct timeval tp;\ - gettimeofday(&tp,0); \ - fprintf(stderr, "%s", __xtransname); fflush(stderr); \ - fprintf(stderr, x+hack,a,b,c); fflush(stderr); \ - fprintf(stderr, "timestamp (ms): %d\n",tp.tv_sec*1000+tp.tv_usec/1000); \ - fflush(stderr); \ - errno=saveerrno; \ - } else ((void)0) -#endif /* XSERV_t && TRANS_SERVER */ -#else /* XTRANSDEBUGTIMESTAMP */ -#if defined(XSERV_t) && defined(TRANS_SERVER) -/* Use ErrorF() for the X server */ -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - ErrorF("%s",__xtransname); \ - ErrorF(x+hack,a,b,c); \ - errno=saveerrno; \ - } else ((void)0) -#else -#define PRMSG(lvl,x,a,b,c) if (lvl <= XTRANSDEBUG){ \ - int hack= 0, saveerrno=errno; \ - fprintf(stderr, "%s", __xtransname); fflush(stderr); \ - fprintf(stderr, x+hack,a,b,c); fflush(stderr); \ - errno=saveerrno; \ - } else ((void)0) -#endif /* XSERV_t && TRANS_SERVER */ -#endif /* XTRANSDEBUGTIMESTAMP */ -#else -#define PRMSG(lvl,x,a,b,c) ((void)0) +# if defined(XSERV_t) && defined(TRANS_SERVER) +# include "os.h" +# else +static inline void _X_ATTRIBUTE_PRINTF(1, 0) +VErrorF(const char *f, va_list args) +{ + vfprintf(stderr, f, args); + fflush(stderr); +} + +static inline void _X_ATTRIBUTE_PRINTF(1, 2) +ErrorF(const char *f, ...) +{ + va_list args; + + va_start(args, f); + VErrorF(f, args); + va_end(args); +} +# endif /* xserver */ #endif /* XTRANSDEBUG */ +static inline void _X_ATTRIBUTE_PRINTF(2, 3) +prmsg(int lvl, const char *f, ...) +{ +#ifdef XTRANSDEBUG + va_list args; + + va_start(args, f); + if (lvl <= XTRANSDEBUG) { + int saveerrno = errno; + + ErrorF("%s", __xtransname); + VErrorF(f, args); + +# ifdef XTRANSDEBUGTIMESTAMP + { + struct timeval tp; + gettimeofday(&tp, 0); + ErrorF("timestamp (ms): %d\n", + tp.tv_sec * 1000 + tp.tv_usec / 1000); + } +# endif + errno = saveerrno; + } + va_end(args); +#endif /* XTRANSDEBUG */ +} + +#endif /* XTRANS_TRANSPORT_C */ + #endif /* _XTRANSINT_H_ */ diff --git a/X11/xtrans/Xtranslcl.c b/X11/xtrans/Xtranslcl.c index a4f3b1062..ddc5a3e81 100644 --- a/X11/xtrans/Xtranslcl.c +++ b/X11/xtrans/Xtranslcl.c @@ -129,7 +129,7 @@ static int TRANS(LocalClose)(XtransConnInfo ciptr); /* Type Not Supported */ static int -TRANS(OpenFail)(XtransConnInfo ciptr, char *port) +TRANS(OpenFail)(XtransConnInfo ciptr _X_UNUSED, char *port _X_UNUSED) { return -1; @@ -138,7 +138,7 @@ TRANS(OpenFail)(XtransConnInfo ciptr, char *port) #ifdef TRANS_REOPEN static int -TRANS(ReopenFail)(XtransConnInfo ciptr, int fd, char *port) +TRANS(ReopenFail)(XtransConnInfo ciptr _X_UNUSED, int fd _X_UNUSED, char *port _X_UNUSED) { return 0; @@ -160,14 +160,14 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) if ((sunaddr = (struct sockaddr_un *) xalloc (ciptr->addrlen)) == NULL) { - PRMSG(1,"FillAddrInfo: failed to allocate memory for addr\n", 0, 0, 0); + prmsg(1,"FillAddrInfo: failed to allocate memory for addr\n"); return 0; } sunaddr->sun_family = AF_UNIX; if (strlen(sun_path) > sizeof(sunaddr->sun_path) - 1) { - PRMSG(1, "FillAddrInfo: path too long\n", 0, 0, 0); + prmsg(1, "FillAddrInfo: path too long\n"); xfree((char *) sunaddr); return 0; } @@ -183,9 +183,8 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) if ((p_sunaddr = (struct sockaddr_un *) xalloc ( ciptr->peeraddrlen)) == NULL) { - PRMSG(1, - "FillAddrInfo: failed to allocate memory for peer addr\n", - 0,0,0); + prmsg(1, + "FillAddrInfo: failed to allocate memory for peer addr\n"); xfree ((char *) sunaddr); ciptr->addr = NULL; @@ -195,7 +194,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) p_sunaddr->sun_family = AF_UNIX; if (strlen(peer_sun_path) > sizeof(p_sunaddr->sun_path) - 1) { - PRMSG(1, "FillAddrInfo: peer path too long\n", 0, 0, 0); + prmsg(1, "FillAddrInfo: peer path too long\n"); xfree((char *) p_sunaddr); return 0; } @@ -228,7 +227,7 @@ extern char *ptsname( int ); -static void _dummy(int sig) +static void _dummy(int sig _X_UNUSED) { } @@ -321,20 +320,22 @@ TRANS(PTSOpenClient)(XtransConnInfo ciptr, char *port) pid_t saved_pid; #endif - PRMSG(2,"PTSOpenClient(%s)\n", port, 0,0 ); + prmsg(2,"PTSOpenClient(%s)\n", port); #if !defined(PTSNODENAME) - PRMSG(1,"PTSOpenClient: Protocol is not supported by a pts connection\n", 0,0,0); + prmsg(1,"PTSOpenClient: Protocol is not supported by a pts connection\n"); return -1; #else if (port && *port ) { if( *port == '/' ) { /* A full pathname */ - (void) sprintf(server_path, "%s", port); - } else { - (void) sprintf(server_path, "%s%s", PTSNODENAME, port); - } + snprintf(server_path, sizeof(server_path), "%s", port); + } else { + snprintf(server_path, sizeof(server_path), "%s%s", + PTSNODENAME, port); + } } else { - (void) sprintf(server_path, "%s%d", PTSNODENAME, getpid()); + snprintf(server_path, sizeof(server_path), "%s%d", + PTSNODENAME, getpid()); } @@ -343,7 +344,7 @@ TRANS(PTSOpenClient)(XtransConnInfo ciptr, char *port) */ if ((server = open (server_path, O_RDWR)) < 0) { - PRMSG(1,"PTSOpenClient: failed to open %s\n", server_path, 0,0); + prmsg(1,"PTSOpenClient: failed to open %s\n", server_path); return -1; } @@ -353,7 +354,7 @@ TRANS(PTSOpenClient)(XtransConnInfo ciptr, char *port) */ if ((fd = open(DEV_PTMX, O_RDWR)) < 0) { - PRMSG(1,"PTSOpenClient: failed to open %s\n", DEV_PTMX, 0,0); + prmsg(1,"PTSOpenClient: failed to open %s\n", DEV_PTMX); close(server); return(-1); } @@ -364,7 +365,7 @@ TRANS(PTSOpenClient)(XtransConnInfo ciptr, char *port) slave = ptsname(fd); /* get name */ if( slave == NULL ) { - PRMSG(1,"PTSOpenClient: failed to get ptsname()\n", 0,0,0); + prmsg(1,"PTSOpenClient: failed to get ptsname()\n"); close(fd); close(server); return -1; @@ -397,14 +398,14 @@ TRANS(PTSOpenClient)(XtransConnInfo ciptr, char *port) if (WIFEXITED(exitval) && WEXITSTATUS(exitval) != 0) { close(fd); close(server); - PRMSG(1, "PTSOpenClient: cannot set the owner of %s\n", - slave, 0, 0); + prmsg(1, "PTSOpenClient: cannot set the owner of %s\n", + slave); return(-1); } if (chmod(slave, 0666) < 0) { close(fd); close(server); - PRMSG(1,"PTSOpenClient: Cannot chmod %s\n", slave, 0,0); + prmsg(1,"PTSOpenClient: Cannot chmod %s\n", slave); return(-1); } @@ -431,8 +432,8 @@ TRANS(PTSOpenClient)(XtransConnInfo ciptr, char *port) (void) signal(SIGALRM, savef); if (ret != 1) { - PRMSG(1, - "PTSOpenClient: failed to get acknoledgement from server\n", 0, 0, 0); + prmsg(1, + "PTSOpenClient: failed to get acknoledgement from server\n"); (void) close(fd); fd = -1; } @@ -443,7 +444,7 @@ TRANS(PTSOpenClient)(XtransConnInfo ciptr, char *port) if (TRANS(FillAddrInfo) (ciptr, slave, server_path) == 0) { - PRMSG(1,"PTSOpenClient: failed to fill in addr info\n", 0, 0, 0); + prmsg(1,"PTSOpenClient: failed to fill in addr info\n"); close(fd); return -1; } @@ -468,10 +469,10 @@ TRANS(PTSOpenServer)(XtransConnInfo ciptr, char *port) int mode; #endif - PRMSG(2,"PTSOpenServer(%s)\n", port, 0,0 ); + prmsg(2,"PTSOpenServer(%s)\n", port); #if !defined(PTSNODENAME) - PRMSG(1,"PTSOpenServer: Protocol is not supported by a pts connection\n", 0,0,0); + prmsg(1,"PTSOpenServer: Protocol is not supported by a pts connection\n"); return -1; #else if (port && *port ) { @@ -490,8 +491,8 @@ TRANS(PTSOpenServer)(XtransConnInfo ciptr, char *port) mode = 0777; #endif if (trans_mkdir(X_STREAMS_DIR, mode) == -1) { - PRMSG (1, "PTSOpenServer: mkdir(%s) failed, errno = %d\n", - X_STREAMS_DIR, errno, 0); + prmsg (1, "PTSOpenServer: mkdir(%s) failed, errno = %d\n", + X_STREAMS_DIR, errno); return(-1); } @@ -502,8 +503,8 @@ TRANS(PTSOpenServer)(XtransConnInfo ciptr, char *port) * prevent clients from trying to connect to the in-use PTS (which * is often in use by something other than another server). */ - PRMSG(1, "PTSOpenServer: A server is already running on port %s\n", port, 0,0 ); - PRMSG(1, "PTSOpenServer: Remove %s if this is incorrect.\n", server_path, 0,0 ); + prmsg(1, "PTSOpenServer: A server is already running on port %s\n", port); + prmsg(1, "PTSOpenServer: Remove %s if this is incorrect.\n", server_path); close(fd); return(-1); } @@ -514,7 +515,7 @@ TRANS(PTSOpenServer)(XtransConnInfo ciptr, char *port) unlink(server_path); if( (fd=open(DEV_PTMX, O_RDWR)) < 0) { - PRMSG(1, "PTSOpenServer: Unable to open %s\n", DEV_PTMX, 0,0 ); + prmsg(1, "PTSOpenServer: Unable to open %s\n", DEV_PTMX); return(-1); } @@ -522,25 +523,25 @@ TRANS(PTSOpenServer)(XtransConnInfo ciptr, char *port) unlockpt(fd); if( (slave=ptsname(fd)) == NULL) { - PRMSG(1, "PTSOpenServer: Unable to get slave device name\n", 0,0,0 ); + prmsg(1, "PTSOpenServer: Unable to get slave device name\n"); close(fd); return(-1); } if( link(slave,server_path) < 0 ) { - PRMSG(1, "PTSOpenServer: Unable to link %s to %s\n", slave, server_path,0 ); + prmsg(1, "PTSOpenServer: Unable to link %s to %s\n", slave, server_path); close(fd); return(-1); } if( chmod(server_path, 0666) < 0 ) { - PRMSG(1, "PTSOpenServer: Unable to chmod %s to 0666\n", server_path,0,0 ); + prmsg(1, "PTSOpenServer: Unable to chmod %s to 0666\n", server_path); close(fd); return(-1); } if( (server=open(server_path, O_RDWR)) < 0 ) { - PRMSG(1, "PTSOpenServer: Unable to open server device %s\n", server_path,0,0 ); + prmsg(1, "PTSOpenServer: Unable to open server device %s\n", server_path); close(fd); return(-1); } @@ -553,7 +554,7 @@ TRANS(PTSOpenServer)(XtransConnInfo ciptr, char *port) if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0) { - PRMSG(1,"PTSOpenServer: failed to fill in addr info\n", 0, 0, 0); + prmsg(1,"PTSOpenServer: failed to fill in addr info\n"); close(fd); return -1; } @@ -573,17 +574,17 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) char buf[256]; struct sockaddr_un *sunaddr; - PRMSG(2,"PTSAccept(%x->%d)\n",ciptr,ciptr->fd,0); + prmsg(2,"PTSAccept(%x->%d)\n",ciptr,ciptr->fd); if( (in=read(ciptr->fd,&length,1)) <= 0 ){ if( !in ) { - PRMSG(2, - "PTSAccept: Incoming connection closed\n",0,0,0); + prmsg(2, + "PTSAccept: Incoming connection closed\n"); } else { - PRMSG(1, + prmsg(1, "PTSAccept: Error reading incoming connection. errno=%d \n", - errno,0,0); + errno); } *status = TRANS_ACCEPT_MISC_ERROR; return -1; @@ -591,13 +592,13 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) if( (in=read(ciptr->fd,buf,length)) <= 0 ){ if( !in ) { - PRMSG(2, - "PTSAccept: Incoming connection closed\n",0,0,0); + prmsg(2, + "PTSAccept: Incoming connection closed\n"); } else { - PRMSG(1, + prmsg(1, "PTSAccept: Error reading device name for new connection. errno=%d \n", - errno,0,0); + errno); } *status = TRANS_ACCEPT_MISC_ERROR; return -1; @@ -606,7 +607,7 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) buf[length] = '\0'; if( (newfd=open(buf,O_RDWR)) < 0 ) { - PRMSG(1, "PTSAccept: Failed to open %s\n",buf,0,0); + prmsg(1, "PTSAccept: Failed to open %s\n",buf); *status = TRANS_ACCEPT_MISC_ERROR; return -1; } @@ -619,8 +620,7 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) newciptr->addrlen=ciptr->addrlen; if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) { - PRMSG(1,"PTSAccept: failed to allocate memory for peer addr\n", - 0,0,0); + prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n"); close(newfd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -630,8 +630,7 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) newciptr->peeraddrlen=sizeof(struct sockaddr_un); if( (sunaddr=(struct sockaddr_un *)xalloc(newciptr->peeraddrlen)) == NULL ) { - PRMSG(1,"PTSAccept: failed to allocate memory for peer addr\n", - 0,0,0); + prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n"); xfree(newciptr->addr); close(newfd); *status = TRANS_ACCEPT_BAD_MALLOC; @@ -674,10 +673,10 @@ TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port) # endif #endif - PRMSG(2,"NAMEDOpenClient(%s)\n", port, 0,0 ); + prmsg(2,"NAMEDOpenClient(%s)\n", port); #if !defined(NAMEDNODENAME) - PRMSG(1,"NAMEDOpenClient: Protocol is not supported by a NAMED connection\n", 0,0,0); + prmsg(1,"NAMEDOpenClient: Protocol is not supported by a NAMED connection\n"); return -1; #else if ( port && *port ) { @@ -691,18 +690,18 @@ TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port) } if ((fd = open(server_path, O_RDWR)) < 0) { - PRMSG(1,"NAMEDOpenClient: Cannot open %s for NAMED connection\n", server_path, 0,0 ); + prmsg(1,"NAMEDOpenClient: Cannot open %s for NAMED connection\n", server_path); return -1; } if (fstat(fd, &filestat) < 0 ) { - PRMSG(1,"NAMEDOpenClient: Cannot stat %s for NAMED connection\n", server_path, 0,0 ); + prmsg(1,"NAMEDOpenClient: Cannot stat %s for NAMED connection\n", server_path); (void) close(fd); return -1; } if ((filestat.st_mode & S_IFMT) != S_IFIFO) { - PRMSG(1,"NAMEDOpenClient: Device %s is not a FIFO\n", server_path, 0,0 ); + prmsg(1,"NAMEDOpenClient: Device %s is not a FIFO\n", server_path); /* Is this really a failure? */ (void) close(fd); return -1; @@ -710,7 +709,7 @@ TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port) if (isastream(fd) <= 0) { - PRMSG(1,"NAMEDOpenClient: %s is not a streams device\n", server_path, 0,0 ); + prmsg(1,"NAMEDOpenClient: %s is not a streams device\n", server_path); (void) close(fd); return -1; } @@ -721,8 +720,7 @@ TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port) if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0) { - PRMSG(1,"NAMEDOpenClient: failed to fill in addr info\n", - 0,0,0); + prmsg(1,"NAMEDOpenClient: failed to fill in addr info\n"); close(fd); return -1; } @@ -742,54 +740,54 @@ TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port) static int TRANS(NAMEDOpenPipe)(const char *server_path) { - PRMSG(2,"NAMEDOpenPipe(%s)\n", server_path, 0,0 ); - int fd, pipefd[2]; struct stat sbuf; int mode; + prmsg(2,"NAMEDOpenPipe(%s)\n", server_path); + #ifdef HAS_STICKY_DIR_BIT mode = 01777; #else mode = 0777; #endif if (trans_mkdir(X_STREAMS_DIR, mode) == -1) { - PRMSG (1, "NAMEDOpenPipe: mkdir(%s) failed, errno = %d\n", - X_STREAMS_DIR, errno, 0); + prmsg (1, "NAMEDOpenPipe: mkdir(%s) failed, errno = %d\n", + X_STREAMS_DIR, errno); return(-1); } if(stat(server_path, &sbuf) != 0) { if (errno == ENOENT) { if ((fd = creat(server_path, (mode_t)0666)) == -1) { - PRMSG(1, "NAMEDOpenPipe: Can't open %s\n", server_path, 0,0 ); + prmsg(1, "NAMEDOpenPipe: Can't open %s\n", server_path); return(-1); } close(fd); if (chmod(server_path, (mode_t)0666) < 0) { - PRMSG(1, "NAMEDOpenPipe: Can't open %s\n", server_path, 0,0 ); + prmsg(1, "NAMEDOpenPipe: Can't open %s\n", server_path); return(-1); } } else { - PRMSG(1, "NAMEDOpenPipe: stat on %s failed\n", server_path, 0,0 ); + prmsg(1, "NAMEDOpenPipe: stat on %s failed\n", server_path); return(-1); } } if( pipe(pipefd) != 0) { - PRMSG(1, "NAMEDOpenPipe: pipe() failed, errno=%d\n",errno, 0,0 ); + prmsg(1, "NAMEDOpenPipe: pipe() failed, errno=%d\n",errno); return(-1); } if( ioctl(pipefd[0], I_PUSH, "connld") != 0) { - PRMSG(1, "NAMEDOpenPipe: ioctl(I_PUSH,\"connld\") failed, errno=%d\n",errno, 0,0 ); + prmsg(1, "NAMEDOpenPipe: ioctl(I_PUSH,\"connld\") failed, errno=%d\n",errno); close(pipefd[0]); close(pipefd[1]); return(-1); } if( fattach(pipefd[0], server_path) != 0) { - PRMSG(1, "NAMEDOpenPipe: fattach(%s) failed, errno=%d\n", server_path,errno, 0 ); + prmsg(1, "NAMEDOpenPipe: fattach(%s) failed, errno=%d\n", server_path,errno); close(pipefd[0]); close(pipefd[1]); return(-1); @@ -807,10 +805,10 @@ TRANS(NAMEDOpenServer)(XtransConnInfo ciptr, char *port) char server_path[64]; #endif - PRMSG(2,"NAMEDOpenServer(%s)\n", port, 0,0 ); + prmsg(2,"NAMEDOpenServer(%s)\n", port); #if !defined(NAMEDNODENAME) - PRMSG(1,"NAMEDOpenServer: Protocol is not supported by a NAMED connection\n", 0,0,0); + prmsg(1,"NAMEDOpenServer: Protocol is not supported by a NAMED connection\n"); return -1; #else if ( port && *port ) { @@ -836,7 +834,7 @@ TRANS(NAMEDOpenServer)(XtransConnInfo ciptr, char *port) if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0) { - PRMSG(1,"NAMEDOpenServer: failed to fill in addr info\n", 0,0,0); + prmsg(1,"NAMEDOpenServer: failed to fill in addr info\n"); TRANS(LocalClose)(ciptr); return -1; } @@ -850,11 +848,10 @@ static int TRANS(NAMEDResetListener) (XtransConnInfo ciptr) { - int status = TRANS_RESET_NOOP; struct sockaddr_un *sockname=(struct sockaddr_un *) ciptr->addr; struct stat statb; - PRMSG(2,"NAMEDResetListener(%p, %d)\n", ciptr, ciptr->fd, 0 ); + prmsg(2,"NAMEDResetListener(%p, %d)\n", ciptr, ciptr->fd); if (ciptr->fd != -1) { /* @@ -863,7 +860,7 @@ TRANS(NAMEDResetListener) (XtransConnInfo ciptr) if (stat (sockname->sun_path, &statb) == -1 || (statb.st_mode & S_IFMT) != S_IFIFO) { - PRMSG(3, "Pipe %s trashed, recreating\n", sockname->sun_path, 0, 0); + prmsg(3, "Pipe %s trashed, recreating\n", sockname->sun_path); TRANS(LocalClose)(ciptr); ciptr->fd = TRANS(NAMEDOpenPipe)(sockname->sun_path); if (ciptr->fd >= 0) @@ -881,10 +878,10 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) { struct strrecvfd str; - PRMSG(2,"NAMEDAccept(%x->%d)\n", ciptr, ciptr->fd, 0 ); + prmsg(2,"NAMEDAccept(%p->%d)\n", ciptr, ciptr->fd); if( ioctl(ciptr->fd, I_RECVFD, &str ) < 0 ) { - PRMSG(1, "NAMEDAccept: ioctl(I_RECVFD) failed, errno=%d\n", errno, 0,0 ); + prmsg(1, "NAMEDAccept: ioctl(I_RECVFD) failed, errno=%d\n", errno); *status = TRANS_ACCEPT_MISC_ERROR; return(-1); } @@ -895,9 +892,8 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) newciptr->family=ciptr->family; newciptr->addrlen=ciptr->addrlen; if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) { - PRMSG(1, - "NAMEDAccept: failed to allocate memory for pipe addr\n", - 0,0,0); + prmsg(1, + "NAMEDAccept: failed to allocate memory for pipe addr\n"); close(str.fd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -907,9 +903,8 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) newciptr->peeraddrlen=newciptr->addrlen; if( (newciptr->peeraddr=(char *)xalloc(newciptr->peeraddrlen)) == NULL ) { - PRMSG(1, - "NAMEDAccept: failed to allocate memory for peer addr\n", - 0,0,0); + prmsg(1, + "NAMEDAccept: failed to allocate memory for peer addr\n"); xfree(newciptr->addr); close(str.fd); *status = TRANS_ACCEPT_BAD_MALLOC; @@ -1021,23 +1016,23 @@ TRANS(SCOOpenClient)(XtransConnInfo ciptr, char *port) extern int getmsg(), putmsg(); #endif - PRMSG(2,"SCOOpenClient(%s)\n", port, 0,0 ); + prmsg(2,"SCOOpenClient(%s)\n", port); if (!port || !port[0]) port = "0"; #if !defined(SCORNODENAME) - PRMSG(2,"SCOOpenClient: Protocol is not supported by a SCO connection\n", 0,0,0); + prmsg(2,"SCOOpenClient: Protocol is not supported by a SCO connection\n"); return -1; #else (void) sprintf(server_path, SCORNODENAME, port); if ((server = open(server_path, O_RDWR)) < 0) { - PRMSG(1,"SCOOpenClient: failed to open %s\n", server_path, 0,0 ); + prmsg(1,"SCOOpenClient: failed to open %s\n", server_path); return -1; } if ((fd = open(DEV_SPX, O_RDWR)) < 0) { - PRMSG(1,"SCOOpenClient: failed to open %s\n", DEV_SPX, 0,0 ); + prmsg(1,"SCOOpenClient: failed to open %s\n", DEV_SPX); close(server); return -1; } @@ -1057,7 +1052,7 @@ TRANS(SCOOpenClient)(XtransConnInfo ciptr, char *port) (void) signal(SIGALRM, savef); if (ret < 0) { - PRMSG(1,"SCOOpenClient: error from getmsg\n", 0,0,0 ); + prmsg(1,"SCOOpenClient: error from getmsg\n"); close(fd); close(server); return -1; @@ -1081,7 +1076,7 @@ TRANS(SCOOpenClient)(XtransConnInfo ciptr, char *port) #endif if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0) { - PRMSG(1,"SCOOpenClient: failed to fill addr info\n", 0, 0, 0); + prmsg(1,"SCOOpenClient: failed to fill addr info\n"); close(fd); return -1; } @@ -1107,12 +1102,12 @@ TRANS(SCOOpenServer)(XtransConnInfo ciptr, char *port) int fds = -1; #endif - PRMSG(2,"SCOOpenServer(%s)\n", port, 0,0 ); + prmsg(2,"SCOOpenServer(%s)\n", port); if (!port || !port[0]) port = "0"; #if !defined(SCORNODENAME) - PRMSG(1,"SCOOpenServer: Protocol is not supported by a SCO connection\n", 0,0,0); + prmsg(1,"SCOOpenServer: Protocol is not supported by a SCO connection\n"); return -1; #else (void) sprintf(serverR_path, SCORNODENAME, port); @@ -1124,7 +1119,7 @@ TRANS(SCOOpenServer)(XtransConnInfo ciptr, char *port) if ((fds = open(DEV_SPX, O_RDWR)) < 0 || (fdr = open(DEV_SPX, O_RDWR)) < 0 ) { - PRMSG(1,"SCOOpenServer: failed to open %s\n", DEV_SPX, 0,0 ); + prmsg(1,"SCOOpenServer: failed to open %s\n", DEV_SPX); if (fds >= 0) close(fds); if (fdr >= 0) @@ -1133,14 +1128,14 @@ TRANS(SCOOpenServer)(XtransConnInfo ciptr, char *port) } if (named_spipe (fds, serverS_path) == -1) { - PRMSG(1,"SCOOpenServer: failed to create %s\n", serverS_path, 0, 0); + prmsg(1,"SCOOpenServer: failed to create %s\n", serverS_path); close (fdr); close (fds); return -1; } if (named_spipe (fdr, serverR_path) == -1) { - PRMSG(1,"SCOOpenServer: failed to create %s\n", serverR_path, 0, 0); + prmsg(1,"SCOOpenServer: failed to create %s\n", serverR_path); close (fdr); close (fds); return -1; @@ -1149,7 +1144,7 @@ TRANS(SCOOpenServer)(XtransConnInfo ciptr, char *port) fds = open (serverS_path, O_RDWR | O_NDELAY); if (fds < 0) { - PRMSG(1,"SCOOpenServer: failed to open %s\n", serverS_path, 0, 0); + prmsg(1,"SCOOpenServer: failed to open %s\n", serverS_path); return -1; } @@ -1162,22 +1157,22 @@ TRANS(SCOOpenServer)(XtransConnInfo ciptr, char *port) mylock.l_start = 0; mylock.l_len = 0; if (fcntl (fds, F_SETLK, &mylock) < 0) { - PRMSG(1,"SCOOpenServer: failed to lock %s\n", serverS_path, 0, 0); + prmsg(1,"SCOOpenServer: failed to lock %s\n", serverS_path); close (fds); return -1; } fdr = open (serverR_path, O_RDWR | O_NDELAY); if (fdr < 0) { - PRMSG(1,"SCOOpenServer: failed to open %s\n", serverR_path, 0, 0); + prmsg(1,"SCOOpenServer: failed to open %s\n", serverR_path); close (fds); return -1; } #endif /* X11_t */ if (connect_spipe(fds, fdr)) { - PRMSG(1,"SCOOpenServer: ioctl(I_FDINSERT) failed on %s\n", - serverS_path, 0, 0); + prmsg(1,"SCOOpenServer: ioctl(I_FDINSERT) failed on %s\n", + serverS_path); close (fdr); close (fds); return -1; @@ -1191,7 +1186,7 @@ TRANS(SCOOpenServer)(XtransConnInfo ciptr, char *port) ciptr->flags |= TRANS_NOUNLINK; #endif if (TRANS(FillAddrInfo) (ciptr, serverS_path, serverR_path) == 0) { - PRMSG(1,"SCOOpenServer: failed to fill in addr info\n", 0,0,0); + prmsg(1,"SCOOpenServer: failed to fill in addr info\n"); close(fds); close(fdr); return -1; @@ -1208,22 +1203,22 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) char c; int fd; - PRMSG(2,"SCOAccept(%d)\n", ciptr->fd, 0,0 ); + prmsg(2,"SCOAccept(%d)\n", ciptr->fd); if (read(ciptr->fd, &c, 1) < 0) { - PRMSG(1,"SCOAccept: can't read from client\n",0,0,0); + prmsg(1,"SCOAccept: can't read from client\n"); *status = TRANS_ACCEPT_MISC_ERROR; return(-1); } if( (fd = open(DEV_SPX, O_RDWR)) < 0 ) { - PRMSG(1,"SCOAccept: can't open \"%s\"\n",DEV_SPX, 0,0 ); + prmsg(1,"SCOAccept: can't open \"%s\"\n",DEV_SPX); *status = TRANS_ACCEPT_MISC_ERROR; return(-1); } if (connect_spipe (ciptr->fd, fd) < 0) { - PRMSG(1,"SCOAccept: ioctl(I_FDINSERT) failed\n", 0, 0, 0); + prmsg(1,"SCOAccept: ioctl(I_FDINSERT) failed\n"); close (fd); *status = TRANS_ACCEPT_MISC_ERROR; return -1; @@ -1235,9 +1230,8 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) newciptr->addrlen=ciptr->addrlen; if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) { - PRMSG(1, - "SCOAccept: failed to allocate memory for peer addr\n", - 0,0,0); + prmsg(1, + "SCOAccept: failed to allocate memory for peer addr\n"); close(fd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -1250,9 +1244,8 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) newciptr->peeraddrlen=newciptr->addrlen; if( (newciptr->peeraddr=(char *)xalloc(newciptr->peeraddrlen)) == NULL ) { - PRMSG(1, - "SCOAccept: failed to allocate memory for peer addr\n", - 0,0,0); + prmsg(1, + "SCOAccept: failed to allocate memory for peer addr\n"); xfree(newciptr->addr); close(fd); *status = TRANS_ACCEPT_BAD_MALLOC; @@ -1282,26 +1275,27 @@ TRANS(PTSReopenServer)(XtransConnInfo ciptr, int fd, char *port) char server_path[64]; #endif - PRMSG(2,"PTSReopenServer(%d,%s)\n", fd, port, 0 ); + prmsg(2,"PTSReopenServer(%d,%s)\n", fd, port); #if !defined(PTSNODENAME) - PRMSG(1,"PTSReopenServer: Protocol is not supported by a pts connection\n", 0,0,0); + prmsg(1,"PTSReopenServer: Protocol is not supported by a pts connection\n"); return 0; #else if (port && *port ) { if( *port == '/' ) { /* A full pathname */ - (void) sprintf(server_path, "%s", port); - } else { - (void) sprintf(server_path, "%s%s", PTSNODENAME, port); - } + snprintf(server_path, sizeof(server_path), "%s", port); + } else { + snprintf(server_path, sizeof(server_path), "%s%s", + PTSNODENAME, port); + } } else { - (void) sprintf(server_path, "%s%ld", PTSNODENAME, (long)getpid()); + snprintf(server_path, sizeof(server_path), "%s%ld", + PTSNODENAME, (long)getpid()); } if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0) { - PRMSG(1,"PTSReopenServer: failed to fill in addr info\n", - 0,0,0); + prmsg(1,"PTSReopenServer: failed to fill in addr info\n"); return 0; } @@ -1315,33 +1309,34 @@ TRANS(PTSReopenServer)(XtransConnInfo ciptr, int fd, char *port) #ifdef LOCAL_TRANS_NAMED static int -TRANS(NAMEDReopenServer)(XtransConnInfo ciptr, int fd, char *port) +TRANS(NAMEDReopenServer)(XtransConnInfo ciptr, int fd _X_UNUSED, char *port) { #ifdef NAMEDNODENAME char server_path[64]; #endif - PRMSG(2,"NAMEDReopenServer(%s)\n", port, 0,0 ); + prmsg(2,"NAMEDReopenServer(%s)\n", port); #if !defined(NAMEDNODENAME) - PRMSG(1,"NAMEDReopenServer: Protocol is not supported by a NAMED connection\n", 0,0,0); + prmsg(1,"NAMEDReopenServer: Protocol is not supported by a NAMED connection\n"); return 0; #else if ( port && *port ) { if( *port == '/' ) { /* A full pathname */ - (void) sprintf(server_path, "%s", port); + snprintf(server_path, sizeof(server_path),"%s", port); } else { - (void) sprintf(server_path, "%s%s", NAMEDNODENAME, port); + snprintf(server_path, sizeof(server_path), "%s%s", + NAMEDNODENAME, port); } } else { - (void) sprintf(server_path, "%s%ld", NAMEDNODENAME, (long)getpid()); + snprintf(server_path, sizeof(server_path), "%s%ld", + NAMEDNODENAME, (long)getpid()); } if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0) { - PRMSG(1,"NAMEDReopenServer: failed to fill in addr info\n", - 0,0,0); + prmsg(1,"NAMEDReopenServer: failed to fill in addr info\n"); return 0; } @@ -1362,12 +1357,12 @@ TRANS(SCOReopenServer)(XtransConnInfo ciptr, int fd, char *port) char serverR_path[64], serverS_path[64]; #endif - PRMSG(2,"SCOReopenServer(%s)\n", port, 0,0 ); + prmsg(2,"SCOReopenServer(%s)\n", port); if (!port || !port[0]) port = "0"; #if !defined(SCORNODENAME) - PRMSG(2,"SCOReopenServer: Protocol is not supported by a SCO connection\n", 0,0,0); + prmsg(2,"SCOReopenServer: Protocol is not supported by a SCO connection\n"); return 0; #else (void) sprintf(serverR_path, SCORNODENAME, port); @@ -1378,7 +1373,7 @@ TRANS(SCOReopenServer)(XtransConnInfo ciptr, int fd, char *port) #endif if (TRANS(FillAddrInfo) (ciptr, serverS_path, serverR_path) == 0) { - PRMSG(1, "SCOReopenServer: failed to fill in addr info\n", 0,0,0); + prmsg(1, "SCOReopenServer: failed to fill in addr info\n"); return 0; } @@ -1399,7 +1394,7 @@ TRANS(SCOReopenServer)(XtransConnInfo ciptr, int fd, char *port) */ typedef struct _LOCALtrans2dev { - char *transname; + const char *transname; #ifdef TRANS_CLIENT @@ -1660,7 +1655,7 @@ static LOCALtrans2dev LOCALtrans2devtab[] = { #define NUMTRANSPORTS (sizeof(LOCALtrans2devtab)/sizeof(LOCALtrans2dev)) -static char *XLOCAL=NULL; +static const char *XLOCAL=NULL; static char *workingXLOCAL=NULL; static char *freeXLOCAL=NULL; @@ -1675,10 +1670,10 @@ static char *freeXLOCAL=NULL; #endif static void -TRANS(LocalInitTransports)(char *protocol) +TRANS(LocalInitTransports)(const char *protocol) { - PRMSG(3,"LocalInitTransports(%s)\n", protocol, 0,0 ); + prmsg(3,"LocalInitTransports(%s)\n", protocol); if( strcmp(protocol,"local") && strcmp(protocol,"LOCAL") ) { @@ -1700,7 +1695,7 @@ static void TRANS(LocalEndTransports)(void) { - PRMSG(3,"LocalEndTransports()\n", 0,0,0 ); + prmsg(3,"LocalEndTransports()\n"); xfree(freeXLOCAL); } @@ -1715,7 +1710,7 @@ TRANS(LocalGetNextTransport)(void) int i,j; char *typetocheck; char typebuf[TYPEBUFSIZE]; - PRMSG(3,"LocalGetNextTransport()\n", 0,0,0 ); + prmsg(3,"LocalGetNextTransport()\n"); while(1) { @@ -1795,7 +1790,7 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) XtransConnInfo ciptr; int index; - PRMSG(3,"LocalOpenClient()\n", 0,0,0 ); + prmsg(3,"LocalOpenClient()\n"); /* * Make sure 'host' is really local. If not, we return failure. @@ -1807,9 +1802,9 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) if (strcmp (host, "unix") != 0 && !HostReallyLocal (host)) { - PRMSG (1, + prmsg (1, "LocalOpenClient: Cannot connect to non-local host %s\n", - host, 0, 0); + host); return NULL; } @@ -1828,8 +1823,8 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { - PRMSG(1,"LocalOpenClient: calloc(1,%d) failed\n", - sizeof(struct _XtransConnInfo),0,0 ); + prmsg(1,"LocalOpenClient: calloc(1,%lu) failed\n", + sizeof(struct _XtransConnInfo)); return NULL; } @@ -1851,14 +1846,13 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) break; case XTRANS_OPEN_COTS_SERVER: case XTRANS_OPEN_CLTS_SERVER: - PRMSG(1, - "LocalOpenClient: Should not be opening a server with this function\n", - 0,0,0); + prmsg(1, + "LocalOpenClient: Should not be opening a server with this function\n"); break; default: - PRMSG(1, + prmsg(1, "LocalOpenClient: Unknown Open type %d\n", - type, 0,0 ); + type); } if( ciptr->fd >= 0 ) break; @@ -1884,13 +1878,13 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) #ifdef TRANS_SERVER static XtransConnInfo -TRANS(LocalOpenServer)(int type, char *protocol, char *host, char *port) +TRANS(LocalOpenServer)(int type, char *protocol, char *host _X_UNUSED, char *port) { int i; XtransConnInfo ciptr; - PRMSG(2,"LocalOpenServer(%d,%s,%s)\n", type, protocol, port); + prmsg(2,"LocalOpenServer(%d,%s,%s)\n", type, protocol, port); #if defined(X11_t) /* @@ -1903,8 +1897,8 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host, char *port) if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { - PRMSG(1,"LocalOpenServer: calloc(1,%d) failed\n", - sizeof(struct _XtransConnInfo),0,0 ); + prmsg(1,"LocalOpenServer: calloc(1,%lu) failed\n", + sizeof(struct _XtransConnInfo)); return NULL; } @@ -1916,9 +1910,8 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host, char *port) { case XTRANS_OPEN_COTS_CLIENT: case XTRANS_OPEN_CLTS_CLIENT: - PRMSG(1, - "LocalOpenServer: Should not be opening a client with this function\n", - 0,0,0); + prmsg(1, + "LocalOpenServer: Should not be opening a client with this function\n"); break; case XTRANS_OPEN_COTS_SERVER: ciptr->fd=LOCALtrans2devtab[i].devcotsopenserver(ciptr,port); @@ -1927,8 +1920,8 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host, char *port) ciptr->fd=LOCALtrans2devtab[i].devcltsopenserver(ciptr,port); break; default: - PRMSG(1,"LocalOpenServer: Unknown Open type %d\n", - type ,0,0); + prmsg(1,"LocalOpenServer: Unknown Open type %d\n", + type ); } if( ciptr->fd >= 0 ) { ciptr->priv=(char *)&LOCALtrans2devtab[i]; @@ -1954,12 +1947,12 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port) XtransConnInfo ciptr; int stat = 0; - PRMSG(2,"LocalReopenServer(%d,%d,%d)\n", type, index, fd); + prmsg(2,"LocalReopenServer(%d,%d,%d)\n", type, index, fd); if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { - PRMSG(1,"LocalReopenServer: calloc(1,%d) failed\n", - sizeof(struct _XtransConnInfo),0,0 ); + prmsg(1,"LocalReopenServer: calloc(1,%lu) failed\n", + sizeof(struct _XtransConnInfo)); return NULL; } @@ -1974,8 +1967,8 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port) stat = LOCALtrans2devtab[index].devcltsreopenserver(ciptr,fd,port); break; default: - PRMSG(1,"LocalReopenServer: Unknown Open type %d\n", - type ,0,0); + prmsg(1,"LocalReopenServer: Unknown Open type %d\n", + type ); } if( stat > 0 ) { @@ -2000,11 +1993,11 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port) #ifdef TRANS_CLIENT static XtransConnInfo -TRANS(LocalOpenCOTSClient)(Xtransport *thistrans, char *protocol, +TRANS(LocalOpenCOTSClient)(Xtransport *thistrans _X_UNUSED, char *protocol, char *host, char *port) { - PRMSG(2,"LocalOpenCOTSClient(%s,%s,%s)\n",protocol,host,port); + prmsg(2,"LocalOpenCOTSClient(%s,%s,%s)\n",protocol,host,port); return TRANS(LocalOpenClient)(XTRANS_OPEN_COTS_CLIENT, protocol, host, port); } @@ -2023,7 +2016,7 @@ TRANS(LocalOpenCOTSServer)(Xtransport *thistrans, char *protocol, int found = 0; char typebuf[TYPEBUFSIZE]; - PRMSG(2,"LocalOpenCOTSServer(%s,%s,%s)\n",protocol,host,port); + prmsg(2,"LocalOpenCOTSServer(%s,%s,%s)\n",protocol,host,port); /* Check if this local type is in the XLOCAL list */ TRANS(LocalInitTransports)("local"); @@ -2045,7 +2038,7 @@ TRANS(LocalOpenCOTSServer)(Xtransport *thistrans, char *protocol, TRANS(LocalEndTransports)(); if (!found) { - PRMSG(3,"LocalOpenCOTSServer: disabling %s\n",thistrans->TransName,0,0); + prmsg(3,"LocalOpenCOTSServer: disabling %s\n",thistrans->TransName); thistrans->flags |= TRANS_DISABLED; return NULL; } @@ -2059,11 +2052,11 @@ TRANS(LocalOpenCOTSServer)(Xtransport *thistrans, char *protocol, #ifdef TRANS_CLIENT static XtransConnInfo -TRANS(LocalOpenCLTSClient)(Xtransport *thistrans, char *protocol, +TRANS(LocalOpenCLTSClient)(Xtransport *thistrans _X_UNUSED, char *protocol, char *host, char *port) { - PRMSG(2,"LocalOpenCLTSClient(%s,%s,%s)\n",protocol,host,port); + prmsg(2,"LocalOpenCLTSClient(%s,%s,%s)\n",protocol,host,port); return TRANS(LocalOpenClient)(XTRANS_OPEN_CLTS_CLIENT, protocol, host, port); } @@ -2074,11 +2067,11 @@ TRANS(LocalOpenCLTSClient)(Xtransport *thistrans, char *protocol, #ifdef TRANS_SERVER static XtransConnInfo -TRANS(LocalOpenCLTSServer)(Xtransport *thistrans, char *protocol, +TRANS(LocalOpenCLTSServer)(Xtransport *thistrans _X_UNUSED, char *protocol, char *host, char *port) { - PRMSG(2,"LocalOpenCLTSServer(%s,%s,%s)\n",protocol,host,port); + prmsg(2,"LocalOpenCLTSServer(%s,%s,%s)\n",protocol,host,port); return TRANS(LocalOpenServer)(XTRANS_OPEN_CLTS_SERVER, protocol, host, port); } @@ -2094,7 +2087,7 @@ TRANS(LocalReopenCOTSServer)(Xtransport *thistrans, int fd, char *port) { int index; - PRMSG(2,"LocalReopenCOTSServer(%d,%s)\n", fd, port, 0); + prmsg(2,"LocalReopenCOTSServer(%d,%s)\n", fd, port); for(index=1;index<NUMTRANSPORTS;index++) { @@ -2118,7 +2111,7 @@ TRANS(LocalReopenCLTSServer)(Xtransport *thistrans, int fd, char *port) { int index; - PRMSG(2,"LocalReopenCLTSServer(%d,%s)\n", fd, port, 0); + prmsg(2,"LocalReopenCLTSServer(%d,%s)\n", fd, port); for(index=1;index<NUMTRANSPORTS;index++) { @@ -2144,7 +2137,7 @@ static int TRANS(LocalSetOption)(XtransConnInfo ciptr, int option, int arg) { - PRMSG(2,"LocalSetOption(%d,%d,%d)\n",ciptr->fd,option,arg); + prmsg(2,"LocalSetOption(%d,%d,%d)\n",ciptr->fd,option,arg); return -1; } @@ -2153,10 +2146,10 @@ TRANS(LocalSetOption)(XtransConnInfo ciptr, int option, int arg) #ifdef TRANS_SERVER static int -TRANS(LocalCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags) +TRANS(LocalCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags _X_UNUSED) { - PRMSG(2,"LocalCreateListener(%x->%d,%s)\n",ciptr,ciptr->fd,port); + prmsg(2,"LocalCreateListener(%p->%d,%s)\n",ciptr,ciptr->fd,port); return 0; } @@ -2167,7 +2160,7 @@ TRANS(LocalResetListener)(XtransConnInfo ciptr) { LOCALtrans2dev *transptr; - PRMSG(2,"LocalResetListener(%x)\n",ciptr,0,0); + prmsg(2,"LocalResetListener(%p)\n",ciptr); transptr=(LOCALtrans2dev *)ciptr->priv; if (transptr->devreset != NULL) { @@ -2184,14 +2177,14 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status) XtransConnInfo newciptr; LOCALtrans2dev *transptr; - PRMSG(2,"LocalAccept(%x->%d)\n", ciptr, ciptr->fd,0); + prmsg(2,"LocalAccept(%p->%d)\n", ciptr, ciptr->fd); transptr=(LOCALtrans2dev *)ciptr->priv; if( (newciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo)))==NULL ) { - PRMSG(1,"LocalAccept: calloc(1,%d) failed\n", - sizeof(struct _XtransConnInfo),0,0 ); + prmsg(1,"LocalAccept: calloc(1,%lu) failed\n", + sizeof(struct _XtransConnInfo)); *status = TRANS_ACCEPT_BAD_MALLOC; return NULL; } @@ -2218,10 +2211,10 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status) #ifdef TRANS_CLIENT static int -TRANS(LocalConnect)(XtransConnInfo ciptr, char *host, char *port) +TRANS(LocalConnect)(XtransConnInfo ciptr, char *host _X_UNUSED, char *port) { - PRMSG(2,"LocalConnect(%x->%d,%s)\n", ciptr, ciptr->fd, port); + prmsg(2,"LocalConnect(%p->%d,%s)\n", ciptr, ciptr->fd, port); return 0; } @@ -2233,7 +2226,7 @@ static int TRANS(LocalBytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend ) { - PRMSG(2,"LocalBytesReadable(%x->%d,%x)\n", ciptr, ciptr->fd, pend); + prmsg(2,"LocalBytesReadable(%p->%d,%p)\n", ciptr, ciptr->fd, pend); #if defined(SCO325) return ioctl(ciptr->fd, I_NREAD, (char *)pend); @@ -2246,7 +2239,7 @@ static int TRANS(LocalRead)(XtransConnInfo ciptr, char *buf, int size) { - PRMSG(2,"LocalRead(%d,%x,%d)\n", ciptr->fd, buf, size ); + prmsg(2,"LocalRead(%d,%p,%d)\n", ciptr->fd, buf, size ); return read(ciptr->fd,buf,size); } @@ -2255,7 +2248,7 @@ static int TRANS(LocalWrite)(XtransConnInfo ciptr, char *buf, int size) { - PRMSG(2,"LocalWrite(%d,%x,%d)\n", ciptr->fd, buf, size ); + prmsg(2,"LocalWrite(%d,%p,%d)\n", ciptr->fd, buf, size ); return write(ciptr->fd,buf,size); } @@ -2264,7 +2257,7 @@ static int TRANS(LocalReadv)(XtransConnInfo ciptr, struct iovec *buf, int size) { - PRMSG(2,"LocalReadv(%d,%x,%d)\n", ciptr->fd, buf, size ); + prmsg(2,"LocalReadv(%d,%p,%d)\n", ciptr->fd, buf, size ); return READV(ciptr,buf,size); } @@ -2273,7 +2266,7 @@ static int TRANS(LocalWritev)(XtransConnInfo ciptr, struct iovec *buf, int size) { - PRMSG(2,"LocalWritev(%d,%x,%d)\n", ciptr->fd, buf, size ); + prmsg(2,"LocalWritev(%d,%p,%d)\n", ciptr->fd, buf, size ); return WRITEV(ciptr,buf,size); } @@ -2282,7 +2275,7 @@ static int TRANS(LocalDisconnect)(XtransConnInfo ciptr) { - PRMSG(2,"LocalDisconnect(%x->%d)\n", ciptr, ciptr->fd, 0); + prmsg(2,"LocalDisconnect(%p->%d)\n", ciptr, ciptr->fd); return 0; } @@ -2294,7 +2287,7 @@ TRANS(LocalClose)(XtransConnInfo ciptr) struct sockaddr_un *sockname=(struct sockaddr_un *) ciptr->addr; int ret; - PRMSG(2,"LocalClose(%x->%d)\n", ciptr, ciptr->fd ,0); + prmsg(2,"LocalClose(%p->%d)\n", ciptr, ciptr->fd ); ret=close(ciptr->fd); @@ -2316,7 +2309,7 @@ TRANS(LocalCloseForCloning)(XtransConnInfo ciptr) { int ret; - PRMSG(2,"LocalCloseForCloning(%x->%d)\n", ciptr, ciptr->fd ,0); + prmsg(2,"LocalCloseForCloning(%p->%d)\n", ciptr, ciptr->fd ); /* Don't unlink path */ @@ -2337,7 +2330,7 @@ TRANS(LocalCloseForCloning)(XtransConnInfo ciptr) */ #ifdef TRANS_SERVER -static char * local_aliases[] = { +static const char * local_aliases[] = { # ifdef LOCAL_TRANS_PTS "pts", # endif diff --git a/X11/xtrans/Xtranssock.c b/X11/xtrans/Xtranssock.c index 08a763ea7..dff33f323 100644 --- a/X11/xtrans/Xtranssock.c +++ b/X11/xtrans/Xtranssock.c @@ -176,7 +176,7 @@ from the copyright holders. */ typedef struct _Sockettrans2dev { - char *transname; + const char *transname; int family; int devcotsname; int devcltsname; @@ -262,12 +262,12 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr); */ static int -TRANS(SocketSelectFamily) (int first, char *family) +TRANS(SocketSelectFamily) (int first, const char *family) { int i; - PRMSG (3,"SocketSelectFamily(%s)\n", family, 0, 0); + prmsg (3,"SocketSelectFamily(%s)\n", family); for (i = first + 1; i < NUMSOCKETFAMILIES;i++) { @@ -296,7 +296,7 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) void *socknamePtr; SOCKLEN_T namelen; - PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0); + prmsg (3,"SocketINETGetAddr(%p)\n", ciptr); #if defined(IPv6) && defined(AF_INET6) namelen = sizeof(socknamev6); @@ -314,8 +314,8 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) #ifdef WIN32 errno = WSAGetLastError(); #endif - PRMSG (1,"SocketINETGetAddr: getsockname() failed: %d\n", - EGET(),0, 0); + prmsg (1,"SocketINETGetAddr: getsockname() failed: %d\n", + EGET()); return -1; } @@ -325,9 +325,8 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) { - PRMSG (1, - "SocketINETGetAddr: Can't allocate space for the addr\n", - 0, 0, 0); + prmsg (1, + "SocketINETGetAddr: Can't allocate space for the addr\n"); return -1; } @@ -374,7 +373,7 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) bzero(socknamePtr, namelen); - PRMSG (3,"SocketINETGetPeerAddr(%p)\n", ciptr, 0, 0); + prmsg (3,"SocketINETGetPeerAddr(%p)\n", ciptr); if (getpeername (ciptr->fd, (struct sockaddr *) socknamePtr, (void *)&namelen) < 0) @@ -382,8 +381,8 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) #ifdef WIN32 errno = WSAGetLastError(); #endif - PRMSG (1,"SocketINETGetPeerAddr: getpeername() failed: %d\n", - EGET(), 0, 0); + prmsg (1,"SocketINETGetPeerAddr: getpeername() failed: %d\n", + EGET()); return -1; } @@ -393,9 +392,8 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL) { - PRMSG (1, - "SocketINETGetPeerAddr: Can't allocate space for the addr\n", - 0, 0, 0); + prmsg (1, + "SocketINETGetPeerAddr: Can't allocate space for the addr\n"); return -1; } @@ -412,12 +410,12 @@ TRANS(SocketOpen) (int i, int type) { XtransConnInfo ciptr; - PRMSG (3,"SocketOpen(%d,%d)\n", i, type, 0); + prmsg (3,"SocketOpen(%d,%d)\n", i, type); if ((ciptr = (XtransConnInfo) xcalloc ( 1, sizeof(struct _XtransConnInfo))) == NULL) { - PRMSG (1, "SocketOpen: malloc failed\n", 0, 0, 0); + prmsg (1, "SocketOpen: malloc failed\n"); return NULL; } @@ -432,8 +430,8 @@ TRANS(SocketOpen) (int i, int type) #ifdef WIN32 errno = WSAGetLastError(); #endif - PRMSG (2, "SocketOpen: socket() failed for %s\n", - Sockettrans2devtab[i].transname, 0, 0); + prmsg (2, "SocketOpen: socket() failed for %s\n", + Sockettrans2devtab[i].transname); xfree ((char *) ciptr); return NULL; @@ -463,30 +461,30 @@ TRANS(SocketOpen) (int i, int type) #ifdef TRANS_REOPEN static XtransConnInfo -TRANS(SocketReopen) (int i, int type, int fd, char *port) +TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port) { XtransConnInfo ciptr; int portlen; struct sockaddr *addr; - PRMSG (3,"SocketReopen(%d,%d,%s)\n", type, fd, port); + prmsg (3,"SocketReopen(%d,%d,%s)\n", type, fd, port); if (port == NULL) { - PRMSG (1, "SocketReopen: port was null!\n", 0, 0, 0); + prmsg (1, "SocketReopen: port was null!\n"); return NULL; } portlen = strlen(port) + 1; // include space for trailing null #ifdef SOCK_MAXADDRLEN if (portlen < 0 || portlen > (SOCK_MAXADDRLEN + 2)) { - PRMSG (1, "SocketReopen: invalid portlen %d\n", portlen, 0, 0); + prmsg (1, "SocketReopen: invalid portlen %d\n", portlen); return NULL; } if (portlen < 14) portlen = 14; #else if (portlen < 0 || portlen > 14) { - PRMSG (1, "SocketReopen: invalid portlen %d\n", portlen, 0, 0); + prmsg (1, "SocketReopen: invalid portlen %d\n", portlen); return NULL; } #endif /*SOCK_MAXADDRLEN*/ @@ -494,21 +492,21 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port) if ((ciptr = (XtransConnInfo) xcalloc ( 1, sizeof(struct _XtransConnInfo))) == NULL) { - PRMSG (1, "SocketReopen: malloc(ciptr) failed\n", 0, 0, 0); + prmsg (1, "SocketReopen: malloc(ciptr) failed\n"); return NULL; } ciptr->fd = fd; if ((addr = (struct sockaddr *) xcalloc (1, portlen + 2)) == NULL) { - PRMSG (1, "SocketReopen: malloc(addr) failed\n", 0, 0, 0); + prmsg (1, "SocketReopen: malloc(addr) failed\n"); return NULL; } ciptr->addr = (char *) addr; ciptr->addrlen = portlen + 2; if ((ciptr->peeraddr = (char *) xcalloc (1, portlen + 2)) == NULL) { - PRMSG (1, "SocketReopen: malloc(portaddr) failed\n", 0, 0, 0); + prmsg (1, "SocketReopen: malloc(portaddr) failed\n"); return NULL; } ciptr->peeraddrlen = portlen + 2; @@ -548,13 +546,13 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port) #ifdef TRANS_CLIENT static XtransConnInfo -TRANS(SocketOpenCOTSClientBase) (char *transname, char *protocol, - char *host, char *port, int previndex) +TRANS(SocketOpenCOTSClientBase) (const char *transname, const char *protocol, + const char *host, const char *port, int previndex) { XtransConnInfo ciptr; int i = previndex; - PRMSG (2, "SocketOpenCOTSClient(%s,%s,%s)\n", + prmsg (2, "SocketOpenCOTSClient(%s,%s,%s)\n", protocol, host, port); SocketInitOnce(); @@ -570,11 +568,11 @@ TRANS(SocketOpenCOTSClientBase) (char *transname, char *protocol, } if (i < 0) { if (i == -1) - PRMSG (1,"SocketOpenCOTSClient: Unable to open socket for %s\n", - transname, 0, 0); + prmsg (1,"SocketOpenCOTSClient: Unable to open socket for %s\n", + transname); else - PRMSG (1,"SocketOpenCOTSClient: Unable to determine socket type for %s\n", - transname, 0, 0); + prmsg (1,"SocketOpenCOTSClient: Unable to determine socket type for %s\n", + transname); return NULL; } @@ -603,7 +601,7 @@ TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol, XtransConnInfo ciptr; int i = -1; - PRMSG (2,"SocketOpenCOTSServer(%s,%s,%s)\n", protocol, host, port); + prmsg (2,"SocketOpenCOTSServer(%s,%s,%s)\n", protocol, host, port); SocketInitOnce(); @@ -614,11 +612,11 @@ TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol, } if (i < 0) { if (i == -1) - PRMSG (1,"SocketOpenCOTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketOpenCOTSServer: Unable to open socket for %s\n", + thistrans->TransName); else - PRMSG (1,"SocketOpenCOTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketOpenCOTSServer: Unable to determine socket type for %s\n", + thistrans->TransName); return NULL; } @@ -670,7 +668,7 @@ TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol, XtransConnInfo ciptr; int i = -1; - PRMSG (2,"SocketOpenCLTSClient(%s,%s,%s)\n", protocol, host, port); + prmsg (2,"SocketOpenCLTSClient(%s,%s,%s)\n", protocol, host, port); SocketInitOnce(); @@ -681,11 +679,11 @@ TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol, } if (i < 0) { if (i == -1) - PRMSG (1,"SocketOpenCLTSClient: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketOpenCLTSClient: Unable to open socket for %s\n", + thistrans->TransName); else - PRMSG (1,"SocketOpenCLTSClient: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketOpenCLTSClient: Unable to determine socket type for %s\n", + thistrans->TransName); return NULL; } @@ -709,7 +707,7 @@ TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol, XtransConnInfo ciptr; int i = -1; - PRMSG (2,"SocketOpenCLTSServer(%s,%s,%s)\n", protocol, host, port); + prmsg (2,"SocketOpenCLTSServer(%s,%s,%s)\n", protocol, host, port); SocketInitOnce(); @@ -720,11 +718,11 @@ TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol, } if (i < 0) { if (i == -1) - PRMSG (1,"SocketOpenCLTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketOpenCLTSServer: Unable to open socket for %s\n", + thistrans->TransName); else - PRMSG (1,"SocketOpenCLTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketOpenCLTSServer: Unable to determine socket type for %s\n", + thistrans->TransName); return NULL; } @@ -754,8 +752,8 @@ TRANS(SocketReopenCOTSServer) (Xtransport *thistrans, int fd, char *port) XtransConnInfo ciptr; int i = -1; - PRMSG (2, - "SocketReopenCOTSServer(%d, %s)\n", fd, port, 0); + prmsg (2, + "SocketReopenCOTSServer(%d, %s)\n", fd, port); SocketInitOnce(); @@ -766,11 +764,11 @@ TRANS(SocketReopenCOTSServer) (Xtransport *thistrans, int fd, char *port) } if (i < 0) { if (i == -1) - PRMSG (1,"SocketReopenCOTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketReopenCOTSServer: Unable to open socket for %s\n", + thistrans->TransName); else - PRMSG (1,"SocketReopenCOTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketReopenCOTSServer: Unable to determine socket type for %s\n", + thistrans->TransName); return NULL; } @@ -788,8 +786,8 @@ TRANS(SocketReopenCLTSServer) (Xtransport *thistrans, int fd, char *port) XtransConnInfo ciptr; int i = -1; - PRMSG (2, - "SocketReopenCLTSServer(%d, %s)\n", fd, port, 0); + prmsg (2, + "SocketReopenCLTSServer(%d, %s)\n", fd, port); SocketInitOnce(); @@ -800,11 +798,11 @@ TRANS(SocketReopenCLTSServer) (Xtransport *thistrans, int fd, char *port) } if (i < 0) { if (i == -1) - PRMSG (1,"SocketReopenCLTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketReopenCLTSServer: Unable to open socket for %s\n", + thistrans->TransName); else - PRMSG (1,"SocketReopenCLTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); + prmsg (1,"SocketReopenCLTSServer: Unable to determine socket type for %s\n", + thistrans->TransName); return NULL; } @@ -822,7 +820,7 @@ static int TRANS(SocketSetOption) (XtransConnInfo ciptr, int option, int arg) { - PRMSG (2,"SocketSetOption(%d,%d,%d)\n", ciptr->fd, option, arg); + prmsg (2,"SocketSetOption(%d,%d,%d)\n", ciptr->fd, option, arg); return -1; } @@ -850,7 +848,7 @@ set_sun_path(const char *port, const char *upath, char *path, int abstract) if (strlen(port) + strlen(upath) > maxlen) return -1; - sprintf(path, "%s%s%s", at, upath, port); + snprintf(path, sizeof(s.sun_path), "%s%s%s", at, upath, port); return 0; } #endif @@ -867,7 +865,7 @@ TRANS(SocketCreateListener) (XtransConnInfo ciptr, int fd = ciptr->fd; int retry; - PRMSG (3, "SocketCreateListener(%x,%p)\n", ciptr, fd, 0); + prmsg (3, "SocketCreateListener(%p,%d)\n", ciptr, fd); if (Sockettrans2devtab[ciptr->index].family == AF_INET #if defined(IPv6) && defined(AF_INET6) @@ -888,8 +886,7 @@ TRANS(SocketCreateListener) (XtransConnInfo ciptr, } if (retry-- == 0) { - PRMSG (1, "SocketCreateListener: failed to bind listener\n", - 0, 0, 0); + prmsg (1, "SocketCreateListener: failed to bind listener\n"); close (fd); return TRANS_CREATE_LISTENER_FAILED; } @@ -920,7 +917,7 @@ TRANS(SocketCreateListener) (XtransConnInfo ciptr, if (listen (fd, BACKLOG) < 0) { - PRMSG (1, "SocketCreateListener: listen() failed\n", 0, 0, 0); + prmsg (1, "SocketCreateListener: listen() failed\n"); close (fd); return TRANS_CREATE_LISTENER_FAILED; } @@ -955,7 +952,7 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int char portbuf[PORTBUFSIZE]; #endif - PRMSG (2, "SocketINETCreateListener(%s)\n", port, 0, 0); + prmsg (2, "SocketINETCreateListener(%s)\n", port); #ifdef X11_t /* @@ -971,7 +968,7 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int { /* fixup the server port address */ tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); - sprintf (portbuf,"%lu", tmpport); + snprintf (portbuf, sizeof(portbuf), "%lu", tmpport); port = portbuf; } #endif @@ -984,9 +981,9 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int { if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) { - PRMSG (1, + prmsg (1, "SocketINETCreateListener: Unable to get service for %s\n", - port, 0, 0); + port); return TRANS_CREATE_LISTENER_FAILED; } /* we trust getservbyname to return a valid number */ @@ -1041,17 +1038,15 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int if ((status = TRANS(SocketCreateListener) (ciptr, (struct sockaddr *) &sockname, namelen, flags)) < 0) { - PRMSG (1, - "SocketINETCreateListener: ...SocketCreateListener() failed\n", - 0, 0, 0); + prmsg (1, + "SocketINETCreateListener: ...SocketCreateListener() failed\n"); return status; } if (TRANS(SocketINETGetAddr) (ciptr) < 0) { - PRMSG (1, - "SocketINETCreateListener: ...SocketINETGetAddr() failed\n", - 0, 0, 0); + prmsg (1, + "SocketINETCreateListener: ...SocketINETGetAddr() failed\n"); return TRANS_CREATE_LISTENER_FAILED; } @@ -1080,8 +1075,8 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port, abstract = ciptr->transptr->flags & TRANS_ABSTRACT; #endif - PRMSG (2, "SocketUNIXCreateListener(%s)\n", - port ? port : "NULL", 0, 0); + prmsg (2, "SocketUNIXCreateListener(%s)\n", + port ? port : "NULL"); /* Make sure the directory is created */ @@ -1094,8 +1089,8 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port, mode = 0777; #endif if (!abstract && trans_mkdir(UNIX_DIR, mode) == -1) { - PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n", - UNIX_DIR, errno, 0); + prmsg (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n", + UNIX_DIR, errno); (void) umask (oldUmask); return TRANS_CREATE_LISTENER_FAILED; } @@ -1109,7 +1104,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port, port = tmpport; } if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) { - PRMSG (1, "SocketUNIXCreateListener: path too long\n", 0, 0, 0); + prmsg (1, "SocketUNIXCreateListener: path too long\n"); return TRANS_CREATE_LISTENER_FAILED; } @@ -1133,9 +1128,8 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port, if ((status = TRANS(SocketCreateListener) (ciptr, (struct sockaddr *) &sockname, namelen, flags)) < 0) { - PRMSG (1, - "SocketUNIXCreateListener: ...SocketCreateListener() failed\n", - 0, 0, 0); + prmsg (1, + "SocketUNIXCreateListener: ...SocketCreateListener() failed\n"); (void) umask (oldUmask); return status; } @@ -1151,9 +1145,8 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port, if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) { - PRMSG (1, - "SocketUNIXCreateListener: Can't allocate space for the addr\n", - 0, 0, 0); + prmsg (1, + "SocketUNIXCreateListener: Can't allocate space for the addr\n"); (void) umask (oldUmask); return TRANS_CREATE_LISTENER_FAILED; } @@ -1188,7 +1181,7 @@ TRANS(SocketUNIXResetListener) (XtransConnInfo ciptr) abstract = ciptr->transptr->flags & TRANS_ABSTRACT; #endif - PRMSG (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd, 0); + prmsg (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd); if (!abstract && ( stat (unsock->sun_path, &statb) == -1 || @@ -1209,8 +1202,8 @@ TRANS(SocketUNIXResetListener) (XtransConnInfo ciptr) mode = 0777; #endif if (trans_mkdir(UNIX_DIR, mode) == -1) { - PRMSG (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n", - UNIX_DIR, errno, 0); + prmsg (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n", + UNIX_DIR, errno); (void) umask (oldUmask); return TRANS_RESET_FAILURE; } @@ -1266,12 +1259,12 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) #endif SOCKLEN_T namelen = sizeof(sockname); - PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0); + prmsg (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd); if ((newciptr = (XtransConnInfo) xcalloc ( 1, sizeof(struct _XtransConnInfo))) == NULL) { - PRMSG (1, "SocketINETAccept: malloc failed\n", 0, 0, 0); + prmsg (1, "SocketINETAccept: malloc failed\n"); *status = TRANS_ACCEPT_BAD_MALLOC; return NULL; } @@ -1282,7 +1275,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) #ifdef WIN32 errno = WSAGetLastError(); #endif - PRMSG (1, "SocketINETAccept: accept() failed\n", 0, 0, 0); + prmsg (1, "SocketINETAccept: accept() failed\n"); xfree (newciptr); *status = TRANS_ACCEPT_FAILED; return NULL; @@ -1307,9 +1300,8 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) if (TRANS(SocketINETGetAddr) (newciptr) < 0) { - PRMSG (1, - "SocketINETAccept: ...SocketINETGetAddr() failed:\n", - 0, 0, 0); + prmsg (1, + "SocketINETAccept: ...SocketINETGetAddr() failed:\n"); close (newciptr->fd); xfree (newciptr); *status = TRANS_ACCEPT_MISC_ERROR; @@ -1318,9 +1310,8 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) if (TRANS(SocketINETGetPeerAddr) (newciptr) < 0) { - PRMSG (1, - "SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n", - 0, 0, 0); + prmsg (1, + "SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n"); close (newciptr->fd); if (newciptr->addr) xfree (newciptr->addr); xfree (newciptr); @@ -1345,12 +1336,12 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) struct sockaddr_un sockname; SOCKLEN_T namelen = sizeof sockname; - PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0); + prmsg (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd); if ((newciptr = (XtransConnInfo) xcalloc ( 1, sizeof(struct _XtransConnInfo))) == NULL) { - PRMSG (1, "SocketUNIXAccept: malloc() failed\n", 0, 0, 0); + prmsg (1, "SocketUNIXAccept: malloc() failed\n"); *status = TRANS_ACCEPT_BAD_MALLOC; return NULL; } @@ -1358,7 +1349,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) if ((newciptr->fd = accept (ciptr->fd, (struct sockaddr *) &sockname, (void *)&namelen)) < 0) { - PRMSG (1, "SocketUNIXAccept: accept() failed\n", 0, 0, 0); + prmsg (1, "SocketUNIXAccept: accept() failed\n"); xfree (newciptr); *status = TRANS_ACCEPT_FAILED; return NULL; @@ -1372,9 +1363,8 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL) { - PRMSG (1, - "SocketUNIXAccept: Can't allocate space for the addr\n", - 0, 0, 0); + prmsg (1, + "SocketUNIXAccept: Can't allocate space for the addr\n"); close (newciptr->fd); xfree (newciptr); *status = TRANS_ACCEPT_BAD_MALLOC; @@ -1391,9 +1381,8 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) if ((newciptr->peeraddr = (char *) xalloc (ciptr->addrlen)) == NULL) { - PRMSG (1, - "SocketUNIXAccept: Can't allocate space for the addr\n", - 0, 0, 0); + prmsg (1, + "SocketUNIXAccept: Can't allocate space for the addr\n"); close (newciptr->fd); if (newciptr->addr) xfree (newciptr->addr); xfree (newciptr); @@ -1442,23 +1431,23 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) struct addrinfo hints; char ntopbuf[INET6_ADDRSTRLEN]; int resetonce = 0; -#endif +#else struct sockaddr_in sockname; + struct hostent *hostp; + struct servent *servp; + unsigned long tmpaddr; +#endif #ifdef XTHREADS_NEEDS_BYNAMEPARAMS _Xgethostbynameparams hparams; _Xgetservbynameparams sparams; #endif - struct hostent *hostp; - struct servent *servp; - unsigned long tmpaddr; #ifdef X11_t char portbuf[PORTBUFSIZE]; #endif - long tmpport; char hostnamebuf[256]; /* tmp space */ - PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port); + prmsg (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port); if (!host) { @@ -1479,8 +1468,8 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) if (is_numeric (port)) { - tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); - sprintf (portbuf, "%lu", tmpport); + long tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); + snprintf (portbuf, sizeof(portbuf), "%lu", tmpport); port = portbuf; } #endif @@ -1509,7 +1498,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) res = getaddrinfo(host,port,&hints,&addrlist->firstaddr); if (res != 0) { - PRMSG (1, "SocketINETConnect() can't get address " + prmsg (1, "SocketINETConnect() can't get address " "for %s:%s: %s\n", host, port, gai_strerror(res)); ESET(EINVAL); return TRANS_CONNECT_FAILED; @@ -1518,7 +1507,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) addrlist->addr ; res++) { addrlist->addr = addrlist->addr->ai_next; } - PRMSG(4,"Got New Address list with %d addresses\n", res, 0, 0); + prmsg(4,"Got New Address list with %d addresses\n", res); res = 0; addrlist->addr = NULL; } @@ -1527,8 +1516,8 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) if (addrlist->addr == NULL) { if (resetonce) { /* Already checked entire list - no usable addresses */ - PRMSG (1, "SocketINETConnect() no usable address " - "for %s:%s\n", host, port, 0); + prmsg (1, "SocketINETConnect() no usable address " + "for %s:%s\n", host, port); return TRANS_CONNECT_FAILED; } else { /* Go back to beginning of list */ @@ -1543,12 +1532,12 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) if (addrlist->addr->ai_family == AF_INET) { struct sockaddr_in *sin = (struct sockaddr_in *) socketaddr; - PRMSG (4,"SocketINETConnect() sockname.sin_addr = %s\n", + prmsg (4,"SocketINETConnect() sockname.sin_addr = %s\n", inet_ntop(addrlist->addr->ai_family,&sin->sin_addr, - ntopbuf,sizeof(ntopbuf)), 0, 0); + ntopbuf,sizeof(ntopbuf))); - PRMSG (4,"SocketINETConnect() sockname.sin_port = %d\n", - ntohs(sin->sin_port), 0, 0); + prmsg (4,"SocketINETConnect() sockname.sin_port = %d\n", + ntohs(sin->sin_port)); if (Sockettrans2devtab[ciptr->index].family == AF_INET6) { if (strcmp(Sockettrans2devtab[ciptr->index].transname, @@ -1570,26 +1559,24 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) Sockettrans2devtab[newciptr->index].family != AF_INET) { socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Cannot get IPv4 " - " socketfor IPv4 address\n", 0,0,0); + prmsg (4,"SocketINETConnect() Cannot get IPv4 " + " socketfor IPv4 address\n"); } if (newciptr) xfree(newciptr); } else { socketaddr = NULL; - PRMSG (4,"SocketINETConnect Skipping IPv4 address\n", - 0,0,0); + prmsg (4,"SocketINETConnect Skipping IPv4 address\n"); } } } else if (addrlist->addr->ai_family == AF_INET6) { struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) socketaddr; - PRMSG (4,"SocketINETConnect() sockname.sin6_addr = %s\n", + prmsg (4,"SocketINETConnect() sockname.sin6_addr = %s\n", inet_ntop(addrlist->addr->ai_family, - &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)), - 0, 0); - PRMSG (4,"SocketINETConnect() sockname.sin6_port = %d\n", - ntohs(sin6->sin6_port), 0, 0); + &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf))); + prmsg (4,"SocketINETConnect() sockname.sin6_port = %d\n", + ntohs(sin6->sin6_port)); if (Sockettrans2devtab[ciptr->index].family == AF_INET) { if (strcmp(Sockettrans2devtab[ciptr->index].transname, @@ -1608,8 +1595,8 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) Sockettrans2devtab[newciptr->index].family != AF_INET6) { socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Cannot get IPv6 " - "socket for IPv6 address\n", 0,0,0); + prmsg (4,"SocketINETConnect() Cannot get IPv6 " + "socket for IPv6 address\n"); } if (newciptr) xfree(newciptr); @@ -1617,8 +1604,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) else { socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Skipping IPv6 address\n", - 0,0,0); + prmsg (4,"SocketINETConnect() Skipping IPv6 address\n"); } } } else { @@ -1656,17 +1642,17 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) tmpaddr = INADDR_NONE; } - PRMSG (4,"SocketINETConnect() inet_addr(%s) = %x\n", host, tmpaddr, 0); + prmsg (4,"SocketINETConnect() inet_addr(%s) = %x\n", host, tmpaddr); if (tmpaddr == INADDR_NONE) { if ((hostp = _XGethostbyname(host,hparams)) == NULL) { - PRMSG (1,"SocketINETConnect: Can't get address for %s\n", - host, 0, 0); + prmsg (1,"SocketINETConnect: Can't get address for %s\n", + host); ESET(EINVAL); return TRANS_CONNECT_FAILED; } if (hostp->h_addrtype != AF_INET) { /* is IP host? */ - PRMSG (1,"SocketINETConnect: not INET host%s\n", host, 0, 0); + prmsg (1,"SocketINETConnect: not INET host%s\n", host); ESET(EPROTOTYPE); return TRANS_CONNECT_FAILED; } @@ -1686,20 +1672,20 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) if (!is_numeric (port)) { if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) { - PRMSG (1,"SocketINETConnect: can't get service for %s\n", - port, 0, 0); + prmsg (1,"SocketINETConnect: can't get service for %s\n", + port); return TRANS_CONNECT_FAILED; } sockname.sin_port = htons (servp->s_port); } else { - tmpport = strtol (port, (char**)NULL, 10); + long tmpport = strtol (port, (char**)NULL, 10); if (tmpport < 1024 || tmpport > USHRT_MAX) return TRANS_CONNECT_FAILED; sockname.sin_port = htons (((unsigned short) tmpport)); } - PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n", - ntohs(sockname.sin_port), 0, 0); + prmsg (4,"SocketINETConnect: sockname.sin_port = %d\n", + ntohs(sockname.sin_port)); socketaddr = (struct sockaddr *) &sockname; socketaddrlen = sizeof(sockname); } @@ -1769,8 +1755,8 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) res = TRANS_IN_PROGRESS; else { - PRMSG (2,"SocketINETConnect: Can't connect: errno = %d\n", - olderrno,0, 0); + prmsg (2,"SocketINETConnect: Can't connect: errno = %d\n", + olderrno); res = TRANS_CONNECT_FAILED; } @@ -1784,17 +1770,15 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) if (TRANS(SocketINETGetAddr) (ciptr) < 0) { - PRMSG (1, - "SocketINETConnect: ...SocketINETGetAddr() failed:\n", - 0, 0, 0); + prmsg (1, + "SocketINETConnect: ...SocketINETGetAddr() failed:\n"); res = TRANS_CONNECT_FAILED; } else if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0) { - PRMSG (1, - "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n", - 0, 0, 0); + prmsg (1, + "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n"); res = TRANS_CONNECT_FAILED; } } @@ -1962,7 +1946,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) abstract = ciptr->transptr->flags & TRANS_ABSTRACT; #endif - PRMSG (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port); + prmsg (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port); /* * Make sure 'host' is really local. If not, we return failure. @@ -1974,9 +1958,9 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) if (host && *host && host[0]!='/' && strcmp (host, "unix") != 0 && !UnixHostReallyLocal (host)) { - PRMSG (1, + prmsg (1, "SocketUNIXConnect: Cannot connect to non-local host %s\n", - host, 0, 0); + host); return TRANS_CONNECT_FAILED; } @@ -1987,8 +1971,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) if (!port || !*port) { - PRMSG (1,"SocketUNIXConnect: Missing port specification\n", - 0, 0, 0); + prmsg (1,"SocketUNIXConnect: Missing port specification\n"); return TRANS_CONNECT_FAILED; } @@ -1999,7 +1982,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) sockname.sun_family = AF_UNIX; if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) { - PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0); + prmsg (1, "SocketUNIXConnect: path too long\n"); return TRANS_CONNECT_FAILED; } @@ -2066,8 +2049,8 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) return TRANS_CONNECT_FAILED; } } else { - PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n", - EGET(),0, 0); + prmsg (2,"SocketUNIXConnect: Can't connect: errno = %d\n", + EGET()); return TRANS_CONNECT_FAILED; } @@ -2082,9 +2065,8 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) if ((ciptr->addr = (char *) xalloc(namelen)) == NULL || (ciptr->peeraddr = (char *) xalloc(namelen)) == NULL) { - PRMSG (1, - "SocketUNIXCreateListener: Can't allocate space for the addr\n", - 0, 0, 0); + prmsg (1, + "SocketUNIXCreateListener: Can't allocate space for the addr\n"); return TRANS_CONNECT_FAILED; } @@ -2109,7 +2091,7 @@ static int TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend) { - PRMSG (2,"SocketBytesReadable(%p,%d,%p)\n", + prmsg (2,"SocketBytesReadable(%p,%d,%p)\n", ciptr, ciptr->fd, pend); #ifdef WIN32 { @@ -2131,7 +2113,7 @@ static int TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size) { - PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size); + prmsg (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size); #if defined(WIN32) { @@ -2151,7 +2133,7 @@ static int TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size) { - PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size); + prmsg (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size); #if defined(WIN32) { @@ -2171,7 +2153,7 @@ static int TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size) { - PRMSG (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size); + prmsg (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size); return READV (ciptr, buf, size); } @@ -2181,7 +2163,7 @@ static int TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size) { - PRMSG (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size); + prmsg (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size); return WRITEV (ciptr, buf, size); } @@ -2191,7 +2173,7 @@ static int TRANS(SocketDisconnect) (XtransConnInfo ciptr) { - PRMSG (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd, 0); + prmsg (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd); #ifdef WIN32 { @@ -2210,7 +2192,7 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr) { - PRMSG (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd, 0); + prmsg (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd); #ifdef WIN32 { @@ -2238,7 +2220,7 @@ TRANS(SocketUNIXClose) (XtransConnInfo ciptr) struct sockaddr_un *sockname = (struct sockaddr_un *) ciptr->addr; int ret; - PRMSG (2,"SocketUNIXClose(%p,%d)\n", ciptr, ciptr->fd, 0); + prmsg (2,"SocketUNIXClose(%p,%d)\n", ciptr, ciptr->fd); ret = close(ciptr->fd); @@ -2265,8 +2247,8 @@ TRANS(SocketUNIXCloseForCloning) (XtransConnInfo ciptr) int ret; - PRMSG (2,"SocketUNIXCloseForCloning(%p,%d)\n", - ciptr, ciptr->fd, 0); + prmsg (2,"SocketUNIXCloseForCloning(%p,%d)\n", + ciptr, ciptr->fd); ret = close(ciptr->fd); @@ -2278,7 +2260,7 @@ TRANS(SocketUNIXCloseForCloning) (XtransConnInfo ciptr) #ifdef TCPCONN # ifdef TRANS_SERVER -static char* tcp_nolisten[] = { +static const char* tcp_nolisten[] = { "inet", #if defined(IPv6) && defined(AF_INET6) "inet6", diff --git a/X11/xtrans/Xtranstli.c b/X11/xtrans/Xtranstli.c index f35214c6f..8601c137b 100644 --- a/X11/xtrans/Xtranstli.c +++ b/X11/xtrans/Xtranstli.c @@ -123,7 +123,7 @@ TRANS(TLISelectFamily)(char *family) { int i; - PRMSG(3,"TLISelectFamily(%s)\n", family, 0,0 ); + prmsg(3,"TLISelectFamily(%s)\n", family); for(i=0;i<NUMTLIFAMILIES;i++) { @@ -146,7 +146,7 @@ TRANS(TLIGetAddr)(XtransConnInfo ciptr) Xtransaddr sockname; struct netbuf netbuf; - PRMSG(3,"TLIGetAddr(%x)\n", ciptr, 0,0 ); + prmsg(3,"TLIGetAddr(%x)\n", ciptr); netbuf.buf=(char *)&sockname; netbuf.len=sizeof(sockname); @@ -154,13 +154,13 @@ TRANS(TLIGetAddr)(XtransConnInfo ciptr) if( t_getname(ciptr->fd,&netbuf,LOCALNAME) < 0 ) { - PRMSG(1,"TLIGetAddr: t_getname(LOCALNAME) failed: %d\n", - errno, 0,0 ); + prmsg(1,"TLIGetAddr: t_getname(LOCALNAME) failed: %d\n", + errno); return -1; } - PRMSG(4,"TLIGetAddr: got family %d len %d\n", - ((struct sockaddr *) &sockname)->sa_family ,netbuf.len, 0 ); + prmsg(4,"TLIGetAddr: got family %d len %d\n", + ((struct sockaddr *) &sockname)->sa_family ,netbuf.len); /* * Everything looks good: fill in the XtransConnInfo structure. @@ -171,8 +171,7 @@ TRANS(TLIGetAddr)(XtransConnInfo ciptr) if( (ciptr->addr=(char *)xalloc(netbuf.len)) == NULL ) { - PRMSG(1, "TLIGetAddr: Can't allocate space for the addr\n", - 0,0,0); + prmsg(1, "TLIGetAddr: Can't allocate space for the addr\n"); return -1; } @@ -196,7 +195,7 @@ TRANS(TLIGetPeerAddr)(XtransConnInfo ciptr) Xtransaddr sockname; struct netbuf netbuf; - PRMSG(3,"TLIGetPeerAddr(%x)\n", ciptr, 0,0 ); + prmsg(3,"TLIGetPeerAddr(%x)\n", ciptr); netbuf.buf=(char *)&sockname; netbuf.len=sizeof(sockname); @@ -204,13 +203,13 @@ TRANS(TLIGetPeerAddr)(XtransConnInfo ciptr) if( t_getname(ciptr->fd,&netbuf,REMOTENAME) < 0 ) { - PRMSG(1,"TLIGetPeerAddr: t_getname(REMOTENAME) failed: %d\n", - errno, 0,0 ); + prmsg(1,"TLIGetPeerAddr: t_getname(REMOTENAME) failed: %d\n", + errno); return -1; } - PRMSG(4,"TLIGetPeerAddr: got family %d len %d\n", - ((struct sockaddr *) &sockname)->sa_family ,netbuf.len, 0 ); + prmsg(4,"TLIGetPeerAddr: got family %d len %d\n", + ((struct sockaddr *) &sockname)->sa_family ,netbuf.len); /* * Everything looks good: fill in the XtransConnInfo structure. @@ -221,9 +220,8 @@ TRANS(TLIGetPeerAddr)(XtransConnInfo ciptr) if( (ciptr->peeraddr=(char *)xalloc(netbuf.len)) == NULL ) { - PRMSG(1, - "TLIGetPeerAddr: Can't allocate space for the addr\n", - 0,0,0); + prmsg(1, + "TLIGetPeerAddr: Can't allocate space for the addr\n"); return -1; } @@ -251,24 +249,22 @@ TRANS(TLITLIBindLocal)(int fd, int family, char *port) struct sockaddr_un *sunaddr=NULL; struct t_bind *req=NULL; - PRMSG(2, "TLITLIBindLocal(%d,%d,%s)\n", fd, family, port); + prmsg(2, "TLITLIBindLocal(%d,%d,%s)\n", fd, family, port); if( family == AF_UNIX ) { if( (req=(struct t_bind *)t_alloc(fd,T_BIND,0)) == NULL ) { - PRMSG(1, - "TLITLIBindLocal() failed to allocate a t_bind\n", - 0,0,0 ); + prmsg(1, + "TLITLIBindLocal() failed to allocate a t_bind\n"); return -1; } if( (sunaddr=(struct sockaddr_un *) malloc(sizeof(struct sockaddr_un))) == NULL ) { - PRMSG(1, - "TLITLIBindLocal: failed to allocate a sockaddr_un\n", - 0,0,0 ); + prmsg(1, + "TLITLIBindLocal: failed to allocate a sockaddr_un\n"); t_free((char *)req,T_BIND); return -1; } @@ -286,8 +282,8 @@ TRANS(TLITLIBindLocal)(int fd, int family, char *port) (void) sprintf(sunaddr->sun_path,"%s%d", TLINODENAME, getpid()^time(NULL) ); - PRMSG(4, "TLITLIBindLocal: binding to %s\n", - sunaddr->sun_path, 0,0); + prmsg(4, "TLITLIBindLocal: binding to %s\n", + sunaddr->sun_path); req->addr.buf=(char *)sunaddr; req->addr.len=sizeof(*sunaddr); @@ -296,9 +292,9 @@ TRANS(TLITLIBindLocal)(int fd, int family, char *port) if( t_bind(fd, req, NULL) < 0 ) { - PRMSG(1, + prmsg(1, "TLIBindLocal: Unable to bind TLI device to %s\n", - port, 0,0 ); + port); if (sunaddr) free((char *) sunaddr); if (req) @@ -314,17 +310,17 @@ TRANS(TLIOpen)(char *device) { XtransConnInfo ciptr; - PRMSG(3,"TLIOpen(%s)\n", device, 0,0 ); + prmsg(3,"TLIOpen(%s)\n", device); if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { - PRMSG(1, "TLIOpen: calloc failed\n", 0,0,0 ); + prmsg(1, "TLIOpen: calloc failed\n"); return NULL; } if( (ciptr->fd=t_open( device, O_RDWR, NULL )) < 0 ) { - PRMSG(1, "TLIOpen: t_open failed for %s\n", device, 0,0 ); + prmsg(1, "TLIOpen: t_open failed for %s\n", device); free(ciptr); return NULL; } @@ -341,17 +337,17 @@ TRANS(TLIReopen)(char *device, int fd, char *port) { XtransConnInfo ciptr; - PRMSG(3,"TLIReopen(%s,%d, %s)\n", device, fd, port ); + prmsg(3,"TLIReopen(%s,%d, %s)\n", device, fd, port ); if (t_sync (fd) < 0) { - PRMSG(1, "TLIReopen: t_sync failed\n", 0,0,0 ); + prmsg(1, "TLIReopen: t_sync failed\n"); return NULL; } if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { - PRMSG(1, "TLIReopen: calloc failed\n", 0,0,0 ); + prmsg(1, "TLIReopen: calloc failed\n"); return NULL; } @@ -374,7 +370,7 @@ TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port, void *handlep; long lport; - PRMSG(3,"TLIAddrToNetbuf(%d,%s,%s)\n", tlifamily, host, port ); + prmsg(3,"TLIAddrToNetbuf(%d,%s,%s)\n", tlifamily, host, port ); if( (handlep=setnetconfig()) == NULL ) return -1; @@ -395,15 +391,14 @@ TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port, if( strcmp(netconfigp->nc_protofmly, TLItrans2devtab[tlifamily].protofamily) != 0 ) continue; - PRMSG(5,"TLIAddrToNetbuf: Trying to resolve %s.%s for %s\n", + prmsg(5,"TLIAddrToNetbuf: Trying to resolve %s.%s for %s\n", host, port, TLItrans2devtab[tlifamily].protofamily ); if( netdir_getbyname(netconfigp,&nd_hostserv, &nd_addrlistp) == 0 ) { /* we have at least one address to use */ - PRMSG(5, "TLIAddrToNetbuf: found address for %s.%s\n", host, port, 0 ); - PRMSG(5, "TLIAddrToNetbuf: %s\n",taddr2uaddr(netconfigp,nd_addrlistp->n_addrs), - 0,0 ); + prmsg(5, "TLIAddrToNetbuf: found address for %s.%s\n", host, port); + prmsg(5, "TLIAddrToNetbuf: %s\n",taddr2uaddr(netconfigp,nd_addrlistp->n_addrs)); memcpy(netbufp->buf,nd_addrlistp->n_addrs->buf, nd_addrlistp->n_addrs->len); @@ -431,27 +426,27 @@ TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol, XtransConnInfo ciptr; int i; - PRMSG(2,"TLIOpenCOTSClient(%s,%s,%s)\n", protocol, host, port ); + prmsg(2,"TLIOpenCOTSClient(%s,%s,%s)\n", protocol, host, port ); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { - PRMSG(1,"TLIOpenCOTSClient: Unable to determine device for %s\n", - thistrans->TransName, 0,0 ); + prmsg(1,"TLIOpenCOTSClient: Unable to determine device for %s\n", + thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL ) { - PRMSG(1,"TLIOpenCOTSClient: Unable to open device for %s\n", - thistrans->TransName, 0,0 ); + prmsg(1,"TLIOpenCOTSClient: Unable to open device for %s\n", + thistrans->TransName); return NULL; } if( TRANS(TLITLIBindLocal)(ciptr->fd,TLItrans2devtab[i].family,port) < 0 ) { - PRMSG(1, + prmsg(1, "TLIOpenCOTSClient: ...TLITLIBindLocal() failed: %d\n", - errno, 0,0 ); + errno); t_close(ciptr->fd); xfree(ciptr); return NULL; @@ -459,9 +454,9 @@ TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol, if( TRANS(TLIGetAddr)(ciptr) < 0 ) { - PRMSG(1, + prmsg(1, "TLIOpenCOTSClient: ...TLIGetAddr() failed: %d\n", - errno, 0,0 ); + errno); t_close(ciptr->fd); xfree(ciptr); return NULL; @@ -486,21 +481,21 @@ TRANS(TLIOpenCOTSServer)(Xtransport *thistrans, char *protocol, XtransConnInfo ciptr; int i; - PRMSG(2,"TLIOpenCOTSServer(%s,%s,%s)\n", protocol, host, port ); + prmsg(2,"TLIOpenCOTSServer(%s,%s,%s)\n", protocol, host, port ); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { - PRMSG(1, + prmsg(1, "TLIOpenCOTSServer: Unable to determine device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL ) { - PRMSG(1, + prmsg(1, "TLIOpenCOTSServer: Unable to open device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } @@ -529,29 +524,29 @@ TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol, XtransConnInfo ciptr; int i; - PRMSG(2,"TLIOpenCLTSClient(%s,%s,%s)\n", protocol, host, port ); + prmsg(2,"TLIOpenCLTSClient(%s,%s,%s)\n", protocol, host, port ); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { - PRMSG(1, + prmsg(1, "TLIOpenCLTSClient: Unable to determine device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcltsname)) == NULL ) { - PRMSG(1, + prmsg(1, "TLIOpenCLTSClient: Unable to open device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } if( TRANS(TLITLIBindLocal)(ciptr->fd,TLItrans2devtab[i].family,port) < 0 ) { - PRMSG(1, + prmsg(1, "TLIOpenCLTSClient: ...TLITLIBindLocal() failed: %d\n", - errno, 0,0 ); + errno); t_close(ciptr->fd); xfree(ciptr); return NULL; @@ -559,9 +554,9 @@ TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol, if( TRANS(TLIGetAddr)(ciptr) < 0 ) { - PRMSG(1, + prmsg(1, "TLIOpenCLTSClient: ...TLIGetPeerAddr() failed: %d\n", - errno, 0,0 ); + errno); t_close(ciptr->fd); xfree(ciptr); return NULL; @@ -583,21 +578,21 @@ TRANS(TLIOpenCLTSServer)(Xtransport *thistrans, char *protocol, XtransConnInfo ciptr; int i; - PRMSG(2,"TLIOpenCLTSServer(%s,%s,%s)\n", protocol, host, port ); + prmsg(2,"TLIOpenCLTSServer(%s,%s,%s)\n", protocol, host, port ); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { - PRMSG(1, + prmsg(1, "TLIOpenCLTSServer: Unable to determine device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcltsname)) == NULL ) { - PRMSG(1, + prmsg(1, "TLIOpenCLTSServer: Unable to open device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } @@ -616,22 +611,22 @@ TRANS(TLIReopenCOTSServer)(Xtransport *thistrans, int fd, char *port) XtransConnInfo ciptr; int i; - PRMSG(2,"TLIReopenCOTSServer(%d, %s)\n", fd, port, 0 ); + prmsg(2,"TLIReopenCOTSServer(%d, %s)\n", fd, port); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { - PRMSG(1, + prmsg(1, "TLIReopenCOTSServer: Unable to determine device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIReopen)( TLItrans2devtab[i].devcotsname, fd, port)) == NULL ) { - PRMSG(1, + prmsg(1, "TLIReopenCOTSServer: Unable to open device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } @@ -650,22 +645,22 @@ TRANS(TLIReopenCLTSServer)(Xtransport *thistrans, int fd, char *port) XtransConnInfo ciptr; int i; - PRMSG(2,"TLIReopenCLTSServer(%d, %s)\n", fd, port, 0 ); + prmsg(2,"TLIReopenCLTSServer(%d, %s)\n", fd, port); if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 ) { - PRMSG(1, + prmsg(1, "TLIReopenCLTSServer: Unable to determine device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } if( (ciptr=TRANS(TLIReopen)( TLItrans2devtab[i].devcltsname, fd, port)) == NULL ) { - PRMSG(1, + prmsg(1, "TLIReopenCLTSServer: Unable to open device for %s\n", - thistrans->TransName, 0,0 ); + thistrans->TransName); return NULL; } @@ -681,7 +676,7 @@ static int TRANS(TLISetOption)(XtransConnInfo ciptr, int option, int arg) { - PRMSG(2,"TLISetOption(%d,%d,%d)\n", ciptr->fd, option, arg ); + prmsg(2,"TLISetOption(%d,%d,%d)\n", ciptr->fd, option, arg ); return -1; } @@ -695,19 +690,18 @@ TRANS(TLICreateListener)(XtransConnInfo ciptr, struct t_bind *req) { struct t_bind *ret; - PRMSG(2,"TLICreateListener(%x->%d,%x)\n", ciptr, ciptr->fd, req ); + prmsg(2,"TLICreateListener(%x->%d,%x)\n", ciptr, ciptr->fd, req ); if( (ret=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,T_ALL)) == NULL ) { - PRMSG(1, "TLICreateListener: failed to allocate a t_bind\n", - 0,0,0 ); + prmsg(1, "TLICreateListener: failed to allocate a t_bind\n"); t_free((char *)req,T_BIND); return TRANS_CREATE_LISTENER_FAILED; } if( t_bind(ciptr->fd, req, ret) < 0 ) { - PRMSG(1, "TLICreateListener: t_bind failed\n", 0,0,0 ); + prmsg(1, "TLICreateListener: t_bind failed\n"); t_free((char *)req,T_BIND); t_free((char *)ret,T_BIND); return TRANS_CREATE_LISTENER_FAILED; @@ -715,8 +709,8 @@ TRANS(TLICreateListener)(XtransConnInfo ciptr, struct t_bind *req) if( memcmp(req->addr.buf,ret->addr.buf,req->addr.len) != 0 ) { - PRMSG(1, "TLICreateListener: unable to bind to %x\n", - req, 0,0 ); + prmsg(1, "TLICreateListener: unable to bind to %x\n", + req); t_free((char *)req,T_BIND); t_free((char *)ret,T_BIND); return TRANS_ADDR_IN_USE; @@ -728,9 +722,8 @@ TRANS(TLICreateListener)(XtransConnInfo ciptr, struct t_bind *req) if( (ciptr->addr=(char *)xalloc(ret->addr.len)) == NULL ) { - PRMSG(1, - "TLICreateListener: Unable to allocate space for the address\n", - 0,0,0 ); + prmsg(1, + "TLICreateListener: Unable to allocate space for the address\n"); t_free((char *)req,T_BIND); t_free((char *)ret, T_BIND); return TRANS_CREATE_LISTENER_FAILED; @@ -755,7 +748,7 @@ TRANS(TLIINETCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flag struct sockaddr_in *sinaddr; long tmpport; - PRMSG(2,"TLIINETCreateListener(%x->%d,%s)\n", ciptr, + prmsg(2,"TLIINETCreateListener(%x->%d,%s)\n", ciptr, ciptr->fd, port ? port : "NULL" ); #ifdef X11_t @@ -778,18 +771,17 @@ TRANS(TLIINETCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flag if( (req=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,T_ALL)) == NULL ) { - PRMSG(1, - "TLIINETCreateListener: failed to allocate a t_bind\n", - 0,0,0 ); + prmsg(1, + "TLIINETCreateListener: failed to allocate a t_bind\n"); return TRANS_CREATE_LISTENER_FAILED; } if( port && *port ) { if(TRANS(TLIAddrToNetbuf)(ciptr->index,HOST_SELF,port,&(req->addr)) < 0) { - PRMSG(1, + prmsg(1, "TLIINETCreateListener: can't resolve name:HOST_SELF.%s\n", - port, 0,0 ); + port); t_free((char *)req,T_BIND); return TRANS_CREATE_LISTENER_FAILED; } @@ -816,23 +808,21 @@ TRANS(TLITLICreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags struct sockaddr_un *sunaddr; int ret_value; - PRMSG(2,"TLITLICreateListener(%x->%d,%s)\n", ciptr, ciptr->fd, + prmsg(2,"TLITLICreateListener(%x->%d,%s)\n", ciptr, ciptr->fd, port ? port : "NULL"); if( (req=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,0)) == NULL ) { - PRMSG(1, - "TLITLICreateListener: failed to allocate a t_bind\n", - 0,0,0 ); + prmsg(1, + "TLITLICreateListener: failed to allocate a t_bind\n"); return TRANS_CREATE_LISTENER_FAILED; } if( (sunaddr=(struct sockaddr_un *) malloc(sizeof(struct sockaddr_un))) == NULL ) { - PRMSG(1, - "TLITLICreateListener: failed to allocate a sockaddr_un\n", - 0,0,0 ); + prmsg(1, + "TLITLICreateListener: failed to allocate a sockaddr_un\n"); t_free((char *)req,T_BIND); return TRANS_CREATE_LISTENER_FAILED; } @@ -872,11 +862,11 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) XtransConnInfo newciptr; int i; - PRMSG(2,"TLIAccept(%x->%d)\n", ciptr, ciptr->fd, 0 ); + prmsg(2,"TLIAccept(%x->%d)\n", ciptr, ciptr->fd); if( (call=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_ALL)) == NULL ) { - PRMSG(1, "TLIAccept() failed to allocate a t_call\n", 0,0,0 ); + prmsg(1, "TLIAccept() failed to allocate a t_call\n"); *status = TRANS_ACCEPT_BAD_MALLOC; return NULL; } @@ -885,8 +875,8 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) { extern char *t_errlist[]; extern int t_errno; - PRMSG(1, "TLIAccept() t_listen() failed\n", 0,0,0 ); - PRMSG(1, "TLIAccept: %s\n", t_errlist[t_errno], 0,0 ); + prmsg(1, "TLIAccept() t_listen() failed\n"); + prmsg(1, "TLIAccept: %s\n", t_errlist[t_errno]); t_free((char *)call,T_CALL); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; @@ -900,7 +890,7 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) if( (newciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL ) { - PRMSG(1, "TLIAccept() failed to open a new endpoint\n", 0,0,0 ); + prmsg(1, "TLIAccept() failed to open a new endpoint\n"); t_free((char *)call,T_CALL); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; @@ -908,9 +898,9 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) if( TRANS(TLITLIBindLocal)(newciptr->fd,TLItrans2devtab[i].family,"") < 0 ) { - PRMSG(1, + prmsg(1, "TLIAccept: TRANS(TLITLIBindLocal)() failed: %d\n", - errno, 0,0 ); + errno); t_free((char *)call,T_CALL); t_close(newciptr->fd); xfree(newciptr); @@ -923,19 +913,19 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) { extern char *t_errlist[]; extern int t_errno; - PRMSG(1, "TLIAccept() t_accept() failed\n", 0,0,0 ); - PRMSG(1, "TLIAccept: %s\n", t_errlist[t_errno], 0,0 ); + prmsg(1, "TLIAccept() t_accept() failed\n"); + prmsg(1, "TLIAccept: %s\n", t_errlist[t_errno]); if( t_errno == TLOOK ) { int evtype = t_look(ciptr->fd); - PRMSG(1, "TLIAccept() t_look() returned %d\n", evtype,0,0 ); + prmsg(1, "TLIAccept() t_look() returned %d\n", evtype); switch( evtype ) { case T_DISCONNECT: if( t_rcvdis(ciptr->fd, NULL) < 0 ) { - PRMSG(1, "TLIAccept() t_rcvdis() failed\n", 0,0,0 ); - PRMSG(1, "TLIAccept: %s\n", t_errlist[t_errno], 0,0 ); + prmsg(1, "TLIAccept() t_rcvdis() failed\n"); + prmsg(1, "TLIAccept: %s\n", t_errlist[t_errno]); } break; default: @@ -953,9 +943,9 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) if( TRANS(TLIGetAddr)(newciptr) < 0 ) { - PRMSG(1, + prmsg(1, "TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n", - errno, 0,0 ); + errno); t_close(newciptr->fd); xfree(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; @@ -964,9 +954,9 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) if( TRANS(TLIGetPeerAddr)(newciptr) < 0 ) { - PRMSG(1, + prmsg(1, "TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n", - errno, 0,0 ); + errno); t_close(newciptr->fd); xfree(newciptr->addr); xfree(newciptr); @@ -976,8 +966,8 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) if( ioctl(newciptr->fd, I_POP,"timod") < 0 ) { - PRMSG(1, "TLIAccept() ioctl(I_POP, \"timod\") failed %d\n", - errno,0,0 ); + prmsg(1, "TLIAccept() ioctl(I_POP, \"timod\") failed %d\n", + errno); t_close(newciptr->fd); xfree(newciptr->addr); xfree(newciptr); @@ -987,8 +977,8 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) if( ioctl(newciptr->fd, I_PUSH,"tirdwr") < 0 ) { - PRMSG(1, "TLIAccept() ioctl(I_PUSH,\"tirdwr\") failed %d\n", - errno,0,0 ); + prmsg(1, "TLIAccept() ioctl(I_PUSH,\"tirdwr\") failed %d\n", + errno); t_close(newciptr->fd); xfree(newciptr->addr); xfree(newciptr); @@ -1010,14 +1000,14 @@ static int TRANS(TLIConnect)(XtransConnInfo ciptr, struct t_call *sndcall ) { - PRMSG(2, "TLIConnect(%x->%d,%x)\n", ciptr, ciptr->fd, sndcall); + prmsg(2, "TLIConnect(%x->%d,%x)\n", ciptr, ciptr->fd, sndcall); if( t_connect(ciptr->fd,sndcall,NULL) < 0 ) { extern char *t_errlist[]; extern int t_errno; - PRMSG(1, "TLIConnect() t_connect() failed\n", 0,0,0 ); - PRMSG(1, "TLIConnect: %s\n", t_errlist[t_errno], 0,0 ); + prmsg(1, "TLIConnect() t_connect() failed\n"); + prmsg(1, "TLIConnect: %s\n", t_errlist[t_errno]); t_free((char *)sndcall,T_CALL); if (t_errno == TLOOK && t_look(ciptr->fd) == T_DISCONNECT) { @@ -1036,31 +1026,31 @@ TRANS(TLIConnect)(XtransConnInfo ciptr, struct t_call *sndcall ) if( TRANS(TLIGetAddr)(ciptr) < 0 ) { - PRMSG(1, + prmsg(1, "TLIConnect: ...TLIGetAddr() failed: %d\n", - errno, 0,0 ); + errno); return TRANS_CONNECT_FAILED; } if( TRANS(TLIGetPeerAddr)(ciptr) < 0 ) { - PRMSG(1, + prmsg(1, "TLIConnect: ...TLIGetPeerAddr() failed: %d\n", - errno, 0,0 ); + errno); return TRANS_CONNECT_FAILED; } if( ioctl(ciptr->fd, I_POP,"timod") < 0 ) { - PRMSG(1, "TLIConnect() ioctl(I_POP,\"timod\") failed %d\n", - errno,0,0 ); + prmsg(1, "TLIConnect() ioctl(I_POP,\"timod\") failed %d\n", + errno); return TRANS_CONNECT_FAILED; } if( ioctl(ciptr->fd, I_PUSH,"tirdwr") < 0 ) { - PRMSG(1, "TLIConnect() ioctl(I_PUSH,\"tirdwr\") failed %d\n", - errno,0,0 ); + prmsg(1, "TLIConnect() ioctl(I_PUSH,\"tirdwr\") failed %d\n", + errno); return TRANS_CONNECT_FAILED; } @@ -1076,7 +1066,7 @@ TRANS(TLIINETConnect)(XtransConnInfo ciptr, char *host, char *port) struct t_call *sndcall; long tmpport; - PRMSG(2, "TLIINETConnect(%s,%s)\n", host, port, 0); + prmsg(2, "TLIINETConnect(%s,%s)\n", host, port); #ifdef X11_t /* @@ -1098,14 +1088,14 @@ TRANS(TLIINETConnect)(XtransConnInfo ciptr, char *host, char *port) if( (sndcall=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_ALL)) == NULL ) { - PRMSG(1, "TLIINETConnect() failed to allocate a t_call\n", 0,0,0 ); + prmsg(1, "TLIINETConnect() failed to allocate a t_call\n"); return TRANS_CONNECT_FAILED; } if( TRANS(TLIAddrToNetbuf)(ciptr->index, host, port, &(sndcall->addr) ) < 0 ) { - PRMSG(1, "TLIINETConnect() unable to resolve name:%s.%s\n", - host, port, 0 ); + prmsg(1, "TLIINETConnect() unable to resolve name:%s.%s\n", + host, port); t_free((char *)sndcall,T_CALL); return TRANS_CONNECT_FAILED; } @@ -1122,20 +1112,19 @@ TRANS(TLITLIConnect)(XtransConnInfo ciptr, char *host, char *port) struct sockaddr_un *sunaddr; int ret_value; - PRMSG(2, "TLITLIConnect(%s,%s)\n", host, port, 0); + prmsg(2, "TLITLIConnect(%s,%s)\n", host, port); if( (sndcall=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_OPT|T_UDATA)) == NULL ) { - PRMSG(1, "TLITLIConnect() failed to allocate a t_call\n", 0,0,0 ); + prmsg(1, "TLITLIConnect() failed to allocate a t_call\n"); return TRANS_CONNECT_FAILED; } if( (sunaddr=(struct sockaddr_un *) malloc(sizeof(struct sockaddr_un))) == NULL ) { - PRMSG(1, - "TLITLIConnect: failed to allocate a sockaddr_un\n", - 0,0,0 ); + prmsg(1, + "TLITLIConnect: failed to allocate a sockaddr_un\n"); t_free((char *)sndcall,T_CALL); return TRANS_CONNECT_FAILED; } @@ -1170,7 +1159,7 @@ TRANS(TLIBytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend) int ret; struct pollfd filedes; - PRMSG(2, "TLIByteReadable(%x->%d,%x)\n", ciptr, ciptr->fd, pend ); + prmsg(2, "TLIByteReadable(%x->%d,%x)\n", ciptr, ciptr->fd, pend ); /* * This function should detect hangup conditions. Use poll to check @@ -1212,7 +1201,7 @@ static int TRANS(TLIRead)(XtransConnInfo ciptr, char *buf, int size) { - PRMSG(2, "TLIRead(%d,%x,%d)\n", ciptr->fd, buf, size ); + prmsg(2, "TLIRead(%d,%x,%d)\n", ciptr->fd, buf, size ); return read(ciptr->fd,buf,size); } @@ -1222,7 +1211,7 @@ static int TRANS(TLIWrite)(XtransConnInfo ciptr, char *buf, int size) { - PRMSG(2, "TLIWrite(%d,%x,%d)\n", ciptr->fd, buf, size ); + prmsg(2, "TLIWrite(%d,%x,%d)\n", ciptr->fd, buf, size ); return write(ciptr->fd,buf,size); } @@ -1232,7 +1221,7 @@ static int TRANS(TLIReadv)(XtransConnInfo ciptr, struct iovec *buf, int size) { - PRMSG(2, "TLIReadv(%d,%x,%d)\n", ciptr->fd, buf, size ); + prmsg(2, "TLIReadv(%d,%x,%d)\n", ciptr->fd, buf, size ); return READV(ciptr,buf,size); } @@ -1242,7 +1231,7 @@ static int TRANS(TLIWritev)(XtransConnInfo ciptr, struct iovec *buf, int size) { - PRMSG(2, "TLIWritev(%d,%x,%d)\n", ciptr->fd, buf, size ); + prmsg(2, "TLIWritev(%d,%x,%d)\n", ciptr->fd, buf, size ); return WRITEV(ciptr,buf,size); } @@ -1252,7 +1241,7 @@ static int TRANS(TLIDisconnect)(XtransConnInfo ciptr) { - PRMSG(2, "TLIDisconnect(%x->%d)\n", ciptr, ciptr->fd, 0 ); + prmsg(2, "TLIDisconnect(%x->%d)\n", ciptr, ciptr->fd); /* * Restore the TLI modules so that the connection can be properly shutdown. @@ -1272,7 +1261,7 @@ static int TRANS(TLIClose)(XtransConnInfo ciptr) { - PRMSG(2, "TLIClose(%x->%d)\n", ciptr, ciptr->fd, 0 ); + prmsg(2, "TLIClose(%x->%d)\n", ciptr, ciptr->fd); t_unbind(ciptr->fd); @@ -1288,7 +1277,7 @@ TRANS(TLICloseForCloning)(XtransConnInfo ciptr) * Don't unbind. */ - PRMSG(2, "TLICloseForCloning(%x->%d)\n", ciptr, ciptr->fd, 0 ); + prmsg(2, "TLICloseForCloning(%x->%d)\n", ciptr, ciptr->fd); return (t_close(ciptr->fd)); } diff --git a/X11/xtrans/Xtransutil.c b/X11/xtrans/Xtransutil.c index 56f01583a..5dd245307 100644 --- a/X11/xtrans/Xtransutil.c +++ b/X11/xtrans/Xtransutil.c @@ -91,7 +91,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) { - PRMSG(2,"ConvertAddress(%d,%d,%x)\n",*familyp,*addrlenp,*addrp); + prmsg(2,"ConvertAddress(%d,%d,%p)\n",*familyp,*addrlenp,*addrp); switch( *familyp ) { @@ -178,8 +178,8 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) #endif default: - PRMSG(1,"ConvertAddress: Unknown family type %d\n", - *familyp, 0,0 ); + prmsg(1,"ConvertAddress: Unknown family type %d\n", + *familyp); return -1; } @@ -242,7 +242,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr) char *addr = ciptr->addr; char hostnamebuf[256]; char *networkId = NULL; - char *transName = ciptr->transptr->TransName; + const char *transName = ciptr->transptr->TransName; if (gethostname (hostnamebuf, sizeof (hostnamebuf)) < 0) { @@ -316,7 +316,7 @@ int void #endif #endif -nameserver_lost(int sig) +nameserver_lost(int sig _X_UNUSED) { nameserver_timedout = 1; longjmp (env, -1); @@ -437,7 +437,7 @@ TRANS(WSAStartup) (void) { static WSADATA wsadata; - PRMSG (2,"WSAStartup()\n", 0, 0, 0); + prmsg (2,"WSAStartup()\n"); if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata)) return 1; @@ -485,8 +485,8 @@ trans_mkdir(const char *path, int mode) if (lstat(path, &buf) != 0) { if (errno != ENOENT) { - PRMSG(1, "mkdir: ERROR: (l)stat failed for %s (%d)\n", - path, errno, 0); + prmsg(1, "mkdir: ERROR: (l)stat failed for %s (%d)\n", + path, errno); return -1; } /* Dir doesn't exist. Try to create it */ @@ -499,15 +499,15 @@ trans_mkdir(const char *path, int mode) */ if (geteuid() != 0) { if (mode & 01000) { - PRMSG(1, "mkdir: ERROR: euid != 0," + prmsg(1, "mkdir: ERROR: euid != 0," "directory %s will not be created.\n", - path, 0, 0); + path); #ifdef FAIL_HARD return -1; #endif } else { - PRMSG(1, "mkdir: Cannot create %s with root ownership\n", - path, 0, 0); + prmsg(1, "mkdir: Cannot create %s with root ownership\n", + path); } } #endif @@ -515,8 +515,8 @@ trans_mkdir(const char *path, int mode) #ifndef WIN32 if (mkdir(path, mode) == 0) { if (chmod(path, mode)) { - PRMSG(1, "mkdir: ERROR: Mode of %s should be set to %04o\n", - path, mode, 0); + prmsg(1, "mkdir: ERROR: Mode of %s should be set to %04o\n", + path, mode); #ifdef FAIL_HARD return -1; #endif @@ -525,8 +525,8 @@ trans_mkdir(const char *path, int mode) if (mkdir(path) == 0) { #endif } else { - PRMSG(1, "mkdir: ERROR: Cannot create %s\n", - path, 0, 0); + prmsg(1, "mkdir: ERROR: Cannot create %s\n", + path); return -1; } @@ -584,8 +584,8 @@ trans_mkdir(const char *path, int mode) struct stat fbuf; if ((fd = open(path, O_RDONLY)) != -1) { if (fstat(fd, &fbuf) == -1) { - PRMSG(1, "mkdir: ERROR: fstat failed for %s (%d)\n", - path, errno, 0); + prmsg(1, "mkdir: ERROR: fstat failed for %s (%d)\n", + path, errno); return -1; } /* @@ -595,8 +595,8 @@ trans_mkdir(const char *path, int mode) if (!S_ISDIR(fbuf.st_mode) || buf.st_dev != fbuf.st_dev || buf.st_ino != fbuf.st_ino) { - PRMSG(1, "mkdir: ERROR: inode for %s changed\n", - path, 0, 0); + prmsg(1, "mkdir: ERROR: inode for %s changed\n", + path); return -1; } if (updateOwner && fchown(fd, 0, 0) == 0) @@ -611,30 +611,29 @@ trans_mkdir(const char *path, int mode) if (updateOwner && !updatedOwner) { #ifdef FAIL_HARD if (status & FAIL_IF_NOT_ROOT) { - PRMSG(1, "mkdir: ERROR: Owner of %s must be set to root\n", - path, 0, 0); + prmsg(1, "mkdir: ERROR: Owner of %s must be set to root\n", + path); return -1; } #endif #if !defined(__APPLE_CC__) && !defined(__CYGWIN__) - PRMSG(1, "mkdir: Owner of %s should be set to root\n", - path, 0, 0); + prmsg(1, "mkdir: Owner of %s should be set to root\n", + path); #endif } if (updateMode && !updatedMode) { #ifdef FAIL_HARD if (status & FAIL_IF_NOMODE) { - PRMSG(1, "mkdir: ERROR: Mode of %s must be set to %04o\n", - path, mode, 0); + prmsg(1, "mkdir: ERROR: Mode of %s must be set to %04o\n", + path, mode); return -1; } #endif - PRMSG(1, "mkdir: Mode of %s should be set to %04o\n", - path, mode, 0); + prmsg(1, "mkdir: Mode of %s should be set to %04o\n", + path, mode); if (status & WARN_NO_ACCESS) { - PRMSG(1, "mkdir: this may cause subsequent errors\n", - 0, 0, 0); + prmsg(1, "mkdir: this may cause subsequent errors\n"); } } return 0; diff --git a/X11/xtrans/doc/xtrans.xml b/X11/xtrans/doc/xtrans.xml index 5b01b89be..82e95a408 100644 --- a/X11/xtrans/doc/xtrans.xml +++ b/X11/xtrans/doc/xtrans.xml @@ -103,7 +103,7 @@ for client vs. server code. </para></note> </preface> -<chapter id='purposes_and_goals'> +<chapter id='Purposes_and_Goals'> <title>Purposes and Goals</title> <para>The X Transport Interface is intended to combine all system and @@ -121,7 +121,7 @@ FS, and connection-less oriented protocols such as XDMCP.</para> </chapter> -<chapter id='overview_of_the_interface'> +<chapter id='Overview_of_the_Interface'> <title>Overview of the Interface</title> <para> @@ -142,7 +142,7 @@ an interface would affect performance. </para> </chapter> -<chapter id='definition_of_address_specification_format'> +<chapter id='Definition_of_Address_Specification_Format'> <title>Definition of Address Specification Format</title> <para> @@ -169,14 +169,14 @@ part of an address. </para> </chapter> -<chapter id='internal_data_structures'> +<chapter id='Internal_Data_Structures'> <title>Internal Data Structures</title> <para> There are two major data structures associated with the transport independent portion of this interface. Additional data structures may be used internally by each transport. </para> -<sect1 id="xtransport"> +<sect1 id='Xtransport'> <title>Xtransport</title> <para> Each transport supported has an entry in the transport table. The transport @@ -337,7 +337,7 @@ should not be unlinked. </para> </sect1> -<sect1 id="xtransconninfo"> +<sect1 id='XtransConnInfo'> <title>XtransConnInfo</title> <para> Each connection will have an opaque <structname>XtransConnInfo</structname> @@ -364,7 +364,7 @@ struct _XtransConnInfo { </sect1> </chapter> -<chapter id='exposed_transport_independent_api'> +<chapter id='Exposed_Transport_Independent_API'> <title>Exposed Transport Independent API</title> <para> @@ -385,7 +385,7 @@ All failures are considered fatal, and the connection should be closed and re-established if desired. In most cases, however, the value of errno will be available for debugging purposes. </para> -<sect1 id="core_interface_api"> +<sect1 id='Core_Interface_API'> <title>Core Interface API</title> <itemizedlist mark='bullet'> <listitem> @@ -659,7 +659,7 @@ is the list of transports. </itemizedlist> </sect1> -<sect1 id="utility_api"> +<sect1 id='Utility_API'> <title>Utility API</title> <para> This section describes a few useful functions that have been implemented on @@ -681,7 +681,7 @@ FamilyLocal)). </sect1> </chapter> -<chapter id="transport_option_definition"> +<chapter id='Transport_Option_Definition'> <title>Transport Option Definition</title> <para> The following options are defined for the @@ -715,7 +715,7 @@ connection will not be closed when an exec occurs. </itemizedlist> </chapter> -<chapter id="hidden_transport_dependent_api"> +<chapter id='Hidden_Transport_Dependent_API'> <title>Hidden Transport Dependent API</title> <para> The hidden transport dependent functions are placed in the Xtransport record. @@ -935,7 +935,7 @@ This function will break the connection, and close the endpoint. </listitem> </itemizedlist> </chapter> -<chapter id="configuration"> +<chapter id='Configuration'> <title>Configuration</title> <para> @@ -1018,7 +1018,7 @@ In X11R7 modular releases, these flags are set when running </chapter> -<chapter id="transport_specific_definitions"> +<chapter id='Transport_Specific_Definitions'> <title>Transport Specific Definitions</title> <informaltable pgwide='0' frame='none'> @@ -1075,7 +1075,7 @@ In X11R7 modular releases, these flags are set when running </chapter> -<chapter id="implementation_notes"> +<chapter id='Implementation_Notes'> <title>Implementation Notes</title> <para> This section refers to the prototype implementation that is being developed diff --git a/X11/xtrans/transport.c b/X11/xtrans/transport.c index 0013b01d8..c14057dd3 100644 --- a/X11/xtrans/transport.c +++ b/X11/xtrans/transport.c @@ -53,6 +53,9 @@ from The Open Group. #define xrealloc(_ptr,_size) realloc(_ptr,_size) #define xfree(_ptr) free(_ptr) +#define XTRANS_TRANSPORT_C /* used to flag Xtransint.h that it's being used + here, not just #included in another file */ + #include "Xtransint.h" #ifdef __clang__ |