diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2003-12-07 06:14:16 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2003-12-07 06:14:16 +0800 |
commit | a64569fb24cf8abce85eec72a80b5898aab06a4b (patch) | |
tree | 476f4cb9bcd46f051dbd584ed727b25c5b58a4ce /net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c | |
parent | 7213ae8b23a8783350dd132708ae45fbc09b1e0c (diff) | |
download | marcuscom-ports-a64569fb24cf8abce85eec72a80b5898aab06a4b.tar marcuscom-ports-a64569fb24cf8abce85eec72a80b5898aab06a4b.tar.gz marcuscom-ports-a64569fb24cf8abce85eec72a80b5898aab06a4b.tar.bz2 marcuscom-ports-a64569fb24cf8abce85eec72a80b5898aab06a4b.tar.lz marcuscom-ports-a64569fb24cf8abce85eec72a80b5898aab06a4b.tar.xz marcuscom-ports-a64569fb24cf8abce85eec72a80b5898aab06a4b.tar.zst marcuscom-ports-a64569fb24cf8abce85eec72a80b5898aab06a4b.zip |
Reuse some of the Linux code instead of duplicating it.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@1402 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c')
-rw-r--r-- | net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c | 64 |
1 files changed, 24 insertions, 40 deletions
diff --git a/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c b/net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c index 5427e0687..9a29aefb1 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 Sat Dec 6 01:19:49 2003 ++++ src/netstatus-sysdeps.c Sat Dec 6 17:11:01 2003 @@ -27,10 +27,13 @@ #include <stdio.h> @@ -14,7 +14,24 @@ static inline char * parse_iface_name (const char *buf) { -@@ -206,3 +209,158 @@ +@@ -90,6 +93,7 @@ + } + } + } ++#endif + + static inline int + parse_stats (char *buf, +@@ -124,6 +128,8 @@ + return TRUE; + } + ++#if !defined(__FreeBSD__) ++ + static inline FILE * + get_proc_net_dev_fh (void) + { +@@ -206,3 +212,125 @@ return error_message; } @@ -34,8 +51,8 @@ + *prx_idx = *ptx_idx = -1; + *brx_idx = *btx_idx = -1; + -+ p = strtok (buf, " "); -+ for (i = 0; p; i++, p = strtok (NULL, " ")) ++ p = strtok (buf, " \n\t"); ++ for (i = 0; p; i++, p = strtok (NULL, " \t\n")) + { + if (!strcmp (p, "Ipkts")) + { @@ -56,39 +73,6 @@ + } +} + -+static inline int -+parse_stats (char *buf, -+ int prx_idx, -+ int ptx_idx, -+ long *in_packets, -+ long *out_packets, -+ int brx_idx, -+ int btx_idx, -+ long *in_bytes, -+ long *out_bytes) -+{ -+ char *p; -+ int i; -+ -+ p = strtok (buf, " "); -+ for (i = 0; p; i++, p = strtok (NULL, " ")) -+ { -+ if (i == prx_idx) -+ *in_packets = g_ascii_strtoull (p, NULL, 10); -+ if (i == ptx_idx) -+ *out_packets = g_ascii_strtoull (p, NULL, 10); -+ if (i == brx_idx) -+ *in_bytes = g_ascii_strtoull (p, NULL, 10); -+ if (i == btx_idx) -+ *out_bytes = g_ascii_strtoull (p, NULL, 10); -+ } -+ -+ if (i <= prx_idx || i <= ptx_idx || i <= brx_idx || i <=btx_idx) -+ return FALSE; -+ -+ return TRUE; -+} -+ +char * +netstatus_sysdeps_read_iface_statistics (const char *iface, + long *in_packets, @@ -162,9 +146,9 @@ + } + else { + if (error_message) -+ g_free (error_message); -+ error_message = g_strdup_printf ("Error running /usr/bin/netstat for '%s': %s", iface, -+ err->message); ++ g_free (error_message); ++ error_message = g_strdup_printf ("Error running /usr/bin/netstat for '%s': %s", ++ iface, err->message); + g_error_free (err); + } + |