blob: 7a01c2abae290485379862111337ba0cddc10f4b [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>
landley00f87f12006-10-25 18:38:37 -040021#include <sys/stat.h>
landley09ea7ac2006-10-30 01:38:00 -050022#include <sys/statvfs.h>
23#include <sys/types.h>
24#include <sys/wait.h>
landley4f344e32006-10-05 16:18:03 -040025#include <unistd.h>
landleyc5621502006-09-28 17:18:51 -040026
landley4f344e32006-10-05 16:18:03 -040027#include "lib/lib.h"
Rob Landleyf2311a42006-11-04 17:45:18 -050028#include "gen_config.h"
29#include "toys/toylist.h"
landleyc5621502006-09-28 17:18:51 -040030
Rob Landleyf2311a42006-11-04 17:45:18 -050031// These live in main.c
landleyc5621502006-09-28 17:18:51 -040032
landley4f344e32006-10-05 16:18:03 -040033struct toy_list *toy_find(char *name);
landleycd9dfc32006-10-18 18:38:16 -040034void toy_init(struct toy_list *which, char *argv[]);
35void toy_exec(char *argv[]);
landleyc5621502006-09-28 17:18:51 -040036
Rob Landleyf2311a42006-11-04 17:45:18 -050037// Global context for any applet.
landleyc5621502006-09-28 17:18:51 -040038
39extern struct toy_context {
landley4f344e32006-10-05 16:18:03 -040040 struct toy_list *which; // Which entry in toy_list is this one?
41 int exitval; // Value error_exit feeds to exit()
landley09ea7ac2006-10-30 01:38:00 -050042 char **argv; // Command line arguments
Rob Landley8324b892006-11-19 02:49:22 -050043 unsigned optflags; // Command line option flags from get_optflags()
44 char **optargs; // Arguments left over from get_optflags()
landleyc5621502006-09-28 17:18:51 -040045} toys;
Rob Landley8324b892006-11-19 02:49:22 -050046
47// One big temporary buffer, for use by applets (not library functions).
48
Rob Landley1521a9e2006-11-25 16:06:55 -050049char toybuf[4096];