blob: 3c6cec9256d482afebf2cc3522e8d32851f9e811 [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 Landleyfd1c5ba2007-02-03 14:10:00 -05009#include "gen_config.h"
10
Rob Landley90163772007-01-18 21:54:08 -050011#include "lib/portability.h"
12
landley09ea7ac2006-10-30 01:38:00 -050013#include <ctype.h>
Rob Landleyfd1c5ba2007-02-03 14:10:00 -050014#include <dirent.h>
landley09ea7ac2006-10-30 01:38:00 -050015#include <errno.h>
16#include <fcntl.h>
17#include <inttypes.h>
landley4f344e32006-10-05 16:18:03 -040018#include <limits.h>
Rob Landley6973a1d2006-11-25 16:50:00 -050019#include <setjmp.h>
landley4f344e32006-10-05 16:18:03 -040020#include <stdarg.h>
landley09ea7ac2006-10-30 01:38:00 -050021#include <stdint.h>
landleyc5621502006-09-28 17:18:51 -040022#include <stdio.h>
landley4f344e32006-10-05 16:18:03 -040023#include <stdlib.h>
24#include <string.h>
landleyc5621502006-09-28 17:18:51 -040025#include <strings.h>
Rob Landley055cfcb2007-01-14 20:20:06 -050026#include <sys/ioctl.h>
Rob Landleye2580db2007-01-23 13:20:38 -050027#include <sys/mount.h>
landley00f87f12006-10-25 18:38:37 -040028#include <sys/stat.h>
landley09ea7ac2006-10-30 01:38:00 -050029#include <sys/statvfs.h>
30#include <sys/types.h>
31#include <sys/wait.h>
Rob Landley6b7092f2007-01-23 19:54:01 -050032#include <time.h>
landley4f344e32006-10-05 16:18:03 -040033#include <unistd.h>
landleyc5621502006-09-28 17:18:51 -040034
landley4f344e32006-10-05 16:18:03 -040035#include "lib/lib.h"
Rob Landleye2580db2007-01-23 13:20:38 -050036#include "toys/e2fs.h"
Rob Landley3ac8d262007-01-28 04:54:01 -050037#include "toys/toylist.h"
landleyc5621502006-09-28 17:18:51 -040038
Rob Landleyf2311a42006-11-04 17:45:18 -050039// These live in main.c
landleyc5621502006-09-28 17:18:51 -040040
landley4f344e32006-10-05 16:18:03 -040041struct toy_list *toy_find(char *name);
landleycd9dfc32006-10-18 18:38:16 -040042void toy_init(struct toy_list *which, char *argv[]);
43void toy_exec(char *argv[]);
landleyc5621502006-09-28 17:18:51 -040044
Rob Landleyf2311a42006-11-04 17:45:18 -050045// Global context for any applet.
landleyc5621502006-09-28 17:18:51 -040046
47extern struct toy_context {
landley4f344e32006-10-05 16:18:03 -040048 struct toy_list *which; // Which entry in toy_list is this one?
49 int exitval; // Value error_exit feeds to exit()
landley09ea7ac2006-10-30 01:38:00 -050050 char **argv; // Command line arguments
Rob Landley8324b892006-11-19 02:49:22 -050051 unsigned optflags; // Command line option flags from get_optflags()
52 char **optargs; // Arguments left over from get_optflags()
landleyc5621502006-09-28 17:18:51 -040053} toys;
Rob Landley8324b892006-11-19 02:49:22 -050054
55// One big temporary buffer, for use by applets (not library functions).
56
Rob Landley055cfcb2007-01-14 20:20:06 -050057extern char toybuf[4096];