summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBenoît Dejean <bdejean@src.gnome.org>2004-11-13 21:06:08 +0000
committerBenoît Dejean <bdejean@src.gnome.org>2004-11-13 21:06:08 +0000
commitbbb6cbaa87456712e42bd350097dfebf9b9ff056 (patch)
treede833b80b7d5de0d6a92c16ff04da7e764093d5c /examples
parentce229a4e199e3bf1858ce16254f1b18ed3dc678a (diff)
downloadlibgtop-bbb6cbaa87456712e42bd350097dfebf9b9ff056.tar.gz
Updated.
* pprint.c: (pprint_get_fsusage), (pprint_get_mountlist), (pprint_get_netload), (pprint_get_netlist), (main): Updated.
Diffstat (limited to 'examples')
-rw-r--r--examples/ChangeLog5
-rw-r--r--examples/pprint.c39
2 files changed, 39 insertions, 5 deletions
diff --git a/examples/ChangeLog b/examples/ChangeLog
index 5cda37c1..d7943d5a 100644
--- a/examples/ChangeLog
+++ b/examples/ChangeLog
@@ -1,3 +1,8 @@
+2004-11-13 Benoît Dejean <tazforever@dlfp.org>
+
+ * pprint.c: (pprint_get_fsusage), (pprint_get_mountlist),
+ (pprint_get_netload), (pprint_get_netlist), (main): Updated.
+
2004-09-25 Benoît Dejean <tazforever@dlfp.org>
* pprint.c: (main): Re-added pprint_get_msg_limits()
diff --git a/examples/pprint.c b/examples/pprint.c
index 76b1943d..cba8db64 100644
--- a/examples/pprint.c
+++ b/examples/pprint.c
@@ -9,7 +9,7 @@
#define buf_offsetof(MEMBER) ((ptrdiff_t)&(buf.MEMBER) - (ptrdiff_t)&buf)
-#define HEADER_PPRINT(FUNC) printf(#FUNC "\tsizeof = %lu B\n", \
+#define HEADER_PPRINT(FUNC) printf("### " #FUNC " ###\nsizeof *buf = %lu B\n", \
(unsigned long) sizeof buf)
#define PPRINT(DATA, FORMAT) printf("\t%4lu B %3lu " #DATA " = " FORMAT "\n", \
@@ -24,7 +24,7 @@ for(i = 0; i < (SIZE - 1); ++i) printf(".%u = " FORMAT ", ", i, buf.ARRAY[i]); \
printf(".%u = " FORMAT " }\n", SIZE - 1 , buf.ARRAY[SIZE - 1]); \
} while(0)
-#define FOOTER_PPRINT() putchar('\n')
+#define FOOTER_PPRINT() putchar('\n');
@@ -60,6 +60,7 @@ static void pprint_get_fsusage(const char *mountpoint)
glibtop_get_fsusage(&buf, mountpoint);
HEADER_PPRINT(glibtop_get_fsusage);
+ printf("pprint_get_fsusage (mountpoint = \"%s\"\n", mountpoint);
PPRINT(flags, "%#llx");
PPRINT(blocks, "%llu");
PPRINT(bfree, "%llu");
@@ -121,6 +122,7 @@ static void pprint_get_mountlist(gboolean allfs)
entries = glibtop_get_mountlist(&buf, allfs);
HEADER_PPRINT(glibtop_get_mountlist);
+ printf("glibtop_get_mountlist (allfs = %d)\n", allfs);
PPRINT(flags, "%#llx");
PPRINT(number, "%llu");
PPRINT(total, "%llu");
@@ -175,10 +177,33 @@ static void pprint_get_netload(const char *iface)
glibtop_get_netload(&buf, iface);
HEADER_PPRINT(glibtop_get_netload);
+ printf("glibtop_get_netload (iface = \"%s\")\n", iface);
+ PPRINT(flags, "%#llx");
FOOTER_PPRINT();
}
+static void pprint_get_netlist()
+{
+ glibtop_netlist buf;
+ char **devices;
+ guint32 i;
+
+ devices = glibtop_get_netlist(&buf);
+
+ HEADER_PPRINT(glibtop_get_netlist);
+
+ for(i = 0; i < buf.number; ++i)
+ {
+ printf("\t%s\n", devices[i]);
+ }
+
+ FOOTER_PPRINT();
+
+ g_strfreev(devices);
+}
+
+
static void pprint_get_swap()
{
@@ -214,6 +239,8 @@ static void pprint_get_uptime()
+
+
int main()
{
glibtop_init();
@@ -231,11 +258,13 @@ int main()
pprint_get_msg_limits();
-/* pprint_get_netload("lo"); */
-
-
pprint_get_swap();
+ pprint_get_netlist();
+
+ pprint_get_netload("eth0");
+ pprint_get_netload("ppp0");
+ pprint_get_netload("<unknown>");
/* pprint_get_sysinfo(); */
pprint_get_uptime();