aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-10-08 00:02:30 -0500
committerRob Landley <rob@landley.net>2012-10-08 00:02:30 -0500
commitc0e56edaf256adb6c60c5a052525a1ffbb927901 (patch)
treed6bcc5c181ca46910a12d4dece4b26d6c71be3e1 /toys/lsb
parentdc7a77d1940858495f76998f4d13cac9f73e0226 (diff)
downloadtoybox-c0e56edaf256adb6c60c5a052525a1ffbb927901.tar.gz
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.
Diffstat (limited to 'toys/lsb')
-rw-r--r--toys/lsb/dmesg.c5
-rw-r--r--toys/lsb/hostname.c1
-rw-r--r--toys/lsb/killall.c7
-rw-r--r--toys/lsb/mknod.c1
-rw-r--r--toys/lsb/mktemp.c9
-rw-r--r--toys/lsb/passwd.c11
6 files changed, 10 insertions, 24 deletions
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 <sys/klog.h>
-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 <time.h>
-
-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"