diff options
| author | Mike Frysinger <vapier@gentoo.org> | 2007-03-09 08:25:24 +0000 |
|---|---|---|
| committer | Mike Frysinger <vapier@gentoo.org> | 2007-03-09 08:25:24 +0000 |
| commit | 67a32adbca0c8db05e0863a72fe0cc644005adee (patch) | |
| tree | 1b5c7929aca17c8abf014e30d9e5d3abd983f30c /shell | |
| parent | a1c631278bce9da92a4e8628a946e0e91cf2e2b5 (diff) | |
| download | busybox-w32-67a32adbca0c8db05e0863a72fe0cc644005adee.tar.gz busybox-w32-67a32adbca0c8db05e0863a72fe0cc644005adee.tar.bz2 busybox-w32-67a32adbca0c8db05e0863a72fe0cc644005adee.zip | |
add STANDALONE support
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/msh.c | 78 |
1 files changed, 73 insertions, 5 deletions
diff --git a/shell/msh.c b/shell/msh.c index 58c498b61..89c375380 100644 --- a/shell/msh.c +++ b/shell/msh.c | |||
| @@ -13,12 +13,80 @@ | |||
| 13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #include <setjmp.h> | 16 | #ifdef STANDALONE |
| 17 | #include <sys/times.h> | 17 | # ifndef _GNU_SOURCE |
| 18 | #include "busybox.h" | 18 | # define _GNU_SOURCE |
| 19 | 19 | # endif | |
| 20 | # include <setjmp.h> | ||
| 21 | # include <sys/times.h> | ||
| 22 | # include <sys/types.h> | ||
| 23 | # include <sys/stat.h> | ||
| 24 | # include <sys/wait.h> | ||
| 25 | # include <signal.h> | ||
| 26 | # include <stdio.h> | ||
| 27 | # include <stdlib.h> | ||
| 28 | # include <unistd.h> | ||
| 29 | # include <string.h> | ||
| 30 | # include <errno.h> | ||
| 31 | # include <dirent.h> | ||
| 32 | # include <fcntl.h> | ||
| 33 | # include <ctype.h> | ||
| 34 | # include <assert.h> | ||
| 35 | # define bb_dev_null "/dev/null" | ||
| 36 | # define DEFAULT_SHELL "/proc/self/exe" | ||
| 37 | # define CONFIG_BUSYBOX_EXEC_PATH "/proc/self/exe" | ||
| 38 | # define BB_BANNER "busybox standalone" | ||
| 39 | # define ENABLE_FEATURE_SH_STANDALONE_SHELL 0 | ||
| 40 | # define bb_msg_memory_exhausted "memory exhausted" | ||
| 41 | # define xmalloc(size) malloc(size) | ||
| 42 | # define msh_main(argc,argv) main(argc,argv) | ||
| 43 | # define safe_read(fd,buf,count) read(fd,buf,count) | ||
| 44 | # define NOT_LONE_DASH(s) ((s)[0] != '-' || (s)[1]) | ||
| 45 | # define LONE_CHAR(s,c) ((s)[0] == (c) && !(s)[1]) | ||
| 46 | # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) | ||
| 47 | static char *find_applet_by_name(const char *applet) | ||
| 48 | { | ||
| 49 | return NULL; | ||
| 50 | } | ||
| 51 | static void utoa_to_buf(unsigned n, char *buf, unsigned buflen) | ||
| 52 | { | ||
| 53 | unsigned i, out, res; | ||
| 54 | assert(sizeof(unsigned) == 4); | ||
| 55 | if (buflen) { | ||
| 56 | out = 0; | ||
| 57 | for (i = 1000000000; i; i /= 10) { | ||
| 58 | res = n / i; | ||
| 59 | if (res || out || i == 1) { | ||
| 60 | if (!--buflen) break; | ||
| 61 | out++; | ||
| 62 | n -= res*i; | ||
| 63 | *buf++ = '0' + res; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | *buf = '\0'; | ||
| 67 | } | ||
| 68 | } | ||
| 69 | static void itoa_to_buf(int n, char *buf, unsigned buflen) | ||
| 70 | { | ||
| 71 | if (buflen && n<0) { | ||
| 72 | n = -n; | ||
| 73 | *buf++ = '-'; | ||
| 74 | buflen--; | ||
| 75 | } | ||
| 76 | utoa_to_buf((unsigned)n, buf, buflen); | ||
| 77 | } | ||
| 78 | static char local_buf[12]; | ||
| 79 | static char *itoa(int n) | ||
| 80 | { | ||
| 81 | itoa_to_buf(n, local_buf, sizeof(local_buf)); | ||
| 82 | return local_buf; | ||
| 83 | } | ||
| 84 | #else | ||
| 85 | # include <setjmp.h> | ||
| 86 | # include <sys/times.h> | ||
| 87 | # include "busybox.h" | ||
| 20 | extern char **environ; | 88 | extern char **environ; |
| 21 | 89 | #endif | |
| 22 | 90 | ||
| 23 | /*#define MSHDEBUG 1*/ | 91 | /*#define MSHDEBUG 1*/ |
| 24 | 92 | ||
