aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorKim F. Storm2003-01-08 15:35:03 +0000
committerKim F. Storm2003-01-08 15:35:03 +0000
commit0dccee41bdaaa72630cafd355c037d56658b8808 (patch)
tree65d22bced7bdf70b4447facc0d30571bba1288d8 /src/process.c
parent06e022f657947e8c9c068b814cde2b7d7cadea17 (diff)
downloademacs-0dccee41bdaaa72630cafd355c037d56658b8808.tar.gz
emacs-0dccee41bdaaa72630cafd355c037d56658b8808.zip
(format-network-address): Added optional OMIT-PORT arg. Callers changed.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/process.c b/src/process.c
index 482b24c165b..6017801a659 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1052,11 +1052,13 @@ a socket connection. */)
1052 1052
1053#ifdef HAVE_SOCKETS 1053#ifdef HAVE_SOCKETS
1054DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address, 1054DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address,
1055 1, 1, 0, 1055 1, 2, 0,
1056 doc: /* Convert network ADDRESS from internal format to a string. 1056 doc: /* Convert network ADDRESS from internal format to a string.
1057Returns nil if format of ADDRESS is invalid. */) 1057If optional second argument OMIT-PORT is non-nil, don't include a port
1058 (address) 1058number in the string; in this case, interpret a 4 element vector as an
1059 Lisp_Object address; 1059IP address. Returns nil if format of ADDRESS is invalid. */)
1060 (address, omit_port)
1061 Lisp_Object address, omit_port;
1060{ 1062{
1061 if (NILP (address)) 1063 if (NILP (address))
1062 return Qnil; 1064 return Qnil;
@@ -1068,17 +1070,24 @@ Returns nil if format of ADDRESS is invalid. */)
1068 { 1070 {
1069 register struct Lisp_Vector *p = XVECTOR (address); 1071 register struct Lisp_Vector *p = XVECTOR (address);
1070 Lisp_Object args[6]; 1072 Lisp_Object args[6];
1073 int nargs, i;
1071 1074
1072 if (p->size != 5) 1075 if (!NILP (omit_port) && (p->size == 4 || p->size == 5))
1076 {
1077 args[0] = build_string ("%d.%d.%d.%d");
1078 nargs = 4;
1079 }
1080 else if (p->size == 5)
1081 {
1082 args[0] = build_string ("%d.%d.%d.%d:%d");
1083 nargs = 5;
1084 }
1085 else
1073 return Qnil; 1086 return Qnil;
1074 1087
1075 args[0] = build_string ("%d.%d.%d.%d:%d"); 1088 for (i = 0; i < nargs; i++)
1076 args[1] = p->contents[0]; 1089 args[i+1] = p->contents[i];
1077 args[2] = p->contents[1]; 1090 return Fformat (nargs+1, args);
1078 args[3] = p->contents[2];
1079 args[4] = p->contents[3];
1080 args[5] = p->contents[4];
1081 return Fformat (6, args);
1082 } 1091 }
1083 1092
1084 if (CONSP (address)) 1093 if (CONSP (address))
@@ -1255,7 +1264,7 @@ list_processes_1 (query_only)
1255 if (INTEGERP (port)) 1264 if (INTEGERP (port))
1256 port = Fnumber_to_string (port); 1265 port = Fnumber_to_string (port);
1257 if (NILP (port)) 1266 if (NILP (port))
1258 port = Fformat_network_address (Fplist_get (p->childp, QClocal)); 1267 port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil);
1259 sprintf (tembuf, "(network %s server on %s)\n", 1268 sprintf (tembuf, "(network %s server on %s)\n",
1260 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), 1269 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"),
1261 (STRINGP (port) ? (char *)SDATA (port) : "?")); 1270 (STRINGP (port) ? (char *)SDATA (port) : "?"));
@@ -1273,7 +1282,7 @@ list_processes_1 (query_only)
1273 host = Fnumber_to_string (host); 1282 host = Fnumber_to_string (host);
1274 } 1283 }
1275 if (NILP (host)) 1284 if (NILP (host))
1276 host = Fformat_network_address (Fplist_get (p->childp, QCremote)); 1285 host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil);
1277 sprintf (tembuf, "(network %s connection to %s)\n", 1286 sprintf (tembuf, "(network %s connection to %s)\n",
1278 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"), 1287 (DATAGRAM_CHAN_P (XINT (p->infd)) ? "datagram" : "stream"),
1279 (STRINGP (host) ? (char *)SDATA (host) : "?")); 1288 (STRINGP (host) ? (char *)SDATA (host) : "?"));