blob: e658d3b7db3866c7cf2897c4777be9e0d2ad7d3c [file] [log] [blame]
Eric Andersencc8ed391999-10-05 16:24:54 +00001#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 */
13typedef 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
30struct 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
56struct Applet {
57 const char* name;
58 int (*main)(int argc, char** argv);
59};
60
61extern void name_and_error(const char*);
62extern int is_a_directory(const char*);
63extern char* join_paths(char *, const char *, const char *);
64
65extern int descend(
66 struct FileInfo *o
67 ,int (*function)(const struct FileInfo * i));
68
69extern struct mntent *
70 findMountPoint(const char*, const char *);
71
72extern void usage(const char*);
73extern int busybox_main(int argc, char** argv);
74extern int block_device_main(int argc, char** argv);
75extern int cat_more_main(int argc, char** argv);
76extern int chgrp_main(int argc, char** argv);
77extern int chmod_main(int argc, char** argv);
78extern int chown_main(int argc, char** argv);
79extern int chroot_main(int argc, char** argv);
80extern int clear_main(int argc, char** argv);
81extern int date_main(int argc, char** argv);
82extern int dd_main(int argc, char** argv);
83extern int df_main(int argc, char** argv);
84extern int dmesg_main(int argc, char** argv);
85extern int dyadic_main(int argc, char** argv);
86extern int false_main(int argc, char** argv);
87extern int fdisk_main(int argc, char** argv);
88extern int find_main(int argc, char** argv);
89extern int grep_main(int argc, char** argv);
90extern int halt_main(int argc, char** argv);
91extern int init_main(int argc, char** argv);
92extern int kill_main(int argc, char** argv);
93extern int length_main(int argc, char** argv);
94extern int ln_main(int argc, char** argv);
95extern int loadkmap_main(int argc, char** argv);
96extern int losetup_main(int argc, char** argv);
97extern int ls_main(int argc, char** argv);
98extern int makedevs_main(int argc, char** argv);
99extern int math_main(int argc, char** argv);
100extern int mknod_main(int argc, char** argv);
101extern int mkswap_main(int argc, char** argv);
102extern int mnc_main(int argc, char** argv);
103extern int monadic_main(int argc, char** argv);
104extern int mount_main(int argc, char** argv);
105extern int mt_main(int argc, char** argv);
106extern int printf_main(int argc, char** argv);
107extern int pwd_main(int argc, char** argv);
108extern int reboot_main(int argc, char** argv);
109extern int rm_main(int argc, char** argv);
110extern int scan_partitions_main(int argc, char** argv);
111extern int sh_main(int argc, char** argv);
112extern int sleep_main(int argc, char** argv);
113extern int tar_main(int argc, char** argv);
114extern int sync_main(int argc, char** argv);
115extern int tput_main(int argc, char** argv);
116extern int true_main(int argc, char** argv);
117extern int tryopen_main(int argc, char** argv);
118extern int umount_main(int argc, char** argv);
119extern int update_main(int argc, char** argv);
120extern int zcat_main(int argc, char** argv);
121extern int gzip_main(int argc, char** argv);
122
123extern int
124parse_mode(
125 const char* s
126,mode_t * or
127,mode_t * and
128,int * group_execute);
129
130extern int parse_user_name(const char* string, struct FileInfo * i);
131
132extern const char block_device_usage[];
133extern const char chgrp_usage[];
134extern const char chmod_usage[];
135extern const char chown_usage[];
136extern const char chroot_usage[];
137extern const char clear_usage[];
138extern const char cp_usage[];
139extern const char date_usage[];
140extern const char dd_usage[];
141extern const char df_usage[];
142extern const char dmesg_usage[];
143extern const char dutmp_usage[];
144extern const char false_usage[];
145extern const char fdflush_usage[];
146extern const char find_usage[];
147extern const char grep_usage[];
148extern const char halt_usage[];
149extern const char init_usage[];
150extern const char kill_usage[];
151extern const char length_usage[];
152extern const char ln_usage[];
153extern const char loadkmap_usage[];
154extern const char losetup_usage[];
155extern const char ls_usage[];
156extern const char math_usage[];
157extern const char makedevs_usage[];
158extern const char mkdir_usage[];
159extern const char mknod_usage[];
160extern const char mkswap_usage[];
161extern const char mnc_usage[];
162extern const char more_usage[];
163extern const char mount_usage[];
164extern const char mt_usage[];
165extern const char mv_usage[];
166extern const char printf_usage[];
167extern const char pwd_usage[];
168extern const char reboot_usage[];
169extern const char rm_usage[];
170extern const char rmdir_usage[];
171extern const char scan_partitions_usage[];
172extern const char sleep_usage[];
173extern const char tar_usage[];
174extern const char swapoff_usage[];
175extern const char swapon_usage[];
176extern const char sync_usage[];
177extern const char touch_usage[];
178extern const char tput_usage[];
179extern const char true_usage[];
180extern const char tryopen_usage[];
181extern const char umount_usage[];
182extern const char update_usage[];
183extern const char zcat_usage[];
184extern const char gzip_usage[];
185
186
187
188#endif
189