aboutsummaryrefslogtreecommitdiff
path: root/toys/example/demo_human_readable.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2017-10-31 15:51:02 -0500
committerRob Landley <rob@landley.net>2017-10-31 15:51:02 -0500
commite913247fec162437920266182834aedadcb03004 (patch)
tree8f61ef4d6dfdb0d256279d4e5e34347f498aa13b /toys/example/demo_human_readable.c
parentb2d8cf906502226904e149e20279a899ba22e035 (diff)
downloadtoybox-e913247fec162437920266182834aedadcb03004.tar.gz
Rename test_*.c to demo_*.c (because "make test_$CMD" means something already),
fluff out README, and add a comment to hostid explaining its deprecation.
Diffstat (limited to 'toys/example/demo_human_readable.c')
-rw-r--r--toys/example/demo_human_readable.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/toys/example/demo_human_readable.c b/toys/example/demo_human_readable.c
new file mode 100644
index 00000000..9fff2626
--- /dev/null
+++ b/toys/example/demo_human_readable.c
@@ -0,0 +1,23 @@
+/* test_human_readable.c - Expose lib/lib.c human_readable() for testing.
+ *
+ * Copyright 2015 Rob Landley <rob@landley.net>
+
+USE_TEST_HUMAN_READABLE(NEWTOY(test_human_readable, "<1>1ibs", TOYFLAG_BIN))
+
+config TEST_HUMAN_READABLE
+ bool "test_human_readable"
+ default n
+ help
+ usage: test_human_readable [-sbi] NUMBER
+*/
+
+#define FOR_test_human_readable
+#include "toys.h"
+
+void test_human_readable_main(void)
+{
+ char *c;
+
+ human_readable(toybuf, strtoll(*toys.optargs, &c, 0), toys.optflags);
+ printf("%s\n", toybuf);
+}