Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 1 | /* |
| 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 Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 24 | #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 Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 36 | #define STDIN 0 |
| 37 | #define STDOUT 1 |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 38 | #define FALSE ((int) 1) |
| 39 | #define TRUE ((int) 0) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 40 | |
| 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 Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 52 | struct Applet { |
| 53 | const char* name; |
| 54 | int (*main)(int argc, char** argv); |
| 55 | }; |
| 56 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 57 | extern int busybox_main(int argc, char** argv); |
| 58 | extern int block_device_main(int argc, char** argv); |
| 59 | extern int cat_more_main(int argc, char** argv); |
Eric Andersen | 4bea32a | 1999-10-06 00:30:51 +0000 | [diff] [blame] | 60 | extern int more_main(int argc, char** argv); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 61 | extern int cp_main(int argc, char** argv); |
Eric Andersen | 1b61f41 | 1999-10-13 18:56:42 +0000 | [diff] [blame] | 62 | extern int chmod_chown_chgrp_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 63 | extern int chroot_main(int argc, char** argv); |
| 64 | extern int clear_main(int argc, char** argv); |
| 65 | extern int date_main(int argc, char** argv); |
| 66 | extern int dd_main(int argc, char** argv); |
| 67 | extern int df_main(int argc, char** argv); |
| 68 | extern int dmesg_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 69 | extern int false_main(int argc, char** argv); |
| 70 | extern int fdisk_main(int argc, char** argv); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 71 | extern int fdflush_main(int argc, char **argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 72 | extern int find_main(int argc, char** argv); |
| 73 | extern int grep_main(int argc, char** argv); |
| 74 | extern int halt_main(int argc, char** argv); |
| 75 | extern int init_main(int argc, char** argv); |
| 76 | extern int kill_main(int argc, char** argv); |
| 77 | extern int length_main(int argc, char** argv); |
| 78 | extern int ln_main(int argc, char** argv); |
| 79 | extern int loadkmap_main(int argc, char** argv); |
| 80 | extern int losetup_main(int argc, char** argv); |
| 81 | extern int ls_main(int argc, char** argv); |
| 82 | extern int makedevs_main(int argc, char** argv); |
| 83 | extern int math_main(int argc, char** argv); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 84 | extern int mkdir_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 85 | extern int mknod_main(int argc, char** argv); |
| 86 | extern int mkswap_main(int argc, char** argv); |
| 87 | extern int mnc_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 88 | extern int mount_main(int argc, char** argv); |
| 89 | extern int mt_main(int argc, char** argv); |
Eric Andersen | 596e546 | 1999-10-07 08:30:23 +0000 | [diff] [blame] | 90 | extern int mv_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 91 | extern int printf_main(int argc, char** argv); |
| 92 | extern int pwd_main(int argc, char** argv); |
| 93 | extern int reboot_main(int argc, char** argv); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 94 | extern int rmdir_main(int argc, char **argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 95 | extern int rm_main(int argc, char** argv); |
| 96 | extern int scan_partitions_main(int argc, char** argv); |
| 97 | extern int sh_main(int argc, char** argv); |
| 98 | extern int sleep_main(int argc, char** argv); |
| 99 | extern int tar_main(int argc, char** argv); |
Eric Andersen | 596e546 | 1999-10-07 08:30:23 +0000 | [diff] [blame] | 100 | extern int touch_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 101 | extern int sync_main(int argc, char** argv); |
| 102 | extern int tput_main(int argc, char** argv); |
| 103 | extern int true_main(int argc, char** argv); |
| 104 | extern int tryopen_main(int argc, char** argv); |
| 105 | extern int umount_main(int argc, char** argv); |
| 106 | extern int update_main(int argc, char** argv); |
| 107 | extern int zcat_main(int argc, char** argv); |
| 108 | extern int gzip_main(int argc, char** argv); |
| 109 | |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 110 | |
| 111 | const char *modeString(int mode); |
| 112 | const char *timeString(time_t timeVal); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 113 | int isDirectory(const char *name); |
| 114 | int isDevice(const char *name); |
| 115 | int copyFile(const char *srcName, const char *destName, int setModes, |
| 116 | int followLinks); |
| 117 | char *buildName(const char *dirName, const char *fileName); |
| 118 | int makeString(int argc, const char **argv, char *buf, int bufLen); |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 119 | char *getChunk(int size); |
| 120 | char *chunkstrdup(const char *str); |
| 121 | void freeChunks(void); |
| 122 | int fullWrite(int fd, const char *buf, int len); |
| 123 | int fullRead(int fd, char *buf, int len); |
Eric Andersen | bed30e9 | 1999-10-18 19:02:32 +0000 | [diff] [blame^] | 124 | int recursiveAction(const char *fileName, int recurse, int followLinks, int delayDirAction, |
Eric Andersen | 9b58718 | 1999-10-17 05:43:39 +0000 | [diff] [blame] | 125 | int (*fileAction) (const char *fileName, struct stat* statbuf), |
| 126 | int (*dirAction) (const char *fileName, struct stat* statbuf)); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 127 | int match(const char* text, const char * pattern); |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 128 | const char* timeString(time_t timeVal); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 129 | |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 130 | extern void createPath (const char *name, int mode); |
| 131 | extern int parse_mode( const char* s, mode_t* theMode); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 132 | |
| 133 | #endif |
| 134 | |