blob: b676e5f864573f8407e9320f041a0e4eef6bbc82 [file] [log] [blame]
Eric Andersen2b69c401999-10-05 22:58:32 +00001/*
2 * Busybox main header file
3 *
4 * Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
21 * Permission has been granted to redistribute this code under the GPL.
22 *
23 */
Eric Andersencc8ed391999-10-05 16:24:54 +000024#ifndef _INTERNAL_H_
25#define _INTERNAL_H_
26
27#include "busybox.def.h"
28
29#include <stdlib.h>
30#include <string.h>
31#include <unistd.h>
32#include <sys/stat.h>
33
34
35/* Some useful definitions */
Eric Andersencc8ed391999-10-05 16:24:54 +000036#define STDIN 0
37#define STDOUT 1
Eric Andersenf811e071999-10-09 00:25:00 +000038#define FALSE ((int) 1)
39#define TRUE ((int) 0)
Eric Andersencc8ed391999-10-05 16:24:54 +000040
41#define PATH_LEN 1024
42#define BUF_SIZE 8192
43#define EXPAND_ALLOC 1024
44
45#define isBlank(ch) (((ch) == ' ') || ((ch) == '\t'))
46#define isDecimal(ch) (((ch) >= '0') && ((ch) <= '9'))
47#define isOctal(ch) (((ch) >= '0') && ((ch) <= '7'))
48#define isWildCard(ch) (((ch) == '*') || ((ch) == '?') || ((ch) == '['))
49
50
51
Eric Andersencc8ed391999-10-05 16:24:54 +000052struct Applet {
53 const char* name;
54 int (*main)(int argc, char** argv);
55};
56
Eric Andersencc8ed391999-10-05 16:24:54 +000057extern int busybox_main(int argc, char** argv);
58extern int block_device_main(int argc, char** argv);
59extern int cat_more_main(int argc, char** argv);
Eric Andersen4bea32a1999-10-06 00:30:51 +000060extern int more_main(int argc, char** argv);
Eric Andersenf811e071999-10-09 00:25:00 +000061extern int cp_main(int argc, char** argv);
Eric Andersen1b61f411999-10-13 18:56:42 +000062extern int chmod_chown_chgrp_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +000063extern int chroot_main(int argc, char** argv);
64extern int clear_main(int argc, char** argv);
65extern int date_main(int argc, char** argv);
66extern int dd_main(int argc, char** argv);
67extern int df_main(int argc, char** argv);
68extern int dmesg_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +000069extern int false_main(int argc, char** argv);
70extern int fdisk_main(int argc, char** argv);
Eric Andersenf6be9441999-10-13 21:12:06 +000071extern int fdflush_main(int argc, char **argv);
Eric Andersencc8ed391999-10-05 16:24:54 +000072extern int find_main(int argc, char** argv);
73extern int grep_main(int argc, char** argv);
74extern int halt_main(int argc, char** argv);
75extern int init_main(int argc, char** argv);
76extern int kill_main(int argc, char** argv);
77extern int length_main(int argc, char** argv);
78extern int ln_main(int argc, char** argv);
79extern int loadkmap_main(int argc, char** argv);
80extern int losetup_main(int argc, char** argv);
81extern int ls_main(int argc, char** argv);
82extern int makedevs_main(int argc, char** argv);
83extern int math_main(int argc, char** argv);
Eric Andersenf6be9441999-10-13 21:12:06 +000084extern int mkdir_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +000085extern int mknod_main(int argc, char** argv);
86extern int mkswap_main(int argc, char** argv);
87extern int mnc_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +000088extern int mount_main(int argc, char** argv);
89extern int mt_main(int argc, char** argv);
Eric Andersen596e5461999-10-07 08:30:23 +000090extern int mv_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +000091extern int printf_main(int argc, char** argv);
92extern int pwd_main(int argc, char** argv);
93extern int reboot_main(int argc, char** argv);
Eric Andersenf6be9441999-10-13 21:12:06 +000094extern int rmdir_main(int argc, char **argv);
Eric Andersencc8ed391999-10-05 16:24:54 +000095extern int rm_main(int argc, char** argv);
96extern int scan_partitions_main(int argc, char** argv);
97extern int sh_main(int argc, char** argv);
98extern int sleep_main(int argc, char** argv);
Eric Andersen87590061999-10-18 21:22:59 +000099extern int swap_on_off_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000100extern int tar_main(int argc, char** argv);
Eric Andersen596e5461999-10-07 08:30:23 +0000101extern int touch_main(int argc, char** argv);
Eric Andersencc8ed391999-10-05 16:24:54 +0000102extern int sync_main(int argc, char** argv);
103extern int tput_main(int argc, char** argv);
104extern int true_main(int argc, char** argv);
105extern int tryopen_main(int argc, char** argv);
106extern int umount_main(int argc, char** argv);
107extern int update_main(int argc, char** argv);
108extern int zcat_main(int argc, char** argv);
109extern int gzip_main(int argc, char** argv);
110
Eric Andersen2b69c401999-10-05 22:58:32 +0000111
112const char *modeString(int mode);
113const char *timeString(time_t timeVal);
Eric Andersenf811e071999-10-09 00:25:00 +0000114int isDirectory(const char *name);
115int isDevice(const char *name);
116int copyFile(const char *srcName, const char *destName, int setModes,
117 int followLinks);
118char *buildName(const char *dirName, const char *fileName);
119int makeString(int argc, const char **argv, char *buf, int bufLen);
Eric Andersen2b69c401999-10-05 22:58:32 +0000120char *getChunk(int size);
121char *chunkstrdup(const char *str);
122void freeChunks(void);
123int fullWrite(int fd, const char *buf, int len);
124int fullRead(int fd, char *buf, int len);
Eric Andersenbed30e91999-10-18 19:02:32 +0000125int recursiveAction(const char *fileName, int recurse, int followLinks, int delayDirAction,
Eric Andersen9b587181999-10-17 05:43:39 +0000126 int (*fileAction) (const char *fileName, struct stat* statbuf),
127 int (*dirAction) (const char *fileName, struct stat* statbuf));
Eric Andersenf811e071999-10-09 00:25:00 +0000128int match(const char* text, const char * pattern);
Eric Andersen17d49ef1999-10-06 20:25:32 +0000129const char* timeString(time_t timeVal);
Eric Andersencc8ed391999-10-05 16:24:54 +0000130
Eric Andersenf6be9441999-10-13 21:12:06 +0000131extern void createPath (const char *name, int mode);
132extern int parse_mode( const char* s, mode_t* theMode);
Eric Andersencc8ed391999-10-05 16:24:54 +0000133
134#endif
135