Mercurial > hg > toybox
annotate toys/hello.c @ 239:4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
and update a chunk of code.html (much more to do there).
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 20 Jan 2008 19:00:16 -0600 |
parents | 163498bf547b |
children | 157eab6dcdd2 |
rev | line source |
---|---|
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
1 /* vi: set sw=4 ts=4: |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
2 * |
13
d87d8a056295
Add a hello world applet, partly as an example and partly for testing purposes.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 * hello.c - A hello world program. |
194
30a6db5a95c2
Add comments about SUSv3 specs (or lack thereof).
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
4 * |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
5 * Copyright 2006 Rob Landley <rob@landley.net> |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
6 * |
194
30a6db5a95c2
Add comments about SUSv3 specs (or lack thereof).
Rob Landley <rob@landley.net>
parents:
186
diff
changeset
|
7 * Not in SUSv3. |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
8 * See http://www.opengroup.org/onlinepubs/009695399/utilities/ |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
9 |
239
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
10 USE_HELLO(NEWTOY(hello, "e@d*c#b:a", TOYFLAG_USR|TOYFLAG_BIN)) |
234
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
11 |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
12 config HELLO |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
13 bool "hello" |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
14 default y |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
15 help |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
16 A hello world program. You don't need this. |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
17 |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
18 Mostly used as an example/skeleton file for adding new commands, |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
19 occasionally nice to test kernel booting via "init=/bin/hello". |
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
194
diff
changeset
|
20 */ |
13
d87d8a056295
Add a hello world applet, partly as an example and partly for testing purposes.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 |
d87d8a056295
Add a hello world applet, partly as an example and partly for testing purposes.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 #include "toys.h" |
d87d8a056295
Add a hello world applet, partly as an example and partly for testing purposes.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 |
239
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
24 // Hello doesn't use these globals, they're here for example/skeleton purposes. |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
25 |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
26 DEFINE_GLOBALS( |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
27 char *b_string; |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
28 long c_number; |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
29 struct arg_list *d_list; |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
30 long e_count; |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
31 |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
32 int more_globals; |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
33 ) |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
34 |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
35 #define TT this.hello |
4f1ca01db000
Fluff out hello.c to supply more example code as a skeleton for new commands,
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
36 |
186
25447caf1b4b
Change command main() functions to return void, and exit(toys.exitval) from
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
37 void hello_main(void) |
13
d87d8a056295
Add a hello world applet, partly as an example and partly for testing purposes.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
38 { |
d87d8a056295
Add a hello world applet, partly as an example and partly for testing purposes.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
39 printf("Hello world\n"); |
d87d8a056295
Add a hello world applet, partly as an example and partly for testing purposes.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
40 } |