annotate toys/example/skeleton.c @ 1499:319e79bab052 draft

Separate more commands so single.sh can build them standalone.
author Rob Landley <rob@landley.net>
date Fri, 26 Sep 2014 18:42:23 -0500
parents dd2fd057111f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1267
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 /* skeleton.c - Example program to act as template for new commands.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 *
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 * Copyright 2014 Rob Landley <rob@landley.net>
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
4 *
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
6 * See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/cmdbehav.html
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
7
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 // Accept many different kinds of command line argument (see top of lib/args.c)
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 // Demonstrate two commands in the same file (see www/documentation.html)
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
10
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 USE_SKELETON(NEWTOY(skeleton, "(walrus)(blubber):;(also):e@d*c#b:a", TOYFLAG_USR|TOYFLAG_BIN))
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 USE_SKELETON_ALIAS(NEWTOY(skeleton_alias, "b#dq", TOYFLAG_USR|TOYFLAG_BIN))
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
13
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 config SKELETON
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 bool "skeleton"
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 default n
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 help
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 usage: skeleton [-a] [-b STRING] [-c NUMBER] [-d LIST] [-e COUNT] [...]
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
19
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 Template for new commands. You don't need this.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
21
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 When creating a new command, copy this file and delete the parts you
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 don't need. Be sure to replace all instances of "skeleton" (upper and lower
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 case) with your new command name.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
25
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 For simple commands, "hello.c" is probably a better starting point.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
27
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 config SKELETON_ALIAS
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 bool "skeleton_alias"
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 default n
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 help
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
32 usage: skeleton_alias [-dq] [-b NUMBER]
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
33
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 Example of a second command with different arguments in the same source
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 file as the first. This allows shared infrastructure not added to lib/.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 */
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
37
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 #define FOR_skeleton
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 #include "toys.h"
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
40
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 // The union lets lib/args.c store arguments for either command.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 // It's customary to put a space between argument variables and other globals.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 GLOBALS(
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
44 union {
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
45 struct {
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 char *b_string;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 long c_number;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
48 struct arg_list *d_list;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
49 long e_count;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
50 char *also_string;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
51 char *blubber_string;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
52 } s;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
53 struct {
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
54 long b_number;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 } a;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
56 };
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
57
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
58 int more_globals;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 )
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
60
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 // Don't blindly build allyesconfig. The maximum _sane_ config is defconfig.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 #warning skeleton.c is just an example, not something to deploy.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
63
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
64 // Parse many different kinds of command line argument:
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
65 void skeleton_main(void)
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
66 {
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
67 char **optargs;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
68
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
69 printf("Ran %s\n", toys.which->name);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
70
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
71 // Command line options parsing is done for you by lib/args.c called
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
72 // from main.c using the optstring in the NEWTOY macros. Display results.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
73 if (toys.optflags) printf("flags=%x\n", toys.optflags);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
74 if (toys.optflags & FLAG_a) printf("Saw a\n");
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
75 if (toys.optflags & FLAG_b) printf("b=%s\n", TT.s.b_string);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
76 if (toys.optflags & FLAG_c) printf("c=%ld\n", TT.s.c_number);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
77 while (TT.s.d_list) {
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
78 printf("d=%s\n", TT.s.d_list->arg);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
79 TT.s.d_list = TT.s.d_list->next;
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
80 }
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
81 if (TT.s.e_count) printf("e was seen %ld times\n", TT.s.e_count);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
82 for (optargs = toys.optargs; *optargs; optargs++)
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
83 printf("optarg=%s\n", *optargs);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
84 if (toys.optflags & FLAG_walrus) printf("Saw --walrus\n");
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
85 if (TT.s.blubber_string) printf("--blubber=%s\n", TT.s.blubber_string);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
86
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
87 printf("Other globals should start zeroed: %d\n", TT.more_globals);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
88 }
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
89
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
90 // Switch gears from skeleton to skeleton_alias (swap FLAG macros).
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
91 #define CLEANUP_skeleton
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
92 #define FOR_skeleton_alias
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
93 #include "generated/flags.h"
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
94
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
95 void skeleton_alias_main(void)
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
96 {
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
97 printf("Ran %s\n", toys.which->name);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
98 printf("flags=%x\n", toys.optflags);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
99
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
100 // Note, this FLAG_b is a different bit position than the other FLAG_b,
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
101 // and fills out a different variable of a different type.
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
102 if (toys.optflags & FLAG_b) printf("b=%ld", TT.a.b_number);
dd2fd057111f Add example directory, move hello.c into it, add skeleton.c to demonstrate more complciated stuff (multiple commands per file, etc), and have genconfig.sh sort backwards so posix is first and example last in menuconfig.
Rob Landley <rob@landley.net>
parents:
diff changeset
103 }