aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-01-29 00:25:07 +0100
committerLars Ingebrigtsen2016-01-29 00:25:07 +0100
commit7c6a60fa2c7f7c8b3f5b2effdda1b3ce9e231071 (patch)
treebb369edc2be0eae692883451415d90dc71d3ac50 /src/process.c
parentb013e6a90c0d5f734f37ffafdc848ab94e92380d (diff)
downloademacs-7c6a60fa2c7f7c8b3f5b2effdda1b3ce9e231071.tar.gz
emacs-7c6a60fa2c7f7c8b3f5b2effdda1b3ce9e231071.zip
Return IP addresses in the correct order
* src/process.c (Fmake_network_process): Return the IP addresses in the same order as getaddrinfo does. (set_network_socket_coding_system): Clean up the code slightly.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c141
1 files changed, 72 insertions, 69 deletions
diff --git a/src/process.c b/src/process.c
index 1329d968e28..2f7668a555e 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2904,11 +2904,14 @@ usage: (make-serial-process &rest ARGS) */)
2904 return proc; 2904 return proc;
2905} 2905}
2906 2906
2907void set_network_socket_coding_system (Lisp_Object proc) { 2907void set_network_socket_coding_system (Lisp_Object proc)
2908{
2908 Lisp_Object tem; 2909 Lisp_Object tem;
2909 struct Lisp_Process *p = XPROCESS (proc); 2910 struct Lisp_Process *p = XPROCESS (proc);
2910 Lisp_Object contact = p->childp; 2911 Lisp_Object contact = p->childp;
2911 Lisp_Object service, host, name; 2912 Lisp_Object service, host, name;
2913 Lisp_Object coding_systems = Qt;
2914 Lisp_Object val;
2912 2915
2913 service = Fplist_get (contact, QCservice); 2916 service = Fplist_get (contact, QCservice);
2914 host = Fplist_get (contact, QChost); 2917 host = Fplist_get (contact, QChost);
@@ -2918,75 +2921,72 @@ void set_network_socket_coding_system (Lisp_Object proc) {
2918 if (!NILP (tem) && (!CONSP (tem) || !CONSP (XCDR (tem)))) 2921 if (!NILP (tem) && (!CONSP (tem) || !CONSP (XCDR (tem))))
2919 tem = Qnil; /* No error message (too late!). */ 2922 tem = Qnil; /* No error message (too late!). */
2920 2923
2921 { 2924 /* Setup coding systems for communicating with the network stream. */
2922 /* Setup coding systems for communicating with the network stream. */ 2925 /* Qt denotes we have not yet called Ffind_operation_coding_system. */
2923 /* Qt denotes we have not yet called Ffind_operation_coding_system. */
2924 Lisp_Object coding_systems = Qt;
2925 Lisp_Object val;
2926 2926
2927 if (!NILP (tem)) 2927 if (!NILP (tem))
2928 { 2928 {
2929 val = XCAR (XCDR (tem)); 2929 val = XCAR (XCDR (tem));
2930 if (CONSP (val)) 2930 if (CONSP (val))
2931 val = XCAR (val); 2931 val = XCAR (val);
2932 } 2932 }
2933 else if (!NILP (Vcoding_system_for_read)) 2933 else if (!NILP (Vcoding_system_for_read))
2934 val = Vcoding_system_for_read; 2934 val = Vcoding_system_for_read;
2935 else if ((!NILP (p->buffer) && 2935 else if ((!NILP (p->buffer) &&
2936 NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters))) 2936 NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters)))
2937 || (NILP (p->buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))) 2937 || (NILP (p->buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
2938 /* We dare not decode end-of-line format by setting VAL to 2938 /* We dare not decode end-of-line format by setting VAL to
2939 Qraw_text, because the existing Emacs Lisp libraries 2939 Qraw_text, because the existing Emacs Lisp libraries
2940 assume that they receive bare code including a sequence of 2940 assume that they receive bare code including a sequence of
2941 CR LF. */ 2941 CR LF. */
2942 val = Qnil; 2942 val = Qnil;
2943 else 2943 else
2944 { 2944 {
2945 if (NILP (host) || NILP (service)) 2945 if (NILP (host) || NILP (service))
2946 coding_systems = Qnil; 2946 coding_systems = Qnil;
2947 else 2947 else
2948 coding_systems = CALLN (Ffind_operation_coding_system, 2948 coding_systems = CALLN (Ffind_operation_coding_system,
2949 Qopen_network_stream, name, p->buffer, 2949 Qopen_network_stream, name, p->buffer,
2950 host, service); 2950 host, service);
2951 if (CONSP (coding_systems)) 2951 if (CONSP (coding_systems))
2952 val = XCAR (coding_systems); 2952 val = XCAR (coding_systems);
2953 else if (CONSP (Vdefault_process_coding_system)) 2953 else if (CONSP (Vdefault_process_coding_system))
2954 val = XCAR (Vdefault_process_coding_system); 2954 val = XCAR (Vdefault_process_coding_system);
2955 else 2955 else
2956 val = Qnil; 2956 val = Qnil;
2957 } 2957 }
2958 pset_decode_coding_system (p, val); 2958 pset_decode_coding_system (p, val);
2959
2960 if (!NILP (tem))
2961 {
2962 val = XCAR (XCDR (tem));
2963 if (CONSP (val))
2964 val = XCDR (val);
2965 }
2966 else if (!NILP (Vcoding_system_for_write))
2967 val = Vcoding_system_for_write;
2968 else if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
2969 val = Qnil;
2970 else
2971 {
2972 if (EQ (coding_systems, Qt))
2973 {
2974 if (NILP (host) || NILP (service))
2975 coding_systems = Qnil;
2976 else
2977 coding_systems = CALLN (Ffind_operation_coding_system,
2978 Qopen_network_stream, name, p->buffer,
2979 host, service);
2980 }
2981 if (CONSP (coding_systems))
2982 val = XCDR (coding_systems);
2983 else if (CONSP (Vdefault_process_coding_system))
2984 val = XCDR (Vdefault_process_coding_system);
2985 else
2986 val = Qnil;
2987 }
2988 pset_encode_coding_system (p, val);
2959 2989
2960 if (!NILP (tem))
2961 {
2962 val = XCAR (XCDR (tem));
2963 if (CONSP (val))
2964 val = XCDR (val);
2965 }
2966 else if (!NILP (Vcoding_system_for_write))
2967 val = Vcoding_system_for_write;
2968 else if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
2969 val = Qnil;
2970 else
2971 {
2972 if (EQ (coding_systems, Qt))
2973 {
2974 if (NILP (host) || NILP (service))
2975 coding_systems = Qnil;
2976 else
2977 coding_systems = CALLN (Ffind_operation_coding_system,
2978 Qopen_network_stream, name, p->buffer,
2979 host, service);
2980 }
2981 if (CONSP (coding_systems))
2982 val = XCDR (coding_systems);
2983 else if (CONSP (Vdefault_process_coding_system))
2984 val = XCDR (Vdefault_process_coding_system);
2985 else
2986 val = Qnil;
2987 }
2988 pset_encode_coding_system (p, val);
2989 }
2990 setup_process_coding_systems (proc); 2990 setup_process_coding_systems (proc);
2991 2991
2992 pset_decoding_buf (p, empty_unibyte_string); 2992 pset_decoding_buf (p, empty_unibyte_string);
@@ -2997,7 +2997,8 @@ void set_network_socket_coding_system (Lisp_Object proc) {
2997 = !(!NILP (tem) || NILP (p->buffer) || !inherit_process_coding_system); 2997 = !(!NILP (tem) || NILP (p->buffer) || !inherit_process_coding_system);
2998} 2998}
2999 2999
3000void connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses) { 3000void connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
3001{
3001 ptrdiff_t count = SPECPDL_INDEX (); 3002 ptrdiff_t count = SPECPDL_INDEX ();
3002 ptrdiff_t count1; 3003 ptrdiff_t count1;
3003 int s = -1, outch, inch; 3004 int s = -1, outch, inch;
@@ -3659,6 +3660,8 @@ usage: (make-network-process &rest ARGS) */)
3659 family = lres->ai_family; 3660 family = lres->ai_family;
3660 } 3661 }
3661 3662
3663 ip_addresses = Fnreverse (ip_addresses);
3664
3662 goto open_socket; 3665 goto open_socket;
3663 } 3666 }
3664#endif /* HAVE_GETADDRINFO */ 3667#endif /* HAVE_GETADDRINFO */