From 0e15740580a00f8127eb616eadd3c1dde88adc90 Mon Sep 17 00:00:00 2001 From: matthieu Date: Sun, 8 Apr 2012 14:50:52 +0000 Subject: [PATCH] Update to xtrans 1.2.7 --- lib/libxtrans/ChangeLog | 460 ++++++++++++++++++++++++ lib/libxtrans/Xtrans.c | 312 ++++++++--------- lib/libxtrans/Xtrans.h | 70 ++-- lib/libxtrans/Xtransint.h | 137 +++++--- lib/libxtrans/Xtranslcl.c | 472 ++++++++++++------------- lib/libxtrans/Xtranssock.c | 507 +++++++++++++-------------- lib/libxtrans/Xtranstli.c | 637 +++++++++++++++++----------------- lib/libxtrans/Xtransutil.c | 99 +++--- lib/libxtrans/configure.ac | 69 ++-- lib/libxtrans/doc/Makefile.am | 61 +--- lib/libxtrans/doc/xtrans.xml | 137 ++++---- lib/libxtrans/docbook.am | 105 ++++++ lib/libxtrans/transport.c | 22 +- lib/libxtrans/xtrans.m4 | 16 +- 14 files changed, 1771 insertions(+), 1333 deletions(-) create mode 100644 lib/libxtrans/docbook.am diff --git a/lib/libxtrans/ChangeLog b/lib/libxtrans/ChangeLog index ea8805240..f1a486c9d 100644 --- a/lib/libxtrans/ChangeLog +++ b/lib/libxtrans/ChangeLog @@ -1,3 +1,463 @@ +commit 8ce5ecd33b05becc054dbd07f87e385165b6c979 +Author: Alan Coopersmith +Date: Thu Mar 22 20:04:07 2012 -0700 + + xtrans 1.2.7 + + Signed-off-by: Alan Coopersmith + +commit f8eea0bf256de59602790b6a7c7877b31520440f +Author: Matt Dew +Date: Wed Jan 11 22:23:32 2012 -0700 + + informaltable cleanup + + On certain tables, add top and bottom borders to table + header and a bottom border to the table. This matches + what those tables in the old pdfs looked like. + + the prevents tables from + splitting across pages. Useful for tiny tables. + + Converting the colwidth to a floating point, + IE, 1* -> 1.0* cleans up these build errors: + WARNING: table-layout="fixed" and column-width unspecified + => falling back to proportional-column-width(1) + + Signed-off-by: Matt Dew + +commit 6086f6c1d0e0a1c9e590879acb2319dea0eb6e96 +Author: Robert Bragg +Date: Mon Dec 12 00:30:43 2011 +0000 + + Xtranssock.c: avoid buffer overrun in SocketReopen + + This function was constructing an address from a port string allocating + a buffer according to the size of the string but then later copying + the address according to sizeof(struct sockaddr). + + This patch ensures that we allocate a struct sockaddr buffer with enough + space for the port string to be copied into sa_data[] and uses that + combined length to determine how much should be copied at the end of the + function. + + This fixes a crash when using xwayland which uses ListenOnOpenFD() that + will call _XSERVTransReopenCOTSServer() with a short port string like + ":1". + + Signed-off-by: Robert Bragg + Reviewed-by: Alan Coopersmith + Signed-off-by: Alan Coopersmith + +commit a04a45cb94f7f569e6dd77df93258fa167d0a4ea +Author: Alan Coopersmith +Date: Wed Nov 30 18:40:46 2011 -0800 + + Remove unnecessary casts on malloc, calloc & free calls + + Signed-off-by: Alan Coopersmith + Reviewed-by: Mark Kettenis + +commit a0bfb4fefd20b396e3d88eff0c60602fc436dad5 +Author: Alan Coopersmith +Date: Wed Nov 30 18:11:15 2011 -0800 + + Replace malloc(strlen)+strcpy with strdup + + Signed-off-by: Alan Coopersmith + Reviewed-by: Mark Kettenis + +commit b89e1b45198c48996750b5da3d715c10f974243f +Author: Alan Coopersmith +Date: Wed Nov 30 18:05:05 2011 -0800 + + Finish conversion to standard C allocation functions + + Commit 4ac40cd5451 started this, by no longer special casing the + xserver to include it's former custom allocation functions, this + just takes the remaining #defines and pre-substitutes them into + the code. + + Signed-off-by: Alan Coopersmith + +commit ff992be7b05483f9a0586a27ee0edb6d99580b84 +Author: Alan Hourihane +Date: Thu Dec 1 12:04:22 2011 +0000 + + Fix some resource & memory leaks in libxtrans. + + Signed-off-by: Alan Hourihane + Reviewed-by: Alan Coopersmith + Signed-off-by: Alan Coopersmith + +commit 29c9e101f7ad72556aa6b3dbc17d66a1ace9b2b1 +Author: Matt Dew +Date: Tue Oct 4 21:59:50 2011 -0600 + + Cleanup IDs and links in doc + + 1 - fix the capitalization of the ID attributes to match either the + or <funcdef> string it goes with. + 2 - fix any <linkend>'s that were affected by 1. + 3 - any <function> in the docs that has an actual funcdef, + will become an olink. + + Signed-off-by: Matt Dew <marcoz@osource.org> + +commit 0f942e5f015cb3270e6f2e17c308bee894cb5fe3 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Sun Sep 25 11:39:13 2011 -0700 + + Convert a bunch of sprintf calls to snprintf + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit eb9a8904fbef61a57ff01c90627ead57055ed62b +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Sun Sep 25 11:18:26 2011 -0700 + + Add const attributes to fix gcc -Wwrite-strings warnings + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit 4e610d4bbcf29cca9dc5dbad29ca820996aaa8c7 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Sun Sep 25 10:59:45 2011 -0700 + + Fix warning: unused variable 'tmpport' with various configurations + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit a74c5d915c3095059356f83d1b845192e5c472c2 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Sun Sep 25 10:57:00 2011 -0700 + + Add _X_UNUSED attributes to silence unused parameter warnings + + Not all the transport variants use all the arguments to every function, + but as long as one transport type needs it, they all get the args passed. + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit 64f765de138cb9b757df315469b3136d32222ea2 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Sat Sep 24 00:04:40 2011 -0700 + + Mark __xtransname strings for debug messages as const char * + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit ea921932dae7049b231bead7f8f3f088d7beaf9e +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Fri Sep 23 23:03:09 2011 -0700 + + Fix unused variable warnings + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit c1968d10f97d62ac05d698822c2688151f70a9eb +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Fri Sep 23 22:59:11 2011 -0700 + + Fix warning: ISO C90 forbids mixed declarations and code + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit 225c45b3accab56fab361104a3d14b80f6cec954 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Fri Sep 23 22:57:56 2011 -0700 + + Fix printf format string warnings + + Now that prmsg lets arguments types actually be checked, fix + the warnings found. + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit b1b69ce8e8e4fe0f190c8bd85b537309e71055c8 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Fri Sep 23 22:35:03 2011 -0700 + + Convert PRMSG macro to prmsg inline function + + Allows using varargs to have the correct number of arguments passed to + get rid of the many gcc warnings about variable printf format strings, + and to reduce the duplication from having 5 implementations of the + PRMSG macro depending on the debug options defined & output method used. + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit cbdb434033da1725a69014cc6e4d89c691a6fd95 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Sat Sep 24 07:43:07 2011 -0700 + + Fix warnings about static functions declared but never defined + + Add #define XTRANS_TRANSPORT_C to transport.c and check for it + before making static function declarations and other bits needed + only when compiling the Xtrans code itself, not from other sources + that include the Xtransint.h header for the struct definitions. + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit cf39d738086b0a7c668fb3720d64de8d711a1a97 +Author: Arvind Umrao <arvind.umrao@oracle.com> +Date: Tue Sep 20 22:56:52 2011 +0530 + + Removing SUN specific code, let solaris create .X11-pipe with sticky bit on + + Alan told me, named pipe support was added around Solaris 2.6 when that was a much better performing transport than Unix sockets on the Solaris kernels of the time. By Solaris 10, Unix sockets had been reimplemented in the kernel to be faster, so they became the default again. In Solaris 11, we don't even have named pipe support in the libxcb library that implements X client connection code now, so the named pipes would only be accessed by code with a different libX11 or a statically linked libX11 from Solaris 2.6-9 + + Signed-off-by: Arvind Umrao <arvind.umrao@oracle.com> + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + +commit a477713b89686480cf59a9c75c0aaeeba2386d0a +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Tue Sep 20 18:56:47 2011 -0400 + + specs: regroup <author> <editor> <othercredit> under authorgroup + + Some elements are not displayed when outside authorgroup + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 1ad48fb9bc18d0c7a8fbec1d2cd232877e945047 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Tue Sep 20 15:47:09 2011 -0400 + + specs: refactor copyright legal text for multi licensing + + we can use <copyright> markup for the first holder + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit bd93bf86fd914a9cc54e2bedec5b063e5a38b732 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Mon Sep 19 10:58:40 2011 -0400 + + doc: support multi licensed copyright notice and license text + + For documentation having multiple licenses, the copyright and legalnotice + elements sequence cannot instantiated multiple times. + The copyright notice and license text are therefore coded inside a + legalnotice element. The role attribute on the paragraph is used to allow + styling of the copyright notice text which should not be italicized. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit eb9ec458b7fb5332f7ae7b8faf59443a9075ec60 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Fri Sep 16 22:54:41 2011 -0700 + + Strip trailing whitespace + + Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}' + git diff -w & git diff -b show no diffs from this change + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + +commit 36174eb06e805fa51c9c2e9e914fdfad4a99f50f +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Wed Sep 14 15:29:19 2011 -0400 + + docs: fix authors affiliation + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 9b6c2473be2848ce0a4986ddaa59e5f5ef028bfc +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Mon Sep 12 16:37:24 2011 -0400 + + docs: use the &fullrelvers; entity to set X11 release information + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit b5754cdf64f3396a5853413eda1943cf75ff3cbd +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Sun Sep 11 19:49:54 2011 -0400 + + docs: remove <productnumber> which is not used by default + + This element is not rendered by default on the title. A template + customization is required to display it. + X Window System does not have a product number. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 20f338c548e5fcb16650a4e2c25c2008c1fdac36 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Thu Sep 8 20:00:00 2011 -0400 + + docbook.am: embed css styles inside the HTML HEAD element + + Rather than referring to the external xorg.css stylesheet, embed the content + of the file in the html output produced. This is accomplished by using + version 1.10 of xorg-xhtml.xsl. + + This makes the whole html docs tree much more relocatable. + In addition, it eliminates xorg.css as a runtime file which makes + xorg-sgml-doctools a build time only package. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 8eb827af1b57ec52be183cddaf32257968c02878 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Wed Sep 7 10:31:04 2011 -0400 + + docbook.am: global maintenance update - entities, images and olinking + + Adding support in libX11 for html chunking caused a reorg of docbook.am + as well as the xorg-sgml-doctools masterdb for olinking. + The parameter img.src.path is added for pdf images. + A searchpath to the root builddir is added for local entities, if present. + + The docbook.am makefile hides all the details and is identical for + all 22 modules having DocBook documentation. It is included by a thin + Makefile.am which requires no docbook knowledge. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit b710cdadc92fc212af361bee48f5af6333ec3e6d +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Sun Jun 12 18:39:46 2011 -0400 + + Install xml versions of specs even if HAVE_XMLTO is false + + DocBook/XML input source is also a usefull output format that can be viewed + with an XML viewer or editor and by some O/S help system. + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit 78d1f7d29145567e11b985042e917a435bef95f9 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Sun Jun 5 16:27:37 2011 -0400 + + Install target dbs alongside generated documents + + This matches a change in xorg-sgml-docs whereby the masterdb will look for + the target dbs into the same location as the generated documents. + + The target dbs are now installed alongside the generated documents. + Previously they are installed in $prefix/sgml/X11/dbs alongside masterdb which + has the potential of installing outside the package prefix and cause + distcheck to fail when user does not have write permission in this package. + + Requires XORG_CHECK_SGML_DOCTOOLS(1.8) which was released 2011-06-11 + +commit e05d7abbcf880099058b699ac52f65edcac95582 +Author: Jeremy Huddleston <jeremyhu@apple.com> +Date: Sun Apr 24 19:39:26 2011 -0700 + + Silence warnings when building with clang + + /usr/X11/include/X11/Xtrans/Xtransint.h:349:12: error: unused function 'is_numeric' [-Werror,-Wunused-function] + static int is_numeric ( + ^ + /usr/X11/include/X11/Xtrans/Xtransint.h:354:12: error: unused function 'trans_mkdir' [-Werror,-Wunused-function] + static int trans_mkdir ( + ^ + + In file included from /usr/X11/include/X11/Xtrans/transport.c:67: + ... + fatal error: too many errors emitted, stopping now [-ferror-limit=] + + Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com> + +commit 27ae0ad1406a33919ea9f76034495bca7cccf051 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Sun Feb 27 15:06:18 2011 -0500 + + Documentation: add Docbook external references support + + When writing technical documentation, it is often necessary to cross + reference to other information. When that other information is not in the + current document, additional support is needed, namely <olink>. + + A new feature with version 1.7 of xorg-sgml-doctools adds references to + other documents within or outside this package. + + This patch adds technical support for this feature but does not change + the content of the documentation as seen by the end user. + + Each book or article must generate a database containing the href + of sections that can be referred to from another document. This database + is installed in DATAROOTDIR/sgml/X11/dbs. There is a requirement that + the value of DATAROOTDIR for xorg-sgml-doctools and for the package + documentation is the same. This forms a virtual document tree. + + This database is consulted by other documents while they are being generated + in order to fulfill the missing information for linking. + Refer to the xorg-sgml-doctools for further technical information. + + Co-authored-by: Matt Dew <marcoz@osource.org> + + Signed-off-by: Gaetan Nadon <memsize@videotron.ca> + +commit cc199c31465b258032bdb9083879699202db7ee9 +Author: Adam Jackson <ajax@redhat.com> +Date: Mon Feb 21 12:44:06 2011 -0500 + + Remove a decnet leftover + + Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> + Reviewed-by: Daniel Stone <daniel@fooishbar.org> + Signed-off-by: Adam Jackson <ajax@redhat.com> + +commit 91620213d2bd75fe322df06c5b6f55b85a10e55a +Author: Adam Jackson <ajax@redhat.com> +Date: Tue Mar 15 15:47:08 2011 -0400 + + Remove K&R token pasting macros + + Reviewed-by: Julien Cristau <jcristau@debian.org> + Signed-off-by: Adam Jackson <ajax@redhat.com> + +commit 4ac40cd5451983e6f62527700cdf9e2f8a29c013 +Author: Adam Jackson <ajax@redhat.com> +Date: Tue Mar 15 15:45:56 2011 -0400 + + Don't special-case allocation for the X server + + xserver uses malloc/free directly now, don't route through the Xalloc + wrappers. + + Reviewed-by: Julien Cristau <jcristau@debian.org> + Signed-off-by: Adam Jackson <ajax@redhat.com> + +commit 638caa2053330038c5ba5a5682ff02be6aa0faa6 +Author: Gaetan Nadon <memsize@videotron.ca> +Date: Wed Feb 2 11:43:46 2011 -0500 + + config: comment, minor upgrade, quote and layout configure.ac + + Group statements per section as per Autoconf standard layout + Quote statements where appropriate. + Autoconf recommends not using dnl instead of # for comments + + Use AC_CONFIG_FILES to replace the deprecated AC_OUTPUT with parameters. + Add AC_CONFIG_SRCDIR([Makefile.am]) + + This helps automated maintenance and release activities. + Details can be found in http://wiki.x.org/wiki/NewModuleGuidelines + +commit a26753b7b20cd5cadc1e7fa007cec063f39a49e8 +Author: Alan Coopersmith <alan.coopersmith@oracle.com> +Date: Thu Dec 16 23:59:20 2010 -0800 + + doc: Correct column count in transport configuration table + + Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> + commit 59f57d1a19d4091fef115b9eafa139bf620332cb Author: Alan Coopersmith <alan.coopersmith@oracle.com> Date: Mon Nov 8 16:33:45 2010 -0800 diff --git a/lib/libxtrans/Xtrans.c b/lib/libxtrans/Xtrans.c index 55f52a7e9..54e3bdca7 100644 --- a/lib/libxtrans/Xtrans.c +++ b/lib/libxtrans/Xtrans.c @@ -132,31 +132,31 @@ 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); + free (ciptr->addr); if (ciptr->peeraddr) - xfree (ciptr->peeraddr); + free (ciptr->peeraddr); if (ciptr->port) - xfree (ciptr->port); + free (ciptr->port); - xfree ((char *) ciptr); + free (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 @@ -203,21 +203,19 @@ 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; - size_t len; - PRMSG (3,"ParseAddress(%s)\n", address, 0, 0); + prmsg (3,"ParseAddress(%s)\n", address); /* Copy the string so it can be changed */ - len = strlen (address) + 1; - tmpptr = mybuf = (char *) xalloc (len); - strlcpy (mybuf, address, len); + tmpptr = mybuf = strdup (address); /* Parse the string to get each component */ - + /* Get the protocol part */ _protocol = mybuf; @@ -230,7 +228,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) *protocol = NULL; *host = NULL; *port = NULL; - xfree (tmpptr); + free (tmpptr); return 0; } @@ -280,26 +278,10 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) *protocol = NULL; *host = NULL; *port = NULL; - xfree (tmpptr); + free (tmpptr); return 0; } - /* Check for DECnet */ - - if ((mybuf != _host) && (*(mybuf - 1) == ':') -#if defined(IPv6) && defined(AF_INET6) - /* An IPv6 address can end in :: so three : in a row is assumed to be - an IPv6 host and not a DECnet node with a : in it's name, unless - DECnet is specifically requested */ - && ( ((mybuf - 1) == _host) || (*(mybuf - 2) != ':') || - ((_protocol != NULL) && (strcmp(_protocol, "dnet") == 0)) ) -#endif - ) - { - _protocol = "dnet"; - *(mybuf - 1) = '\0'; - } - *mybuf ++= '\0'; _host_len = strlen(_host); @@ -310,9 +292,9 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) } #if defined(IPv6) && defined(AF_INET6) /* hostname in IPv6 [numeric_addr]:0 form? */ - else if ( (_host_len > 3) && + else if ( (_host_len > 3) && ((strcmp(_protocol, "tcp") == 0) || (strcmp(_protocol, "inet6") == 0)) - && (*_host == '[') && (*(_host + _host_len - 1) == ']') ) { + && (*_host == '[') && (*(_host + _host_len - 1) == ']') ) { struct sockaddr_in6 sin6; *(_host + _host_len - 1) = '\0'; @@ -362,49 +344,41 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) * Now that we have all of the components, allocate new * string space for them. */ - len = strlen (_protocol) + 1; - if ((*protocol = (char *) xalloc(len)) == NULL) + + if ((*protocol = strdup (_protocol)) == NULL) { /* Malloc failed */ *port = NULL; *host = NULL; *protocol = NULL; - xfree (tmpptr); + free (tmpptr); return 0; } - else - strlcpy (*protocol, _protocol, len); - len = strlen (_host) + 1; - if ((*host = (char *) xalloc (len)) == NULL) + if ((*host = strdup (_host)) == NULL) { /* Malloc failed */ *port = NULL; *host = NULL; - xfree (*protocol); + free (*protocol); *protocol = NULL; - xfree (tmpptr); - return 0; - } - else - strlcpy (*host, _host, len); - - len = strlen (_port) + 1; - if ((*port = (char *) xalloc (len)) == NULL) - { - /* Malloc failed */ - *port = NULL; - xfree (*host); - *host = NULL; - xfree (*protocol); - *protocol = NULL; - xfree (tmpptr); + free (tmpptr); return 0; } - else - strlcpy (*port, _port, len); - xfree (tmpptr); + if ((*port = strdup (_port)) == NULL) + { + /* Malloc failed */ + *port = NULL; + free (*host); + *host = NULL; + free (*protocol); + *protocol = NULL; + free (tmpptr); + return 0; + } + + free (tmpptr); return 1; } @@ -424,12 +398,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 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 @@ -438,7 +412,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; } @@ -446,12 +420,12 @@ 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); - xfree (port); + free (protocol); + free (host); + free (port); return NULL; } @@ -480,27 +454,27 @@ 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)) + 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); - xfree (host); - xfree (port); + free (protocol); + free (host); + free (port); return NULL; } ciptr->transptr = thistrans; ciptr->port = port; /* We need this for TRANS(Reopen) */ - xfree (protocol); - xfree (host); + free (protocol); + free (host); return ciptr; } @@ -522,9 +496,8 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) Xtransport *thistrans = NULL; char *save_port; int i; - size_t len; - 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 */ @@ -537,22 +510,19 @@ 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; } - - len = strlen (port) + 1; - if ((save_port = (char *) xalloc (len)) == NULL) + + if ((save_port = strdup (port)) == NULL) { - PRMSG (1,"Reopen: Unable to malloc port string\n", 0, 0, 0); + prmsg (1,"Reopen: Unable to malloc port string\n"); return NULL; } - strlcpy (save_port, port, len); - /* Get a new XtransConnInfo object */ switch (type) @@ -564,12 +534,13 @@ 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"); + free (save_port); return NULL; } @@ -595,7 +566,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); } @@ -608,7 +579,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); } @@ -621,7 +592,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); } @@ -634,7 +605,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); } @@ -647,7 +618,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); } @@ -655,33 +626,28 @@ 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); } int -TRANS(GetReopenInfo) (XtransConnInfo ciptr, +TRANS(GetReopenInfo) (XtransConnInfo ciptr, int *trans_id, int *fd, char **port) { int i; - size_t len; for (i = 0; i < NUMTRANS; i++) if (Xtransports[i].transport == ciptr->transptr) { *trans_id = Xtransports[i].transport_id; *fd = ciptr->fd; - - len = strlen (ciptr->port) + 1; - if ((*port = (char *) xalloc (len)) == NULL) + + if ((*port = strdup (ciptr->port)) == NULL) return 0; else - { - strlcpy (*port, ciptr->port, len); return 1; - } } return 0; @@ -697,7 +663,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. @@ -719,7 +685,7 @@ TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg) break; case 1: /* Set to non-blocking mode */ -#if defined(O_NONBLOCK) && !defined(SCO325) +#if defined(O_NONBLOCK) && !defined(SCO325) ret = fcntl (fd, F_GETFL, 0); if (ret != -1) ret = fcntl (fd, F_SETFL, ret | O_NONBLOCK); @@ -731,7 +697,7 @@ TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg) ret = ioctl (fd, FIOSNBIO, &arg); } #else -#if defined(WIN32) +#if defined(WIN32) { #ifdef WIN32 u_long arg; @@ -769,7 +735,7 @@ TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg) #endif /* F_SETFD */ break; } - + return ret; } @@ -783,16 +749,16 @@ TRANS(CreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags) } int -TRANS(NoListen) (char * protocol) - +TRANS(NoListen) (const char * protocol) + { Xtransport *trans; int i = 0, ret = 0; - - if ((trans = TRANS(SelectTransport)(protocol)) == NULL) + + 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; } @@ -825,7 +791,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); @@ -849,12 +815,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; } @@ -864,19 +830,19 @@ TRANS(Connect) (XtransConnInfo ciptr, char *address) if (!port || !*port) { - PRMSG (1,"Connect: Missing port specification in %s\n", - address, 0, 0); - if (protocol) xfree (protocol); - if (host) xfree (host); + prmsg (1,"Connect: Missing port specification in %s\n", + address); + if (protocol) free (protocol); + if (host) free (host); return -1; } ret = ciptr->transptr->Connect (ciptr, host, port); - if (protocol) xfree (protocol); - if (host) xfree (host); - if (port) xfree (port); - + if (protocol) free (protocol); + if (host) free (host); + if (port) free (port); + return ret; } @@ -931,7 +897,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); @@ -946,7 +912,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); @@ -964,18 +930,18 @@ TRANS(IsLocal) (XtransConnInfo ciptr) int -TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, +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) + if ((*addrp = malloc (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); @@ -984,18 +950,18 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, } int -TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, +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) + if ((*addrp = malloc (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); @@ -1053,7 +1019,7 @@ extern int xquartz_launchd_fd; #endif int -TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, +TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, XtransConnInfo **ciptrs_ret) { @@ -1064,8 +1030,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; @@ -1075,7 +1041,7 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, if((ciptr = TRANS(ReopenCOTSServer(TRANS_SOCKET_LOCAL_INDEX, xquartz_launchd_fd, getenv("DISPLAY"))))==NULL) fprintf(stderr,"Got NULL while trying to Reopen launchd port\n"); - else + else temp_ciptrs[(*count_ret)++] = ciptr; } #endif @@ -1091,17 +1057,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) @@ -1120,9 +1086,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]); @@ -1134,9 +1099,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; } @@ -1146,10 +1111,10 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, if (Xtransports[i].transport_id == TRANS_SOCKET_INET6_INDEX) 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)++; @@ -1157,13 +1122,13 @@ 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()); if (*count_ret > 0) { - if ((*ciptrs_ret = (XtransConnInfo *) xalloc ( + if ((*ciptrs_ret = malloc ( *count_ret * sizeof (XtransConnInfo))) == NULL) { return -1; @@ -1176,12 +1141,12 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, } else *ciptrs_ret = NULL; - + return 0; } int -TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, +TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, XtransConnInfo **ciptrs_ret) { @@ -1189,8 +1154,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; @@ -1204,14 +1169,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; } @@ -1225,9 +1190,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]); @@ -1239,30 +1203,30 @@ 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()); if (*count_ret > 0) { - if ((*ciptrs_ret = (XtransConnInfo *) xalloc ( + if ((*ciptrs_ret = malloc ( *count_ret * sizeof (XtransConnInfo))) == NULL) { return -1; @@ -1275,7 +1239,7 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, } else *ciptrs_ret = NULL; - + return 0; } @@ -1289,7 +1253,7 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, */ -#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32) +#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32) /* * emulate readv @@ -1321,7 +1285,7 @@ static int TRANS(ReadV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt) #endif /* SYSV && __i386__ || WIN32 || __sxg__ */ -#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32) +#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32) /* * emulate writev diff --git a/lib/libxtrans/Xtrans.h b/lib/libxtrans/Xtrans.h index cb83196f1..2945b2aba 100644 --- a/lib/libxtrans/Xtrans.h +++ b/lib/libxtrans/Xtrans.h @@ -57,112 +57,84 @@ from The Open Group. #include <sys/socket.h> #endif +#ifdef __clang__ +/* Not all clients make use of all provided statics */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" +#endif /* * Set the functions names according to where this code is being compiled. */ #ifdef X11_t -#if !defined(UNIXCPP) || defined(ANSICPP) #define TRANS(func) _X11Trans##func -#else -#define TRANS(func) _X11Trans/**/func -#endif #ifdef XTRANSDEBUG -static char* __xtransname = "_X11Trans"; +static const char *__xtransname = "_X11Trans"; #endif #endif /* X11_t */ #ifdef XSERV_t -#if !defined(UNIXCPP) || defined(ANSICPP) #define TRANS(func) _XSERVTrans##func -#else -#define TRANS(func) _XSERVTrans/**/func -#endif #ifdef XTRANSDEBUG -static char* __xtransname = "_XSERVTrans"; +static const char *__xtransname = "_XSERVTrans"; #endif #define X11_t #endif /* XSERV_t */ #ifdef XIM_t -#if !defined(UNIXCPP) || defined(ANSICPP) #define TRANS(func) _XimXTrans##func -#else -#define TRANS(func) _XimXTrans/**/func -#endif #ifdef XTRANSDEBUG -static char* __xtransname = "_XimTrans"; +static const char *__xtransname = "_XimTrans"; #endif #endif /* XIM_t */ #ifdef FS_t -#if !defined(UNIXCPP) || defined(ANSICPP) #define TRANS(func) _FSTrans##func -#else -#define TRANS(func) _FSTrans/**/func -#endif #ifdef XTRANSDEBUG -static char* __xtransname = "_FSTrans"; +static const char *__xtransname = "_FSTrans"; #endif #endif /* FS_t */ #ifdef FONT_t -#if !defined(UNIXCPP) || defined(ANSICPP) #define TRANS(func) _FontTrans##func -#else -#define TRANS(func) _FontTrans/**/func -#endif #ifdef XTRANSDEBUG -static char* __xtransname = "_FontTrans"; +static const char *__xtransname = "_FontTrans"; #endif #endif /* FONT_t */ #ifdef ICE_t -#if !defined(UNIXCPP) || defined(ANSICPP) #define TRANS(func) _IceTrans##func -#else -#define TRANS(func) _IceTrans/**/func -#endif #ifdef XTRANSDEBUG -static char* __xtransname = "_IceTrans"; +static const char *__xtransname = "_IceTrans"; #endif #endif /* ICE_t */ #ifdef TEST_t -#if !defined(UNIXCPP) || defined(ANSICPP) #define TRANS(func) _TESTTrans##func -#else -#define TRANS(func) _TESTTrans/**/func -#endif #ifdef XTRANSDEBUG -static char* __xtransname = "_TESTTrans"; +static const char *__xtransname = "_TESTTrans"; #endif #endif /* TEST_t */ #ifdef LBXPROXY_t -#if !defined(UNIXCPP) || defined(ANSICPP) #define TRANS(func) _LBXPROXYTrans##func -#else -#define TRANS(func) _LBXPROXYTrans/**/func -#endif #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) -#if !defined(UNIXCPP) || defined(ANSICPP) #define TRANS(func) _XTrans##func -#else -#define TRANS(func) _XTrans/**/func -#endif #ifdef XTRANSDEBUG -static char* __xtransname = "_XTrans"; +static const char *__xtransname = "_XTrans"; #endif #endif /* !TRANS */ +#ifdef __clang__ +#pragma clang diagnostic pop +#endif /* * Create a single address structure that can be used wherever @@ -190,7 +162,7 @@ typedef long BytesReadable_t; #endif -#if defined(WIN32) || defined(USG) +#if defined(WIN32) || defined(USG) /* * TRANS(Readv) and TRANS(Writev) use struct iovec, normally found @@ -332,7 +304,7 @@ int TRANS(CreateListener)( ); int TRANS(NoListen) ( - char* /* protocol*/ + const char* /* protocol*/ ); int TRANS(ResetListener)( @@ -465,13 +437,13 @@ TRANS(GetPeerNetworkId)( #endif /* ICE_t */ -int +int TRANS(GetHostname) ( char * /* buf */, int /* maxlen */ ); -#if defined(WIN32) && defined(TCPCONN) +#if defined(WIN32) && defined(TCPCONN) int TRANS(WSAStartup)(); #endif diff --git a/lib/libxtrans/Xtransint.h b/lib/libxtrans/Xtransint.h index dd1f683b3..3bce8dc6b 100644 --- a/lib/libxtrans/Xtransint.h +++ b/lib/libxtrans/Xtransint.h @@ -51,10 +51,10 @@ from The Open Group. #define _XTRANSINT_H_ /* - * XTRANSDEBUG will enable the PRMSG() macros used in the X Transport - * Interface code. Each use of the PRMSG macro has a level associated with - * it. XTRANSDEBUG is defined to be a level. If the invocation level is =< - * the value of XTRANSDEBUG, then the message will be printed out to stderr. + * XTRANSDEBUG will enable the PRMSG() macros used in the X Transport + * Interface code. Each use of the PRMSG macro has a level associated with + * it. XTRANSDEBUG is defined to be a level. If the invocation level is =< + * the value of XTRANSDEBUG, then the message will be printed out to stderr. * Recommended levels are: * * XTRANSDEBUG=1 Error messages @@ -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,12 +311,21 @@ 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 +#pragma clang diagnostic ignored "-Wunused-function" +#endif + /* * readv() and writev() don't exist or don't work correctly on some * systems, so they may be emulated. */ -#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32) +#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32) #define READV(ciptr, iov, iovcnt) TRANS(ReadV)(ciptr, iov, iovcnt) @@ -329,7 +342,7 @@ static int TRANS(ReadV)( #endif /* CRAY || (SYSV && __i386__) || WIN32 || __sxg__ || */ -#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32) +#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32) #define WRITEV(ciptr, iov, iovcnt) TRANS(WriteV)(ciptr, iov, iovcnt) @@ -357,58 +370,70 @@ static int trans_mkdir ( ); #endif +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + /* * 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/lib/libxtrans/Xtranslcl.c b/lib/libxtrans/Xtranslcl.c index ca04e7f03..5beef7c98 100644 --- a/lib/libxtrans/Xtranslcl.c +++ b/lib/libxtrans/Xtranslcl.c @@ -49,7 +49,7 @@ from The Open Group. /* * - * The connection code/ideas in lib/X and server/os for SVR4/Intel + * The connection code/ideas in lib/X and server/os for SVR4/Intel * environments was contributed by the following companies/groups: * * MetroLink Inc @@ -61,12 +61,12 @@ from The Open Group. * * The goal is to have common connection code among all SVR4/Intel vendors. * - * ALL THE ABOVE COMPANIES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, - * IN NO EVENT SHALL THESE COMPANIES * BE LIABLE FOR ANY SPECIAL, INDIRECT - * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE + * ALL THE ABOVE COMPANIES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, + * IN NO EVENT SHALL THESE COMPANIES * BE LIABLE FOR ANY SPECIAL, INDIRECT + * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE * OR PERFORMANCE OF THIS SOFTWARE. */ @@ -123,7 +123,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; @@ -132,7 +132,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; @@ -152,21 +152,21 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) ciptr->family = AF_UNIX; ciptr->addrlen = sizeof (struct sockaddr_un); - if ((sunaddr = (struct sockaddr_un *) xalloc (ciptr->addrlen)) == NULL) + if ((sunaddr = malloc (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); - xfree((char *) sunaddr); + prmsg(1, "FillAddrInfo: path too long\n"); + free((char *) sunaddr); return 0; } strcpy (sunaddr->sun_path, sun_path); -#if defined(BSD44SOCKETS) +#if defined(BSD44SOCKETS) sunaddr->sun_len = strlen (sunaddr->sun_path); #endif @@ -174,13 +174,11 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) ciptr->peeraddrlen = sizeof (struct sockaddr_un); - if ((p_sunaddr = (struct sockaddr_un *) xalloc ( - ciptr->peeraddrlen)) == NULL) + if ((p_sunaddr = malloc (ciptr->peeraddrlen)) == NULL) { - PRMSG(1, - "FillAddrInfo: failed to allocate memory for peer addr\n", - 0,0,0); - xfree ((char *) sunaddr); + prmsg(1, + "FillAddrInfo: failed to allocate memory for peer addr\n"); + free (sunaddr); ciptr->addr = NULL; return 0; @@ -189,12 +187,12 @@ 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); - xfree((char *) p_sunaddr); + prmsg(1, "FillAddrInfo: peer path too long\n"); + free((char *) p_sunaddr); return 0; } strcpy (p_sunaddr->sun_path, peer_sun_path); -#if defined(BSD44SOCKETS) +#if defined(BSD44SOCKETS) p_sunaddr->sun_len = strlen (p_sunaddr->sun_path); #endif @@ -208,7 +206,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) #ifdef LOCAL_TRANS_PTS /* PTS */ -#if defined(SYSV) && !defined(__SCO__) +#if defined(SYSV) && !defined(__SCO__) #define SIGNAL_T int #else #define SIGNAL_T void @@ -222,7 +220,7 @@ extern char *ptsname( int ); -static void _dummy(int sig) +static void _dummy(int sig _X_UNUSED) { } @@ -315,20 +313,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()); } @@ -337,7 +337,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; } @@ -347,7 +347,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); } @@ -358,7 +358,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; @@ -391,14 +391,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); } @@ -425,8 +425,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; } @@ -437,7 +437,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; } @@ -462,10 +462,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 ) { @@ -484,8 +484,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); } @@ -496,8 +496,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); } @@ -508,7 +508,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); } @@ -516,25 +516,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); } @@ -547,7 +547,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; } @@ -567,17 +567,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; @@ -585,13 +585,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; @@ -600,7 +600,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; } @@ -612,9 +612,8 @@ 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); + if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) { + prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n"); close(newfd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -623,10 +622,9 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen); 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); - xfree(newciptr->addr); + if( (sunaddr = malloc(newciptr->peeraddrlen)) == NULL ) { + prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n"); + free(newciptr->addr); close(newfd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -634,7 +632,7 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) sunaddr->sun_family=AF_UNIX; strcpy(sunaddr->sun_path,buf); -#if defined(BSD44SOCKETS) +#if defined(BSD44SOCKETS) sunaddr->sun_len=strlen(sunaddr->sun_path); #endif @@ -663,15 +661,15 @@ TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port) int fd; char server_path[64]; struct stat filestat; -# ifndef sun +# ifndef sun extern int isastream(int); # 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 ) { @@ -685,26 +683,26 @@ 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); + (void) close(fd); return -1; } 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; } @@ -715,8 +713,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; } @@ -736,58 +733,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; - -#if defined(sun) && defined(X11_t) - mode = 0775; /* Solaris requires uid or gid 0 to create X11 pipes */ -#else + + prmsg(2,"NAMEDOpenPipe(%s)\n", server_path); + #ifdef HAS_STICKY_DIR_BIT mode = 01777; #else mode = 0777; -#endif #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); @@ -805,10 +798,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 ) { @@ -827,14 +820,14 @@ TRANS(NAMEDOpenServer)(XtransConnInfo ciptr, char *port) if (fd < 0) { return -1; } - + /* * Everything looks good: fill in the XtransConnInfo structure. */ 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; } @@ -848,12 +841,11 @@ 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) { /* * see if the pipe has disappeared @@ -861,7 +853,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) @@ -879,10 +871,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); } @@ -892,10 +884,9 @@ 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); + if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) { + prmsg(1, + "NAMEDAccept: failed to allocate memory for pipe addr\n"); close(str.fd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -904,11 +895,10 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen); 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); - xfree(newciptr->addr); + if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) { + prmsg(1, + "NAMEDAccept: failed to allocate memory for peer addr\n"); + free(newciptr->addr); close(str.fd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -1019,23 +1009,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; } @@ -1055,7 +1045,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; @@ -1079,7 +1069,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; } @@ -1105,12 +1095,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); @@ -1122,7 +1112,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) @@ -1131,14 +1121,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; @@ -1147,7 +1137,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; } @@ -1160,22 +1150,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; @@ -1189,7 +1179,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; @@ -1206,22 +1196,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; @@ -1232,10 +1222,9 @@ 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); + if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) { + prmsg(1, + "SCOAccept: failed to allocate memory for peer addr\n"); close(fd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -1247,11 +1236,10 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) #endif 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); - xfree(newciptr->addr); + if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) { + prmsg(1, + "SCOAccept: failed to allocate memory for peer addr\n"); + free(newciptr->addr); close(fd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -1280,26 +1268,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; } @@ -1313,33 +1302,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; } @@ -1360,12 +1350,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); @@ -1376,7 +1366,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; } @@ -1397,7 +1387,7 @@ TRANS(SCOReopenServer)(XtransConnInfo ciptr, int fd, char *port) */ typedef struct _LOCALtrans2dev { - char *transname; + const char *transname; #ifdef TRANS_CLIENT @@ -1658,7 +1648,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; @@ -1673,24 +1663,20 @@ 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") ) { - workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (protocol) + 1); - if (workingXLOCAL) - strcpy (workingXLOCAL, protocol); + workingXLOCAL = freeXLOCAL = strdup (protocol); } else { XLOCAL=(char *)getenv("XLOCAL"); if(XLOCAL==NULL) XLOCAL=DEF_XLOCAL; - workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (XLOCAL) + 1); - if (workingXLOCAL) - strcpy (workingXLOCAL, XLOCAL); + workingXLOCAL = freeXLOCAL = strdup (XLOCAL); } } @@ -1698,8 +1684,8 @@ static void TRANS(LocalEndTransports)(void) { - PRMSG(3,"LocalEndTransports()\n", 0,0,0 ); - xfree(freeXLOCAL); + prmsg(3,"LocalEndTransports()\n"); + free(freeXLOCAL); } #define TYPEBUFSIZE 32 @@ -1713,7 +1699,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) { @@ -1793,7 +1779,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. @@ -1805,9 +1791,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; } @@ -1824,10 +1810,10 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) */ #endif /* X11_t */ - if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) + if( (ciptr = calloc(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; } @@ -1849,14 +1835,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; @@ -1866,7 +1851,7 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) if( ciptr->fd < 0 ) { - xfree(ciptr); + free(ciptr); return NULL; } @@ -1882,13 +1867,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) /* @@ -1899,10 +1884,10 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host, char *port) */ #endif /* X11_t */ - if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) + if( (ciptr = calloc(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; } @@ -1914,9 +1899,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); @@ -1925,8 +1909,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]; @@ -1936,7 +1920,7 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host, char *port) } } - xfree(ciptr); + free(ciptr); return NULL; } @@ -1952,12 +1936,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 ) + if( (ciptr = calloc(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; } @@ -1972,8 +1956,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 ) { @@ -1983,7 +1967,7 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port) return ciptr; } - xfree(ciptr); + free(ciptr); return NULL; } @@ -1998,11 +1982,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); } @@ -2013,7 +1997,7 @@ TRANS(LocalOpenCOTSClient)(Xtransport *thistrans, char *protocol, #ifdef TRANS_SERVER static XtransConnInfo -TRANS(LocalOpenCOTSServer)(Xtransport *thistrans, char *protocol, +TRANS(LocalOpenCOTSServer)(Xtransport *thistrans, char *protocol, char *host, char *port) { @@ -2021,7 +2005,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"); @@ -2043,7 +2027,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; } @@ -2057,11 +2041,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); } @@ -2072,11 +2056,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); } @@ -2092,7 +2076,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++) { @@ -2116,7 +2100,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++) { @@ -2142,7 +2126,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; } @@ -2151,10 +2135,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; } @@ -2164,8 +2148,8 @@ 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) { @@ -2182,14 +2166,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 ) + if( (newciptr = calloc(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; } @@ -2198,7 +2182,7 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status) if( newciptr->fd < 0 ) { - xfree(newciptr); + free(newciptr); return NULL; } @@ -2216,10 +2200,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; } @@ -2231,7 +2215,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); @@ -2244,7 +2228,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); } @@ -2253,7 +2237,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); } @@ -2262,7 +2246,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); } @@ -2271,7 +2255,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); } @@ -2280,7 +2264,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; } @@ -2292,7 +2276,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); @@ -2314,7 +2298,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 */ @@ -2328,22 +2312,22 @@ TRANS(LocalCloseForCloning)(XtransConnInfo ciptr) * MakeAllCOTSServerListeners() will go through the entire Xtransports[] * array defined in Xtrans.c and try to OpenCOTSServer() for each entry. * We will add duplicate entries to that table so that the OpenCOTSServer() - * function will get called once for each type of local transport. + * function will get called once for each type of local transport. * * The TransName is in lowercase, so it will never match during a normal * call to SelectTransport() in Xtrans.c. */ #ifdef TRANS_SERVER -static char * local_aliases[] = { +static const char * local_aliases[] = { # ifdef LOCAL_TRANS_PTS "pts", # endif "named", # ifdef sun "pipe", /* compatibility with Solaris Xlib */ -# endif -# ifdef LOCAL_TRANS_SCO +# endif +# ifdef LOCAL_TRANS_SCO "sco", # endif NULL }; diff --git a/lib/libxtrans/Xtranssock.c b/lib/libxtrans/Xtranssock.c index e32e62a31..5d1e29597 100644 --- a/lib/libxtrans/Xtranssock.c +++ b/lib/libxtrans/Xtranssock.c @@ -97,7 +97,7 @@ from the copyright holders. #ifndef NO_TCP_H -#if defined(linux) || defined(__GLIBC__) +#if defined(linux) || defined(__GLIBC__) #include <sys/param.h> #endif /* osf */ #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) @@ -114,11 +114,11 @@ from the copyright holders. #if (defined(__i386__) && defined(SYSV)) && !defined(SCO325) && !defined(sun) #include <net/errno.h> -#endif +#endif -#if defined(__i386__) && defined(SYSV) +#if defined(__i386__) && defined(SYSV) #include <sys/stropts.h> -#endif +#endif #include <unistd.h> @@ -171,8 +171,8 @@ from the copyright holders. * */ -typedef struct _Sockettrans2dev { - char *transname; +typedef struct _Sockettrans2dev { + const char *transname; int family; int devcotsname; int devcltsname; @@ -244,7 +244,7 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr); #if defined HAVE_SOCKLEN_T || (defined(IPv6) && defined(AF_INET6)) # define SOCKLEN_T socklen_t #elif defined(SVR4) || defined(__SVR4) || defined(__SCO__) -# define SOCKLEN_T size_t +# define SOCKLEN_T size_t #else # define SOCKLEN_T int #endif @@ -254,12 +254,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++) { @@ -288,7 +288,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); @@ -299,15 +299,15 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) #endif bzero(socknamePtr, namelen); - + if (getsockname (ciptr->fd,(struct sockaddr *) socknamePtr, (void *)&namelen) < 0) { #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; } @@ -315,11 +315,10 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) * Everything looks good: fill in the XtransConnInfo structure. */ - if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) + if ((ciptr->addr = malloc (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; } @@ -365,8 +364,8 @@ 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) @@ -374,8 +373,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; } @@ -383,11 +382,10 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) * Everything looks good: fill in the XtransConnInfo structure. */ - if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL) + if ((ciptr->peeraddr = malloc (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; } @@ -404,12 +402,11 @@ 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) + if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL) { - PRMSG (1, "SocketOpen: malloc failed\n", 0, 0, 0); + prmsg (1, "SocketOpen: malloc failed\n"); return NULL; } @@ -424,10 +421,10 @@ 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); + free (ciptr); return NULL; } @@ -455,60 +452,64 @@ 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; + size_t addrlen; - 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*/ - if ((ciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) + if ((ciptr = calloc (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); + addrlen = portlen + offsetof(struct sockaddr, sa_data); + if ((addr = calloc (1, addrlen)) == NULL) { + prmsg (1, "SocketReopen: malloc(addr) failed\n"); + free (ciptr); return NULL; } ciptr->addr = (char *) addr; - ciptr->addrlen = portlen + 2; + ciptr->addrlen = addrlen; - if ((ciptr->peeraddr = (char *) xcalloc (1, portlen + 2)) == NULL) { - PRMSG (1, "SocketReopen: malloc(portaddr) failed\n", 0, 0, 0); + if ((ciptr->peeraddr = calloc (1, addrlen)) == NULL) { + prmsg (1, "SocketReopen: malloc(portaddr) failed\n"); + free (addr); + free (ciptr); return NULL; } - ciptr->peeraddrlen = portlen + 2; + ciptr->peeraddrlen = addrlen; /* Initialize ciptr structure as if it were a normally-opened unix socket */ ciptr->flags = TRANS_LOCAL | TRANS_NOUNLINK; #ifdef BSD44SOCKETS - addr->sa_len = portlen + 1; + addr->sa_len = addrlen; #endif addr->sa_family = AF_UNIX; #ifdef HAS_STRLCPY @@ -517,7 +518,7 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port) strncpy(addr->sa_data, port, portlen); #endif ciptr->family = AF_UNIX; - memcpy(ciptr->peeraddr, ciptr->addr, sizeof(struct sockaddr)); + memcpy(ciptr->peeraddr, ciptr->addr, addrlen); ciptr->port = rindex(addr->sa_data, ':'); if (ciptr->port == NULL) { if (is_numeric(addr->sa_data)) { @@ -540,13 +541,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(); @@ -562,11 +563,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; } @@ -574,7 +575,7 @@ TRANS(SocketOpenCOTSClientBase) (char *transname, char *protocol, } static XtransConnInfo -TRANS(SocketOpenCOTSClient) (Xtransport *thistrans, char *protocol, +TRANS(SocketOpenCOTSClient) (Xtransport *thistrans, char *protocol, char *host, char *port) { return TRANS(SocketOpenCOTSClientBase)( @@ -588,14 +589,14 @@ TRANS(SocketOpenCOTSClient) (Xtransport *thistrans, char *protocol, #ifdef TRANS_SERVER static XtransConnInfo -TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol, +TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol, char *host, char *port) { 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(); @@ -606,11 +607,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; } @@ -655,14 +656,14 @@ TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol, #ifdef TRANS_CLIENT static XtransConnInfo -TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol, +TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol, char *host, char *port) { 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(); @@ -673,11 +674,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; } @@ -694,14 +695,14 @@ TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol, #ifdef TRANS_SERVER static XtransConnInfo -TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol, +TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol, char *host, char *port) { 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(); @@ -712,11 +713,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; } @@ -746,8 +747,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(); @@ -758,11 +759,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; } @@ -780,8 +781,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(); @@ -792,11 +793,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; } @@ -814,7 +815,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; } @@ -842,7 +843,7 @@ set_sun_path(const char *port, const char *upath, char *path, int abstract) if (strlen(port) + strlen(upath) > maxlen) return -1; - snprintf(path, maxlen+1, "%s%s%s", at, upath, port); + snprintf(path, sizeof(s.sun_path), "%s%s%s", at, upath, port); return 0; } #endif @@ -850,7 +851,7 @@ set_sun_path(const char *port, const char *upath, char *path, int abstract) #ifdef TRANS_SERVER static int -TRANS(SocketCreateListener) (XtransConnInfo ciptr, +TRANS(SocketCreateListener) (XtransConnInfo ciptr, struct sockaddr *sockname, int socknamelen, unsigned int flags) @@ -859,7 +860,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) @@ -878,10 +879,9 @@ TRANS(SocketCreateListener) (XtransConnInfo ciptr, else return TRANS_ADDR_IN_USE; } - + 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; } @@ -912,11 +912,11 @@ 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; } - + /* Set a flag to indicate that this connection is a listener */ ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS); @@ -946,8 +946,8 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int #ifdef X11_t char portbuf[PORTBUFSIZE]; #endif - - PRMSG (2, "SocketINETCreateListener(%s)\n", port, 0, 0); + + prmsg (2, "SocketINETCreateListener(%s)\n", port); #ifdef X11_t /* @@ -976,9 +976,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 */ @@ -987,11 +987,11 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int else { tmpport = strtol (port, (char**)NULL, 10); - /* + /* * check that somehow the port address isn't negative or in * the range of reserved port addresses. This can happen and - * be very bad if the server is suid-root and the user does - * something (dumb) like `X :60049`. + * be very bad if the server is suid-root and the user does + * something (dumb) like `X :60049`. */ if (tmpport < 1024 || tmpport > USHRT_MAX) return TRANS_CREATE_LISTENER_FAILED; @@ -1033,17 +1033,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; } @@ -1072,8 +1070,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 */ @@ -1086,8 +1084,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; } @@ -1101,11 +1099,11 @@ 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; } -#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) +#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) sockname.sun_len = strlen(sockname.sun_path); #endif @@ -1125,9 +1123,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; } @@ -1141,11 +1138,10 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port, namelen = sizeof (sockname); /* this will always make it the same size */ - if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) + if ((ciptr->addr = malloc (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; } @@ -1180,7 +1176,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 || @@ -1201,8 +1197,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; } @@ -1254,12 +1250,11 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) struct sockaddr_in sockname; 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) + if ((newciptr = calloc (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; } @@ -1270,8 +1265,8 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) #ifdef WIN32 errno = WSAGetLastError(); #endif - PRMSG (1, "SocketINETAccept: accept() failed\n", 0, 0, 0); - xfree (newciptr); + prmsg (1, "SocketINETAccept: accept() failed\n"); + free (newciptr); *status = TRANS_ACCEPT_FAILED; return NULL; } @@ -1289,29 +1284,27 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) #endif /* - * Get this address again because the transport may give a more + * Get this address again because the transport may give a more * specific address now that a connection is established. */ 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); + free (newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } 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); + if (newciptr->addr) free (newciptr->addr); + free (newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } @@ -1333,12 +1326,11 @@ 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) + if ((newciptr = calloc (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; } @@ -1346,8 +1338,8 @@ 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); - xfree (newciptr); + prmsg (1, "SocketUNIXAccept: accept() failed\n"); + free (newciptr); *status = TRANS_ACCEPT_FAILED; return NULL; } @@ -1358,13 +1350,12 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) * since this is unix domain. */ - if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL) + if ((newciptr->addr = malloc (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); + free (newciptr); *status = TRANS_ACCEPT_BAD_MALLOC; return NULL; } @@ -1377,18 +1368,17 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) newciptr->addrlen = ciptr->addrlen; memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen); - if ((newciptr->peeraddr = (char *) xalloc (ciptr->addrlen)) == NULL) + if ((newciptr->peeraddr = malloc (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); + if (newciptr->addr) free (newciptr->addr); + free (newciptr); *status = TRANS_ACCEPT_BAD_MALLOC; return NULL; } - + newciptr->peeraddrlen = ciptr->addrlen; memcpy (newciptr->peeraddr, ciptr->addr, newciptr->addrlen); @@ -1411,7 +1401,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) #if defined(IPv6) && defined(AF_INET6) struct addrlist { struct addrinfo * addr; - struct addrinfo * firstaddr; + struct addrinfo * firstaddr; char port[PORTBUFSIZE]; char host[MAXHOSTNAMELEN]; }; @@ -1430,23 +1420,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) { @@ -1467,7 +1457,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) if (is_numeric (port)) { - tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); + long tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); snprintf (portbuf, sizeof(portbuf), "%lu", tmpport); port = portbuf; } @@ -1497,7 +1487,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; @@ -1506,24 +1496,24 @@ 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; } while (socketaddr == NULL) { if (addrlist->addr == NULL) { - if (resetonce) { + 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 */ resetonce = 1; addrlist->addr = addrlist->firstaddr; } - } + } socketaddr = addrlist->addr->ai_addr; socketaddrlen = addrlist->addr->ai_addrlen; @@ -1531,12 +1521,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, @@ -1558,26 +1548,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); + free(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, @@ -1596,17 +1584,16 @@ 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); + free(newciptr); } else { socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Skipping IPv6 address\n", - 0,0,0); + prmsg (4,"SocketINETConnect() Skipping IPv6 address\n"); } } } else { @@ -1615,7 +1602,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) if (socketaddr == NULL) { addrlist->addr = addrlist->addr->ai_next; } - } + } } #else { @@ -1644,21 +1631,21 @@ 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; } - + memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr, sizeof (sockname.sin_addr)); @@ -1674,20 +1661,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); } @@ -1737,7 +1724,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) * number of errors that made us quit before, since those * could be caused by trying to use an IPv6 address to contact * a machine with an IPv4-only server or other reasons that - * only affect one of a set of addresses. + * only affect one of a set of addresses. */ if (olderrno == ECONNREFUSED || olderrno == EINTR @@ -1757,32 +1744,30 @@ 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; + res = TRANS_CONNECT_FAILED; } } else { res = 0; - + /* * Sync up the address fields of ciptr. */ - + 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; } } @@ -1835,7 +1820,7 @@ UnixHostReallyLocal (char *host) for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) { if (i->ai_family == j->ai_family) { if (i->ai_family == AF_INET) { - struct sockaddr_in *sinA + struct sockaddr_in *sinA = (struct sockaddr_in *) i->ai_addr; struct sockaddr_in *sinB = (struct sockaddr_in *) j->ai_addr; @@ -1846,9 +1831,9 @@ UnixHostReallyLocal (char *host) equiv = 1; } } else if (i->ai_family == AF_INET6) { - struct sockaddr_in6 *sinA + struct sockaddr_in6 *sinA = (struct sockaddr_in6 *) i->ai_addr; - struct sockaddr_in6 *sinB + struct sockaddr_in6 *sinB = (struct sockaddr_in6 *) j->ai_addr; struct in6_addr *A = &sinA->sin6_addr; struct in6_addr *B = &sinB->sin6_addr; @@ -1860,7 +1845,7 @@ UnixHostReallyLocal (char *host) } } } - + freeaddrinfo(localhostaddr); freeaddrinfo(otherhostaddr); return equiv; @@ -1890,13 +1875,13 @@ UnixHostReallyLocal (char *host) * from the 1st call, so we must save the address list. */ - specified_local_addr_list[scount][0] = + specified_local_addr_list[scount][0] = hostp->h_addr_list[scount][0]; - specified_local_addr_list[scount][1] = + specified_local_addr_list[scount][1] = hostp->h_addr_list[scount][1]; - specified_local_addr_list[scount][2] = + specified_local_addr_list[scount][2] = hostp->h_addr_list[scount][2]; - specified_local_addr_list[scount][3] = + specified_local_addr_list[scount][3] = hostp->h_addr_list[scount][3]; scount++; } @@ -1912,17 +1897,17 @@ UnixHostReallyLocal (char *host) while (hostp->h_addr_list[j]) { - if ((specified_local_addr_list[i][0] == + if ((specified_local_addr_list[i][0] == hostp->h_addr_list[j][0]) && - (specified_local_addr_list[i][1] == + (specified_local_addr_list[i][1] == hostp->h_addr_list[j][1]) && - (specified_local_addr_list[i][2] == + (specified_local_addr_list[i][2] == hostp->h_addr_list[j][2]) && - (specified_local_addr_list[i][3] == + (specified_local_addr_list[i][3] == hostp->h_addr_list[j][3])) { /* They're equal, so we're done */ - + equiv = 1; break; } @@ -1950,8 +1935,8 @@ 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. * The reason we make this check is because a process may advertise @@ -1962,9 +1947,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; } @@ -1975,23 +1960,22 @@ 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; } /* * Build the socket name. */ - + 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; } -#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) +#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) sockname.sun_len = strlen (sockname.sun_path); #endif @@ -2020,11 +2004,11 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) { int olderrno = errno; int connected = 0; - + if (!connected) { errno = olderrno; - + /* * If the error was ENOENT, the server may be starting up; we used * to suggest to try again in this case with @@ -2054,8 +2038,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; } @@ -2067,12 +2051,11 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) * since this is unix domain. */ - if ((ciptr->addr = (char *) xalloc(namelen)) == NULL || - (ciptr->peeraddr = (char *) xalloc(namelen)) == NULL) + if ((ciptr->addr = malloc(namelen)) == NULL || + (ciptr->peeraddr = malloc(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; } @@ -2097,7 +2080,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 { @@ -2106,7 +2089,7 @@ TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend) return ret; } #else -#if defined(__i386__) && defined(SYSV) && !defined(SCO325) +#if defined(__i386__) && defined(SYSV) && !defined(SCO325) return ioctl (ciptr->fd, I_NREAD, (char *) pend); #else return ioctl (ciptr->fd, FIONREAD, (char *) pend); @@ -2119,9 +2102,9 @@ 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) +#if defined(WIN32) { int ret = recv ((SOCKET)ciptr->fd, buf, size, 0); #ifdef WIN32 @@ -2139,9 +2122,9 @@ 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) +#if defined(WIN32) { int ret = send ((SOCKET)ciptr->fd, buf, size, 0); #ifdef WIN32 @@ -2159,7 +2142,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); } @@ -2169,7 +2152,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); } @@ -2179,10 +2162,10 @@ 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 - { + { int ret = shutdown (ciptr->fd, 2); if (ret == SOCKET_ERROR) errno = WSAGetLastError(); return ret; @@ -2198,7 +2181,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 { @@ -2226,7 +2209,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); @@ -2253,8 +2236,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); @@ -2266,7 +2249,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", @@ -2449,7 +2432,7 @@ Xtransport TRANS(SocketLocalFuncs) = { static char* unix_nolisten[] = { "local" , NULL }; # endif # endif - + Xtransport TRANS(SocketUNIXFuncs) = { /* Socket Interface */ "unix", diff --git a/lib/libxtrans/Xtranstli.c b/lib/libxtrans/Xtranstli.c index a9dfc21da..397c946df 100644 --- a/lib/libxtrans/Xtranstli.c +++ b/lib/libxtrans/Xtranstli.c @@ -75,33 +75,33 @@ static TLItrans2dev TLItrans2devtab[] = { }; #define NUMTLIFAMILIES (sizeof(TLItrans2devtab)/sizeof(TLItrans2dev)) - + /* * The local TLI connection, is a form of a local connection, so use a * sockaddr_un for the address so that it will be treated just like the other * local transports such as UNIX domain sockets, pts, and named. */ - + #if defined(X11_t) #define TLINODENAME "TLI:xserver" #endif - + #if defined(XIM_t) #define TLINODENAME "TLI:xim" #endif - + #if defined(FS_t) || defined(FONT_t) #define TLINODENAME "TLI:fontserver" #endif - + #if defined(ICE_t) #define TLINODENAME "TLI:ICE" #endif - + #if defined(TEST_t) #define TLINODENAME "TLI:test" #endif - + #ifndef PORTBUFSIZE #ifdef TRANS_SERVER #define PORTBUFSIZE 64 @@ -122,9 +122,9 @@ 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++) { if( !strcmp(family,TLItrans2devtab[i].transname) ) @@ -145,41 +145,40 @@ 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); netbuf.maxlen=sizeof(sockname); - + 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. */ - + if( ciptr->addr ) - xfree(ciptr->addr); - - if( (ciptr->addr=(char *)xalloc(netbuf.len)) == NULL ) + free(ciptr->addr); + + if( (ciptr->addr = malloc(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; } - + ciptr->family=((struct sockaddr *) &sockname)->sa_family; ciptr->addrlen=netbuf.len; memcpy(ciptr->addr,&sockname,ciptr->addrlen); - + return 0; } @@ -195,41 +194,40 @@ 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); netbuf.maxlen=sizeof(sockname); - + 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. */ - + if( ciptr->peeraddr ) - xfree(ciptr->peeraddr); - - if( (ciptr->peeraddr=(char *)xalloc(netbuf.len)) == NULL ) + free(ciptr->peeraddr); + + if( (ciptr->peeraddr = malloc(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; } - + ciptr->peeraddrlen=netbuf.len; memcpy(ciptr->peeraddr,&sockname,ciptr->peeraddrlen); - + return 0; } @@ -250,31 +248,29 @@ 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; } - + sunaddr->sun_family=AF_UNIX; - + #ifdef nuke if( *port == '/' ) { /* A full pathname */ (void) strcpy(sunaddr->sun_path, port); @@ -282,23 +278,23 @@ TRANS(TLITLIBindLocal)(int fd, int family, char *port) (void) sprintf(sunaddr->sun_path,"%s%s", TLINODENAME, port ); } #endif /*NUKE*/ - + (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); req->addr.maxlen=sizeof(*sunaddr); } - + 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) @@ -313,22 +309,22 @@ TRANS(TLIOpen)(char *device) { XtransConnInfo ciptr; - - PRMSG(3,"TLIOpen(%s)\n", device, 0,0 ); - - if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) + + prmsg(3,"TLIOpen(%s)\n", device); + + if( (ciptr = calloc(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; } - + return ciptr; } @@ -340,23 +336,23 @@ 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 ) + if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { - PRMSG(1, "TLIReopen: calloc failed\n", 0,0,0 ); + prmsg(1, "TLIReopen: calloc failed\n"); return NULL; } - + ciptr->fd = fd; - + return ciptr; } @@ -364,7 +360,7 @@ TRANS(TLIReopen)(char *device, int fd, char *port) static int -TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port, +TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port, struct netbuf *netbufp) { @@ -373,38 +369,37 @@ TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port, struct nd_addrlist *nd_addrlistp = NULL; 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; lport = strtol (port, (char**)NULL, 10); if (lport < 1024 || lport > USHRT_MAX) return -1; - + nd_hostserv.h_host = host; if( port && *port ) { nd_hostserv.h_serv = port; } else { nd_hostserv.h_serv = NULL; } - + while( (netconfigp=getnetconfig(handlep)) != NULL ) { 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); netbufp->len=nd_addrlistp->n_addrs->len; @@ -413,7 +408,7 @@ TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port, } } endnetconfig(handlep); - + return -1; } @@ -424,52 +419,52 @@ TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port, #ifdef TRANS_CLIENT static XtransConnInfo -TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol, +TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol, char *host, char *port) { 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); + free(ciptr); return NULL; } - + if( TRANS(TLIGetAddr)(ciptr) < 0 ) { - PRMSG(1, + prmsg(1, "TLIOpenCOTSClient: ...TLIGetAddr() failed: %d\n", - errno, 0,0 ); + errno); t_close(ciptr->fd); - xfree(ciptr); + free(ciptr); return NULL; } - + /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */ ciptr->index = i; - + return ciptr; } @@ -479,40 +474,40 @@ TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol, #ifdef TRANS_SERVER static XtransConnInfo -TRANS(TLIOpenCOTSServer)(Xtransport *thistrans, char *protocol, +TRANS(TLIOpenCOTSServer)(Xtransport *thistrans, char *protocol, char *host, char *port) { 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; } - + /* Set the family type */ ciptr->family = TLItrans2devtab[i].family; /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */ - + ciptr->index = i; - + return ciptr; } @@ -522,53 +517,53 @@ TRANS(TLIOpenCOTSServer)(Xtransport *thistrans, char *protocol, #ifdef TRANS_CLIENT static XtransConnInfo -TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol, +TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol, char *host, char *port) { 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); + free(ciptr); return NULL; } - + if( TRANS(TLIGetAddr)(ciptr) < 0 ) { - PRMSG(1, + prmsg(1, "TLIOpenCLTSClient: ...TLIGetPeerAddr() failed: %d\n", - errno, 0,0 ); + errno); t_close(ciptr->fd); - xfree(ciptr); + free(ciptr); return NULL; } - + return ciptr; -} +} #endif /* TRANS_CLIENT */ @@ -576,33 +571,33 @@ TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol, #ifdef TRANS_SERVER static XtransConnInfo -TRANS(TLIOpenCLTSServer)(Xtransport *thistrans, char *protocol, +TRANS(TLIOpenCLTSServer)(Xtransport *thistrans, char *protocol, char *host, char *port) { 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; } - + return ciptr; -} +} #endif /* TRANS_SERVER */ @@ -615,30 +610,30 @@ 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; } - + /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */ - + ciptr->index = i; - + return ciptr; } @@ -649,30 +644,30 @@ 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; } - + ciptr->index = i; return ciptr; -} +} #endif /* TRANS_REOPEN */ @@ -681,8 +676,8 @@ 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; } @@ -694,54 +689,52 @@ 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; } - + 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; } - + /* * Everything looks good: fill in the XtransConnInfo structure. */ - - if( (ciptr->addr=(char *)xalloc(ret->addr.len)) == NULL ) + + if( (ciptr->addr = malloc(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; } - + ciptr->addrlen=ret->addr.len; memcpy(ciptr->addr,ret->addr.buf,ret->addr.len); - + t_free((char *)req,T_BIND); t_free((char *)ret, T_BIND); - + return 0; } @@ -754,10 +747,10 @@ TRANS(TLIINETCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flag struct t_bind *req; 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 /* * X has a well known port, that is transport dependent. It is easier @@ -767,7 +760,7 @@ TRANS(TLIINETCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flag * The port that is passed here is really a string containing the idisplay * from ConnectDisplay(). */ - + if (is_numeric (port)) { tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); @@ -775,21 +768,20 @@ TRANS(TLIINETCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flag port = portbuf; } #endif - + 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; } @@ -803,7 +795,7 @@ TRANS(TLIINETCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flag /* Set the qlen */ req->qlen=1; - + return TRANS(TLICreateListener)(ciptr, req); } @@ -815,28 +807,26 @@ TRANS(TLITLICreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags struct t_bind *req; 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; } - + sunaddr->sun_family=AF_UNIX; if( port && *port ) { if( *port == '/' ) { /* A full pathname */ @@ -847,15 +837,15 @@ TRANS(TLITLICreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags } else { (void) sprintf(sunaddr->sun_path,"%s%d", TLINODENAME, getpid()); } - + req->addr.buf=(char *)sunaddr; req->addr.len=sizeof(*sunaddr); req->addr.maxlen=sizeof(*sunaddr); - + /* Set the qlen */ - + req->qlen=1; - + ret_value = TRANS(TLICreateListener)(ciptr, req); free((char *) sunaddr); @@ -871,71 +861,71 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) struct t_call *call; 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; } - + if( t_listen(ciptr->fd,call) < 0 ) { 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; } - + /* * Now we need to set up the new endpoint for the incoming connection. */ - + i=ciptr->index; /* Makes the next line more readable */ - + 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; } - + 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); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } - - + + if( t_accept(ciptr->fd,newciptr->fd,call) < 0 ) { 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: @@ -948,54 +938,54 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) *status = TRANS_ACCEPT_FAILED; return NULL; } - + t_free((char *)call,T_CALL); - + 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); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } - + 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); + free(newciptr->addr); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } - + 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); + free(newciptr->addr); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } - + 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); + free(newciptr->addr); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } - + *status = 0; return 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) { @@ -1027,43 +1017,43 @@ TRANS(TLIConnect)(XtransConnInfo ciptr, struct t_call *sndcall ) else return TRANS_CONNECT_FAILED; } - + t_free((char *)sndcall,T_CALL); - + /* * Sync up the address fields of ciptr. */ - + 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; } - + return 0; } @@ -1072,12 +1062,12 @@ static int TRANS(TLIINETConnect)(XtransConnInfo ciptr, char *host, char *port) { - char portbuf[PORTBUFSIZE]; + char portbuf[PORTBUFSIZE]; 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 /* * X has a well known port, that is transport dependant. It is easier @@ -1087,7 +1077,7 @@ TRANS(TLIINETConnect)(XtransConnInfo ciptr, char *host, char *port) * The port that is passed here is really a string containing the idisplay * from ConnectDisplay(). */ - + if (is_numeric (port)) { tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); @@ -1095,21 +1085,21 @@ TRANS(TLIINETConnect)(XtransConnInfo ciptr, char *host, char *port) port = portbuf; } #endif - + 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; } - + return TRANS(TLIConnect)(ciptr, sndcall ); } @@ -1121,25 +1111,24 @@ TRANS(TLITLIConnect)(XtransConnInfo ciptr, char *host, char *port) struct t_call *sndcall; 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; } - + sunaddr->sun_family=AF_UNIX; if( *port == '/' || strncmp (port, TLINODENAME, strlen (TLINODENAME)) == 0) { @@ -1152,7 +1141,7 @@ TRANS(TLITLIConnect)(XtransConnInfo ciptr, char *host, char *port) sndcall->addr.buf=(char *)sunaddr; sndcall->addr.len=sizeof(*sunaddr); sndcall->addr.maxlen=sizeof(*sunaddr); - + ret_value = TRANS(TLIConnect)(ciptr, sndcall ); free((char *) sunaddr); @@ -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 @@ -1178,7 +1167,7 @@ TRANS(TLIBytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend) * streams head, and ioctl(N_READ) keeps returning 0 because there is * no data available. The hangup goes undetected, and the client hangs. */ - + ret=ioctl(ciptr->fd, I_NREAD, (char *)pend); if( ret != 0 ) @@ -1191,7 +1180,7 @@ TRANS(TLIBytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend) filedes.events=POLLIN; ret=poll(&filedes, 1, 0); - + if( ret == 0 ) { *pend=0; return 0; /* Really, no data */ @@ -1212,8 +1201,8 @@ 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,8 +1211,8 @@ 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,8 +1221,8 @@ 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,8 +1231,8 @@ 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,8 +1241,8 @@ 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. * This avoids the situation where a connection goes into the TIME_WAIT @@ -1263,7 +1252,7 @@ TRANS(TLIDisconnect)(XtransConnInfo ciptr) ioctl(ciptr->fd, I_PUSH,"timod"); t_snddis(ciptr->fd,NULL); - + return 0; } @@ -1272,8 +1261,8 @@ 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); return (t_close(ciptr->fd)); @@ -1288,8 +1277,8 @@ 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/lib/libxtrans/Xtransutil.c b/lib/libxtrans/Xtransutil.c index 36b3d51ae..dabf9e078 100644 --- a/lib/libxtrans/Xtransutil.c +++ b/lib/libxtrans/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 ) { @@ -142,7 +142,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) { *familyp=FamilyLocal; } - else + else { *familyp=FamilyInternet; *addrlenp = sizeof (struct in_addr); @@ -161,7 +161,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) #endif /* defined(TCPCONN) || defined(STREAMSCONN) */ -#if defined(UNIXCONN) || defined(LOCALCONN) +#if defined(UNIXCONN) || defined(LOCALCONN) case AF_UNIX: { *familyp=FamilyLocal; @@ -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; } @@ -190,18 +190,18 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) * In the case of a local connection, we need to get the * host name for authentication. */ - + char hostnamebuf[256]; int len = TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf); if (len > 0) { if (*addrp && *addrlenp < (len + 1)) { - xfree ((char *) *addrp); + free (*addrp); *addrp = NULL; } if (!*addrp) - *addrp = (Xtransaddr *) xalloc (len + 1); + *addrp = malloc (len + 1); if (*addrp) { strlcpy ((char *) *addrp, hostnamebuf, len + 1); *addrlenp = len; @@ -212,7 +212,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) else { if (*addrp) - xfree ((char *) *addrp); + free (*addrp); *addrp = NULL; *addrlenp = 0; } @@ -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; size_t len; if (gethostname (hostnamebuf, sizeof (hostnamebuf)) < 0) @@ -258,7 +258,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr) struct sockaddr_un *saddr = (struct sockaddr_un *) addr; len = 3 + strlen (transName) + strlen (hostnamebuf) + strlen (saddr->sun_path); - networkId = (char *) xalloc (len); + networkId = (char *) malloc (len); snprintf (networkId, len, "%s/%s:%s", transName, hostnamebuf, saddr->sun_path); break; @@ -289,7 +289,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr) snprintf (portnumbuf, sizeof(portnumbuf), "%d", portnum); len = 3 + strlen (transName) + strlen (hostnamebuf) + strlen (portnumbuf); - networkId = (char *) xalloc (len); + networkId = (char *) malloc (len); snprintf (networkId, len, "%s/%s:%s", transName, hostnamebuf, portnumbuf); break; @@ -319,7 +319,7 @@ int void #endif #endif -nameserver_lost(int sig) +nameserver_lost(int sig _X_UNUSED) { nameserver_timedout = 1; longjmp (env, -1); @@ -345,7 +345,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) switch (family) { case AF_UNSPEC: -#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) +#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) case AF_UNIX: { if (gethostname (addrbuf, sizeof (addrbuf)) == 0) @@ -390,7 +390,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) * Assume that if it does not respond in NAMESERVER_TIMEOUT seconds * that something is wrong and do not make the user wait. * gethostbyaddr will continue after a signal, so we have to - * jump out of it. + * jump out of it. */ nameserver_timedout = 0; @@ -421,7 +421,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) } len = strlen (ciptr->transptr->TransName) + strlen (addr) + 2; - hostname = (char *) xalloc (len); + hostname = (char *) malloc (len); strlcpy (hostname, ciptr->transptr->TransName, len); strlcat (hostname, "/", len); if (addr) @@ -433,13 +433,13 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) #endif /* ICE_t */ -#if defined(WIN32) && defined(TCPCONN) +#if defined(WIN32) && defined(TCPCONN) int 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; @@ -480,15 +480,15 @@ is_numeric (const char *str) * it's not save if the directory has non-root ownership or the sticky * bit cannot be set and fail. */ -static int +static int trans_mkdir(const char *path, int mode) { struct stat buf; 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 */ @@ -501,15 +501,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 @@ -517,8 +517,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 @@ -527,13 +527,13 @@ 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; } return 0; - + } else { if (S_ISDIR(buf.st_mode)) { int updateOwner = 0; @@ -552,7 +552,7 @@ trans_mkdir(const char *path, int mode) */ if ((~mode) & 0077 & buf.st_mode) updateMode = 1; - + /* * If the directory is not writeable not everybody may * be able to create sockets. Therefore warn if mode @@ -562,7 +562,7 @@ trans_mkdir(const char *path, int mode) updateMode = 1; status |= WARN_NO_ACCESS; } - + /* * If 'sticky' bit is requested fail if owner isn't root * as we assume the caller makes certain security implications @@ -574,7 +574,7 @@ trans_mkdir(const char *path, int mode) updateMode = 1; } } - + #ifdef HAS_FCHOWN /* * If fchown(2) and fchmod(2) are available, try to correct the @@ -586,8 +586,9 @@ 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); + close(fd); return -1; } /* @@ -597,8 +598,9 @@ 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); + close(fd); return -1; } if (updateOwner && fchown(fd, 0, 0) == 0) @@ -609,34 +611,33 @@ trans_mkdir(const char *path, int mode) } } #endif - + 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/lib/libxtrans/configure.ac b/lib/libxtrans/configure.ac index ce521bbb6..3d11c34fa 100644 --- a/lib/libxtrans/configure.ac +++ b/lib/libxtrans/configure.ac @@ -1,40 +1,44 @@ -dnl Copyright © 2003 Keith Packard, Noah Levitt -dnl -dnl Permission to use, copy, modify, distribute, and sell this software and its -dnl documentation for any purpose is hereby granted without fee, provided that -dnl the above copyright notice appear in all copies and that both that -dnl copyright notice and this permission notice appear in supporting -dnl documentation, and that the name of Keith Packard not be used in -dnl advertising or publicity pertaining to distribution of the software without -dnl specific, written prior permission. Keith Packard makes no -dnl representations about the suitability of this software for any purpose. It -dnl is provided "as is" without express or implied warranty. -dnl -dnl KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -dnl EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR -dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -dnl PERFORMANCE OF THIS SOFTWARE. -dnl -dnl Process this file with autoconf to create configure. +# Copyright © 2003 Keith Packard, Noah Levitt +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of Keith Packard not be used in +# advertising or publicity pertaining to distribution of the software without +# specific, written prior permission. Keith Packard makes no +# representations about the suitability of this software for any purpose. It +# is provided "as is" without express or implied warranty. +# +# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. +# +# Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([xtrans], [1.2.6], +AC_INIT([xtrans], [1.2.7], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xtrans]) +AC_CONFIG_SRCDIR([Makefile.am]) + +# Initialize Automake AM_INIT_AUTOMAKE([foreign dist-bzip2]) AM_MAINTAINER_MODE -# Require xorg-macros minimum of 1.10 for DocBook XML documentation +# Require xorg-macros minimum of 1.12 for DocBook external references m4_ifndef([XORG_MACROS_VERSION], - [m4_fatal([must install xorg-macros 1.10 or later before running autoconf/autogen])]) -XORG_MACROS_VERSION(1.10) + [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.12) XORG_DEFAULT_OPTIONS XORG_ENABLE_DOCS -XORG_WITH_XMLTO(0.0.20) +XORG_WITH_XMLTO(0.0.22) XORG_WITH_FOP -XORG_CHECK_SGML_DOCTOOLS(1.5) +XORG_WITH_XSLTPROC +XORG_CHECK_SGML_DOCTOOLS(1.8) # Because xtrans is included into other modules rather than being linked # with, these defines have to be added to the cflags line @@ -46,14 +50,15 @@ AC_CHECK_FUNC(fchown, [fchown_define="-DHAS_FCHOWN"], [fchown_define=""]) AC_SUBST(fchown_define) # sticky bit -# -# if any system exists without sticky dir bits this +# +# if any system exists without sticky dir bits this # needs to be redone with a real autoconf test sticky_bit_define="-DHAS_STICKY_DIR_BIT" AC_SUBST(sticky_bit_define) -AC_OUTPUT([Makefile - doc/Makefile - xtrans.pc]) +AC_CONFIG_FILES([Makefile + doc/Makefile + xtrans.pc]) +AC_OUTPUT diff --git a/lib/libxtrans/doc/Makefile.am b/lib/libxtrans/doc/Makefile.am index 19ad93910..014c956ae 100644 --- a/lib/libxtrans/doc/Makefile.am +++ b/lib/libxtrans/doc/Makefile.am @@ -1,62 +1,13 @@ -# -# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# if ENABLE_DOCS -doc_sources = xtrans.xml -dist_doc_DATA = $(doc_sources) -if HAVE_XMLTO -doc_DATA = $(doc_sources:.xml=.html) +# Main DocBook/XML files (DOCTYPE book) +docbook = xtrans.xml -if HAVE_FOP -doc_DATA += $(doc_sources:.xml=.ps) $(doc_sources:.xml=.pdf) -endif +# The location where the DocBook/XML files and their generated formats are installed +shelfdir = $(docdir) -if HAVE_XMLTO_TEXT -doc_DATA += $(doc_sources:.xml=.txt) -endif +# Generate DocBook/XML output formats with or without stylesheets +include $(top_srcdir)/docbook.am -if HAVE_STYLESHEETS -XMLTO_FLAGS = \ - -m $(XSL_STYLESHEET) \ - --stringparam html.stylesheet="$(STYLESHEET_SRCDIR)/xorg.css" -endif - -CLEANFILES = $(doc_DATA) - -SUFFIXES = .xml .ps .pdf .txt .html - -.xml.txt: - $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) txt $< - -.xml.html: - $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) xhtml-nochunks $< - -.xml.pdf: - $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop pdf $< - -.xml.ps: - $(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop ps $< - -endif HAVE_XMLTO endif ENABLE_DOCS diff --git a/lib/libxtrans/doc/xtrans.xml b/lib/libxtrans/doc/xtrans.xml index ec8b42d0c..12dbe3c7f 100644 --- a/lib/libxtrans/doc/xtrans.xml +++ b/lib/libxtrans/doc/xtrans.xml @@ -1,6 +1,9 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" - "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" +[ +<!ENTITY % defs SYSTEM "defs.ent"> %defs; +]> <!-- lifted from troff+ms+XMan by doclifter --> <book id="xtrans"> @@ -8,28 +11,28 @@ <bookinfo> <title>X Transport Interface X Consortium Standard - X Version 11, Release 7.X - - StuartAnderson - + + StuartAnderson + NCR Corporation + + RalphMor + X Consortium + + AlanCoopersmith + Oracle Corp. + - RalphMor - AlanCoopersmith - NCR Corporation + X Version 11, Release &fullrelvers; Version 0.7 - The Open Group - X Version 11, Release 7.x + 19931994 + NCR Corporation - Dayton, Ohio, USA + - -Copyright © 1993, 1994 NCR Corporation - Dayton, Ohio, USA - - All Rights Reserved - Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided @@ -41,7 +44,6 @@ written prior permission. NCR makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. - NCR DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN @@ -51,14 +53,12 @@ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - + Copyright © 1993, 1994, 2002 The Open Group - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal @@ -67,12 +67,10 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -81,19 +79,15 @@ OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. - X Window System is a trademark of The Open Group, Inc. - - The X Transport Interface @@ -109,7 +103,7 @@ for client vs. server code. - + Purposes and Goals The X Transport Interface is intended to combine all system and @@ -127,7 +121,7 @@ FS, and connection-less oriented protocols such as XDMCP. - + Overview of the Interface @@ -148,7 +142,7 @@ an interface would affect performance. - + Definition of Address Specification Format @@ -175,14 +169,14 @@ part of an address. - + Internal Data Structures 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. - + Xtransport Each transport supported has an entry in the transport table. The transport @@ -343,7 +337,7 @@ should not be unlinked. - + XtransConnInfo Each connection will have an opaque XtransConnInfo @@ -370,7 +364,7 @@ struct _XtransConnInfo { - + Exposed Transport Independent API @@ -391,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. - + Core Interface API @@ -665,7 +659,7 @@ is the list of transports. - + Utility API This section describes a few useful functions that have been implemented on @@ -687,7 +681,7 @@ FamilyLocal)). - + Transport Option Definition The following options are defined for the @@ -721,7 +715,7 @@ connection will not be closed when an exec occurs. - + Hidden Transport Dependent API The hidden transport dependent functions are placed in the Xtransport record. @@ -941,7 +935,7 @@ This function will break the connection, and close the endpoint. - + Configuration @@ -962,13 +956,14 @@ In X11R7 modular releases, these flags are set when running XTRANS_CONNECTION_FLAGS macro from xtrans.m4. - - - - - + + + + + + - + #define configure flag Description @@ -1024,18 +1019,18 @@ In X11R7 modular releases, these flags are set when running - + Transport Specific Definitions - + - - - - + + + + - Protocol Family + Protocol Family Address Component @@ -1046,34 +1041,34 @@ In X11R7 modular releases, these flags are set when running - Internet - inet inet6 tcp udp - name of an internet addressable host - string containing the name of a service or a valid port number. Example: "xserver0", "7100" + Internet + inet inet6 tcp udp + name of an internet addressable host + string containing the name of a service or a valid port number. Example: "xserver0", "7100" - DECnet - decnet - name of a DECnet addressable host - string containing the complete name of the object. Example: "X$X0" + DECnet + decnet + name of a DECnet addressable host + string containing the complete name of the object. Example: "X$X0" - NETware - ipx - name of a NETware addressable host - Not sure of the specifics yet. + NETware + ipx + name of a NETware addressable host + Not sure of the specifics yet. - OSI - osi - name of an OSI adressable host. - Not sure of the specifics yet. + OSI + osi + name of an OSI adressable host. + Not sure of the specifics yet. - Local - local pts named sco isc - (ignored) - String containing the port name, ie "xserver0", "fontserver0". + Local + local pts named sco isc + (ignored) + String containing the port name, ie "xserver0", "fontserver0". @@ -1081,7 +1076,7 @@ In X11R7 modular releases, these flags are set when running - + Implementation Notes This section refers to the prototype implementation that is being developed diff --git a/lib/libxtrans/docbook.am b/lib/libxtrans/docbook.am new file mode 100644 index 000000000..bba4d5453 --- /dev/null +++ b/lib/libxtrans/docbook.am @@ -0,0 +1,105 @@ +# +# Generate output formats for a single DocBook/XML with/without chapters +# +# Variables set by the calling Makefile: +# shelfdir: the location where the docs/specs are installed. Typically $(docdir) +# docbook: the main DocBook/XML file, no chapters, appendix or image files +# chapters: all files pulled in by an XInclude statement and images. +# + +# +# This makefile is intended for Users Documentation and Functional Specifications. +# Do not use for Developer Documentation which is not installed and does not require olink. +# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393 +# for an explanation on documents classification. +# + +# DocBook/XML generated output formats to be installed +shelf_DATA = + +# DocBook/XML file with chapters, appendix and images it includes +dist_shelf_DATA = $(docbook) $(chapters) + +if HAVE_XMLTO +if HAVE_STYLESHEETS + +XMLTO_SEARCHPATH_FLAGS = \ + --searchpath "$(XORG_SGML_PATH)/X11" \ + --searchpath "$(abs_top_builddir)" +XMLTO_HTML_OLINK_FLAGS = \ + --stringparam target.database.document=$(XORG_SGML_PATH)/X11/dbs/masterdb.html.xml \ + --stringparam current.docid="$(<:.xml=)" +XMLTO_HTML_STYLESHEET_FLAGS = -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl +XMLTO_HTML_FLAGS = \ + $(XMLTO_SEARCHPATH_FLAGS) \ + $(XMLTO_HTML_STYLESHEET_FLAGS) \ + $(XMLTO_HTML_OLINK_FLAGS) + +shelf_DATA += $(docbook:.xml=.html) +%.html: %.xml $(chapters) + $(AM_V_GEN)$(XMLTO) $(XMLTO_HTML_FLAGS) xhtml-nochunks $< + +if HAVE_XMLTO_TEXT + +shelf_DATA += $(docbook:.xml=.txt) +%.txt: %.xml $(chapters) + $(AM_V_GEN)$(XMLTO) $(XMLTO_HTML_FLAGS) txt $< +endif HAVE_XMLTO_TEXT + +if HAVE_FOP +XMLTO_FO_IMAGEPATH_FLAGS = --stringparam img.src.path=$(abs_builddir)/ +XMLTO_PDF_OLINK_FLAGS = \ + --stringparam target.database.document=$(XORG_SGML_PATH)/X11/dbs/masterdb.pdf.xml \ + --stringparam current.docid="$(<:.xml=)" +XMLTO_FO_STYLESHEET_FLAGS = -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl + +XMLTO_FO_FLAGS = \ + $(XMLTO_SEARCHPATH_FLAGS) \ + $(XMLTO_FO_STYLESHEET_FLAGS) \ + $(XMLTO_FO_IMAGEPATH_FLAGS) \ + $(XMLTO_PDF_OLINK_FLAGS) + +shelf_DATA += $(docbook:.xml=.pdf) +%.pdf: %.xml $(chapters) + $(AM_V_GEN)$(XMLTO) $(XMLTO_FO_FLAGS) --with-fop pdf $< + +shelf_DATA += $(docbook:.xml=.ps) +%.ps: %.xml $(chapters) + $(AM_V_GEN)$(XMLTO) $(XMLTO_FO_FLAGS) --with-fop ps $< +endif HAVE_FOP + +# Generate documents cross-reference target databases +if HAVE_XSLTPROC + +XSLT_SEARCHPATH_FLAGS = \ + --path "$(XORG_SGML_PATH)/X11" \ + --path "$(abs_top_builddir)" +XSLT_OLINK_FLAGS = \ + --stringparam targets.filename "$@" \ + --stringparam collect.xref.targets "only" \ + --stringparam olink.base.uri "$(@:.db=)" + +XSLT_HTML_FLAGS = \ + $(XSLT_SEARCHPATH_FLAGS) \ + $(XSLT_OLINK_FLAGS) \ + --nonet --xinclude \ + $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl +XSLT_PDF_FLAGS = \ + $(XSLT_SEARCHPATH_FLAGS) \ + $(XSLT_OLINK_FLAGS) \ + --nonet --xinclude \ + $(STYLESHEET_SRCDIR)/xorg-fo.xsl + +shelf_DATA += $(docbook:.xml=.html.db) +%.html.db: %.xml $(chapters) + $(AM_V_GEN)$(XSLTPROC) $(XSLT_HTML_FLAGS) $< + +shelf_DATA += $(docbook:.xml=.pdf.db) +%.pdf.db: %.xml $(chapters) + $(AM_V_GEN)$(XSLTPROC) $(XSLT_PDF_FLAGS) $< + +endif HAVE_XSLTPROC +endif HAVE_STYLESHEETS +endif HAVE_XMLTO + +CLEANFILES = $(shelf_DATA) diff --git a/lib/libxtrans/transport.c b/lib/libxtrans/transport.c index 5131d99e4..2cb88825e 100644 --- a/lib/libxtrans/transport.c +++ b/lib/libxtrans/transport.c @@ -47,19 +47,19 @@ from The Open Group. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#ifdef XSERV_t -#include "os.h" -#else #include -#define xalloc(_size) malloc(_size) -#define xcalloc(_num,_size) calloc(_num,_size) -#define xrealloc(_ptr,_size) realloc(_ptr,_size) -#define xfree(_ptr) free(_ptr) -#endif + +#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__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + #ifdef LOCALCONN #include "Xtranslcl.c" #endif @@ -71,3 +71,7 @@ from The Open Group. #endif #include "Xtrans.c" #include "Xtransutil.c" + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/lib/libxtrans/xtrans.m4 b/lib/libxtrans/xtrans.m4 index da35a759d..91c6f9d2f 100644 --- a/lib/libxtrans/xtrans.m4 +++ b/lib/libxtrans/xtrans.m4 @@ -33,9 +33,9 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[ fi # Needs to come after above checks for libsocket & libnsl for SVR4 systems - AC_ARG_ENABLE(ipv6, + AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]), - [IPV6CONN=$enableval], + [IPV6CONN=$enableval], [AC_CHECK_FUNC(getaddrinfo,[IPV6CONN=yes],[IPV6CONN=no])]) AC_MSG_CHECKING([if IPv6 support should be built]) if test "$IPV6CONN" = "yes"; then @@ -44,7 +44,7 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[ AC_MSG_RESULT($IPV6CONN) # 4.3BSD-Reno added a new member to struct sockaddr_in - AC_CHECK_MEMBER([struct sockaddr_in.sin_len], + AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE([BSD44SOCKETS],1, [Define to 1 if `struct sockaddr_in' has a `sin_len' member]), [], [ #include @@ -56,7 +56,7 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[ AC_CHECK_TYPES([socklen_t], [], [], [ AC_INCLUDES_DEFAULT #include ]) - + ]) # XTRANS_TCP_FLAGS # XTRANS_CONNECTION_FLAGS() @@ -78,7 +78,7 @@ AC_DEFUN([XTRANS_CONNECTION_FLAGS],[ AC_DEFINE(UNIXCONN,1,[Support UNIX socket connections]) fi AC_MSG_RESULT($UNIXCONN) - AC_ARG_ENABLE(tcp-transport, + AC_ARG_ENABLE(tcp-transport, AC_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]), [TCPCONN=$enableval], [TCPCONN=yes]) AC_MSG_CHECKING([if Xtrans should support TCP socket connections]) @@ -99,7 +99,7 @@ AC_DEFUN([XTRANS_CONNECTION_FLAGS],[ if test "$LOCALCONN" = "yes"; then AC_DEFINE(LOCALCONN,1,[Support os-specific local connections]) fi - + ]) # XTRANS_CONNECTION_FLAGS @@ -109,7 +109,7 @@ AC_DEFUN([XTRANS_CONNECTION_FLAGS],[ # so that any necessary networking libraries are already found AC_DEFUN([XTRANS_SECURE_RPC_FLAGS], [AC_REQUIRE([XTRANS_TCP_FLAGS]) - AC_ARG_ENABLE(secure-rpc, + AC_ARG_ENABLE(secure-rpc, AC_HELP_STRING([--enable-secure-rpc],[Enable Secure RPC]), [SECURE_RPC=$enableval], [SECURE_RPC="try"]) @@ -120,7 +120,7 @@ AC_DEFUN([XTRANS_SECURE_RPC_FLAGS], if test "x$FOUND_SECURE_RPC" = "xno" ; then if test "x$SECURE_RPC" = "xyes" ; then AC_MSG_ERROR([Secure RPC requested, but required functions not found]) - fi + fi SECURE_RPC="no" else dnl FreeBSD keeps getsecretkey in librpcsvc