diff options
Diffstat (limited to 'Xtrans.c')
-rw-r--r-- | Xtrans.c | 48 |
1 files changed, 25 insertions, 23 deletions
@@ -202,14 +202,36 @@ TRANS(ParseAddress) (const char *address, * If a "::" is found then assume DNET. */ - char *mybuf, *tmpptr; - const char *_protocol; + char *mybuf, *tmpptr = NULL; + const char *_protocol = NULL; char *_host, *_port; char hostnamebuf[256]; int _host_len; prmsg (3,"ParseAddress(%s)\n", address); + /* First, check for AF_UNIX socket paths */ + if (address[0] == '/') { + _protocol = "local"; + _host = ""; + _port = address; + } else +#ifdef HAVE_LAUNCHD + /* launchd sockets will look like 'local//tmp/launch-XgkNns/:0' */ + if(!strncmp(address,"local//",7)) { + _protocol="local"; + _host=""; + _port=address+6; + } else +#endif + if (!strncmp(address, "unix:", 5)) { + _protocol = "local"; + _host = ""; + _port = address + 5; + } + if (_protocol) + goto done_parsing; + /* Copy the string so it can be changed */ tmpptr = mybuf = strdup (address); @@ -331,27 +353,7 @@ TRANS(ParseAddress) (const char *address, */ #endif - if (address != NULL) { - if (address[0] == '/') { - _protocol = "local"; - _host = ""; - _port = address; - } else -#ifdef HAVE_LAUNCHD - /* launchd sockets will look like 'local//tmp/launch-XgkNns/:0' */ - if(!strncmp(address,"local//",7)) { - _protocol="local"; - _host=""; - _port=address+6; - } else -#endif - if (!strncmp(address, "unix:", 5)) { - _protocol = "local"; - _host = ""; - _port = address + 5; - } - } - +done_parsing: /* * Now that we have all of the components, allocate new * string space for them. |