From c0e56edaf256adb6c60c5a052525a1ffbb927901 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 8 Oct 2012 00:02:30 -0500 Subject: 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. --- toys/lsb/dmesg.c | 5 ++--- toys/lsb/hostname.c | 1 + toys/lsb/killall.c | 7 ++----- toys/lsb/mknod.c | 1 + toys/lsb/mktemp.c | 9 ++------- toys/lsb/passwd.c | 11 ++--------- 6 files changed, 10 insertions(+), 24 deletions(-) (limited to 'toys/lsb') diff --git a/toys/lsb/dmesg.c b/toys/lsb/dmesg.c index e54a9e11..8d73513b 100644 --- a/toys/lsb/dmesg.c +++ b/toys/lsb/dmesg.c @@ -21,16 +21,15 @@ config DMESG -c Clear the ring buffer after printing. */ +#define FOR_dmesg #include "toys.h" #include -DEFINE_GLOBALS( +GLOBALS( long level; long size; ) -#define TT this.dmesg - void dmesg_main(void) { // For -n just tell kernel to which messages to keep. diff --git a/toys/lsb/hostname.c b/toys/lsb/hostname.c index bd319188..ca436833 100644 --- a/toys/lsb/hostname.c +++ b/toys/lsb/hostname.c @@ -17,6 +17,7 @@ config HOSTNAME Get/Set the current hostname */ +#define FOR_hostname #include "toys.h" void hostname_main(void) diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c index 80f0253c..ec9df62e 100644 --- a/toys/lsb/killall.c +++ b/toys/lsb/killall.c @@ -20,15 +20,12 @@ config KILLALL -q don't print any warnings or error messages */ +#define FOR_killall #include "toys.h" -#define FLAG_q 1 -#define FLAG_l 2 - -DEFINE_GLOBALS( +GLOBALS( int signum; ) -#define TT this.killall static void kill_process(pid_t pid) { diff --git a/toys/lsb/mknod.c b/toys/lsb/mknod.c index fbdc8800..c1d78b10 100644 --- a/toys/lsb/mknod.c +++ b/toys/lsb/mknod.c @@ -20,6 +20,7 @@ config MKNOD p named pipe (ignores MAJOR/MINOR) */ +#define FOR_mknod #include "toys.h" void mknod_main(void) diff --git a/toys/lsb/mktemp.c b/toys/lsb/mktemp.c index c42588ab..1b2222c0 100644 --- a/toys/lsb/mktemp.c +++ b/toys/lsb/mktemp.c @@ -22,18 +22,13 @@ config MKTEMP -q Quiet */ +#define FOR_mktemp #include "toys.h" -DEFINE_GLOBALS( +GLOBALS( char * tmpdir; ) -#define FLAG_p 1 -#define FLAG_d 2 -#define FLAG_q 4 - -#define TT this.mktemp - void mktemp_main(void) { int d_flag = toys.optflags & FLAG_d; diff --git a/toys/lsb/passwd.c b/toys/lsb/passwd.c index 348c9c21..ef119c5d 100644 --- a/toys/lsb/passwd.c +++ b/toys/lsb/passwd.c @@ -24,21 +24,14 @@ config PASSWD */ +#define FOR_passwd #include "toys.h" #include - -DEFINE_GLOBALS( +GLOBALS( char *algo; ) -#define TT this.passwd - -#define FLAG_u (1 << 0) -#define FLAG_l (1 << 1) -#define FLAG_d (1 << 2) -#define FLAG_a (1 << 3) - #define MAX_SALT_LEN 20 //3 for id, 16 for key, 1 for '\0' #define URANDOM_PATH "/dev/urandom" -- cgit v1.2.3