landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 1 | /* vi: set ts=4 :*/ |
| 2 | /* Toybox infrastructure. |
| 3 | * |
| 4 | * Copyright 2006 Rob Landley <rob@landley.net> |
| 5 | * |
| 6 | * Licensed under GPL version 2, see file LICENSE in this tarball for details. |
| 7 | */ |
| 8 | |
landley | 09ea7ac | 2006-10-30 01:38:00 -0500 | [diff] [blame] | 9 | #include <ctype.h> |
| 10 | #include <errno.h> |
| 11 | #include <fcntl.h> |
| 12 | #include <inttypes.h> |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame] | 13 | #include <limits.h> |
Rob Landley | 6973a1d | 2006-11-25 16:50:00 -0500 | [diff] [blame] | 14 | #include <setjmp.h> |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame] | 15 | #include <stdarg.h> |
landley | 09ea7ac | 2006-10-30 01:38:00 -0500 | [diff] [blame] | 16 | #include <stdint.h> |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 17 | #include <stdio.h> |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame] | 18 | #include <stdlib.h> |
| 19 | #include <string.h> |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 20 | #include <strings.h> |
Rob Landley | 055cfcb | 2007-01-14 20:20:06 -0500 | [diff] [blame^] | 21 | #include <sys/ioctl.h> |
landley | 00f87f1 | 2006-10-25 18:38:37 -0400 | [diff] [blame] | 22 | #include <sys/stat.h> |
landley | 09ea7ac | 2006-10-30 01:38:00 -0500 | [diff] [blame] | 23 | #include <sys/statvfs.h> |
| 24 | #include <sys/types.h> |
| 25 | #include <sys/wait.h> |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame] | 26 | #include <unistd.h> |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 27 | |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame] | 28 | #include "lib/lib.h" |
Rob Landley | 055cfcb | 2007-01-14 20:20:06 -0500 | [diff] [blame^] | 29 | #include "lib/portability.h" |
Rob Landley | f2311a4 | 2006-11-04 17:45:18 -0500 | [diff] [blame] | 30 | #include "gen_config.h" |
| 31 | #include "toys/toylist.h" |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 32 | |
Rob Landley | f2311a4 | 2006-11-04 17:45:18 -0500 | [diff] [blame] | 33 | // These live in main.c |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 34 | |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame] | 35 | struct toy_list *toy_find(char *name); |
landley | cd9dfc3 | 2006-10-18 18:38:16 -0400 | [diff] [blame] | 36 | void toy_init(struct toy_list *which, char *argv[]); |
| 37 | void toy_exec(char *argv[]); |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 38 | |
Rob Landley | f2311a4 | 2006-11-04 17:45:18 -0500 | [diff] [blame] | 39 | // Global context for any applet. |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 40 | |
| 41 | extern struct toy_context { |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame] | 42 | struct toy_list *which; // Which entry in toy_list is this one? |
| 43 | int exitval; // Value error_exit feeds to exit() |
landley | 09ea7ac | 2006-10-30 01:38:00 -0500 | [diff] [blame] | 44 | char **argv; // Command line arguments |
Rob Landley | 8324b89 | 2006-11-19 02:49:22 -0500 | [diff] [blame] | 45 | unsigned optflags; // Command line option flags from get_optflags() |
| 46 | char **optargs; // Arguments left over from get_optflags() |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 47 | } toys; |
Rob Landley | 8324b89 | 2006-11-19 02:49:22 -0500 | [diff] [blame] | 48 | |
| 49 | // One big temporary buffer, for use by applets (not library functions). |
| 50 | |
Rob Landley | 055cfcb | 2007-01-14 20:20:06 -0500 | [diff] [blame^] | 51 | extern char toybuf[4096]; |