Mercurial > hg > toybox
diff toys/posix/df.c @ 674:7e846e281e38
New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 08 Oct 2012 00:02:30 -0500 |
parents | 6df4ccc0acbe |
children | 44904c7212e7 |
line wrap: on
line diff
--- a/toys/posix/df.c Sun Oct 07 23:53:25 2012 -0500 +++ b/toys/posix/df.c Mon Oct 08 00:02:30 2012 -0500 @@ -37,16 +37,15 @@ -k Sets units back to 1024 bytes (the default without -P) */ +#define FOR_df #include "toys.h" -DEFINE_GLOBALS( +GLOBALS( struct arg_list *fstype; long units; ) -#define TT this.df - static void show_mt(struct mtab_list *mt) { int len; @@ -67,7 +66,7 @@ } // If we don't have -a, skip synthetic filesystems - if (!(toys.optflags & 1) && !mt->statvfs.f_blocks) return; + if (!(toys.optflags & FLAG_a) && !mt->statvfs.f_blocks) return; // Figure out how much total/used/free space this filesystem has, // forcing 64-bit math because filesystems are big now. @@ -83,7 +82,7 @@ // Figure out appropriate spacing len = 25 - strlen(mt->device); if (len < 1) len = 1; - if (CFG_DF_PEDANTIC && (toys.optflags & 8)) { + if (CFG_DF_PEDANTIC && (toys.optflags & FLAG_P)) { printf("%s %ld %ld %ld %ld%% %s\n", mt->device, size, used, avail, percent, mt->dir); } else { @@ -98,9 +97,9 @@ // Handle -P and -k TT.units = 1024; - if (CFG_DF_PEDANTIC && (toys.optflags & 8)) { + if (CFG_DF_PEDANTIC && (toys.optflags & FLAG_P)) { // Units are 512 bytes if you select "pedantic" without "kilobytes". - if ((toys.optflags&3) == 1) TT.units = 512; + if ((toys.optflags&(FLAG_P|FLAG_k)) == FLAG_P) TT.units = 512; printf("Filesystem %ld-blocks Used Available Capacity Mounted on\n", TT.units); } else puts("Filesystem\t1K-blocks\tUsed Available Use% Mounted on");