Mercurial > hg > toybox
comparison toys/other/hello.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 | 786841fdb1e0 |
comparison
equal
deleted
inserted
replaced
673:c102f31a753e | 674:7e846e281e38 |
---|---|
19 | 19 |
20 Mostly used as an example/skeleton file for adding new commands, | 20 Mostly used as an example/skeleton file for adding new commands, |
21 occasionally nice to test kernel booting via "init=/bin/hello". | 21 occasionally nice to test kernel booting via "init=/bin/hello". |
22 */ | 22 */ |
23 | 23 |
24 #define FOR_hello | |
24 #include "toys.h" | 25 #include "toys.h" |
25 | 26 |
26 // Hello doesn't use these globals, they're here for example/skeleton purposes. | 27 // Hello doesn't use these globals, they're here for example/skeleton purposes. |
27 | 28 |
28 DEFINE_GLOBALS( | 29 GLOBALS( |
29 char *b_string; | 30 char *b_string; |
30 long c_number; | 31 long c_number; |
31 struct arg_list *d_list; | 32 struct arg_list *d_list; |
32 long e_count; | 33 long e_count; |
33 | 34 |
34 int more_globals; | 35 int more_globals; |
35 ) | 36 ) |
36 | |
37 #define TT this.hello | |
38 | |
39 #define FLAG_a 1 | |
40 #define FLAG_b 2 | |
41 #define FLAG_c 4 | |
42 #define FLAG_d 8 | |
43 #define FLAG_e 16 | |
44 | 37 |
45 void hello_main(void) | 38 void hello_main(void) |
46 { | 39 { |
47 printf("Hello world\n"); | 40 printf("Hello world\n"); |
48 | 41 |