aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--main.c (renamed from toys/main.c)37
-rw-r--r--toys.h48
-rw-r--r--toys/df.c7
4 files changed, 75 insertions, 22 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..984cdeb0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,5 @@
+all:
+ gcc -Os -s $(CFLAGS) -I . main.c toys/*.c lib/*.c -o toybox
+
+clean:
+ rm toybox
diff --git a/toys/main.c b/main.c
index bd15d602..396a354c 100644
--- a/toys/main.c
+++ b/main.c
@@ -6,8 +6,21 @@
* Licensed under GPL version 2, see file LICENSE in this tarball for details.
*/
-#include <stdio.h>
-#include <strings.h>
+#include "toys.h"
+
+// The monster fun applet list.
+
+struct toy_list toy_list[] = {
+ {"toybox", toybox_main},
+ {"df", df_main},
+ {"toysh", toysh_main}
+};
+
+// global context for this applet.
+
+struct toy_context toys;
+
+
/*
name
@@ -28,26 +41,6 @@ int toysh_main(void)
printf("toysh\n");
}
-// The monster fun applet list.
-
-struct toy_list {
- char *name;
- int (*toy_main)(void);
-} toy_list[] = {
- {"toybox", toybox_main},
- {"toysh", toysh_main}
-};
-
-// Global context for this applet.
-
-struct toy_context {
- struct toy_list *which;
- int argc;
- char **argv;
- char buf[4096];
-// toy_union toydata;
-} toys;
-
struct toy_list *find_toy_by_name(char *name)
{
int top, bottom, middle;
diff --git a/toys.h b/toys.h
new file mode 100644
index 00000000..ec1ad762
--- /dev/null
+++ b/toys.h
@@ -0,0 +1,48 @@
+/* vi: set ts=4 :*/
+/* Toybox infrastructure.
+ *
+ * Copyright 2006 Rob Landley <rob@landley.net>
+ *
+ * Licensed under GPL version 2, see file LICENSE in this tarball for details.
+ */
+
+#include <stdio.h>
+#include <strings.h>
+
+/*
+name
+main()
+struct
+usage (short long example info)
+path (/usr/sbin)
+*/
+
+int toybox_main(void);
+int toysh_main(void);
+int df_main(void);
+
+extern struct toy_list {
+ char *name;
+ int (*toy_main)(void);
+} toy_list[];
+struct toy_list *find_toy_by_name(char *name);
+
+// Global context for this applet.
+
+extern struct toy_context {
+ struct toy_list *which;
+ int argc;
+ char **argv;
+ char buf[4096];
+} toys;
+
+struct toybox_data {;};
+struct toysh_data {;};
+struct df_data {;};
+
+union toy_union {
+ struct toybox_data toybox;
+ struct toysh_data toysh;
+ struct df_data df;
+} toy;
+
diff --git a/toys/df.c b/toys/df.c
new file mode 100644
index 00000000..05c4b6c4
--- /dev/null
+++ b/toys/df.c
@@ -0,0 +1,7 @@
+/* vi: set ts=4 : */
+#include "toys.h"
+
+int df_main(void)
+{
+ printf("toys.which->name=%s\n",toys.which->name);
+}