Unneeded code removed, usused field "unsigned pscpu" removed
[oweals/busybox.git] / include / libbb.h
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Busybox main internal header file
4  *
5  * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
6  * Permission has been granted to redistribute this code under the GPL.
7  * 
8  * Licensed under the GPL version 2, see the file LICENSE in this tarball.
9  */
10 #ifndef __LIBBUSYBOX_H__
11 #define __LIBBUSYBOX_H__    1
12
13 #include "platform.h"
14
15 #include <ctype.h>
16 #include <dirent.h>
17 #include <errno.h>
18 #include <fcntl.h>
19 #include <inttypes.h>
20 #include <malloc.h>
21 #include <netdb.h>
22 #include <setjmp.h>
23 #include <signal.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <strings.h>
29 #include <sys/ioctl.h>
30 #include <sys/mman.h>
31 #include <sys/socket.h>
32 #include <sys/stat.h>
33 #include <sys/statfs.h>
34 #include <sys/time.h>
35 #include <sys/types.h>
36 #include <sys/wait.h>
37 #include <termios.h>
38 #include <time.h>
39 #include <unistd.h>
40 #include <utime.h>
41
42 #ifdef CONFIG_SELINUX
43 #include <selinux/selinux.h>
44 #endif
45
46 #ifdef CONFIG_LOCALE_SUPPORT
47 #include <locale.h>
48 #else
49 #define setlocale(x,y)
50 #endif
51
52 #include "pwd_.h"
53 #include "grp_.h"
54 #include "shadow_.h"
55
56 /* Try to pull in PATH_MAX */
57 #include <limits.h>
58 #include <sys/param.h>
59 #ifndef PATH_MAX
60 #define  PATH_MAX         256
61 #endif
62
63 /* Not (yet) used, but tested to work correctly
64 #define MAXINT(T) (T)( \
65         ((T)-1) > 0 \
66         ? (T)-1 \
67         : (T)~((T)1 << (sizeof(T)*8-1)) \
68         )
69
70 #define MININT(T) (T)( \
71         ((T)-1) > 0 \
72         ? (T)0 \
73         : ((T)1 << (sizeof(T)*8-1)) \
74         )
75 */
76
77 /* Large file support */
78 /* Note that CONFIG_LFS forces bbox to be built with all common ops
79  * (stat, lseek etc) mapped to "largefile" variants by libc.
80  * Practically it means that open() automatically has O_LARGEFILE added
81  * and all filesize/file_offset parameters and struct members are "large"
82  * (in today's world - signed 64bit). For full support of large files,
83  * we need a few helper #defines (below) and careful use of off_t
84  * instead of int/ssize_t. No lseek64(), O_LARGEFILE etc necessary */
85 #if ENABLE_LFS
86 /* CONFIG_LFS is on */
87 # if ULONG_MAX > 0xffffffff
88 /* "long" is long enough on this system */
89 #  define STRTOOFF strtol
90 #  define SAFE_STRTOOFF safe_strtol
91 #  define XSTRTOUOFF xstrtoul
92 #  define OFF_FMT "ld"
93 # else
94 /* "long" is too short, need "long long" */
95 #  define STRTOOFF strtoll
96 #  define SAFE_STRTOOFF safe_strtoll
97 #  define XSTRTOUOFF xstrtoull
98 #  define OFF_FMT "lld"
99 # endif
100 #else
101 # if 0 /* #if UINT_MAX == 0xffffffff */
102 /* Doesn't work. off_t is a long. gcc will throw warnings on printf("%d", off_t)
103  * even if long==int on this arch. Crap... */
104 #  define STRTOOFF strtol
105 #  define SAFE_STRTOOFF safe_strtoi
106 #  define XSTRTOUOFF xstrtou
107 #  define OFF_FMT "d"
108 # else
109 #  define STRTOOFF strtol
110 #  define SAFE_STRTOOFF safe_strtol
111 #  define XSTRTOUOFF xstrtoul
112 #  define OFF_FMT "ld"
113 # endif
114 #endif
115 /* scary. better ideas? (but do *test* them first!) */
116 #define OFF_T_MAX  ((off_t)~((off_t)1 << (sizeof(off_t)*8-1)))
117
118 /* Some useful definitions */
119 #undef FALSE
120 #define FALSE   ((int) 0)
121 #undef TRUE
122 #define TRUE    ((int) 1)
123 #undef SKIP
124 #define SKIP    ((int) 2)
125
126 /* for mtab.c */
127 #define MTAB_GETMOUNTPT '1'
128 #define MTAB_GETDEVICE  '2'
129
130 #define BUF_SIZE        8192
131 #define EXPAND_ALLOC    1024
132
133 /* Macros for min/max.  */
134 #ifndef MIN
135 #define MIN(a,b) (((a)<(b))?(a):(b))
136 #endif
137
138 #ifndef MAX
139 #define MAX(a,b) (((a)>(b))?(a):(b))
140 #endif
141
142 /* buffer allocation schemes */
143 #ifdef CONFIG_FEATURE_BUFFERS_GO_ON_STACK
144 #define RESERVE_CONFIG_BUFFER(buffer,len)           char buffer[len]
145 #define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char buffer[len]
146 #define RELEASE_CONFIG_BUFFER(buffer)      ((void)0)
147 #else
148 #ifdef CONFIG_FEATURE_BUFFERS_GO_IN_BSS
149 #define RESERVE_CONFIG_BUFFER(buffer,len)  static          char buffer[len]
150 #define RESERVE_CONFIG_UBUFFER(buffer,len) static unsigned char buffer[len]
151 #define RELEASE_CONFIG_BUFFER(buffer)      ((void)0)
152 #else
153 #define RESERVE_CONFIG_BUFFER(buffer,len)           char *buffer=xmalloc(len)
154 #define RESERVE_CONFIG_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
155 #define RELEASE_CONFIG_BUFFER(buffer)      free (buffer)
156 #endif
157 #endif
158
159
160 #if (__GLIBC__ < 2)
161 int vdprintf(int d, const char *format, va_list ap);
162 #endif
163 // This is declared here rather than #including <libgen.h> in order to avoid
164 // confusing the two versions of basename.  See the dirname/basename man page
165 // for details.
166 char *dirname(char *path);
167 /* Include our own copy of struct sysinfo to avoid binary compatibility
168  * problems with Linux 2.4, which changed things.  Grumble, grumble. */
169 struct sysinfo {
170         long uptime;                    /* Seconds since boot */
171         unsigned long loads[3];         /* 1, 5, and 15 minute load averages */
172         unsigned long totalram;         /* Total usable main memory size */
173         unsigned long freeram;          /* Available memory size */
174         unsigned long sharedram;        /* Amount of shared memory */
175         unsigned long bufferram;        /* Memory used by buffers */
176         unsigned long totalswap;        /* Total swap space size */
177         unsigned long freeswap;         /* swap space still available */
178         unsigned short procs;           /* Number of current processes */
179         unsigned short pad;                     /* Padding needed for m68k */
180         unsigned long totalhigh;        /* Total high memory size */
181         unsigned long freehigh;         /* Available high memory size */
182         unsigned int mem_unit;          /* Memory unit size in bytes */
183         char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
184 };
185 extern int sysinfo(struct sysinfo* info);
186
187
188 extern void chomp(char *s);
189 extern void trim(char *s);
190 extern char *skip_whitespace(const char *);
191
192 extern const char *bb_mode_string(int mode);
193 extern int is_directory(const char *name, int followLinks, struct stat *statBuf);
194 extern int remove_file(const char *path, int flags);
195 extern int copy_file(const char *source, const char *dest, int flags);
196 extern int recursive_action(const char *fileName, int recurse,
197         int followLinks, int depthFirst,
198         int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData, int depth),
199         int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData, int depth),
200         void* userData, int depth);
201 extern int device_open(const char *device, int mode);
202 extern int get_console_fd(void);
203 extern char *find_block_device(char *path);
204 extern off_t bb_copyfd_size(int fd1, int fd2, off_t size);
205 extern off_t bb_copyfd_eof(int fd1, int fd2);
206 extern char bb_process_escape_sequence(const char **ptr);
207 extern char *bb_get_last_path_component(char *path);
208
209
210 extern DIR *xopendir(const char *path);
211 extern DIR *warn_opendir(const char *path);
212
213 char *xgetcwd(char *cwd);
214 char *xreadlink(const char *path);
215 extern void xstat(char *filename, struct stat *buf);
216 extern pid_t spawn(char **argv);
217 extern pid_t xspawn(char **argv);
218 extern int wait4pid(int pid);
219 extern void xsetgid(gid_t gid);
220 extern void xsetuid(uid_t uid);
221 extern void xdaemon(int nochdir, int noclose);
222 extern void xchdir(const char *path);
223 extern void xsetenv(const char *key, const char *value);
224 extern int xopen(const char *pathname, int flags);
225 extern int xopen3(const char *pathname, int flags, int mode);
226 extern off_t xlseek(int fd, off_t offset, int whence);
227 extern off_t fdlength(int fd);
228
229 extern int xsocket(int domain, int type, int protocol);
230 extern void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
231 extern void xlisten(int s, int backlog);
232 extern void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen);
233 extern int xconnect_tcp_v4(struct sockaddr_in *s_addr);
234 extern struct hostent *xgethostbyname(const char *name);
235 extern struct hostent *xgethostbyname2(const char *name, int af);
236
237 extern char *xstrdup(const char *s);
238 extern char *xstrndup(const char *s, int n);
239 extern char *safe_strncpy(char *dst, const char *src, size_t size);
240 extern char *xasprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
241
242 /* dmalloc will redefine these to it's own implementation. It is safe
243  * to have the prototypes here unconditionally.  */
244 extern void *xmalloc(size_t size);
245 extern void *xrealloc(void *old, size_t size);
246 extern void *xzalloc(size_t size);
247
248 extern ssize_t safe_read(int fd, void *buf, size_t count);
249 extern ssize_t full_read(int fd, void *buf, size_t count);
250 extern void xread(int fd, void *buf, size_t count);
251 extern unsigned char xread_char(int fd);
252 extern char *reads(int fd, char *buf, size_t count);
253 extern ssize_t read_close(int fd, void *buf, size_t count);
254 extern ssize_t open_read_close(const char *filename, void *buf, size_t count);
255 extern void *xmalloc_open_read_close(const char *filename, size_t *sizep);
256
257 extern ssize_t safe_write(int fd, const void *buf, size_t count);
258 extern ssize_t full_write(int fd, const void *buf, size_t count);
259 extern void xwrite(int fd, void *buf, size_t count);
260
261 /* Reads and prints to stdout till eof, then closes FILE. Exits on error: */
262 extern void xprint_and_close_file(FILE *file);
263 extern char *xmalloc_fgets(FILE *file);
264 /* Read up to (and including) TERMINATING_STRING: */
265 extern char *xmalloc_fgets_str(FILE *file, const char *terminating_string);
266 /* Chops off '\n' from the end, unlike fgets: */
267 extern char *xmalloc_getline(FILE *file);
268 extern char *bb_get_chunk_from_file(FILE *file, int *end);
269 extern void die_if_ferror(FILE *file, const char *msg);
270 extern void die_if_ferror_stdout(void);
271 extern void xfflush_stdout(void);
272 extern void fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN;
273 extern int fclose_if_not_stdin(FILE *file);
274 extern FILE *xfopen(const char *filename, const char *mode);
275 /* Prints warning to stderr and returns NULL on failure: */
276 extern FILE *fopen_or_warn(const char *filename, const char *mode);
277 /* "Opens" stdin if filename is special, else just opens file: */
278 extern FILE *fopen_or_warn_stdin(const char *filename);
279
280
281 extern void utoa_to_buf(unsigned n, char *buf, unsigned buflen);
282 extern char *utoa(unsigned n);
283 extern void itoa_to_buf(int n, char *buf, unsigned buflen);
284 extern char *itoa(int n);
285
286 // FIXME: the prototype doesn't match libc strtoXX -> confusion
287 // FIXME: alot of unchecked strtoXXX are still in tree
288 // FIXME: atoi_or_else(str, N)?
289 extern int safe_strtoi(const char *arg, int* value);
290 extern int safe_strtou(const char *arg, unsigned* value);
291 extern int safe_strtod(const char *arg, double* value);
292 extern int safe_strtol(const char *arg, long* value);
293 extern int safe_strtoll(const char *arg, long long* value);
294 extern int safe_strtoul(const char *arg, unsigned long* value);
295 extern int safe_strtoull(const char *arg, unsigned long long* value);
296 extern int safe_strtou32(const char *arg, uint32_t* value);
297
298 struct suffix_mult {
299         const char *suffix;
300         unsigned mult;
301 };
302 unsigned long long xstrtoull(const char *numstr, int base);
303 unsigned long long xatoull(const char *numstr);
304 unsigned long xstrtoul_range_sfx(const char *numstr, int base,
305                 unsigned long lower,
306                 unsigned long upper,
307                 const struct suffix_mult *suffixes);
308 unsigned long xstrtoul_range(const char *numstr, int base,
309                 unsigned long lower,
310                 unsigned long upper);
311 unsigned long xstrtoul_sfx(const char *numstr, int base,
312                 const struct suffix_mult *suffixes);
313 unsigned long xstrtoul(const char *numstr, int base);
314 unsigned long xatoul_range_sfx(const char *numstr,
315                 unsigned long lower,
316                 unsigned long upper,
317                 const struct suffix_mult *suffixes);
318 unsigned long xatoul_sfx(const char *numstr,
319                 const struct suffix_mult *suffixes);
320 unsigned long xatoul_range(const char *numstr,
321                 unsigned long lower,
322                 unsigned long upper);
323 unsigned long xatoul(const char *numstr);
324 long xstrtol_range_sfx(const char *numstr, int base,
325                 long lower,
326                 long upper,
327                 const struct suffix_mult *suffixes);
328 long xstrtol_range(const char *numstr, int base, long lower, long upper);
329 long xatol_range_sfx(const char *numstr,
330                 long lower,
331                 long upper,
332                 const struct suffix_mult *suffixes);
333 long xatol_range(const char *numstr, long lower, long upper);
334 long xatol_sfx(const char *numstr, const struct suffix_mult *suffixes);
335 long xatol(const char *numstr);
336 /* Specialized: */
337 unsigned xatou(const char *numstr);
338 int xatoi_range(const char *numstr, int lower, int upper);
339 int xatoi(const char *numstr);
340 /* Using xatoi() instead of naive atoi() is not always convenient -
341  * in many places people want *non-negative* values, but store them
342  * in signed int. Therefore we need this one:
343  * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc */
344 int xatoi_u(const char *numstr);
345 uint32_t xatou32(const char *numstr);
346 /* Useful for reading port numbers */
347 uint16_t xatou16(const char *numstr);
348
349
350 /* These parse entries in /etc/passwd and /etc/group.  This is desirable
351  * for BusyBox since we want to avoid using the glibc NSS stuff, which
352  * increases target size and is often not needed on embedded systems.  */
353 extern long bb_xgetpwnam(const char *name);
354 extern long bb_xgetgrnam(const char *name);
355 extern char *bb_getug(char *buffer, char *idname, long id, int bufsize, char prefix);
356 extern char *bb_getpwuid(char *name, long uid, int bufsize);
357 extern char *bb_getgrgid(char *group, long gid, int bufsize);
358 /* from chpst */
359 struct bb_uidgid_t {
360         uid_t uid;
361         gid_t gid;
362 };
363 extern unsigned uidgid_get(struct bb_uidgid_t*, const char* /*, unsigned*/);
364
365
366 enum { BB_GETOPT_ERROR = 0x80000000 };
367 extern const char *opt_complementary;
368 extern const struct option *applet_long_options;
369 extern uint32_t option_mask32;
370 extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
371
372
373 typedef struct llist_s {
374         char *data;
375         struct llist_s *link;
376 } llist_t;
377 extern void llist_add_to(llist_t **old_head, void *data);
378 extern void llist_add_to_end(llist_t **list_head, void *data);
379 extern void *llist_pop(llist_t **elm);
380 extern void llist_free(llist_t *elm, void (*freeit)(void *data));
381 extern llist_t* rev_llist(llist_t *list);
382
383 enum {
384         LOGMODE_NONE = 0,
385         LOGMODE_STDIO = 1<<0,
386         LOGMODE_SYSLOG = 1<<1,
387         LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
388 };
389 extern const char *msg_eol;
390 extern int logmode;
391 extern int die_sleep;
392 extern int xfunc_error_retval;
393 extern void bb_show_usage(void) ATTRIBUTE_NORETURN ATTRIBUTE_EXTERNALLY_VISIBLE;
394 extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
395 extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
396 extern void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
397 extern void bb_perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
398 extern void bb_vherror_msg(const char *s, va_list p);
399 extern void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
400 extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
401 extern void bb_perror_nomsg_and_die(void) ATTRIBUTE_NORETURN;
402 extern void bb_perror_nomsg(void);
403 extern void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
404 /* These two are used internally -- you shouldn't need to use them */
405 extern void bb_verror_msg(const char *s, va_list p, const char *strerr);
406 extern void bb_vperror_msg(const char *s, va_list p);
407 extern void bb_vinfo_msg(const char *s, va_list p);
408
409
410 extern int bb_echo(int argc, char** argv);
411 extern int bb_test(int argc, char** argv);
412
413 #ifndef BUILD_INDIVIDUAL
414 extern struct BB_applet *find_applet_by_name(const char *name);
415 extern void run_applet_by_name(const char *name, int argc, char **argv);
416 #endif
417
418 extern struct mntent *find_mount_point(const char *name, const char *table);
419 extern void erase_mtab(const char * name);
420 extern unsigned int tty_baud_to_value(speed_t speed);
421 extern speed_t tty_value_to_baud(unsigned int value);
422 extern void bb_warn_ignoring_args(int n);
423
424 extern int get_linux_version_code(void);
425
426 extern char *query_loop(const char *device);
427 extern int del_loop(const char *device);
428 extern int set_loop(char **device, const char *file, unsigned long long offset);
429
430
431 const char *make_human_readable_str(unsigned long long size,
432                 unsigned long block_size, unsigned long display_unit);
433
434 char *bb_askpass(int timeout, const char * prompt);
435 int bb_ask_confirmation(void);
436 int klogctl(int type, char * b, int len);
437
438 extern int bb_parse_mode(const char* s, mode_t* theMode);
439
440 char *concat_path_file(const char *path, const char *filename);
441 char *concat_subpath_file(const char *path, const char *filename);
442 char *last_char_is(const char *s, int c);
443
444 int execable_file(const char *name);
445 char *find_execable(const char *filename);
446 int exists_execable(const char *filename);
447
448 USE_DESKTOP(long long) int uncompress(int fd_in, int fd_out);
449 int inflate(int in, int out);
450
451 int create_icmp_socket(void);
452 int create_icmp6_socket(void);
453
454 unsigned short bb_lookup_port(const char *port, const char *protocol, unsigned short default_port);
455 void bb_lookup_host(struct sockaddr_in *s_in, const char *host);
456
457 int bb_make_directory(char *path, long mode, int flags);
458
459 int get_signum(const char *name);
460 const char *get_signame(int number);
461
462 char *bb_simplify_path(const char *path);
463
464 #define FAIL_DELAY 3
465 extern void bb_do_delay(int seconds);
466 extern void change_identity(const struct passwd *pw);
467 extern const char *change_identity_e2str(const struct passwd *pw);
468 extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args);
469 #ifdef CONFIG_SELINUX
470 extern void renew_current_security_context(void);
471 extern void set_current_security_context(security_context_t sid);
472 #endif
473 extern int run_parts(char **args, const unsigned char test_mode, char **env);
474 extern int restricted_shell(const char *shell);
475 extern void setup_environment(const char *shell, int loginshell, int changeenv, const struct passwd *pw);
476 extern int correct_password(const struct passwd *pw);
477 extern char *pw_encrypt(const char *clear, const char *salt);
478 extern int obscure(const char *old, const char *newval, const struct passwd *pwdp);
479 extern int compare_string_array(const char * const string_array[], const char *key);
480 extern void print_login_issue(const char *issue_file, const char *tty);
481 extern void print_login_prompt(void);
482 #ifdef BB_NOMMU
483 extern void vfork_daemon(int nochdir, int noclose);
484 extern void vfork_daemon_rexec(int nochdir, int noclose,
485                 int argc, char **argv, char *foreground_opt);
486 #endif
487 extern int get_terminal_width_height(int fd, int *width, int *height);
488 extern unsigned long get_ug_id(const char *s, long (*__bb_getxxnam)(const char *));
489
490 int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
491 void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
492 void reset_ino_dev_hashtable(void);
493
494
495 #ifndef COMM_LEN
496 #ifdef TASK_COMM_LEN
497 #define COMM_LEN TASK_COMM_LEN
498 #else
499 /* synchronize with sizeof(task_struct.comm) in /usr/include/linux/sched.h */
500 #define COMM_LEN 16
501 #endif
502 #endif
503 typedef struct {
504         int pid, ppid;
505         char user[9];
506         char state[4];
507         unsigned long rss;
508 #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE
509         unsigned pcpu;
510         unsigned long stime, utime;
511 #endif
512         char *cmd;
513
514         /* basename of executable file in call to exec(2),
515                 size from kernel headers */
516         char short_cmd[COMM_LEN];
517 } procps_status_t;
518 procps_status_t* procps_scan(int save_user_arg0);
519 pid_t *find_pid_by_name(const char* procName);
520 pid_t *pidlist_reverse(pid_t *pidList);
521
522
523 extern const char bb_uuenc_tbl_base64[];
524 extern const char bb_uuenc_tbl_std[];
525 void bb_uuencode(const unsigned char *s, char *store, const int length, const char *tbl);
526
527 typedef struct sha1_ctx_t {
528         uint32_t count[2];
529         uint32_t hash[5];
530         uint32_t wbuf[16];
531 } sha1_ctx_t;
532 void sha1_begin(sha1_ctx_t *ctx);
533 void sha1_hash(const void *data, size_t length, sha1_ctx_t *ctx);
534 void *sha1_end(void *resbuf, sha1_ctx_t *ctx);
535
536 typedef struct md5_ctx_t {
537         uint32_t A;
538         uint32_t B;
539         uint32_t C;
540         uint32_t D;
541         uint64_t total;
542         uint32_t buflen;
543         char buffer[128];
544 } md5_ctx_t;
545 void md5_begin(md5_ctx_t *ctx);
546 void md5_hash(const void *data, size_t length, md5_ctx_t *ctx);
547 void *md5_end(void *resbuf, md5_ctx_t *ctx);
548
549 uint32_t *crc32_filltable(int endian);
550
551
552 enum {  /* DO NOT CHANGE THESE VALUES!  cp.c depends on them. */
553         FILEUTILS_PRESERVE_STATUS = 1,
554         FILEUTILS_DEREFERENCE = 2,
555         FILEUTILS_RECUR = 4,
556         FILEUTILS_FORCE = 8,
557         FILEUTILS_INTERACTIVE = 0x10,
558         FILEUTILS_MAKE_HARDLINK = 0x20,
559         FILEUTILS_MAKE_SOFTLINK = 0x40,
560 };
561 #define FILEUTILS_CP_OPTSTR "pdRfils"
562
563 extern const char *applet_name;
564 extern const char BB_BANNER[];
565
566 extern const char bb_msg_full_version[];
567 extern const char bb_msg_memory_exhausted[];
568 extern const char bb_msg_invalid_date[];
569 extern const char bb_msg_read_error[];
570 extern const char bb_msg_write_error[];
571 extern const char bb_msg_name_longer_than_foo[];
572 extern const char bb_msg_unknown[];
573 extern const char bb_msg_can_not_create_raw_socket[];
574 extern const char bb_msg_perm_denied_are_you_root[];
575 extern const char bb_msg_requires_arg[];
576 extern const char bb_msg_invalid_arg[];
577 extern const char bb_msg_standard_input[];
578 extern const char bb_msg_standard_output[];
579
580 extern const char bb_path_mtab_file[];
581 extern const char bb_path_nologin_file[];
582 extern const char bb_path_passwd_file[];
583 extern const char bb_path_shadow_file[];
584 extern const char bb_path_gshadow_file[];
585 extern const char bb_path_group_file[];
586 extern const char bb_path_securetty_file[];
587 extern const char bb_path_motd_file[];
588 extern const char bb_path_wtmp_file[];
589 extern const char bb_dev_null[];
590
591 #ifndef BUFSIZ
592 #define BUFSIZ 4096
593 #endif
594 extern char bb_common_bufsiz1[BUFSIZ+1];
595
596 /* You can change LIBBB_DEFAULT_LOGIN_SHELL, but don't use it,
597  * use bb_default_login_shell and following defines.
598  * If you change LIBBB_DEFAULT_LOGIN_SHELL,
599  * don't forget to change increment constant. */
600 #define LIBBB_DEFAULT_LOGIN_SHELL      "-/bin/sh"
601 extern const char bb_default_login_shell[];
602 /* "/bin/sh" */
603 #define DEFAULT_SHELL     (bb_default_login_shell+1)
604 /* "sh" */
605 #define DEFAULT_SHELL_SHORT_NAME     (bb_default_login_shell+6)
606
607
608 #ifdef CONFIG_FEATURE_DEVFS
609 # define CURRENT_VC "/dev/vc/0"
610 # define VC_1 "/dev/vc/1"
611 # define VC_2 "/dev/vc/2"
612 # define VC_3 "/dev/vc/3"
613 # define VC_4 "/dev/vc/4"
614 # define VC_5 "/dev/vc/5"
615 #if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)
616 /* Yes, this sucks, but both SH (including sh64) and H8 have a SCI(F) for their
617    respective serial ports .. as such, we can't use the common device paths for
618    these. -- PFM */
619 #  define SC_0 "/dev/ttsc/0"
620 #  define SC_1 "/dev/ttsc/1"
621 #  define SC_FORMAT "/dev/ttsc/%d"
622 #else
623 #  define SC_0 "/dev/tts/0"
624 #  define SC_1 "/dev/tts/1"
625 #  define SC_FORMAT "/dev/tts/%d"
626 #endif
627 # define VC_FORMAT "/dev/vc/%d"
628 # define LOOP_FORMAT "/dev/loop/%d"
629 # define LOOP_NAME "/dev/loop/"
630 # define FB_0 "/dev/fb/0"
631 #else
632 # define CURRENT_VC "/dev/tty0"
633 # define VC_1 "/dev/tty1"
634 # define VC_2 "/dev/tty2"
635 # define VC_3 "/dev/tty3"
636 # define VC_4 "/dev/tty4"
637 # define VC_5 "/dev/tty5"
638 #if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)
639 #  define SC_0 "/dev/ttySC0"
640 #  define SC_1 "/dev/ttySC1"
641 #  define SC_FORMAT "/dev/ttySC%d"
642 #else
643 #  define SC_0 "/dev/ttyS0"
644 #  define SC_1 "/dev/ttyS1"
645 #  define SC_FORMAT "/dev/ttyS%d"
646 #endif
647 # define VC_FORMAT "/dev/tty%d"
648 # define LOOP_FORMAT "/dev/loop%d"
649 # define LOOP_NAME "/dev/loop"
650 # define FB_0 "/dev/fb0"
651 #endif
652
653 /* The following devices are the same on devfs and non-devfs systems.  */
654 #define CURRENT_TTY "/dev/tty"
655 #define CONSOLE_DEV "/dev/console"
656
657
658 #ifndef RB_POWER_OFF
659 /* Stop system and switch power off if possible.  */
660 #define RB_POWER_OFF   0x4321fedc
661 #endif
662
663 // Make sure we call functions instead of macros.
664 #undef isalnum
665 #undef isalpha
666 #undef isascii
667 #undef isblank
668 #undef iscntrl
669 #undef isdigit
670 #undef isgraph
671 #undef islower
672 #undef isprint
673 #undef ispunct
674 #undef isspace
675 #undef isupper
676 #undef isxdigit
677
678 #ifdef DMALLOC
679 #include <dmalloc.h>
680 #endif
681
682 #endif /* __LIBBUSYBOX_H__ */