blob: 403388ed649aa23291189817dc60623ce7db3fc6 [file] [log] [blame]
landleyc5621502006-09-28 17:18:51 -04001/* 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
Rob Landley90163772007-01-18 21:54:08 -05009#include "lib/portability.h"
10
landley09ea7ac2006-10-30 01:38:00 -050011#include <ctype.h>
12#include <errno.h>
13#include <fcntl.h>
14#include <inttypes.h>
landley4f344e32006-10-05 16:18:03 -040015#include <limits.h>
Rob Landley6973a1d2006-11-25 16:50:00 -050016#include <setjmp.h>
landley4f344e32006-10-05 16:18:03 -040017#include <stdarg.h>
landley09ea7ac2006-10-30 01:38:00 -050018#include <stdint.h>
landleyc5621502006-09-28 17:18:51 -040019#include <stdio.h>
landley4f344e32006-10-05 16:18:03 -040020#include <stdlib.h>
21#include <string.h>
landleyc5621502006-09-28 17:18:51 -040022#include <strings.h>
Rob Landley055cfcb2007-01-14 20:20:06 -050023#include <sys/ioctl.h>
landley00f87f12006-10-25 18:38:37 -040024#include <sys/stat.h>
landley09ea7ac2006-10-30 01:38:00 -050025#include <sys/statvfs.h>
26#include <sys/types.h>
27#include <sys/wait.h>
landley4f344e32006-10-05 16:18:03 -040028#include <unistd.h>
landleyc5621502006-09-28 17:18:51 -040029
landley4f344e32006-10-05 16:18:03 -040030#include "lib/lib.h"
Rob Landleyf2311a42006-11-04 17:45:18 -050031#include "gen_config.h"
32#include "toys/toylist.h"
landleyc5621502006-09-28 17:18:51 -040033
Rob Landleyf2311a42006-11-04 17:45:18 -050034// These live in main.c
landleyc5621502006-09-28 17:18:51 -040035
landley4f344e32006-10-05 16:18:03 -040036struct toy_list *toy_find(char *name);
landleycd9dfc32006-10-18 18:38:16 -040037void toy_init(struct toy_list *which, char *argv[]);
38void toy_exec(char *argv[]);
landleyc5621502006-09-28 17:18:51 -040039
Rob Landleyf2311a42006-11-04 17:45:18 -050040// Global context for any applet.
landleyc5621502006-09-28 17:18:51 -040041
42extern struct toy_context {
landley4f344e32006-10-05 16:18:03 -040043 struct toy_list *which; // Which entry in toy_list is this one?
44 int exitval; // Value error_exit feeds to exit()
landley09ea7ac2006-10-30 01:38:00 -050045 char **argv; // Command line arguments
Rob Landley8324b892006-11-19 02:49:22 -050046 unsigned optflags; // Command line option flags from get_optflags()
47 char **optargs; // Arguments left over from get_optflags()
landleyc5621502006-09-28 17:18:51 -040048} toys;
Rob Landley8324b892006-11-19 02:49:22 -050049
50// One big temporary buffer, for use by applets (not library functions).
51
Rob Landley055cfcb2007-01-14 20:20:06 -050052extern char toybuf[4096];