Commit e7650ba6 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Allow using "number strings" as services on non-GNU systems

* src/process.c (string_integer_p): New function.
(Fmake_network_process): Use it to allow connecting to
services specified as "993" even when getaddrbyname isn't
available.
parent ce6a03cb
...@@ -3428,6 +3428,17 @@ conv_numerical_to_lisp (unsigned char *number, int length, int port) ...@@ -3428,6 +3428,17 @@ conv_numerical_to_lisp (unsigned char *number, int length, int port)
} }
#endif #endif
/* Return true if STRING consists only of numerical characters. */
static bool
string_integer_p (Lisp_Object string)
{
char *s = SSDATA (string), c;
while ((c = *s++))
if (c < '0' || c > '9')
return false;
return true;
}
/* Create a network stream/datagram client/server process. Treated /* Create a network stream/datagram client/server process. Treated
exactly like a normal process when reading and writing. Primary exactly like a normal process when reading and writing. Primary
differences are in status display and process deletion. A network differences are in status display and process deletion. A network
...@@ -3852,6 +3863,10 @@ usage: (make-network-process &rest ARGS) */) ...@@ -3852,6 +3863,10 @@ usage: (make-network-process &rest ARGS) */)
port = 0; port = 0;
else if (INTEGERP (service)) else if (INTEGERP (service))
port = (unsigned short) XINT (service); port = (unsigned short) XINT (service);
/* Allow the service to be a string containing the port number,
because that's allowed if you have getaddrbyname. */
else if (string_integer_p (service))
port = strtol (SSDATA (service), NULL, 10);
else else
{ {
struct servent *svc_info; struct servent *svc_info;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment