blob: 010320cf9a96ee63a222cab4b63382accb6a36e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/* demo_number.c - Expose atolx() and human_readable() for testing.
*
* Copyright 2015 Rob Landley <rob@landley.net>
USE_DEMO_NUMBER(NEWTOY(demo_number, "D#=3<3hdbs", TOYFLAG_BIN))
config DEMO_NUMBER
bool "demo_number"
default n
help
usage: demo_number [-hsbi] NUMBER...
-b Use "B" for single byte units (HR_B)
-d Decimal units
-h Human readable
-s Space between number and units (HR_SPACE)
*/
#define FOR_demo_number
#include "toys.h"
GLOBALS(
long D;
)
void demo_number_main(void)
{
char **arg;
for (arg = toys.optargs; *arg; arg++) {
long long ll = atolx(*arg);
if (toys.optflags) {
human_readable_long(toybuf, ll, TT.D, toys.optflags);
xputs(toybuf);
} else printf("%lld\n", ll);
}
}
|