diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2003-12-06 09:25:42 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2003-12-06 09:25:42 +0800 |
commit | df05889f68b7a45d1f55d78e0887c27232b6e2e9 (patch) | |
tree | 5796c91db6c32f397a11709a46cc3585ff7c14c3 /net | |
parent | 152b8689fa4dce172d9a791efa363631a686a898 (diff) | |
download | marcuscom-ports-df05889f68b7a45d1f55d78e0887c27232b6e2e9.tar marcuscom-ports-df05889f68b7a45d1f55d78e0887c27232b6e2e9.tar.gz marcuscom-ports-df05889f68b7a45d1f55d78e0887c27232b6e2e9.tar.bz2 marcuscom-ports-df05889f68b7a45d1f55d78e0887c27232b6e2e9.tar.lz marcuscom-ports-df05889f68b7a45d1f55d78e0887c27232b6e2e9.tar.xz marcuscom-ports-df05889f68b7a45d1f55d78e0887c27232b6e2e9.tar.zst marcuscom-ports-df05889f68b7a45d1f55d78e0887c27232b6e2e9.zip |
Make this actually work for at least one polling cycle.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@1400 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'net')
-rw-r--r-- | net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c | 27 | ||||
-rw-r--r-- | net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c | 27 |
2 files changed, 40 insertions, 14 deletions
diff --git a/net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c b/net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c index cb070768a..aef490b93 100644 --- a/net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c +++ b/net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c @@ -1,5 +1,5 @@ --- src/netstatus-sysdeps.c.orig Mon Jun 9 13:18:04 2003 -+++ src/netstatus-sysdeps.c Fri Dec 5 18:47:38 2003 ++++ src/netstatus-sysdeps.c Fri Dec 5 19:38:31 2003 @@ -31,6 +31,8 @@ #include <glib.h> #include <libgnome/gnome-i18n.h> @@ -9,7 +9,7 @@ static inline char * parse_iface_name (const char *buf) { -@@ -206,3 +208,145 @@ +@@ -206,3 +208,158 @@ return error_message; } @@ -92,7 +92,7 @@ + long *out_bytes) +{ + gchar *buf; -+ gchar cmd[512]; ++ gchar *cmd = NULL; + gchar **command_line; + int prx_idx, ptx_idx; + int brx_idx, btx_idx; @@ -107,9 +107,9 @@ + *in_bytes = -1; + *out_bytes = -1; + -+ g_snprintf (cmd, sizeof(cmd), "/usr/bin/netstat -I %s -b -f inet", -+ iface); ++ cmd = g_strdup_printf ("/usr/bin/netstat netstat -I %s -b -f inet", iface); + command_line = g_strsplit (cmd, " ", -1); ++ g_free (cmd); + + if (g_spawn_async_with_pipes (dir, command_line, NULL, + G_SPAWN_FILE_AND_ARGV_ZERO, NULL, @@ -122,8 +122,17 @@ + parse_header (buf, &prx_idx, &ptx_idx, &brx_idx, &btx_idx); + if (prx_idx == -1 || ptx_idx == -1 || + brx_idx == -1 || btx_idx == -1) -+ return g_strdup ("Could not parse netstat output. Unknown format."); -+ ++ { ++ if (buf) ++ g_free (buf); ++ g_io_channel_unref (channel); ++ g_io_channel_shutdown (channel, TRUE, NULL); ++ close (pout); ++ return g_strdup ("Could not parse netstat output. Unknown format"); ++ } ++ ++ if (buf) ++ g_free (buf); + g_io_channel_read_line (channel, &buf, NULL, NULL, NULL); + + if (!parse_stats (buf, prx_idx, ptx_idx, in_packets, out_packets, @@ -136,11 +145,15 @@ + buf, prx_idx, ptx_idx, brx_idx, btx_idx); + } + ++ if (buf) ++ g_free (buf); ++ + if ((*in_packets == -1 || *out_packets == -1 || *in_bytes == -1 || *out_bytes == -1) && !error_message) + error_message = g_strdup_printf ("Could not obtain information on interface '%s' from netstat", iface); + + g_io_channel_unref (channel); + g_io_channel_shutdown (channel, TRUE, NULL); ++ close (pout); + } + else { + if (error_message) diff --git a/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c b/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c index cb070768a..aef490b93 100644 --- a/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c +++ b/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c @@ -1,5 +1,5 @@ --- src/netstatus-sysdeps.c.orig Mon Jun 9 13:18:04 2003 -+++ src/netstatus-sysdeps.c Fri Dec 5 18:47:38 2003 ++++ src/netstatus-sysdeps.c Fri Dec 5 19:38:31 2003 @@ -31,6 +31,8 @@ #include <glib.h> #include <libgnome/gnome-i18n.h> @@ -9,7 +9,7 @@ static inline char * parse_iface_name (const char *buf) { -@@ -206,3 +208,145 @@ +@@ -206,3 +208,158 @@ return error_message; } @@ -92,7 +92,7 @@ + long *out_bytes) +{ + gchar *buf; -+ gchar cmd[512]; ++ gchar *cmd = NULL; + gchar **command_line; + int prx_idx, ptx_idx; + int brx_idx, btx_idx; @@ -107,9 +107,9 @@ + *in_bytes = -1; + *out_bytes = -1; + -+ g_snprintf (cmd, sizeof(cmd), "/usr/bin/netstat -I %s -b -f inet", -+ iface); ++ cmd = g_strdup_printf ("/usr/bin/netstat netstat -I %s -b -f inet", iface); + command_line = g_strsplit (cmd, " ", -1); ++ g_free (cmd); + + if (g_spawn_async_with_pipes (dir, command_line, NULL, + G_SPAWN_FILE_AND_ARGV_ZERO, NULL, @@ -122,8 +122,17 @@ + parse_header (buf, &prx_idx, &ptx_idx, &brx_idx, &btx_idx); + if (prx_idx == -1 || ptx_idx == -1 || + brx_idx == -1 || btx_idx == -1) -+ return g_strdup ("Could not parse netstat output. Unknown format."); -+ ++ { ++ if (buf) ++ g_free (buf); ++ g_io_channel_unref (channel); ++ g_io_channel_shutdown (channel, TRUE, NULL); ++ close (pout); ++ return g_strdup ("Could not parse netstat output. Unknown format"); ++ } ++ ++ if (buf) ++ g_free (buf); + g_io_channel_read_line (channel, &buf, NULL, NULL, NULL); + + if (!parse_stats (buf, prx_idx, ptx_idx, in_packets, out_packets, @@ -136,11 +145,15 @@ + buf, prx_idx, ptx_idx, brx_idx, btx_idx); + } + ++ if (buf) ++ g_free (buf); ++ + if ((*in_packets == -1 || *out_packets == -1 || *in_bytes == -1 || *out_bytes == -1) && !error_message) + error_message = g_strdup_printf ("Could not obtain information on interface '%s' from netstat", iface); + + g_io_channel_unref (channel); + g_io_channel_shutdown (channel, TRUE, NULL); ++ close (pout); + } + else { + if (error_message) |