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 | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 9 | #include <limits.h> |
| 10 | #include <stdarg.h> |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 11 | #include <stdio.h> |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 12 | #include <stdlib.h> |
| 13 | #include <string.h> |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 14 | #include <strings.h> |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 15 | #include <unistd.h> |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 16 | |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 17 | #include "lib/lib.h" |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 18 | |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 19 | int cd_main(void); |
| 20 | int exit_main(void); |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 21 | int toybox_main(void); |
| 22 | int toysh_main(void); |
| 23 | int df_main(void); |
| 24 | |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 25 | #define TOYFLAG_USR (1<<0) |
| 26 | #define TOYFLAG_BIN (1<<1) |
| 27 | #define TOYFLAG_SBIN (1<<2) |
| 28 | #define TOYMASK_LOCATION ((1<<4)-1) |
| 29 | |
| 30 | #define TOYFLAG_NOFORK (1<<4) |
| 31 | |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 32 | extern struct toy_list { |
| 33 | char *name; |
| 34 | int (*toy_main)(void); |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 35 | int flags; |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 36 | } toy_list[]; |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 37 | struct toy_list *toy_find(char *name); |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 38 | |
| 39 | // Global context for this applet. |
| 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 | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 44 | int argc; |
| 45 | char **argv; |
| 46 | char buf[4096]; |
| 47 | } toys; |
| 48 | |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 49 | struct exit_data {;}; |
| 50 | struct cd_data {;}; |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 51 | struct toybox_data {;}; |
| 52 | struct toysh_data {;}; |
| 53 | struct df_data {;}; |
| 54 | |
| 55 | union toy_union { |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 56 | struct exit_data exit; |
| 57 | struct cd_data cd; |
landley | c562150 | 2006-09-28 17:18:51 -0400 | [diff] [blame] | 58 | struct toybox_data toybox; |
| 59 | struct toysh_data toysh; |
| 60 | struct df_data df; |
| 61 | } toy; |
| 62 | |
landley | 4f344e3 | 2006-10-05 16:18:03 -0400 | [diff] [blame^] | 63 | // I need a real config system. |
| 64 | #define CFG_TOYS_FREE 0 |