aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2016-03-07 18:54:25 -0800
committerPaul Eggert2016-03-07 18:55:20 -0800
commit59c7a5d71145d88933a535e222bdf30105e7d382 (patch)
tree04724485be6c619e6257873f7d05c2ae51bcbb64 /src/process.c
parent6bc8689c042830ae8c13e34af993e8f923e47c9d (diff)
downloademacs-59c7a5d71145d88933a535e222bdf30105e7d382.tar.gz
emacs-59c7a5d71145d88933a535e222bdf30105e7d382.zip
Assume getaddrinfo in C code
* admin/CPP-DEFINES, configure.ac: Remove HAVE_GETADDRINFO, HAVE_H_ERRNO. All uses removed. * doc/lispref/processes.texi (Network, Network Processes), etc/NEWS: Say that port numbers can be integer strings. * lib-src/pop.c (h_errno) [!WINDOWSNT && !HAVE_H_ERRNO]: Remove decl. (socket_connection): Assume HAVE_GETADDRINFO. * lisp/mpc.el (mpc--proc-connect): * lisp/net/network-stream.el (open-network-stream): It’s now OK to use integer strings as port numbers. * src/process.c (conv_numerical_to_lisp) [!HAVE_GETADDRINFO]: Remove. (Fmake_network_process): Assume HAVE_GETADDRINFO.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c68
1 files changed, 4 insertions, 64 deletions
diff --git a/src/process.c b/src/process.c
index 69f5e1ddca6..359cd2195aa 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3429,21 +3429,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
3429 3429
3430} 3430}
3431 3431
3432#ifndef HAVE_GETADDRINFO
3433static Lisp_Object
3434conv_numerical_to_lisp (unsigned char *number, int length, int port)
3435{
3436 Lisp_Object address = Fmake_vector (make_number (length + 1), Qnil);
3437 struct Lisp_Vector *p = XVECTOR (address);
3438
3439 p->contents[length] = make_number (port);
3440 for (int i = 0; i < length; i++)
3441 p->contents[i] = make_number (number[i]);
3442
3443 return address;
3444}
3445#endif
3446
3447/* Create a network stream/datagram client/server process. Treated 3432/* Create a network stream/datagram client/server process. Treated
3448 exactly like a normal process when reading and writing. Primary 3433 exactly like a normal process when reading and writing. Primary
3449 differences are in status display and process deletion. A network 3434 differences are in status display and process deletion. A network
@@ -3479,9 +3464,8 @@ host, and only clients connecting to that address will be accepted.
3479 3464
3480:service SERVICE -- SERVICE is name of the service desired, or an 3465:service SERVICE -- SERVICE is name of the service desired, or an
3481integer specifying a port number to connect to. If SERVICE is t, 3466integer specifying a port number to connect to. If SERVICE is t,
3482a random port number is selected for the server. (If Emacs was 3467a random port number is selected for the server. A port number can
3483compiled with getaddrinfo, a port number can also be specified as a 3468be specified as an integer string, e.g., "80", as well as an integer.
3484string, e.g. "80", as well as an integer. This is not portable.)
3485 3469
3486:type TYPE -- TYPE is the type of connection. The default (nil) is a 3470:type TYPE -- TYPE is the type of connection. The default (nil) is a
3487stream type connection, `datagram' creates a datagram type connection, 3471stream type connection, `datagram' creates a datagram type connection,
@@ -3614,11 +3598,9 @@ usage: (make-network-process &rest ARGS) */)
3614 Lisp_Object proc; 3598 Lisp_Object proc;
3615 Lisp_Object contact; 3599 Lisp_Object contact;
3616 struct Lisp_Process *p; 3600 struct Lisp_Process *p;
3617#if defined HAVE_GETADDRINFO || defined HAVE_GETADDRINFO_A
3618 const char *portstring; 3601 const char *portstring;
3619 ptrdiff_t portstringlen ATTRIBUTE_UNUSED; 3602 ptrdiff_t portstringlen ATTRIBUTE_UNUSED;
3620 char portbuf[INT_BUFSIZE_BOUND (EMACS_INT)]; 3603 char portbuf[INT_BUFSIZE_BOUND (EMACS_INT)];
3621#endif
3622#ifdef HAVE_LOCAL_SOCKETS 3604#ifdef HAVE_LOCAL_SOCKETS
3623 struct sockaddr_un address_un; 3605 struct sockaddr_un address_un;
3624#endif 3606#endif
@@ -3689,7 +3671,7 @@ usage: (make-network-process &rest ARGS) */)
3689 tem = Fplist_get (contact, QCfamily); 3671 tem = Fplist_get (contact, QCfamily);
3690 if (NILP (tem)) 3672 if (NILP (tem))
3691 { 3673 {
3692#if defined (HAVE_GETADDRINFO) && defined (AF_INET6) 3674#ifdef AF_INET6
3693 family = AF_UNSPEC; 3675 family = AF_UNSPEC;
3694#else 3676#else
3695 family = AF_INET; 3677 family = AF_INET;
@@ -3761,7 +3743,6 @@ usage: (make-network-process &rest ARGS) */)
3761 } 3743 }
3762#endif 3744#endif
3763 3745
3764#if defined HAVE_GETADDRINFO || defined HAVE_GETADDRINFO_A
3765 if (!NILP (host)) 3746 if (!NILP (host))
3766 { 3747 {
3767 /* SERVICE can either be a string or int. 3748 /* SERVICE can either be a string or int.
@@ -3783,7 +3764,6 @@ usage: (make-network-process &rest ARGS) */)
3783 portstringlen = SBYTES (service); 3764 portstringlen = SBYTES (service);
3784 } 3765 }
3785 } 3766 }
3786#endif
3787 3767
3788#ifdef HAVE_GETADDRINFO_A 3768#ifdef HAVE_GETADDRINFO_A
3789 if (!NILP (host) && !NILP (Fplist_get (contact, QCnowait))) 3769 if (!NILP (host) && !NILP (Fplist_get (contact, QCnowait)))
@@ -3815,7 +3795,6 @@ usage: (make-network-process &rest ARGS) */)
3815 } 3795 }
3816#endif /* HAVE_GETADDRINFO_A */ 3796#endif /* HAVE_GETADDRINFO_A */
3817 3797
3818#ifdef HAVE_GETADDRINFO
3819 /* If we have a host, use getaddrinfo to resolve both host and service. 3798 /* If we have a host, use getaddrinfo to resolve both host and service.
3820 Otherwise, use getservbyname to lookup the service. */ 3799 Otherwise, use getservbyname to lookup the service. */
3821 3800
@@ -3855,10 +3834,8 @@ usage: (make-network-process &rest ARGS) */)
3855 3834
3856 goto open_socket; 3835 goto open_socket;
3857 } 3836 }
3858#endif /* HAVE_GETADDRINFO */
3859 3837
3860 /* We end up here if getaddrinfo is not defined, or in case no hostname 3838 /* No hostname has been specified (e.g., a local server process). */
3861 has been specified (e.g. for a local server process). */
3862 3839
3863 if (EQ (service, Qt)) 3840 if (EQ (service, Qt))
3864 port = 0; 3841 port = 0;
@@ -3894,43 +3871,6 @@ usage: (make-network-process &rest ARGS) */)
3894 xsignal1 (Qerror, CALLN (Fformat, unknown_service, service)); 3871 xsignal1 (Qerror, CALLN (Fformat, unknown_service, service));
3895 } 3872 }
3896 3873
3897#ifndef HAVE_GETADDRINFO
3898 if (!NILP (host))
3899 {
3900 struct hostent *host_info_ptr;
3901 unsigned char *addr;
3902 int addrlen;
3903
3904 /* gethostbyname may fail with TRY_AGAIN, but we don't honor that,
3905 as it may `hang' Emacs for a very long time. */
3906 immediate_quit = 1;
3907 QUIT;
3908
3909 host_info_ptr = gethostbyname ((const char *) SDATA (host));
3910 immediate_quit = 0;
3911
3912 if (host_info_ptr)
3913 {
3914 addr = (unsigned char *) host_info_ptr->h_addr;
3915 addrlen = host_info_ptr->h_length;
3916 }
3917 else
3918 /* Attempt to interpret host as numeric inet address. This
3919 only works for IPv4 addresses. */
3920 {
3921 unsigned long numeric_addr = inet_addr (SSDATA (host));
3922
3923 if (numeric_addr == -1)
3924 error ("Unknown host \"%s\"", SDATA (host));
3925
3926 addr = (unsigned char *) &numeric_addr;
3927 addrlen = 4;
3928 }
3929
3930 ip_addresses = list1 (conv_numerical_to_lisp (addr, addrlen, port));
3931 }
3932#endif /* not HAVE_GETADDRINFO */
3933
3934 open_socket: 3874 open_socket:
3935 3875
3936 if (!NILP (buffer)) 3876 if (!NILP (buffer))