blob: 27647c93352d74e7d4e3e0cc013653bff5281742 [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
landley09ea7ac2006-10-30 01:38:00 -05009#include <ctype.h>
10#include <errno.h>
11#include <fcntl.h>
12#include <inttypes.h>
landley4f344e32006-10-05 16:18:03 -040013#include <limits.h>
Rob Landley6973a1d2006-11-25 16:50:00 -050014#include <setjmp.h>
landley4f344e32006-10-05 16:18:03 -040015#include <stdarg.h>
landley09ea7ac2006-10-30 01:38:00 -050016#include <stdint.h>
landleyc5621502006-09-28 17:18:51 -040017#include <stdio.h>
landley4f344e32006-10-05 16:18:03 -040018#include <stdlib.h>
19#include <string.h>
landleyc5621502006-09-28 17:18:51 -040020#include <strings.h>
Rob Landley055cfcb2007-01-14 20:20:06 -050021#include <sys/ioctl.h>
landley00f87f12006-10-25 18:38:37 -040022#include <sys/stat.h>
landley09ea7ac2006-10-30 01:38:00 -050023#include <sys/statvfs.h>
24#include <sys/types.h>
25#include <sys/wait.h>
landley4f344e32006-10-05 16:18:03 -040026#include <unistd.h>
landleyc5621502006-09-28 17:18:51 -040027
landley4f344e32006-10-05 16:18:03 -040028#include "lib/lib.h"
Rob Landley055cfcb2007-01-14 20:20:06 -050029#include "lib/portability.h"
Rob Landleyf2311a42006-11-04 17:45:18 -050030#include "gen_config.h"
31#include "toys/toylist.h"
landleyc5621502006-09-28 17:18:51 -040032
Rob Landleyf2311a42006-11-04 17:45:18 -050033// These live in main.c
landleyc5621502006-09-28 17:18:51 -040034
landley4f344e32006-10-05 16:18:03 -040035struct toy_list *toy_find(char *name);
landleycd9dfc32006-10-18 18:38:16 -040036void toy_init(struct toy_list *which, char *argv[]);
37void toy_exec(char *argv[]);
landleyc5621502006-09-28 17:18:51 -040038
Rob Landleyf2311a42006-11-04 17:45:18 -050039// Global context for any applet.
landleyc5621502006-09-28 17:18:51 -040040
41extern struct toy_context {
landley4f344e32006-10-05 16:18:03 -040042 struct toy_list *which; // Which entry in toy_list is this one?
43 int exitval; // Value error_exit feeds to exit()
landley09ea7ac2006-10-30 01:38:00 -050044 char **argv; // Command line arguments
Rob Landley8324b892006-11-19 02:49:22 -050045 unsigned optflags; // Command line option flags from get_optflags()
46 char **optargs; // Arguments left over from get_optflags()
landleyc5621502006-09-28 17:18:51 -040047} toys;
Rob Landley8324b892006-11-19 02:49:22 -050048
49// One big temporary buffer, for use by applets (not library functions).
50
Rob Landley055cfcb2007-01-14 20:20:06 -050051extern char toybuf[4096];