summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorBenoît Dejean <bdejean@src.gnome.org>2005-01-10 17:04:50 +0000
committerBenoît Dejean <bdejean@src.gnome.org>2005-01-10 17:04:50 +0000
commit70ac398a4467a171d280526a2291da7a8bb060c2 (patch)
tree50eb9c150d5e85d8635ff25fa0be4126daa4d9a2 /sysdeps
parent48056f7d8afc0e71adfcd01ae5ab846f3a4c59dc (diff)
downloadlibgtop-70ac398a4467a171d280526a2291da7a8bb060c2.tar.gz
Fixed.
* procopenfiles.c: (get_socket_endpoint): Fixed.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/linux/ChangeLog4
-rw-r--r--sysdeps/linux/procopenfiles.c21
2 files changed, 17 insertions, 8 deletions
diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog
index 84e29bf7..d72c32a4 100644
--- a/sysdeps/linux/ChangeLog
+++ b/sysdeps/linux/ChangeLog
@@ -1,5 +1,9 @@
2005-01-10 Benoît Dejean <TazForEver@dlfp.org>
+ * procopenfiles.c: (get_socket_endpoint): Fixed.
+
+2005-01-10 Benoît Dejean <TazForEver@dlfp.org>
+
* glibtop_server.h:
* procopenfiles.c: (get_socket_endpoint): Disabled.
diff --git a/sysdeps/linux/procopenfiles.c b/sysdeps/linux/procopenfiles.c
index 3cd55d5e..de489cb3 100644
--- a/sysdeps/linux/procopenfiles.c
+++ b/sysdeps/linux/procopenfiles.c
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <arpa/inet.h>
+#include "glibtop_private.h"
static const unsigned long _glibtop_sysdeps_proc_open_files =
(1L << GLIBTOP_PROC_OPEN_FILES_NUMBER)|
@@ -52,23 +53,26 @@ static void
get_socket_endpoint(char *buf, int *prmtport, int s)
{
FILE *f;
- char l[1024];
+ char line[1024];
buf[0] = '\0';
- prmtport = 0;
+ *prmtport = 0;
f = fopen("/proc/net/tcp", "r");
-
if(!f)
return;
- while(fgets(l, sizeof l, f))
+ if(!fgets(line, sizeof line, f)) goto eof;
+
+
+ while(fgets(line, sizeof line, f))
{
- unsigned int loc, locport, rmt;
+ unsigned int rmt;
int sock = -42;
- /* FIXME
- sscanf(l, "%*d: %8x:%4x %8x:%4x %*x %*x:%*x %*x:%*x %*d %*d %*d %d",
- &loc, &locport, &rmt, prmtport, &sock); */
+
+ sscanf(line, "%*d: %*x:%*x %8x:%4x %*x %*x:%*x %*x:%*x %*d %*d %*d %d",
+ &rmt, prmtport, &sock);
+
if(sock == s)
{
inet_ntop(AF_INET, &rmt, buf, GLIBTOP_OPEN_DEST_HOST_LEN);
@@ -76,6 +80,7 @@ get_socket_endpoint(char *buf, int *prmtport, int s)
}
}
+ eof:
fclose(f);
}