aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorKim F. Storm2002-10-24 08:03:41 +0000
committerKim F. Storm2002-10-24 08:03:41 +0000
commit991234f01a74af9d172973a9147429404be4d384 (patch)
tree728b17d4def8c97282930d3d9c239edfbde723af /src/process.c
parent9c1e9d548fcd946e990779aa48c97e8e675b52e6 (diff)
downloademacs-991234f01a74af9d172973a9147429404be4d384.tar.gz
emacs-991234f01a74af9d172973a9147429404be4d384.zip
(Fformat_network_address): New function.
(syms_of_process): Defsubr it. (list_processes_1): Use it to format :local/:remote address if service/host is not set; before emacs would crash in that case. (Fmake_network_process): Don't use Ffind_operation_coding_system to setup coding system if host or service is not set.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c89
1 files changed, 76 insertions, 13 deletions
diff --git a/src/process.c b/src/process.c
index 6f96281ae74..7af60a08742 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1043,6 +1043,54 @@ a socket connection. */)
1043 return XPROCESS (process)->type; 1043 return XPROCESS (process)->type;
1044} 1044}
1045#endif 1045#endif
1046
1047#ifdef HAVE_SOCKETS
1048DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address,
1049 1, 1, 0,
1050 doc: /* Convert network ADDRESS from internal format to a string.
1051Returns nil if format of ADDRESS is invalid. */)
1052 (address)
1053 Lisp_Object address;
1054{
1055 register struct Lisp_Vector *p;
1056 register unsigned char *cp;
1057 register int i;
1058
1059 if (NILP (address))
1060 return Qnil;
1061
1062 if (STRINGP (address)) /* AF_LOCAL */
1063 return address;
1064
1065 if (VECTORP (address)) /* AF_INET */
1066 {
1067 register struct Lisp_Vector *p = XVECTOR (address);
1068 Lisp_Object args[6];
1069
1070 if (p->size != 5)
1071 return Qnil;
1072
1073 args[0] = build_string ("%d.%d.%d.%d:%d");
1074 args[1] = XINT (p->contents[0]);
1075 args[2] = XINT (p->contents[1]);
1076 args[3] = XINT (p->contents[2]);
1077 args[4] = XINT (p->contents[3]);
1078 args[5] = XINT (p->contents[4]);
1079 return Fformat (6, args);
1080 }
1081
1082 if (CONSP (address))
1083 {
1084 Lisp_Object args[2];
1085 args[0] = build_string ("<Family %d>");
1086 args[1] = XINT (Fcar (address));
1087 return Fformat (2, args);
1088
1089 }
1090
1091 return Qnil;
1092}
1093#endif
1046 1094
1047Lisp_Object 1095Lisp_Object
1048list_processes_1 (query_only) 1096list_processes_1 (query_only)
@@ -1204,9 +1252,11 @@ list_processes_1 (query_only)
1204 Lisp_Object port = Fplist_get (p->childp, QCservice); 1252 Lisp_Object port = Fplist_get (p->childp, QCservice);
1205 if (INTEGERP (port)) 1253 if (INTEGERP (port))
1206 port = Fnumber_to_string (port); 1254 port = Fnumber_to_string (port);
1255 if (NILP (port))
1256 port = Fformat_network_address (Fplist_get (p->childp, QClocal));
1207 sprintf (tembuf, "(network %s server on %s)\n", 1257 sprintf (tembuf, "(network %s server on %s)\n",
1208 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), 1258 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"),
1209 SDATA (port)); 1259 (STRINGP (port) ? (char *)SDATA (port) : "?"));
1210 insert_string (tembuf); 1260 insert_string (tembuf);
1211 } 1261 }
1212 else if (NETCONN1_P (p)) 1262 else if (NETCONN1_P (p))
@@ -1220,9 +1270,11 @@ list_processes_1 (query_only)
1220 if (INTEGERP (host)) 1270 if (INTEGERP (host))
1221 host = Fnumber_to_string (host); 1271 host = Fnumber_to_string (host);
1222 } 1272 }
1273 if (NILP (host))
1274 host = Fformat_network_address (Fplist_get (p->childp, QCremote));
1223 sprintf (tembuf, "(network %s connection to %s)\n", 1275 sprintf (tembuf, "(network %s connection to %s)\n",
1224 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), 1276 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"),
1225 SDATA (host)); 1277 (STRINGP (host) ? (char *)SDATA (host) : "?"));
1226 insert_string (tembuf); 1278 insert_string (tembuf);
1227 } 1279 }
1228 else 1280 else
@@ -2498,7 +2550,7 @@ The stopped state is cleared by `continue-process' and set by
2498:sentinel SENTINEL -- Install SENTINEL as the process sentinel. 2550:sentinel SENTINEL -- Install SENTINEL as the process sentinel.
2499 2551
2500:log LOG -- Install LOG as the server process log function. This 2552:log LOG -- Install LOG as the server process log function. This
2501function is called as when the server accepts a network connection from a 2553function is called when the server accepts a network connection from a
2502client. The arguments are SERVER, CLIENT, and MESSAGE, where SERVER 2554client. The arguments are SERVER, CLIENT, and MESSAGE, where SERVER
2503is the server process, CLIENT is the new process for the connection, 2555is the server process, CLIENT is the new process for the connection,
2504and MESSAGE is a string. 2556and MESSAGE is a string.
@@ -3134,11 +3186,16 @@ usage: (make-network-process &rest ARGS) */)
3134 val = Qnil; 3186 val = Qnil;
3135 else 3187 else
3136 { 3188 {
3137 args[0] = Qopen_network_stream, args[1] = name, 3189 if (NILP (host) || NILP (service))
3138 args[2] = buffer, args[3] = host, args[4] = service; 3190 coding_systems = Qnil;
3139 GCPRO1 (proc); 3191 else
3140 coding_systems = Ffind_operation_coding_system (5, args); 3192 {
3141 UNGCPRO; 3193 args[0] = Qopen_network_stream, args[1] = name,
3194 args[2] = buffer, args[3] = host, args[4] = service;
3195 GCPRO1 (proc);
3196 coding_systems = Ffind_operation_coding_system (5, args);
3197 UNGCPRO;
3198 }
3142 if (CONSP (coding_systems)) 3199 if (CONSP (coding_systems))
3143 val = XCAR (coding_systems); 3200 val = XCAR (coding_systems);
3144 else if (CONSP (Vdefault_process_coding_system)) 3201 else if (CONSP (Vdefault_process_coding_system))
@@ -3158,11 +3215,16 @@ usage: (make-network-process &rest ARGS) */)
3158 { 3215 {
3159 if (EQ (coding_systems, Qt)) 3216 if (EQ (coding_systems, Qt))
3160 { 3217 {
3161 args[0] = Qopen_network_stream, args[1] = name, 3218 if (NILP (host) || NILP (service))
3162 args[2] = buffer, args[3] = host, args[4] = service; 3219 coding_systems = Qnil;
3163 GCPRO1 (proc); 3220 else
3164 coding_systems = Ffind_operation_coding_system (5, args); 3221 {
3165 UNGCPRO; 3222 args[0] = Qopen_network_stream, args[1] = name,
3223 args[2] = buffer, args[3] = host, args[4] = service;
3224 GCPRO1 (proc);
3225 coding_systems = Ffind_operation_coding_system (5, args);
3226 UNGCPRO;
3227 }
3166 } 3228 }
3167 if (CONSP (coding_systems)) 3229 if (CONSP (coding_systems))
3168 val = XCDR (coding_systems); 3230 val = XCDR (coding_systems);
@@ -6232,6 +6294,7 @@ The value takes effect when `start-process' is called. */);
6232#ifdef HAVE_SOCKETS 6294#ifdef HAVE_SOCKETS
6233 defsubr (&Sset_network_process_options); 6295 defsubr (&Sset_network_process_options);
6234 defsubr (&Smake_network_process); 6296 defsubr (&Smake_network_process);
6297 defsubr (&Sformat_network_address);
6235#endif /* HAVE_SOCKETS */ 6298#endif /* HAVE_SOCKETS */
6236#ifdef DATAGRAM_SOCKETS 6299#ifdef DATAGRAM_SOCKETS
6237 defsubr (&Sprocess_datagram_address); 6300 defsubr (&Sprocess_datagram_address);