Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame^] | 1 | #ifndef _INTERNAL_H_ |
| 2 | #define _INTERNAL_H_ |
| 3 | |
| 4 | #include "busybox.def.h" |
| 5 | |
| 6 | #include <stdlib.h> |
| 7 | #include <string.h> |
| 8 | #include <unistd.h> |
| 9 | #include <sys/stat.h> |
| 10 | |
| 11 | |
| 12 | /* Some useful definitions */ |
| 13 | typedef int BOOL; |
| 14 | #define STDIN 0 |
| 15 | #define STDOUT 1 |
| 16 | #define FALSE ((BOOL) 0) |
| 17 | #define TRUE ((BOOL) 1) |
| 18 | |
| 19 | #define PATH_LEN 1024 |
| 20 | #define BUF_SIZE 8192 |
| 21 | #define EXPAND_ALLOC 1024 |
| 22 | |
| 23 | #define isBlank(ch) (((ch) == ' ') || ((ch) == '\t')) |
| 24 | #define isDecimal(ch) (((ch) >= '0') && ((ch) <= '9')) |
| 25 | #define isOctal(ch) (((ch) >= '0') && ((ch) <= '7')) |
| 26 | #define isWildCard(ch) (((ch) == '*') || ((ch) == '?') || ((ch) == '[')) |
| 27 | |
| 28 | |
| 29 | |
| 30 | struct FileInfo { |
| 31 | unsigned int complainInPostProcess:1; |
| 32 | unsigned int changeUserID:1; |
| 33 | unsigned int changeGroupID:1; |
| 34 | unsigned int changeMode:1; |
| 35 | unsigned int create:1; |
| 36 | unsigned int force:1; |
| 37 | unsigned int recursive:1; |
| 38 | unsigned int processDirectoriesAfterTheirContents; |
| 39 | unsigned int makeParentDirectories:1; |
| 40 | unsigned int didOperation:1; |
| 41 | unsigned int isSymbolicLink:1; |
| 42 | unsigned int makeSymbolicLink:1; |
| 43 | unsigned int dyadic:1; |
| 44 | const char* source; |
| 45 | const char* destination; |
| 46 | int directoryLength; |
| 47 | uid_t userID; |
| 48 | gid_t groupID; |
| 49 | mode_t andWithMode; |
| 50 | mode_t orWithMode; |
| 51 | struct stat stat; |
| 52 | const struct Applet * |
| 53 | applet; |
| 54 | }; |
| 55 | |
| 56 | struct Applet { |
| 57 | const char* name; |
| 58 | int (*main)(int argc, char** argv); |
| 59 | }; |
| 60 | |
| 61 | extern void name_and_error(const char*); |
| 62 | extern int is_a_directory(const char*); |
| 63 | extern char* join_paths(char *, const char *, const char *); |
| 64 | |
| 65 | extern int descend( |
| 66 | struct FileInfo *o |
| 67 | ,int (*function)(const struct FileInfo * i)); |
| 68 | |
| 69 | extern struct mntent * |
| 70 | findMountPoint(const char*, const char *); |
| 71 | |
| 72 | extern void usage(const char*); |
| 73 | extern int busybox_main(int argc, char** argv); |
| 74 | extern int block_device_main(int argc, char** argv); |
| 75 | extern int cat_more_main(int argc, char** argv); |
| 76 | extern int chgrp_main(int argc, char** argv); |
| 77 | extern int chmod_main(int argc, char** argv); |
| 78 | extern int chown_main(int argc, char** argv); |
| 79 | extern int chroot_main(int argc, char** argv); |
| 80 | extern int clear_main(int argc, char** argv); |
| 81 | extern int date_main(int argc, char** argv); |
| 82 | extern int dd_main(int argc, char** argv); |
| 83 | extern int df_main(int argc, char** argv); |
| 84 | extern int dmesg_main(int argc, char** argv); |
| 85 | extern int dyadic_main(int argc, char** argv); |
| 86 | extern int false_main(int argc, char** argv); |
| 87 | extern int fdisk_main(int argc, char** argv); |
| 88 | extern int find_main(int argc, char** argv); |
| 89 | extern int grep_main(int argc, char** argv); |
| 90 | extern int halt_main(int argc, char** argv); |
| 91 | extern int init_main(int argc, char** argv); |
| 92 | extern int kill_main(int argc, char** argv); |
| 93 | extern int length_main(int argc, char** argv); |
| 94 | extern int ln_main(int argc, char** argv); |
| 95 | extern int loadkmap_main(int argc, char** argv); |
| 96 | extern int losetup_main(int argc, char** argv); |
| 97 | extern int ls_main(int argc, char** argv); |
| 98 | extern int makedevs_main(int argc, char** argv); |
| 99 | extern int math_main(int argc, char** argv); |
| 100 | extern int mknod_main(int argc, char** argv); |
| 101 | extern int mkswap_main(int argc, char** argv); |
| 102 | extern int mnc_main(int argc, char** argv); |
| 103 | extern int monadic_main(int argc, char** argv); |
| 104 | extern int mount_main(int argc, char** argv); |
| 105 | extern int mt_main(int argc, char** argv); |
| 106 | extern int printf_main(int argc, char** argv); |
| 107 | extern int pwd_main(int argc, char** argv); |
| 108 | extern int reboot_main(int argc, char** argv); |
| 109 | extern int rm_main(int argc, char** argv); |
| 110 | extern int scan_partitions_main(int argc, char** argv); |
| 111 | extern int sh_main(int argc, char** argv); |
| 112 | extern int sleep_main(int argc, char** argv); |
| 113 | extern int tar_main(int argc, char** argv); |
| 114 | extern int sync_main(int argc, char** argv); |
| 115 | extern int tput_main(int argc, char** argv); |
| 116 | extern int true_main(int argc, char** argv); |
| 117 | extern int tryopen_main(int argc, char** argv); |
| 118 | extern int umount_main(int argc, char** argv); |
| 119 | extern int update_main(int argc, char** argv); |
| 120 | extern int zcat_main(int argc, char** argv); |
| 121 | extern int gzip_main(int argc, char** argv); |
| 122 | |
| 123 | extern int |
| 124 | parse_mode( |
| 125 | const char* s |
| 126 | ,mode_t * or |
| 127 | ,mode_t * and |
| 128 | ,int * group_execute); |
| 129 | |
| 130 | extern int parse_user_name(const char* string, struct FileInfo * i); |
| 131 | |
| 132 | extern const char block_device_usage[]; |
| 133 | extern const char chgrp_usage[]; |
| 134 | extern const char chmod_usage[]; |
| 135 | extern const char chown_usage[]; |
| 136 | extern const char chroot_usage[]; |
| 137 | extern const char clear_usage[]; |
| 138 | extern const char cp_usage[]; |
| 139 | extern const char date_usage[]; |
| 140 | extern const char dd_usage[]; |
| 141 | extern const char df_usage[]; |
| 142 | extern const char dmesg_usage[]; |
| 143 | extern const char dutmp_usage[]; |
| 144 | extern const char false_usage[]; |
| 145 | extern const char fdflush_usage[]; |
| 146 | extern const char find_usage[]; |
| 147 | extern const char grep_usage[]; |
| 148 | extern const char halt_usage[]; |
| 149 | extern const char init_usage[]; |
| 150 | extern const char kill_usage[]; |
| 151 | extern const char length_usage[]; |
| 152 | extern const char ln_usage[]; |
| 153 | extern const char loadkmap_usage[]; |
| 154 | extern const char losetup_usage[]; |
| 155 | extern const char ls_usage[]; |
| 156 | extern const char math_usage[]; |
| 157 | extern const char makedevs_usage[]; |
| 158 | extern const char mkdir_usage[]; |
| 159 | extern const char mknod_usage[]; |
| 160 | extern const char mkswap_usage[]; |
| 161 | extern const char mnc_usage[]; |
| 162 | extern const char more_usage[]; |
| 163 | extern const char mount_usage[]; |
| 164 | extern const char mt_usage[]; |
| 165 | extern const char mv_usage[]; |
| 166 | extern const char printf_usage[]; |
| 167 | extern const char pwd_usage[]; |
| 168 | extern const char reboot_usage[]; |
| 169 | extern const char rm_usage[]; |
| 170 | extern const char rmdir_usage[]; |
| 171 | extern const char scan_partitions_usage[]; |
| 172 | extern const char sleep_usage[]; |
| 173 | extern const char tar_usage[]; |
| 174 | extern const char swapoff_usage[]; |
| 175 | extern const char swapon_usage[]; |
| 176 | extern const char sync_usage[]; |
| 177 | extern const char touch_usage[]; |
| 178 | extern const char tput_usage[]; |
| 179 | extern const char true_usage[]; |
| 180 | extern const char tryopen_usage[]; |
| 181 | extern const char umount_usage[]; |
| 182 | extern const char update_usage[]; |
| 183 | extern const char zcat_usage[]; |
| 184 | extern const char gzip_usage[]; |
| 185 | |
| 186 | |
| 187 | |
| 188 | #endif |
| 189 | |