summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-08-05 15:08:54 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-08-05 16:55:44 +0200
commitca3ef39738daca07466e139a3dc684e4c10df5db (patch)
tree5c0e92747d1125f0206f82263cd4c64b68f6aba2 /scope.c
parentd8267b3d67c517c31db35982409c2f1289cf1936 (diff)
downloadxscope-peerinfo.tar.gz
Add support for process ID and namespeerinfo
Adds the process ID and name of the other side. Useful if you have multiple clients. Support for OpenBSD could be added in theory since it has a similar "struct sockpeercred" structure (not sure about process name though). After this change, the process ID and name (when available) will be appended between parentheses: 0.01: Client (pid 23433 xdpyinfo) --> 4 bytes ............REQUEST: ListExtensions 0.01: 332 bytes <-- X11 Server (pid 8290 Xorg) ..............REPLY: ListExtensions names: (29) Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/scope.c b/scope.c
index 1919569..73a0858 100644
--- a/scope.c
+++ b/scope.c
@@ -1011,11 +1011,19 @@ ServerHalf(FD fd)
const char *
ClientName(FD fd)
{
- static char name[12];
+ static char name[62];
+ unsigned pos = 0;
+ const char *peer_info;
if (clientNumber <= 1)
- return ("");
- snprintf(name, sizeof(name), " %d", FDinfo[fd].ClientNumber);
+ name[0] = '\0';
+ else
+ pos = snprintf(name, sizeof(name), " %d", FDinfo[fd].ClientNumber);
+
+ peer_info = GetPeerInfo(fd);
+ if (peer_info)
+ snprintf(name + pos, sizeof(name) - pos, " (%s)", peer_info);
+
return (name);
}