aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c11
-rw-r--r--toys/basename.c3
-rw-r--r--toys/bzcat.c4
-rw-r--r--toys/catv.c8
-rw-r--r--toys/count.c3
-rw-r--r--toys/df.c4
-rw-r--r--toys/dirname.c3
-rw-r--r--toys/dmesg.c8
-rw-r--r--toys/echo.c3
-rw-r--r--toys/false.c4
-rw-r--r--toys/hello.c3
-rw-r--r--toys/help.c3
-rw-r--r--toys/mdev.c6
-rw-r--r--toys/mke2fs.c4
-rw-r--r--toys/mkfifo.c4
-rw-r--r--toys/oneit.c4
-rw-r--r--toys/pwd.c4
-rw-r--r--toys/readlink.c7
-rw-r--r--toys/sha1.c2
-rw-r--r--toys/sleep.c4
-rw-r--r--toys/sync.c3
-rw-r--r--toys/touch.c4
-rw-r--r--toys/toylist.h4
-rw-r--r--toys/toysh.c14
-rw-r--r--toys/true.c4
-rw-r--r--toys/tty.c4
-rw-r--r--toys/which.c12
-rw-r--r--toys/yes.c4
-rwxr-xr-x[-rw-r--r--]www/index.html0
29 files changed, 53 insertions, 88 deletions
diff --git a/main.c b/main.c
index ba9dc947..4b58d8c2 100644
--- a/main.c
+++ b/main.c
@@ -80,13 +80,12 @@ void toy_exec(char *argv[])
which = toy_find(argv[0]);
if (!which) return;
-
toy_init(which, argv);
-
- exit(toys.which->toy_main());
+ toys.which->toy_main();
+ exit(toys.exitval);
}
-int toybox_main(void)
+void toybox_main(void)
{
static char *toy_paths[]={"usr/","bin/","sbin/",0};
int i, len = 0;
@@ -115,7 +114,6 @@ int toybox_main(void)
}
}
putchar('\n');
- return 0;
}
int main(int argc, char *argv[])
@@ -132,5 +130,6 @@ int main(int argc, char *argv[])
}
toys.argv = argv-1;
- return toybox_main();
+ toybox_main();
+ return 0;
}
diff --git a/toys/basename.c b/toys/basename.c
index da843b86..ee5345e4 100644
--- a/toys/basename.c
+++ b/toys/basename.c
@@ -6,7 +6,7 @@
#include "toys.h"
-int basename_main(void)
+void basename_main(void)
{
char *name = basename(*toys.optargs);
char *suffix = toys.optargs[1];
@@ -15,5 +15,4 @@ int basename_main(void)
if (end>name && !strcmp(end,suffix)) *end=0;
}
puts(name);
- return 0;
}
diff --git a/toys/bzcat.c b/toys/bzcat.c
index 348a5939..984e4186 100644
--- a/toys/bzcat.c
+++ b/toys/bzcat.c
@@ -5,9 +5,7 @@
#include "toys.h"
-int bzcat_main(void)
+void bzcat_main(void)
{
bunzipStream(0, 1);
-
- return 0;
}
diff --git a/toys/catv.c b/toys/catv.c
index 74242010..e5412700 100644
--- a/toys/catv.c
+++ b/toys/catv.c
@@ -34,21 +34,19 @@ void do_catv(int fd, char *name)
}
if (c < 32) {
if (c == 10) {
- if (toys.optflags & 1) putchar('$');
+ if (toys.optflags & 1) xputc('$');
} else if (toys.optflags & (c==9 ? 2 : 4)) {
printf("^%c", c+'@');
continue;
}
}
- putchar(c);
+ xputc(c);
}
}
}
-int catv_main(void)
+void catv_main(void)
{
toys.optflags^=4;
loopfiles(toys.optargs, do_catv);
-
- return toys.exitval;
}
diff --git a/toys/count.c b/toys/count.c
index d7c05ce7..901962b2 100644
--- a/toys/count.c
+++ b/toys/count.c
@@ -5,7 +5,7 @@
#include "toys.h"
-int count_main(void)
+void count_main(void)
{
uint64_t size = 0;
int len;
@@ -18,5 +18,4 @@ int count_main(void)
fdprintf(2, "%"PRIu64" bytes\r", size);
}
fdprintf(2,"\n");
- return 0;
}
diff --git a/toys/df.c b/toys/df.c
index ffff6ce4..52863cc7 100644
--- a/toys/df.c
+++ b/toys/df.c
@@ -55,7 +55,7 @@ static void show_mt(struct mtab_list *mt)
}
}
-int df_main(void)
+void df_main(void)
{
struct mtab_list *mt, *mt2, *mtlist;
@@ -114,6 +114,4 @@ int df_main(void)
}
if (CFG_TOYBOX_FREE) llist_free(mtlist, NULL);
-
- return 0;
}
diff --git a/toys/dirname.c b/toys/dirname.c
index b33836b6..8810bec5 100644
--- a/toys/dirname.c
+++ b/toys/dirname.c
@@ -7,8 +7,7 @@
#include "toys.h"
#include <libgen.h>
-int dirname_main(void)
+void dirname_main(void)
{
puts(dirname(*toys.optargs));
- return 0;
}
diff --git a/toys/dmesg.c b/toys/dmesg.c
index 7a150121..59343897 100644
--- a/toys/dmesg.c
+++ b/toys/dmesg.c
@@ -10,7 +10,7 @@
#define TT toy.dmesg
-int dmesg_main(void)
+void dmesg_main(void)
{
// For -n just tell kernel to which messages to keep.
if (toys.optflags & 2) {
@@ -30,11 +30,9 @@ int dmesg_main(void)
// Display data, filtering out level markers.
for (i=0; i<size; ) {
if (last=='\n' && data[i]=='<') i += 3;
- else putchar(last = data[i++]);
+ else xputc(last = data[i++]);
}
- if (last!='\n') putchar('\n');
+ if (last!='\n') xputc('\n');
if (CFG_TOYBOX_FREE) free(data);
}
-
- return 0;
}
diff --git a/toys/echo.c b/toys/echo.c
index d8ee08f2..be63225e 100644
--- a/toys/echo.c
+++ b/toys/echo.c
@@ -5,7 +5,7 @@
#include "toys.h"
-int echo_main(void)
+void echo_main(void)
{
int i = 0;
char *arg, *from = "\\abfnrtv", *to = "\\\a\b\f\n\r\t\v";
@@ -48,5 +48,4 @@ int echo_main(void)
if (!(toys.optflags&1)) xputc('\n');
done:
xflush();
- return 0;
}
diff --git a/toys/false.c b/toys/false.c
index 48b9d65a..e8f585c5 100644
--- a/toys/false.c
+++ b/toys/false.c
@@ -5,7 +5,7 @@
#include "toys.h"
-int false_main(void)
+void false_main(void)
{
- return 1;
+ toys.exitval = 1;
}
diff --git a/toys/hello.c b/toys/hello.c
index 1f587723..bb344e93 100644
--- a/toys/hello.c
+++ b/toys/hello.c
@@ -5,8 +5,7 @@
#include "toys.h"
-int hello_main(void)
+void hello_main(void)
{
printf("Hello world\n");
- return 0;
}
diff --git a/toys/help.c b/toys/help.c
index ea70a1bf..d4849912 100644
--- a/toys/help.c
+++ b/toys/help.c
@@ -14,7 +14,7 @@ static char *help_data =
#include "toys/toylist.h"
;
-int help_main(void)
+void help_main(void)
{
struct toy_list *t = toy_find(*toys.optargs);
int i = t-toy_list;
@@ -29,5 +29,4 @@ int help_main(void)
}
fprintf(toys.exithelp ? stderr : stdout, "%s", s);
- return 0;
}
diff --git a/toys/mdev.c b/toys/mdev.c
index a4ddb0b7..e979ca13 100644
--- a/toys/mdev.c
+++ b/toys/mdev.c
@@ -180,17 +180,15 @@ static void find_dev(char *path)
closedir(dir);
}
-int mdev_main(int argc, char *argv[])
+void mdev_main(int argc, char *argv[])
{
if (toys.optflags) {
strcpy(toybuf, "/sys/block");
find_dev(toybuf);
strcpy(toybuf, "/sys/class");
find_dev(toybuf);
- return 0;
+ return;
}
// hotplug support goes here
-
- return 0;
}
diff --git a/toys/mke2fs.c b/toys/mke2fs.c
index b102a2fe..5c1d8266 100644
--- a/toys/mke2fs.c
+++ b/toys/mke2fs.c
@@ -339,7 +339,7 @@ static void fill_inode(struct ext2_inode *in, struct dirtree *this)
// The first argument is the name of the file to create. If it already
// exists, that size will be used.
-int mke2fs_main(void)
+void mke2fs_main(void)
{
int i, temp;
off_t length;
@@ -561,8 +561,6 @@ int mke2fs_main(void)
// Write data blocks (TODO)
put_zeroes((end-start) * TT.blocksize);
}
-
- return 0;
}
// Scratch pad:
diff --git a/toys/mkfifo.c b/toys/mkfifo.c
index a15c121c..a959a480 100644
--- a/toys/mkfifo.c
+++ b/toys/mkfifo.c
@@ -7,7 +7,7 @@
#include "toys.h"
-int mkfifo_main(void)
+void mkfifo_main(void)
{
char *arg;
int i;
@@ -24,6 +24,4 @@ int mkfifo_main(void)
for (i = 0; (arg = toys.optargs[i]); i++)
if (mkfifo(arg, mode))
perror_exit(arg);
-
- return 0;
}
diff --git a/toys/oneit.c b/toys/oneit.c
index 3ac5db4f..ed4c29ad 100644
--- a/toys/oneit.c
+++ b/toys/oneit.c
@@ -16,7 +16,7 @@
// PID 1 then reaps zombies until the child process it spawned exits, at which
// point it calls sync() and reboot(). I could stick a kill -1 in there.
-int oneit_main(void)
+void oneit_main(void)
{
int i;
pid_t pid;
@@ -38,7 +38,7 @@ int oneit_main(void)
open("/dev/tty0",O_RDWR);
}
- // Can't xexec() here because we vforked so we don't want to error_exit().
+ // Can't xexec() here, because we vforked so we don't want to error_exit().
toy_exec(toys.optargs);
execvp(*toys.optargs, toys.optargs);
_exit(127);
diff --git a/toys/pwd.c b/toys/pwd.c
index a6fdd441..f5f04e83 100644
--- a/toys/pwd.c
+++ b/toys/pwd.c
@@ -5,12 +5,10 @@
#include "toys.h"
-int pwd_main(void)
+void pwd_main(void)
{
char *pwd = xgetcwd();
xprintf("%s\n", pwd);
if (CFG_TOYBOX_FREE) free(pwd);
-
- return 0;
}
diff --git a/toys/readlink.c b/toys/readlink.c
index 25dc7ba1..60a49770 100644
--- a/toys/readlink.c
+++ b/toys/readlink.c
@@ -6,15 +6,12 @@
#include "toys.h"
-int readlink_main(void)
+void readlink_main(void)
{
char *s = xreadlink(*toys.optargs);
if (s) {
xputs(s);
if (CFG_TOYBOX_FREE) free(s);
- return 0;
- }
-
- return 1;
+ } else toys.exitval = 1;
}
diff --git a/toys/sha1.c b/toys/sha1.c
index 77228afb..7c598c88 100644
--- a/toys/sha1.c
+++ b/toys/sha1.c
@@ -46,7 +46,7 @@ void printy(unsigned char *this)
int i;
for (i = 0; i < 20; i++) printf("%02x", this[i]);
- putchar('\n');
+ xputc('\n');
}
/* Hash a single 512-bit block. This is the core of the algorithm. */
diff --git a/toys/sleep.c b/toys/sleep.c
index 06c4565d..1426690f 100644
--- a/toys/sleep.c
+++ b/toys/sleep.c
@@ -5,7 +5,7 @@
#include "toys.h"
-int sleep_main(void)
+void sleep_main(void)
{
- return sleep(atol(*toys.optargs));
+ toys.exitval = sleep(atol(*toys.optargs));
}
diff --git a/toys/sync.c b/toys/sync.c
index 4918dc47..dcb141d4 100644
--- a/toys/sync.c
+++ b/toys/sync.c
@@ -5,8 +5,7 @@
#include "toys.h"
-int sync_main(void)
+void sync_main(void)
{
sync();
- return 0;
}
diff --git a/toys/touch.c b/toys/touch.c
index a06204ac..61eb18b9 100644
--- a/toys/touch.c
+++ b/toys/touch.c
@@ -20,7 +20,7 @@
#define TIME 0x10
#define LENGTH 0x20
-int touch_main(void)
+void touch_main(void)
{
char *arg;
int i, set_a, set_m, create;
@@ -87,6 +87,4 @@ time_error:
error:
perror_exit(arg);
}
-
- return 0;
}
diff --git a/toys/toylist.h b/toys/toylist.h
index d7f30dcb..074ddbb8 100644
--- a/toys/toylist.h
+++ b/toys/toylist.h
@@ -9,7 +9,7 @@
// file twice (with different macros) to populate toy_list[].
#ifndef NEWTOY
-#define NEWTOY(name, opts, flags) int name##_main(void);
+#define NEWTOY(name, opts, flags) void name##_main(void);
#define OLDTOY(name, oldname, opts, flags)
struct df_data {
@@ -90,7 +90,7 @@ extern union toy_union {
extern struct toy_list {
char *name;
- int (*toy_main)(void);
+ void (*toy_main)(void);
char *options;
int flags;
} toy_list[];
diff --git a/toys/toysh.c b/toys/toysh.c
index 18a3dce4..dbb187fa 100644
--- a/toys/toysh.c
+++ b/toys/toysh.c
@@ -133,7 +133,8 @@ static void run_pipeline(struct pipeline *line)
memcpy(&temp, &toys, sizeof(struct toy_context));
bzero(&toys, sizeof(struct toy_context));
toy_init(tl, cmd->argv);
- cmd->pid = tl->toy_main();
+ tl->toy_main();
+ cmd->pid = toys.exitval;
free(toys.optargs);
memcpy(&toys, &temp, sizeof(struct toy_context));
} else {
@@ -184,19 +185,18 @@ static void handle(char *command)
}
}
-int cd_main(void)
+void cd_main(void)
{
char *dest = *toys.optargs ? *toys.optargs : getenv("HOME");
if (chdir(dest)) error_exit("chdir %s",dest);
- return 0;
}
-int exit_main(void)
+void exit_main(void)
{
exit(*toys.optargs ? atoi(*toys.optargs) : 0);
}
-int toysh_main(void)
+void toysh_main(void)
{
FILE *f;
@@ -210,12 +210,12 @@ int toysh_main(void)
size_t cmdlen = 0;
for (;;) {
char *command = 0;
- if (!f) putchar('$');
+ if (!f) xputc('$');
if (1 > getline(&command, &cmdlen, f ? : stdin)) break;
handle(command);
free(command);
}
}
- return 1;
+ toys.exitval = 1;
}
diff --git a/toys/true.c b/toys/true.c
index 49ec11bf..6e40eb14 100644
--- a/toys/true.c
+++ b/toys/true.c
@@ -5,7 +5,7 @@
#include "toys.h"
-int true_main(void)
+void true_main(void)
{
- return 0;
+ return;
}
diff --git a/toys/tty.c b/toys/tty.c
index d04e3012..3dfba9ee 100644
--- a/toys/tty.c
+++ b/toys/tty.c
@@ -6,12 +6,12 @@
#include "toys.h"
-int tty_main(void)
+void tty_main(void)
{
char *name = ttyname(0);
if (!toys.optflags) {
if (name) puts(name);
else puts("Not a tty");
}
- return !name;
+ toys.exitval = !name;
}
diff --git a/toys/which.c b/toys/which.c
index 546bdcca..c01f3bb3 100644
--- a/toys/which.c
+++ b/toys/which.c
@@ -52,16 +52,12 @@ static int which_in_path(char *filename)
return 0;
}
-int which_main(void)
+void which_main(void)
{
- int rc = 0;
-
- if (!*toys.optargs) rc++;
+ if (!*toys.optargs) toys.exitval++;
else {
int i;
- for (i=0; toys.optargs[i]; i++) rc |= which_in_path(toys.optargs[i]);
+ for (i=0; toys.optargs[i]; i++)
+ toys.exitval |= which_in_path(toys.optargs[i]);
}
- // if (CFG_TOYBOX_FREE) free(argv);
-
- return rc;
}
diff --git a/toys/yes.c b/toys/yes.c
index 6f2c6a3d..0b48929e 100644
--- a/toys/yes.c
+++ b/toys/yes.c
@@ -5,7 +5,7 @@
#include "toys.h"
-int yes_main(void)
+void yes_main(void)
{
for (;;) {
int i;
@@ -16,6 +16,4 @@ int yes_main(void)
if (!i) xputc('y');
xputc('\n');
}
-
- return 0;
}
diff --git a/www/index.html b/www/index.html
index a201bd8e..a201bd8e 100644..100755
--- a/www/index.html
+++ b/www/index.html