From ce23ce407cb1cf68d9ab32957ec08ae914434c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Dejean?= Date: Mon, 23 Jun 2008 22:07:26 +0000 Subject: Improved example. svn path=/trunk/; revision=2758 --- examples/df.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/examples/df.c b/examples/df.c index 27be1371..6fcbae00 100644 --- a/examples/df.c +++ b/examples/df.c @@ -27,25 +27,31 @@ static void print_fsusage(const char *mountpoint) } -int main() +int main(int argc, char **argv) { glibtop_mountlist buf; - glibtop_mountentry *entries; - size_t i; glibtop_init(); printf("%-30s %10s %10s %10s %5s %10s %10s\n", "Filesystem", "Size", "Used", "Avail", "Use%", "Read", "Write"); - entries = glibtop_get_mountlist(&buf, TRUE); + if (argc > 1) { + while (*++argv) + print_fsusage(*argv); + } else { + glibtop_mountentry *entries; + size_t i; - for(i = 0; i < buf.number; ++i) - { - print_fsusage(entries[i].mountdir); - } + entries = glibtop_get_mountlist(&buf, TRUE); - g_free(entries); + for(i = 0; i < buf.number; ++i) + { + print_fsusage(entries[i].mountdir); + } + + g_free(entries); + } glibtop_close(); -- cgit v1.2.1