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); |
Eric Andersen | e77ae3a | 1999-10-19 20:03:34 +0000 | [diff] [blame] | 59 | extern int cat_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 | e77ae3a | 1999-10-19 20:03:34 +0000 | [diff] [blame] | 69 | extern int dutmp_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 70 | extern int false_main(int argc, char** argv); |
| 71 | extern int fdisk_main(int argc, char** argv); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 72 | extern int fdflush_main(int argc, char **argv); |
Eric Andersen | e494fdd | 1999-10-19 20:23:03 +0000 | [diff] [blame^] | 73 | extern int fsck_minix_main(int argc, char **argv); |
| 74 | extern int mkfs_minix_main(int argc, char **argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 75 | extern int find_main(int argc, char** argv); |
| 76 | extern int grep_main(int argc, char** argv); |
| 77 | extern int halt_main(int argc, char** argv); |
| 78 | extern int init_main(int argc, char** argv); |
| 79 | extern int kill_main(int argc, char** argv); |
| 80 | extern int length_main(int argc, char** argv); |
| 81 | extern int ln_main(int argc, char** argv); |
Eric Andersen | 3e0fbae | 1999-10-19 06:02:44 +0000 | [diff] [blame] | 82 | extern int loadfont_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 83 | extern int loadkmap_main(int argc, char** argv); |
| 84 | extern int losetup_main(int argc, char** argv); |
| 85 | extern int ls_main(int argc, char** argv); |
| 86 | extern int makedevs_main(int argc, char** argv); |
| 87 | extern int math_main(int argc, char** argv); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 88 | extern int mkdir_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 89 | extern int mknod_main(int argc, char** argv); |
| 90 | extern int mkswap_main(int argc, char** argv); |
| 91 | extern int mnc_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 92 | extern int mount_main(int argc, char** argv); |
| 93 | extern int mt_main(int argc, char** argv); |
Eric Andersen | 596e546 | 1999-10-07 08:30:23 +0000 | [diff] [blame] | 94 | extern int mv_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 95 | extern int printf_main(int argc, char** argv); |
| 96 | extern int pwd_main(int argc, char** argv); |
| 97 | extern int reboot_main(int argc, char** argv); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 98 | extern int rmdir_main(int argc, char **argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 99 | extern int rm_main(int argc, char** argv); |
| 100 | extern int scan_partitions_main(int argc, char** argv); |
| 101 | extern int sh_main(int argc, char** argv); |
Eric Andersen | e77ae3a | 1999-10-19 20:03:34 +0000 | [diff] [blame] | 102 | extern int sfdisk_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 103 | extern int sleep_main(int argc, char** argv); |
Eric Andersen | 8759006 | 1999-10-18 21:22:59 +0000 | [diff] [blame] | 104 | extern int swap_on_off_main(int argc, char** argv); |
Eric Andersen | e77ae3a | 1999-10-19 20:03:34 +0000 | [diff] [blame] | 105 | extern int sync_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 106 | extern int tar_main(int argc, char** argv); |
Eric Andersen | 596e546 | 1999-10-07 08:30:23 +0000 | [diff] [blame] | 107 | extern int touch_main(int argc, char** argv); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 108 | extern int tput_main(int argc, char** argv); |
| 109 | extern int true_main(int argc, char** argv); |
| 110 | extern int tryopen_main(int argc, char** argv); |
| 111 | extern int umount_main(int argc, char** argv); |
| 112 | extern int update_main(int argc, char** argv); |
| 113 | extern int zcat_main(int argc, char** argv); |
| 114 | extern int gzip_main(int argc, char** argv); |
| 115 | |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 116 | |
| 117 | const char *modeString(int mode); |
| 118 | const char *timeString(time_t timeVal); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 119 | int isDirectory(const char *name); |
| 120 | int isDevice(const char *name); |
| 121 | int copyFile(const char *srcName, const char *destName, int setModes, |
| 122 | int followLinks); |
| 123 | char *buildName(const char *dirName, const char *fileName); |
| 124 | int makeString(int argc, const char **argv, char *buf, int bufLen); |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 125 | char *getChunk(int size); |
| 126 | char *chunkstrdup(const char *str); |
| 127 | void freeChunks(void); |
| 128 | int fullWrite(int fd, const char *buf, int len); |
| 129 | int fullRead(int fd, char *buf, int len); |
Eric Andersen | bed30e9 | 1999-10-18 19:02:32 +0000 | [diff] [blame] | 130 | int recursiveAction(const char *fileName, int recurse, int followLinks, int delayDirAction, |
Eric Andersen | 9b58718 | 1999-10-17 05:43:39 +0000 | [diff] [blame] | 131 | int (*fileAction) (const char *fileName, struct stat* statbuf), |
| 132 | int (*dirAction) (const char *fileName, struct stat* statbuf)); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 133 | int match(const char* text, const char * pattern); |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 134 | const char* timeString(time_t timeVal); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 135 | |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 136 | extern void createPath (const char *name, int mode); |
| 137 | extern int parse_mode( const char* s, mode_t* theMode); |
Eric Andersen | b0e9a70 | 1999-10-18 22:28:26 +0000 | [diff] [blame] | 138 | extern volatile void usage(const char *usage); |
| 139 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 140 | |
| 141 | #endif |
| 142 | |