libgtop r2758 - trunk/examples



Author: bdejean
Date: Mon Jun 23 22:07:26 2008
New Revision: 2758
URL: http://svn.gnome.org/viewvc/libgtop?rev=2758&view=rev

Log:
Improved example.


Modified:
   trunk/examples/df.c

Modified: trunk/examples/df.c
==============================================================================
--- trunk/examples/df.c	(original)
+++ trunk/examples/df.c	Mon Jun 23 22:07:26 2008
@@ -27,25 +27,31 @@
 }
 
 
-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;
+
+    entries = glibtop_get_mountlist(&buf, TRUE);
+
+    for(i = 0; i < buf.number; ++i)
+      {
+	print_fsusage(entries[i].mountdir);
+      }
 
-  for(i = 0; i < buf.number; ++i)
-    {
-      print_fsusage(entries[i].mountdir);
-    }
-
-  g_free(entries);
+    g_free(entries);
+  }
 
   glibtop_close();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]