diff options
author | mjn3 <mjn3@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | mjn3 <mjn3@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-03-19 09:13:01 +0000 |
commit | e901c15d890dbbdce4c086963cb1513653fc46b5 (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /include/libbb.h | |
parent | 40758c00616c3b2c85d83eb4afdeb04b1f65c9f1 (diff) | |
download | busybox-w32-e901c15d890dbbdce4c086963cb1513653fc46b5.tar.gz busybox-w32-e901c15d890dbbdce4c086963cb1513653fc46b5.tar.bz2 busybox-w32-e901c15d890dbbdce4c086963cb1513653fc46b5.zip |
Major coreutils update.
git-svn-id: svn://busybox.net/trunk/busybox@6751 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 216 |
1 files changed, 133 insertions, 83 deletions
diff --git a/include/libbb.h b/include/libbb.h index 8cb72de8b..f79def321 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <stdarg.h> | 28 | #include <stdarg.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <sys/types.h> | 30 | #include <sys/types.h> |
31 | #include <termios.h> | ||
31 | 32 | ||
32 | #include <netdb.h> | 33 | #include <netdb.h> |
33 | 34 | ||
@@ -86,84 +87,132 @@ char *strtok_r(char *s, const char *delim, char **ptrptr); | |||
86 | #define MAX(a,b) (((a)>(b))?(a):(b)) | 87 | #define MAX(a,b) (((a)>(b))?(a):(b)) |
87 | #endif | 88 | #endif |
88 | 89 | ||
89 | extern void show_usage(void) __attribute__ ((noreturn)); | 90 | extern void bb_show_usage(void) __attribute__ ((noreturn)); |
90 | extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); | 91 | extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); |
91 | extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); | 92 | extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); |
92 | extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); | 93 | extern void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); |
93 | extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); | 94 | extern void bb_perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); |
94 | extern void vherror_msg(const char *s, va_list p); | 95 | extern void bb_vherror_msg(const char *s, va_list p); |
95 | extern void herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); | 96 | extern void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); |
96 | extern void herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); | 97 | extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); |
98 | |||
99 | extern void bb_perror_nomsg_and_die(void) __attribute__ ((noreturn)); | ||
100 | extern void bb_perror_nomsg(void); | ||
97 | 101 | ||
98 | /* These two are used internally -- you shouldn't need to use them */ | 102 | /* These two are used internally -- you shouldn't need to use them */ |
99 | extern void verror_msg(const char *s, va_list p); | 103 | extern void bb_verror_msg(const char *s, va_list p) __attribute__ ((format (printf, 1, 0))); |
100 | extern void vperror_msg(const char *s, va_list p); | 104 | extern void bb_vperror_msg(const char *s, va_list p) __attribute__ ((format (printf, 1, 0))); |
101 | 105 | ||
102 | const char *mode_string(int mode); | 106 | extern const char *bb_mode_string(int mode); |
103 | const char *time_string(time_t timeVal); | 107 | extern int is_directory(const char *name, int followLinks, struct stat *statBuf); |
104 | int is_directory(const char *name, int followLinks, struct stat *statBuf); | 108 | |
105 | int isDevice(const char *name); | 109 | extern int remove_file(const char *path, int flags); |
106 | 110 | extern int copy_file(const char *source, const char *dest, int flags); | |
107 | int remove_file(const char *path, int flags); | 111 | extern ssize_t safe_read(int fd, void *buf, size_t count); |
108 | int copy_file(const char *source, const char *dest, int flags); | 112 | extern ssize_t bb_full_write(int fd, const void *buf, size_t len); |
109 | int copy_file_chunk(FILE *src_file, FILE *dst_file, unsigned long long chunksize); | 113 | extern ssize_t bb_full_read(int fd, void *buf, size_t len); |
110 | char *buildName(const char *dirName, const char *fileName); | 114 | extern int recursive_action(const char *fileName, int recurse, |
111 | int makeString(int argc, const char **argv, char *buf, int bufLen); | 115 | int followLinks, int depthFirst, |
112 | char *getChunk(int size); | ||
113 | char *chunkstrdup(const char *str); | ||
114 | void freeChunks(void); | ||
115 | ssize_t safe_read(int fd, void *buf, size_t count); | ||
116 | int full_write(int fd, const char *buf, int len); | ||
117 | int full_read(int fd, char *buf, int len); | ||
118 | int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst, | ||
119 | int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData), | 116 | int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData), |
120 | int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData), | 117 | int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData), |
121 | void* userData); | 118 | void* userData); |
122 | 119 | ||
123 | extern int parse_mode( const char* s, mode_t* theMode); | 120 | extern int bb_parse_mode( const char* s, mode_t* theMode); |
124 | extern long bb_xgetlarg(char *arg, int base, long lower, long upper); | 121 | extern long bb_xgetlarg(char *arg, int base, long lower, long upper); |
125 | 122 | ||
123 | extern unsigned long bb_baud_to_value(speed_t speed); | ||
124 | extern speed_t bb_value_to_baud(unsigned long value); | ||
125 | |||
126 | extern int get_kernel_revision(void); | 126 | extern int get_kernel_revision(void); |
127 | 127 | ||
128 | extern int get_console_fd(void); | 128 | extern int get_console_fd(void); |
129 | extern struct mntent *find_mount_point(const char *name, const char *table); | 129 | extern struct mntent *find_mount_point(const char *name, const char *table); |
130 | extern void write_mtab(char* blockDevice, char* directory, | 130 | extern void write_mtab(char* blockDevice, char* directory, |
131 | char* filesystemType, long flags, char* string_flags); | 131 | char* filesystemType, long flags, char* string_flags); |
132 | extern void erase_mtab(const char * name); | 132 | extern void erase_mtab(const char * name); |
133 | extern long atoi_w_units (const char *cp); | 133 | extern long *find_pid_by_name( const char* pidName); |
134 | extern long* find_pid_by_name( const char* pidName); | ||
135 | extern char *find_real_root_device_name(const char* name); | 134 | extern char *find_real_root_device_name(const char* name); |
136 | extern char *get_line_from_file(FILE *file); | 135 | extern char *bb_get_line_from_file(FILE *file); |
137 | extern void print_file(FILE *file); | 136 | extern char *bb_get_chomped_line_from_file(FILE *file); |
138 | extern int copyfd(int fd1, int fd2, const off_t chunksize); | 137 | extern int bb_copyfd(int fd1, int fd2, const off_t chunksize); |
139 | extern int print_file_by_name(char *filename); | 138 | extern void bb_xprint_and_close_file(FILE *file); |
140 | extern char process_escape_sequence(const char **ptr); | 139 | extern int bb_xprint_file_by_name(const char *filename); |
141 | extern char *get_last_path_component(char *path); | 140 | extern char bb_process_escape_sequence(const char **ptr); |
142 | extern FILE *wfopen(const char *path, const char *mode); | 141 | extern char *bb_get_last_path_component(char *path); |
143 | extern FILE *xfopen(const char *path, const char *mode); | 142 | extern FILE *bb_wfopen(const char *path, const char *mode); |
143 | extern FILE *bb_xfopen(const char *path, const char *mode); | ||
144 | |||
145 | //#warning rename? | ||
146 | extern int bb_fclose_nonstdin(FILE *f); | ||
147 | extern void bb_fflush_stdout_and_exit(int retval) __attribute__ ((noreturn)); | ||
148 | extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts); | ||
149 | //#warning rename? | ||
150 | extern FILE *bb_wfopen_input(const char *filename); | ||
151 | |||
152 | extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format, | ||
153 | va_list arg) __attribute__ ((format (printf, 2, 0))); | ||
154 | extern int bb_vprintf(const char * __restrict format, va_list arg) | ||
155 | __attribute__ ((format (printf, 1, 0))); | ||
156 | extern int bb_fprintf(FILE * __restrict stream, const char * __restrict format, ...) | ||
157 | __attribute__ ((format (printf, 2, 3))); | ||
158 | extern int bb_printf(const char * __restrict format, ...) | ||
159 | __attribute__ ((format (printf, 1, 2))); | ||
160 | |||
161 | //#warning rename to xferror_filename? | ||
162 | extern void bb_xferror(FILE *fp, const char *fn); | ||
163 | extern void bb_xferror_stdout(void); | ||
164 | extern void bb_xfflush_stdout(void); | ||
165 | |||
166 | extern void bb_warn_ignoring_args(int n); | ||
167 | |||
144 | extern void chomp(char *s); | 168 | extern void chomp(char *s); |
145 | extern void trim(char *s); | 169 | extern void trim(char *s); |
170 | extern const char *bb_skip_whitespace(const char *); | ||
171 | |||
146 | extern struct BB_applet *find_applet_by_name(const char *name); | 172 | extern struct BB_applet *find_applet_by_name(const char *name); |
147 | void run_applet_by_name(const char *name, int argc, char **argv); | 173 | void run_applet_by_name(const char *name, int argc, char **argv); |
148 | 174 | ||
175 | //#warning is this needed anymore? | ||
149 | #ifndef DMALLOC | 176 | #ifndef DMALLOC |
150 | extern void *xmalloc (size_t size); | 177 | extern void *xmalloc (size_t size); |
151 | extern void *xrealloc(void *old, size_t size); | 178 | extern void *xrealloc(void *old, size_t size); |
152 | extern void *xcalloc(size_t nmemb, size_t size); | 179 | extern void *xcalloc(size_t nmemb, size_t size); |
153 | extern char *xstrdup (const char *s); | 180 | extern char *bb_xstrdup (const char *s); |
154 | #endif | 181 | #endif |
155 | extern char *xstrndup (const char *s, int n); | 182 | extern char *bb_xstrndup (const char *s, int n); |
156 | extern char * safe_strncpy(char *dst, const char *src, size_t size); | 183 | extern char * safe_strncpy(char *dst, const char *src, size_t size); |
157 | 184 | ||
158 | struct suffix_mult { | 185 | struct suffix_mult { |
159 | const char *suffix; | 186 | const char *suffix; |
160 | int mult; | 187 | unsigned int mult; |
161 | }; | 188 | }; |
162 | 189 | ||
163 | extern unsigned long parse_number(const char *numstr, | 190 | extern unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base, |
191 | unsigned long lower, | ||
192 | unsigned long upper, | ||
193 | const struct suffix_mult *suffixes); | ||
194 | extern unsigned long bb_xgetularg_bnd(const char *arg, int base, | ||
195 | unsigned long lower, | ||
196 | unsigned long upper); | ||
197 | extern unsigned long bb_xgetularg10_bnd(const char *arg, | ||
198 | unsigned long lower, | ||
199 | unsigned long upper); | ||
200 | extern unsigned long bb_xgetularg10(const char *arg); | ||
201 | |||
202 | extern long bb_xgetlarg_bnd_sfx(const char *arg, int base, | ||
203 | long lower, | ||
204 | long upper, | ||
205 | const struct suffix_mult *suffixes); | ||
206 | extern long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes); | ||
207 | |||
208 | |||
209 | //#warning pitchable now? | ||
210 | extern unsigned long bb_xparse_number(const char *numstr, | ||
164 | const struct suffix_mult *suffixes); | 211 | const struct suffix_mult *suffixes); |
165 | 212 | ||
166 | 213 | ||
214 | //#warning change names? | ||
215 | |||
167 | /* These parse entries in /etc/passwd and /etc/group. This is desirable | 216 | /* These parse entries in /etc/passwd and /etc/group. This is desirable |
168 | * for BusyBox since we want to avoid using the glibc NSS stuff, which | 217 | * for BusyBox since we want to avoid using the glibc NSS stuff, which |
169 | * increases target size and is often not needed embedded systems. */ | 218 | * increases target size and is often not needed embedded systems. */ |
@@ -217,7 +266,7 @@ enum { | |||
217 | }; | 266 | }; |
218 | const char *make_human_readable_str(unsigned long size, unsigned long block_size, unsigned long display_unit); | 267 | const char *make_human_readable_str(unsigned long size, unsigned long block_size, unsigned long display_unit); |
219 | 268 | ||
220 | int ask_confirmation(void); | 269 | int bb_ask_confirmation(void); |
221 | int klogctl(int type, char * b, int len); | 270 | int klogctl(int type, char * b, int len); |
222 | 271 | ||
223 | char *xgetcwd(char *cwd); | 272 | char *xgetcwd(char *cwd); |
@@ -228,6 +277,7 @@ char *last_char_is(const char *s, int c); | |||
228 | extern long arith (const char *startbuf, int *errcode); | 277 | extern long arith (const char *startbuf, int *errcode); |
229 | 278 | ||
230 | int read_package_field(const char *package_buffer, char **field_name, char **field_value); | 279 | int read_package_field(const char *package_buffer, char **field_name, char **field_value); |
280 | //#warning yuk! | ||
231 | char *fgets_str(FILE *file, const char *terminating_string); | 281 | char *fgets_str(FILE *file, const char *terminating_string); |
232 | 282 | ||
233 | extern int uncompress(int fd_in, int fd_out); | 283 | extern int uncompress(int fd_in, int fd_out); |
@@ -239,19 +289,15 @@ extern int create_icmp_socket(void); | |||
239 | extern int create_icmp6_socket(void); | 289 | extern int create_icmp6_socket(void); |
240 | extern int xconnect(const char *host, const char *port); | 290 | extern int xconnect(const char *host, const char *port); |
241 | 291 | ||
292 | //#warning wrap this? | ||
242 | char *dirname (char *path); | 293 | char *dirname (char *path); |
243 | 294 | ||
244 | int make_directory (char *path, long mode, int flags); | 295 | int bb_make_directory (char *path, long mode, int flags); |
245 | 296 | ||
246 | const char *u_signal_names(const char *str_sig, int *signo, int startnum); | 297 | const char *u_signal_names(const char *str_sig, int *signo, int startnum); |
247 | char *simplify_path(const char *path); | 298 | char *bb_simplify_path(const char *path); |
248 | |||
249 | #define CT_AUTO 0 | ||
250 | #define CT_UNIX2DOS 1 | ||
251 | #define CT_DOS2UNIX 2 | ||
252 | /* extern int convert(char *fn, int ConvType); */ | ||
253 | 299 | ||
254 | enum { | 300 | enum { /* DO NOT CHANGE THESE VALUES! cp.c depends on them. */ |
255 | FILEUTILS_PRESERVE_STATUS = 1, | 301 | FILEUTILS_PRESERVE_STATUS = 1, |
256 | FILEUTILS_DEREFERENCE = 2, | 302 | FILEUTILS_DEREFERENCE = 2, |
257 | FILEUTILS_RECUR = 4, | 303 | FILEUTILS_RECUR = 4, |
@@ -259,29 +305,31 @@ enum { | |||
259 | FILEUTILS_INTERACTIVE = 16 | 305 | FILEUTILS_INTERACTIVE = 16 |
260 | }; | 306 | }; |
261 | 307 | ||
262 | extern const char *applet_name; | 308 | extern const char *bb_applet_name; |
263 | extern const char * const full_version; | 309 | |
264 | extern const char * const name_too_long; | 310 | extern const char * const bb_msg_full_version; |
265 | extern const char * const omitting_directory; | 311 | extern const char * const bb_msg_memory_exhausted; |
266 | extern const char * const not_a_directory; | 312 | extern const char * const bb_msg_invalid_date; |
267 | extern const char * const memory_exhausted; | 313 | extern const char * const bb_msg_io_error; |
268 | extern const char * const invalid_date; | 314 | extern const char * const bb_msg_write_error; |
269 | extern const char * const invalid_option; | 315 | extern const char * const bb_msg_name_longer_than_foo; |
270 | extern const char * const io_error; | 316 | extern const char * const bb_msg_unknown; |
271 | extern const char * const dash_dash_help; | 317 | extern const char * const bb_msg_can_not_create_raw_socket; |
272 | extern const char * const write_error; | 318 | extern const char * const bb_msg_perm_denied_are_you_root; |
273 | extern const char * const too_few_args; | 319 | extern const char * const bb_msg_standard_input; |
274 | extern const char * const name_longer_than_foo; | 320 | extern const char * const bb_msg_standard_output; |
275 | extern const char * const unknown; | 321 | |
276 | extern const char * const can_not_create_raw_socket; | 322 | extern const char * const bb_path_nologin_file; |
277 | extern const char * const nologin_file; | 323 | extern const char * const bb_path_passwd_file; |
278 | extern const char * const passwd_file; | 324 | extern const char * const bb_path_shadow_file; |
279 | extern const char * const shadow_file; | 325 | extern const char * const bb_path_gshadow_file; |
280 | extern const char * const gshadow_file; | 326 | extern const char * const bb_path_group_file; |
281 | extern const char * const group_file; | 327 | extern const char * const bb_path_securetty_file; |
282 | extern const char * const securetty_file; | 328 | extern const char * const bb_path_motd_file; |
283 | extern const char * const motd_file; | 329 | |
284 | extern const char * const _path_login; | 330 | extern const char bb_path_mtab_file[]; |
331 | |||
332 | extern int bb_default_error_retval; | ||
285 | 333 | ||
286 | #ifdef CONFIG_FEATURE_DEVFS | 334 | #ifdef CONFIG_FEATURE_DEVFS |
287 | # define CURRENT_VC "/dev/vc/0" | 335 | # define CURRENT_VC "/dev/vc/0" |
@@ -309,6 +357,8 @@ extern const char * const _path_login; | |||
309 | # define LOOP_FORMAT "/dev/loop%d" | 357 | # define LOOP_FORMAT "/dev/loop%d" |
310 | #endif | 358 | #endif |
311 | 359 | ||
360 | //#warning put these in .o files | ||
361 | |||
312 | /* The following devices are the same on devfs and non-devfs systems. */ | 362 | /* The following devices are the same on devfs and non-devfs systems. */ |
313 | #define CURRENT_TTY "/dev/tty" | 363 | #define CURRENT_TTY "/dev/tty" |
314 | #define CONSOLE_DEV "/dev/console" | 364 | #define CONSOLE_DEV "/dev/console" |
@@ -318,10 +368,10 @@ void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); | |||
318 | void reset_ino_dev_hashtable(void); | 368 | void reset_ino_dev_hashtable(void); |
319 | 369 | ||
320 | /* Stupid gcc always includes its own builtin strlen()... */ | 370 | /* Stupid gcc always includes its own builtin strlen()... */ |
321 | extern size_t xstrlen(const char *string); | 371 | extern size_t bb_strlen(const char *string); |
322 | #define strlen(x) xstrlen(x) | 372 | #define strlen(x) bb_strlen(x) |
323 | 373 | ||
324 | void bb_asprintf(char **string_ptr, const char *format, ...) __attribute__ ((format (printf, 2, 3))); | 374 | void bb_xasprintf(char **string_ptr, const char *format, ...) __attribute__ ((format (printf, 2, 3))); |
325 | 375 | ||
326 | 376 | ||
327 | #define FAIL_DELAY 3 | 377 | #define FAIL_DELAY 3 |
@@ -335,10 +385,10 @@ extern char *pw_encrypt(const char *clear, const char *salt); | |||
335 | extern struct spwd *pwd_to_spwd(const struct passwd *pw); | 385 | extern struct spwd *pwd_to_spwd(const struct passwd *pw); |
336 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); | 386 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); |
337 | 387 | ||
338 | extern int xopen(const char *pathname, int flags); | 388 | extern int bb_xopen(const char *pathname, int flags); |
339 | extern ssize_t xread(int fd, void *buf, size_t count); | 389 | extern ssize_t bb_xread(int fd, void *buf, size_t count); |
340 | extern void xread_all(int fd, void *buf, size_t count); | 390 | extern void bb_xread_all(int fd, void *buf, size_t count); |
341 | extern unsigned char xread_char(int fd); | 391 | extern unsigned char bb_xread_char(int fd); |
342 | 392 | ||
343 | typedef struct { | 393 | typedef struct { |
344 | int pid; | 394 | int pid; |