diff options
author | Eric Andersen <andersen@codepoet.org> | 2005-07-18 23:51:27 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2005-07-18 23:51:27 +0000 |
commit | 164a716f964bba247c660bc70149234f95146871 (patch) | |
tree | 95a8a6f75cb2ed1bb07cb6019088db7348ebf4d4 | |
parent | 8c59a0bf0e9e2d87b0ff273ea3f0bf05bbbf6373 (diff) | |
download | busybox-w32-164a716f964bba247c660bc70149234f95146871.tar.gz busybox-w32-164a716f964bba247c660bc70149234f95146871.tar.bz2 busybox-w32-164a716f964bba247c660bc70149234f95146871.zip |
busybox-1.0.1-rc1.patch
http://busybox.net/lists/busybox/2005-July/014974.html
97 files changed, 1705 insertions, 1129 deletions
diff --git a/busybox/.cvsignore b/busybox/.cvsignore deleted file mode 100644 index 4e4f5863e..000000000 --- a/busybox/.cvsignore +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | busybox | ||
2 | busybox.links | ||
3 | _install | ||
4 | .config | ||
5 | .menuconfig.log | ||
6 | .config.cmd | ||
7 | .config.old | ||
diff --git a/busybox/AUTHORS b/busybox/AUTHORS index 87df22d55..cf2dedd3a 100644 --- a/busybox/AUTHORS +++ b/busybox/AUTHORS | |||
@@ -2,7 +2,7 @@ List of the authors of code contained in BusyBox. | |||
2 | 2 | ||
3 | If you have code in BusyBox, you should be listed here. If you should be | 3 | If you have code in BusyBox, you should be listed here. If you should be |
4 | listed, or the description of what you have done needs more detail, or is | 4 | listed, or the description of what you have done needs more detail, or is |
5 | incorect, _please_ let me know. | 5 | incorrect, _please_ let me know. |
6 | 6 | ||
7 | -Erik | 7 | -Erik |
8 | 8 | ||
@@ -69,6 +69,11 @@ Daniel Jacobowitz <dan@debian.org> | |||
69 | Matt Kraai <kraai@alumni.cmu.edu> | 69 | Matt Kraai <kraai@alumni.cmu.edu> |
70 | documentation, bugfixes, test suite | 70 | documentation, bugfixes, test suite |
71 | 71 | ||
72 | Rob Landley <rob@landley.net> | ||
73 | sed (major rewrite in 2003, and I now maintain the thing). | ||
74 | bunzip2 (complete from-scratch rewrite, then mjn3 optimized the result.) | ||
75 | I've patched lots of other applets, but don't maintain 'em. | ||
76 | |||
72 | Stephan Linz <linz@li-pro.net> | 77 | Stephan Linz <linz@li-pro.net> |
73 | ipcalc, Red Hat equivalence | 78 | ipcalc, Red Hat equivalence |
74 | 79 | ||
@@ -76,9 +81,9 @@ John Lombardo <john@deltanet.com> | |||
76 | tr | 81 | tr |
77 | 82 | ||
78 | Glenn McGrath <bug1@iinet.net.au> | 83 | Glenn McGrath <bug1@iinet.net.au> |
79 | Common unarchving code and unarchiving applets, ifupdown, ftpgetput, | 84 | Common unarchiving code and unarchiving applets, ifupdown, ftpgetput, |
80 | nameif, sed, patch, fold, install, uudecode. | 85 | nameif, sed, patch, fold, install, uudecode. |
81 | Various bugfixes, review and apply numerous patches. | 86 | Various bugfixes, review and apply numerous patches. |
82 | 87 | ||
83 | Manuel Novoa III <mjn3@codepoet.org> | 88 | Manuel Novoa III <mjn3@codepoet.org> |
84 | cat, head, mkfifo, mknod, rmdir, sleep, tee, tty, uniq, usleep, wc, yes, | 89 | cat, head, mkfifo, mknod, rmdir, sleep, tee, tty, uniq, usleep, wc, yes, |
diff --git a/busybox/Makefile b/busybox/Makefile index 3e2b3ef18..81c59a089 100644 --- a/busybox/Makefile +++ b/busybox/Makefile | |||
@@ -22,7 +22,7 @@ | |||
22 | #-------------------------------------------------------------- | 22 | #-------------------------------------------------------------- |
23 | noconfig_targets := menuconfig config oldconfig randconfig \ | 23 | noconfig_targets := menuconfig config oldconfig randconfig \ |
24 | defconfig allyesconfig allnoconfig clean distclean \ | 24 | defconfig allyesconfig allnoconfig clean distclean \ |
25 | release tags | 25 | release tags |
26 | 26 | ||
27 | ifndef TOPDIR | 27 | ifndef TOPDIR |
28 | TOPDIR=$(CURDIR)/ | 28 | TOPDIR=$(CURDIR)/ |
@@ -147,7 +147,7 @@ uninstall: busybox.links | |||
147 | rm -f $(PREFIX)/bin/busybox | 147 | rm -f $(PREFIX)/bin/busybox |
148 | for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done | 148 | for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done |
149 | 149 | ||
150 | install-hardlinks: applets/install.sh busybox busybox.links | 150 | install-hardlinks: $(top_srcdir)/applets/install.sh busybox busybox.links |
151 | $(SHELL) $< $(PREFIX) --hardlinks | 151 | $(SHELL) $< $(PREFIX) --hardlinks |
152 | 152 | ||
153 | check: busybox | 153 | check: busybox |
@@ -193,7 +193,7 @@ scripts/mkdep: $(top_srcdir)/scripts/mkdep.c | |||
193 | scripts/split-include: $(top_srcdir)/scripts/split-include.c | 193 | scripts/split-include: $(top_srcdir)/scripts/split-include.c |
194 | $(HOSTCC) $(HOSTCFLAGS) -o $@ $< | 194 | $(HOSTCC) $(HOSTCFLAGS) -o $@ $< |
195 | 195 | ||
196 | .depend: scripts/mkdep | 196 | .depend: scripts/mkdep include/config.h |
197 | rm -f .depend .hdepend; | 197 | rm -f .depend .hdepend; |
198 | mkdir -p include/config; | 198 | mkdir -p include/config; |
199 | scripts/mkdep -I include -- \ | 199 | scripts/mkdep -I include -- \ |
@@ -201,7 +201,7 @@ scripts/split-include: $(top_srcdir)/scripts/split-include.c | |||
201 | scripts/mkdep -I include -- \ | 201 | scripts/mkdep -I include -- \ |
202 | `find $(top_srcdir) -name \*.h -print | sed -e "s,^./,,"` >> .hdepend; | 202 | `find $(top_srcdir) -name \*.h -print | sed -e "s,^./,,"` >> .hdepend; |
203 | 203 | ||
204 | depend dep: include/config.h .depend | 204 | depend dep: .depend |
205 | 205 | ||
206 | include/config/MARKER: depend scripts/split-include | 206 | include/config/MARKER: depend scripts/split-include |
207 | scripts/split-include include/config.h include/config | 207 | scripts/split-include include/config.h include/config |
diff --git a/busybox/applets/busybox.c b/busybox/applets/busybox.c index dbb5e176b..ee74b4c18 100644 --- a/busybox/applets/busybox.c +++ b/busybox/applets/busybox.c | |||
@@ -144,25 +144,25 @@ int busybox_main(int argc, char **argv) | |||
144 | output_width -= 20; | 144 | output_width -= 20; |
145 | #endif | 145 | #endif |
146 | 146 | ||
147 | fprintf(stderr, "%s\n\n" | 147 | printf("%s\n\n" |
148 | "Usage: busybox [function] [arguments]...\n" | 148 | "Usage: busybox [function] [arguments]...\n" |
149 | " or: [function] [arguments]...\n\n" | 149 | " or: [function] [arguments]...\n\n" |
150 | "\tBusyBox is a multi-call binary that combines many common Unix\n" | 150 | "\tBusyBox is a multi-call binary that combines many common Unix\n" |
151 | "\tutilities into a single executable. Most people will create a\n" | 151 | "\tutilities into a single executable. Most people will create a\n" |
152 | "\tlink to busybox for each function they wish to use, and BusyBox\n" | 152 | "\tlink to busybox for each function they wish to use and BusyBox\n" |
153 | "\twill act like whatever it was invoked as.\n" | 153 | "\twill act like whatever it was invoked as!\n" |
154 | "\nCurrently defined functions:\n", bb_msg_full_version); | 154 | "\nCurrently defined functions:\n", bb_msg_full_version); |
155 | 155 | ||
156 | while (a->name != 0) { | 156 | while (a->name != 0) { |
157 | col += | 157 | col += |
158 | fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "), | 158 | printf("%s%s", ((col == 0) ? "\t" : ", "), |
159 | (a++)->name); | 159 | (a++)->name); |
160 | if (col > output_width && a->name != 0) { | 160 | if (col > output_width && a->name != 0) { |
161 | fprintf(stderr, ",\n"); | 161 | printf(",\n"); |
162 | col = 0; | 162 | col = 0; |
163 | } | 163 | } |
164 | } | 164 | } |
165 | fprintf(stderr, "\n\n"); | 165 | printf("\n\n"); |
166 | exit(0); | 166 | exit(0); |
167 | } | 167 | } |
168 | 168 | ||
diff --git a/busybox/archival/ar.c b/busybox/archival/ar.c index 44c5db035..8326aa6de 100644 --- a/busybox/archival/ar.c +++ b/busybox/archival/ar.c | |||
@@ -56,19 +56,21 @@ static void header_verbose_list_ar(const file_header_t *file_header) | |||
56 | #define AR_OPT_PRESERVE_DATE 0x08 | 56 | #define AR_OPT_PRESERVE_DATE 0x08 |
57 | #define AR_OPT_VERBOSE 0x10 | 57 | #define AR_OPT_VERBOSE 0x10 |
58 | #define AR_OPT_CREATE 0x20 | 58 | #define AR_OPT_CREATE 0x20 |
59 | #define AR_OPT_INSERT 0x40 | ||
59 | 60 | ||
60 | extern int ar_main(int argc, char **argv) | 61 | extern int ar_main(int argc, char **argv) |
61 | { | 62 | { |
62 | archive_handle_t *archive_handle; | 63 | archive_handle_t *archive_handle; |
63 | unsigned long opt; | 64 | unsigned long opt; |
65 | char *msg_unsupported_err = "Archive %s not supported. Install binutils 'ar'."; | ||
64 | char magic[8]; | 66 | char magic[8]; |
65 | 67 | ||
66 | archive_handle = init_handle(); | 68 | archive_handle = init_handle(); |
67 | 69 | ||
68 | bb_opt_complementaly = "p~tx:t~px:x~pt"; | 70 | bb_opt_complementaly = "p~tx:t~px:x~pt"; |
69 | opt = bb_getopt_ulflags(argc, argv, "ptxovc"); | 71 | opt = bb_getopt_ulflags(argc, argv, "ptxovcr"); |
70 | 72 | ||
71 | if ((opt & 0x80000000UL) || (optind == argc)) { | 73 | if ((opt & BB_GETOPT_ERROR) || (opt == 0) || (optind == argc)) { |
72 | bb_show_usage(); | 74 | bb_show_usage(); |
73 | } | 75 | } |
74 | 76 | ||
@@ -88,7 +90,10 @@ extern int ar_main(int argc, char **argv) | |||
88 | archive_handle->action_header = header_verbose_list_ar; | 90 | archive_handle->action_header = header_verbose_list_ar; |
89 | } | 91 | } |
90 | if (opt & AR_OPT_CREATE) { | 92 | if (opt & AR_OPT_CREATE) { |
91 | bb_error_msg_and_die("Archive creation not supported. Install binutils 'ar'."); | 93 | bb_error_msg_and_die(msg_unsupported_err, "creation"); |
94 | } | ||
95 | if (opt & AR_OPT_INSERT) { | ||
96 | bb_error_msg_and_die(msg_unsupported_err, "insertion"); | ||
92 | } | 97 | } |
93 | 98 | ||
94 | archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY); | 99 | archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY); |
diff --git a/busybox/archival/dpkg.c b/busybox/archival/dpkg.c index c096518a2..d3b56e398 100644 --- a/busybox/archival/dpkg.c +++ b/busybox/archival/dpkg.c | |||
@@ -1327,7 +1327,7 @@ void free_array(char **array) | |||
1327 | * the status_hashtable to retrieve the info. This results in smaller code than | 1327 | * the status_hashtable to retrieve the info. This results in smaller code than |
1328 | * scanning the status file. The resulting list, however, is unsorted. | 1328 | * scanning the status file. The resulting list, however, is unsorted. |
1329 | */ | 1329 | */ |
1330 | void list_packages(void) | 1330 | static void list_packages(void) |
1331 | { | 1331 | { |
1332 | int i; | 1332 | int i; |
1333 | 1333 | ||
diff --git a/busybox/archival/dpkg_deb.c b/busybox/archival/dpkg_deb.c index 5aa9881d5..b95ec2d6e 100644 --- a/busybox/archival/dpkg_deb.c +++ b/busybox/archival/dpkg_deb.c | |||
@@ -88,7 +88,7 @@ extern int dpkg_deb_main(int argc, char **argv) | |||
88 | argcount = 2; | 88 | argcount = 2; |
89 | } | 89 | } |
90 | 90 | ||
91 | if ((optind + argcount != argc) || (opt & 0x80000000UL)) { | 91 | if ((optind + argcount != argc) || (opt & BB_GETOPT_ERROR)) { |
92 | bb_show_usage(); | 92 | bb_show_usage(); |
93 | } | 93 | } |
94 | 94 | ||
diff --git a/busybox/archival/gzip.c b/busybox/archival/gzip.c index d494aa30e..6cf4b395e 100644 --- a/busybox/archival/gzip.c +++ b/busybox/archival/gzip.c | |||
@@ -51,12 +51,6 @@ | |||
51 | #include <time.h> | 51 | #include <time.h> |
52 | #include "busybox.h" | 52 | #include "busybox.h" |
53 | 53 | ||
54 | #define memzero(s, n) memset ((void *)(s), 0, (n)) | ||
55 | |||
56 | #ifndef RETSIGTYPE | ||
57 | # define RETSIGTYPE void | ||
58 | #endif | ||
59 | |||
60 | typedef unsigned char uch; | 54 | typedef unsigned char uch; |
61 | typedef unsigned short ush; | 55 | typedef unsigned short ush; |
62 | typedef unsigned long ulg; | 56 | typedef unsigned long ulg; |
@@ -214,9 +208,6 @@ typedef int file_t; /* Do not use stdio */ | |||
214 | static int zip(int in, int out); | 208 | static int zip(int in, int out); |
215 | static int file_read(char *buf, unsigned size); | 209 | static int file_read(char *buf, unsigned size); |
216 | 210 | ||
217 | /* from gzip.c */ | ||
218 | static RETSIGTYPE abort_gzip(void); | ||
219 | |||
220 | /* from deflate.c */ | 211 | /* from deflate.c */ |
221 | static void lm_init(ush * flags); | 212 | static void lm_init(ush * flags); |
222 | static ulg deflate(void); | 213 | static ulg deflate(void); |
@@ -335,7 +326,7 @@ static void put_short(ush w) | |||
335 | /* ======================================================================== | 326 | /* ======================================================================== |
336 | * Signal and error handler. | 327 | * Signal and error handler. |
337 | */ | 328 | */ |
338 | static void abort_gzip() | 329 | static void abort_gzip(int ignored) |
339 | { | 330 | { |
340 | exit(ERROR); | 331 | exit(ERROR); |
341 | } | 332 | } |
@@ -350,13 +341,6 @@ static void clear_bufs(void) | |||
350 | bytes_in = 0L; | 341 | bytes_in = 0L; |
351 | } | 342 | } |
352 | 343 | ||
353 | static void write_bb_error_msg(void) | ||
354 | { | ||
355 | fputc('\n', stderr); | ||
356 | bb_perror_nomsg(); | ||
357 | abort_gzip(); | ||
358 | } | ||
359 | |||
360 | /* =========================================================================== | 344 | /* =========================================================================== |
361 | * Does the same as write(), but also handles partial pipe writes and checks | 345 | * Does the same as write(), but also handles partial pipe writes and checks |
362 | * for error return. | 346 | * for error return. |
@@ -366,9 +350,7 @@ static void write_buf(int fd, void *buf, unsigned cnt) | |||
366 | unsigned n; | 350 | unsigned n; |
367 | 351 | ||
368 | while ((n = write(fd, buf, cnt)) != cnt) { | 352 | while ((n = write(fd, buf, cnt)) != cnt) { |
369 | if (n == (unsigned) (-1)) { | 353 | if (n == (unsigned) (-1)) bb_error_msg_and_die("can't write"); |
370 | write_bb_error_msg(); | ||
371 | } | ||
372 | cnt -= n; | 354 | cnt -= n; |
373 | buf = (void *) ((char *) buf + n); | 355 | buf = (void *) ((char *) buf + n); |
374 | } | 356 | } |
@@ -559,7 +541,7 @@ static unsigned bi_reverse(unsigned code, int len) | |||
559 | /* =========================================================================== | 541 | /* =========================================================================== |
560 | * Write out any remaining bits in an incomplete byte. | 542 | * Write out any remaining bits in an incomplete byte. |
561 | */ | 543 | */ |
562 | static void bi_windup() | 544 | static void bi_windup(void) |
563 | { | 545 | { |
564 | if (bi_valid > 8) { | 546 | if (bi_valid > 8) { |
565 | put_short(bi_buf); | 547 | put_short(bi_buf); |
@@ -846,7 +828,7 @@ static void lm_init(ush * flags) | |||
846 | register unsigned j; | 828 | register unsigned j; |
847 | 829 | ||
848 | /* Initialize the hash table. */ | 830 | /* Initialize the hash table. */ |
849 | memzero((char *) head, HASH_SIZE * sizeof(*head)); | 831 | memset(head, 0, HASH_SIZE * sizeof(*head)); |
850 | /* prev will be initialized on the fly */ | 832 | /* prev will be initialized on the fly */ |
851 | 833 | ||
852 | *flags |= SLOW; | 834 | *flags |= SLOW; |
@@ -996,7 +978,7 @@ static void check_match(IPos start, IPos match, int length) | |||
996 | * file reads are performed for at least two bytes (required for the | 978 | * file reads are performed for at least two bytes (required for the |
997 | * translate_eol option). | 979 | * translate_eol option). |
998 | */ | 980 | */ |
999 | static void fill_window() | 981 | static void fill_window(void) |
1000 | { | 982 | { |
1001 | register unsigned n, m; | 983 | register unsigned n, m; |
1002 | unsigned more = | 984 | unsigned more = |
@@ -1060,7 +1042,7 @@ static void fill_window() | |||
1060 | * evaluation for matches: a match is finally adopted only if there is | 1042 | * evaluation for matches: a match is finally adopted only if there is |
1061 | * no better match at the next window position. | 1043 | * no better match at the next window position. |
1062 | */ | 1044 | */ |
1063 | static ulg deflate() | 1045 | static ulg deflate(void) |
1064 | { | 1046 | { |
1065 | IPos hash_head; /* head of hash chain */ | 1047 | IPos hash_head; /* head of hash chain */ |
1066 | IPos prev_match; /* previous match */ | 1048 | IPos prev_match; /* previous match */ |
@@ -1188,8 +1170,6 @@ static ulg deflate() | |||
1188 | 1170 | ||
1189 | typedef struct dirent dir_type; | 1171 | typedef struct dirent dir_type; |
1190 | 1172 | ||
1191 | typedef RETSIGTYPE(*sig_type) (int); | ||
1192 | |||
1193 | /* ======================================================================== */ | 1173 | /* ======================================================================== */ |
1194 | int gzip_main(int argc, char **argv) | 1174 | int gzip_main(int argc, char **argv) |
1195 | { | 1175 | { |
@@ -1235,16 +1215,16 @@ int gzip_main(int argc, char **argv) | |||
1235 | 1215 | ||
1236 | foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; | 1216 | foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; |
1237 | if (foreground) { | 1217 | if (foreground) { |
1238 | (void) signal(SIGINT, (sig_type) abort_gzip); | 1218 | (void) signal(SIGINT, abort_gzip); |
1239 | } | 1219 | } |
1240 | #ifdef SIGTERM | 1220 | #ifdef SIGTERM |
1241 | if (signal(SIGTERM, SIG_IGN) != SIG_IGN) { | 1221 | if (signal(SIGTERM, SIG_IGN) != SIG_IGN) { |
1242 | (void) signal(SIGTERM, (sig_type) abort_gzip); | 1222 | (void) signal(SIGTERM, abort_gzip); |
1243 | } | 1223 | } |
1244 | #endif | 1224 | #endif |
1245 | #ifdef SIGHUP | 1225 | #ifdef SIGHUP |
1246 | if (signal(SIGHUP, SIG_IGN) != SIG_IGN) { | 1226 | if (signal(SIGHUP, SIG_IGN) != SIG_IGN) { |
1247 | (void) signal(SIGHUP, (sig_type) abort_gzip); | 1227 | (void) signal(SIGHUP, abort_gzip); |
1248 | } | 1228 | } |
1249 | #endif | 1229 | #endif |
1250 | 1230 | ||
@@ -1271,6 +1251,7 @@ int gzip_main(int argc, char **argv) | |||
1271 | for (i = optind; i < argc; i++) { | 1251 | for (i = optind; i < argc; i++) { |
1272 | char *path = NULL; | 1252 | char *path = NULL; |
1273 | 1253 | ||
1254 | clear_bufs(); | ||
1274 | if (strcmp(argv[i], "-") == 0) { | 1255 | if (strcmp(argv[i], "-") == 0) { |
1275 | time_stamp = 0; | 1256 | time_stamp = 0; |
1276 | ifile_size = -1L; | 1257 | ifile_size = -1L; |
@@ -1749,7 +1730,7 @@ static void ct_init(ush * attr, int *methodp) | |||
1749 | /* =========================================================================== | 1730 | /* =========================================================================== |
1750 | * Initialize a new block. | 1731 | * Initialize a new block. |
1751 | */ | 1732 | */ |
1752 | static void init_block() | 1733 | static void init_block(void) |
1753 | { | 1734 | { |
1754 | int n; /* iterates over tree elements */ | 1735 | int n; /* iterates over tree elements */ |
1755 | 1736 | ||
@@ -2162,7 +2143,7 @@ static void send_tree(ct_data * tree, int max_code) | |||
2162 | * Construct the Huffman tree for the bit lengths and return the index in | 2143 | * Construct the Huffman tree for the bit lengths and return the index in |
2163 | * bl_order of the last bit length code to send. | 2144 | * bl_order of the last bit length code to send. |
2164 | */ | 2145 | */ |
2165 | static const int build_bl_tree() | 2146 | static int build_bl_tree(void) |
2166 | { | 2147 | { |
2167 | int max_blindex; /* index of last bit length code of non zero freq */ | 2148 | int max_blindex; /* index of last bit length code of non zero freq */ |
2168 | 2149 | ||
@@ -2425,7 +2406,7 @@ static void compress_block(ct_data * ltree, ct_data * dtree) | |||
2425 | * IN assertion: the fields freq of dyn_ltree are set and the total of all | 2406 | * IN assertion: the fields freq of dyn_ltree are set and the total of all |
2426 | * frequencies does not exceed 64K (to fit in an int on 16 bit machines). | 2407 | * frequencies does not exceed 64K (to fit in an int on 16 bit machines). |
2427 | */ | 2408 | */ |
2428 | static void set_file_type() | 2409 | static void set_file_type(void) |
2429 | { | 2410 | { |
2430 | int n = 0; | 2411 | int n = 0; |
2431 | unsigned ascii_freq = 0; | 2412 | unsigned ascii_freq = 0; |
@@ -2538,7 +2519,7 @@ static int file_read(char *buf, unsigned size) | |||
2538 | * Write the output buffer outbuf[0..outcnt-1] and update bytes_out. | 2519 | * Write the output buffer outbuf[0..outcnt-1] and update bytes_out. |
2539 | * (used for the compressed data only) | 2520 | * (used for the compressed data only) |
2540 | */ | 2521 | */ |
2541 | static void flush_outbuf() | 2522 | static void flush_outbuf(void) |
2542 | { | 2523 | { |
2543 | if (outcnt == 0) | 2524 | if (outcnt == 0) |
2544 | return; | 2525 | return; |
diff --git a/busybox/archival/libunarchive/archive_xread_all_eof.c b/busybox/archival/libunarchive/archive_xread_all_eof.c index 8084e3524..f1eea2928 100644 --- a/busybox/archival/libunarchive/archive_xread_all_eof.c +++ b/busybox/archival/libunarchive/archive_xread_all_eof.c | |||
@@ -26,7 +26,7 @@ extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned | |||
26 | 26 | ||
27 | size = bb_full_read(archive_handle->src_fd, buf, count); | 27 | size = bb_full_read(archive_handle->src_fd, buf, count); |
28 | if ((size != 0) && (size != count)) { | 28 | if ((size != 0) && (size != count)) { |
29 | bb_perror_msg_and_die("Short read, read %d of %d", size, count); | 29 | bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count); |
30 | } | 30 | } |
31 | return(size); | 31 | return(size); |
32 | } | 32 | } |
diff --git a/busybox/archival/libunarchive/decompress_bunzip2.c b/busybox/archival/libunarchive/decompress_bunzip2.c index 259a47776..07e3cf018 100644 --- a/busybox/archival/libunarchive/decompress_bunzip2.c +++ b/busybox/archival/libunarchive/decompress_bunzip2.c | |||
@@ -134,8 +134,6 @@ static unsigned int get_bits(bunzip_data *bd, char bits_wanted) | |||
134 | 134 | ||
135 | static int get_next_block(bunzip_data *bd) | 135 | static int get_next_block(bunzip_data *bd) |
136 | { | 136 | { |
137 | /* Note: Ignore the warning about hufGroup, base and limit being used uninitialized. | ||
138 | * They will be initialized on the fist pass of the loop. */ | ||
139 | struct group_data *hufGroup; | 137 | struct group_data *hufGroup; |
140 | int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector, | 138 | int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector, |
141 | i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256]; | 139 | i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256]; |
@@ -286,16 +284,15 @@ static int get_next_block(bunzip_data *bd) | |||
286 | mtfSymbol[i]=(unsigned char)i; | 284 | mtfSymbol[i]=(unsigned char)i; |
287 | } | 285 | } |
288 | /* Loop through compressed symbols. */ | 286 | /* Loop through compressed symbols. */ |
289 | runPos=dbufCount=symCount=selector=0; | 287 | runPos=dbufCount=selector=0; |
290 | for(;;) { | 288 | for(;;) { |
291 | /* Determine which Huffman coding group to use. */ | 289 | /* fetch next Huffman coding group from list. */ |
292 | if(!(symCount--)) { | 290 | symCount=GROUP_SIZE-1; |
293 | symCount=GROUP_SIZE-1; | 291 | if(selector>=nSelectors) return RETVAL_DATA_ERROR; |
294 | if(selector>=nSelectors) return RETVAL_DATA_ERROR; | 292 | hufGroup=bd->groups+selectors[selector++]; |
295 | hufGroup=bd->groups+selectors[selector++]; | 293 | base=hufGroup->base-1; |
296 | base=hufGroup->base-1; | 294 | limit=hufGroup->limit-1; |
297 | limit=hufGroup->limit-1; | 295 | continue_this_group: |
298 | } | ||
299 | /* Read next Huffman-coded symbol. */ | 296 | /* Read next Huffman-coded symbol. */ |
300 | /* Note: It is far cheaper to read maxLen bits and back up than it is | 297 | /* Note: It is far cheaper to read maxLen bits and back up than it is |
301 | to read minLen bits and then an additional bit at a time, testing | 298 | to read minLen bits and then an additional bit at a time, testing |
@@ -346,7 +343,7 @@ got_huff_bits: | |||
346 | context). Thus space is saved. */ | 343 | context). Thus space is saved. */ |
347 | t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */ | 344 | t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */ |
348 | runPos <<= 1; | 345 | runPos <<= 1; |
349 | continue; | 346 | goto end_of_huffman_loop; |
350 | } | 347 | } |
351 | /* When we hit the first non-run symbol after a run, we now know | 348 | /* When we hit the first non-run symbol after a run, we now know |
352 | how many times to repeat the last literal, so append that many | 349 | how many times to repeat the last literal, so append that many |
@@ -384,6 +381,10 @@ got_huff_bits: | |||
384 | /* We have our literal byte. Save it into dbuf. */ | 381 | /* We have our literal byte. Save it into dbuf. */ |
385 | byteCount[uc]++; | 382 | byteCount[uc]++; |
386 | dbuf[dbufCount++] = (unsigned int)uc; | 383 | dbuf[dbufCount++] = (unsigned int)uc; |
384 | /* Skip group initialization if we're not done with this group. Done this | ||
385 | * way to avoid compiler warning. */ | ||
386 | end_of_huffman_loop: | ||
387 | if(symCount--) goto continue_this_group; | ||
387 | } | 388 | } |
388 | /* At this point, we've read all the Huffman-coded symbols (and repeated | 389 | /* At this point, we've read all the Huffman-coded symbols (and repeated |
389 | runs) for this block from the input stream, and decoded them into the | 390 | runs) for this block from the input stream, and decoded them into the |
diff --git a/busybox/archival/libunarchive/decompress_unzip.c b/busybox/archival/libunarchive/decompress_unzip.c index e8cf54bff..b17065d92 100644 --- a/busybox/archival/libunarchive/decompress_unzip.c +++ b/busybox/archival/libunarchive/decompress_unzip.c | |||
@@ -151,7 +151,10 @@ static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current | |||
151 | /* Leave the first 4 bytes empty so we can always unwind the bitbuffer | 151 | /* Leave the first 4 bytes empty so we can always unwind the bitbuffer |
152 | * to the front of the bytebuffer, leave 4 bytes free at end of tail | 152 | * to the front of the bytebuffer, leave 4 bytes free at end of tail |
153 | * so we can easily top up buffer in check_trailer_gzip() */ | 153 | * so we can easily top up buffer in check_trailer_gzip() */ |
154 | bytebuffer_size = 4 + bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8); | 154 | if (!(bytebuffer_size = bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8))) { |
155 | bb_error_msg_and_die("unexpected end of file"); | ||
156 | } | ||
157 | bytebuffer_size += 4; | ||
155 | bytebuffer_offset = 4; | 158 | bytebuffer_offset = 4; |
156 | } | 159 | } |
157 | bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current; | 160 | bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current; |
diff --git a/busybox/archival/tar.c b/busybox/archival/tar.c index 950e21dd3..b2a212397 100644 --- a/busybox/archival/tar.c +++ b/busybox/archival/tar.c | |||
@@ -724,7 +724,7 @@ int tar_main(int argc, char **argv) | |||
724 | ); | 724 | ); |
725 | 725 | ||
726 | /* Check one and only one context option was given */ | 726 | /* Check one and only one context option was given */ |
727 | if(opt & 0x80000000UL) { | 727 | if(opt & BB_GETOPT_ERROR) { |
728 | bb_show_usage(); | 728 | bb_show_usage(); |
729 | } | 729 | } |
730 | #ifdef CONFIG_FEATURE_TAR_CREATE | 730 | #ifdef CONFIG_FEATURE_TAR_CREATE |
diff --git a/busybox/coreutils/Config.in b/busybox/coreutils/Config.in index e1f0516fd..5a521b536 100644 --- a/busybox/coreutils/Config.in +++ b/busybox/coreutils/Config.in | |||
@@ -545,7 +545,7 @@ config CONFIG_WC | |||
545 | config CONFIG_WHO | 545 | config CONFIG_WHO |
546 | bool "who" | 546 | bool "who" |
547 | default n | 547 | default n |
548 | select CONFIG_FEATURE_U_W_TMP | 548 | select CONFIG_FEATURE_UTMP |
549 | help | 549 | help |
550 | who is used to show who is logged on. | 550 | who is used to show who is logged on. |
551 | 551 | ||
diff --git a/busybox/coreutils/cp.c b/busybox/coreutils/cp.c index 6a82f6bff..97731e83f 100644 --- a/busybox/coreutils/cp.c +++ b/busybox/coreutils/cp.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #include "libcoreutils/coreutils.h" | 42 | #include "libcoreutils/coreutils.h" |
43 | 43 | ||
44 | /* WARNING!! ORDER IS IMPORTANT!! */ | 44 | /* WARNING!! ORDER IS IMPORTANT!! */ |
45 | static const char cp_opts[] = "pdRfiar"; | 45 | static const char cp_opts[] = "pdRfiarP"; |
46 | 46 | ||
47 | extern int cp_main(int argc, char **argv) | 47 | extern int cp_main(int argc, char **argv) |
48 | { | 48 | { |
@@ -73,6 +73,12 @@ extern int cp_main(int argc, char **argv) | |||
73 | */ | 73 | */ |
74 | flags |= FILEUTILS_RECUR; | 74 | flags |= FILEUTILS_RECUR; |
75 | } | 75 | } |
76 | if (flags & 128) { | ||
77 | /* Make -P a synonym for -d, | ||
78 | * -d is the GNU option while -P is the POSIX 2003 option | ||
79 | */ | ||
80 | flags |= FILEUTILS_DEREFERENCE; | ||
81 | } | ||
76 | 82 | ||
77 | flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */ | 83 | flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */ |
78 | 84 | ||
diff --git a/busybox/coreutils/cut.c b/busybox/coreutils/cut.c index d26e80eee..e5fb5aff7 100644 --- a/busybox/coreutils/cut.c +++ b/busybox/coreutils/cut.c | |||
@@ -300,7 +300,7 @@ extern int cut_main(int argc, char **argv) | |||
300 | part = opt & (OPT_BYTE_FLGS|OPT_CHAR_FLGS|OPT_FIELDS_FLGS); | 300 | part = opt & (OPT_BYTE_FLGS|OPT_CHAR_FLGS|OPT_FIELDS_FLGS); |
301 | if(part == 0) | 301 | if(part == 0) |
302 | bb_error_msg_and_die("you must specify a list of bytes, characters, or fields"); | 302 | bb_error_msg_and_die("you must specify a list of bytes, characters, or fields"); |
303 | if(opt & 0x80000000UL) | 303 | if(opt & BB_GETOPT_ERROR) |
304 | bb_error_msg_and_die("only one type of list may be specified"); | 304 | bb_error_msg_and_die("only one type of list may be specified"); |
305 | parse_lists(sopt); | 305 | parse_lists(sopt); |
306 | if((opt & (OPT_DELIM_FLGS))) { | 306 | if((opt & (OPT_DELIM_FLGS))) { |
diff --git a/busybox/coreutils/date.c b/busybox/coreutils/date.c index 3608df69f..70484e2cd 100644 --- a/busybox/coreutils/date.c +++ b/busybox/coreutils/date.c | |||
@@ -136,7 +136,6 @@ int date_main(int argc, char **argv) | |||
136 | { | 136 | { |
137 | char *date_str = NULL; | 137 | char *date_str = NULL; |
138 | char *date_fmt = NULL; | 138 | char *date_fmt = NULL; |
139 | char *t_buff; | ||
140 | int set_time; | 139 | int set_time; |
141 | int utc; | 140 | int utc; |
142 | int use_arg = 0; | 141 | int use_arg = 0; |
@@ -166,7 +165,7 @@ int date_main(int argc, char **argv) | |||
166 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 165 | bb_error_msg_and_die(bb_msg_memory_exhausted); |
167 | } | 166 | } |
168 | use_arg = opt & DATE_OPT_DATE; | 167 | use_arg = opt & DATE_OPT_DATE; |
169 | if(opt & 0x80000000UL) | 168 | if(opt & BB_GETOPT_ERROR) |
170 | bb_show_usage(); | 169 | bb_show_usage(); |
171 | #ifdef CONFIG_FEATURE_DATE_ISOFMT | 170 | #ifdef CONFIG_FEATURE_DATE_ISOFMT |
172 | if(opt & DATE_OPT_TIMESPEC) { | 171 | if(opt & DATE_OPT_TIMESPEC) { |
@@ -283,10 +282,13 @@ int date_main(int argc, char **argv) | |||
283 | date_fmt = "%Y.%m.%d-%H:%M:%S"; | 282 | date_fmt = "%Y.%m.%d-%H:%M:%S"; |
284 | } | 283 | } |
285 | 284 | ||
286 | /* Print OUTPUT (after ALL that!) */ | 285 | { |
287 | t_buff = xmalloc(201); | 286 | /* Print OUTPUT (after ALL that!) */ |
288 | strftime(t_buff, 200, date_fmt, &tm_time); | 287 | RESERVE_CONFIG_BUFFER(t_buff, 201); |
289 | puts(t_buff); | 288 | strftime(t_buff, 200, date_fmt, &tm_time); |
289 | puts(t_buff); | ||
290 | RELEASE_CONFIG_BUFFER(t_buff); | ||
291 | } | ||
290 | 292 | ||
291 | return EXIT_SUCCESS; | 293 | return EXIT_SUCCESS; |
292 | } | 294 | } |
diff --git a/busybox/coreutils/expr.c b/busybox/coreutils/expr.c index cbbd4cd03..3f052d92a 100644 --- a/busybox/coreutils/expr.c +++ b/busybox/coreutils/expr.c | |||
@@ -245,10 +245,9 @@ static int arithmetic_common (VALUE *l, VALUE *r, int op) | |||
245 | static VALUE *docolon (VALUE *sv, VALUE *pv) | 245 | static VALUE *docolon (VALUE *sv, VALUE *pv) |
246 | { | 246 | { |
247 | VALUE *v; | 247 | VALUE *v; |
248 | const char *errmsg; | 248 | regex_t re_buffer; |
249 | struct re_pattern_buffer re_buffer; | 249 | const int NMATCH = 2; |
250 | struct re_registers re_regs; | 250 | regmatch_t re_regs[NMATCH]; |
251 | int len; | ||
252 | 251 | ||
253 | tostring (sv); | 252 | tostring (sv); |
254 | tostring (pv); | 253 | tostring (pv); |
@@ -260,27 +259,22 @@ of a basic regular expression is not portable; it is being ignored", | |||
260 | pv->u.s); | 259 | pv->u.s); |
261 | } | 260 | } |
262 | 261 | ||
263 | len = strlen (pv->u.s); | ||
264 | memset (&re_buffer, 0, sizeof (re_buffer)); | 262 | memset (&re_buffer, 0, sizeof (re_buffer)); |
265 | memset (&re_regs, 0, sizeof (re_regs)); | 263 | memset (re_regs, 0, sizeof (*re_regs)); |
266 | re_buffer.allocated = 2 * len; | 264 | if( regcomp (&re_buffer, pv->u.s, 0) != 0 ) |
267 | re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated); | 265 | bb_error_msg_and_die("Invalid regular expression"); |
268 | re_buffer.translate = 0; | 266 | |
269 | re_syntax_options = RE_SYNTAX_POSIX_BASIC; | 267 | /* expr uses an anchored pattern match, so check that there was a |
270 | errmsg = re_compile_pattern (pv->u.s, len, &re_buffer); | 268 | * match and that the match starts at offset 0. */ |
271 | if (errmsg) { | 269 | if (regexec (&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH && |
272 | bb_error_msg_and_die("%s", errmsg); | 270 | re_regs[0].rm_so == 0) { |
273 | } | ||
274 | |||
275 | len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs); | ||
276 | if (len >= 0) { | ||
277 | /* Were \(...\) used? */ | 271 | /* Were \(...\) used? */ |
278 | if (re_buffer.re_nsub > 0) { /* was (re_regs.start[1] >= 0) */ | 272 | if (re_buffer.re_nsub > 0) { |
279 | sv->u.s[re_regs.end[1]] = '\0'; | 273 | sv->u.s[re_regs[1].rm_eo] = '\0'; |
280 | v = str_value (sv->u.s + re_regs.start[1]); | 274 | v = str_value (sv->u.s + re_regs[1].rm_so); |
281 | } | 275 | } |
282 | else | 276 | else |
283 | v = int_value (len); | 277 | v = int_value (re_regs[0].rm_eo); |
284 | } | 278 | } |
285 | else { | 279 | else { |
286 | /* Match failed -- return the right kind of null. */ | 280 | /* Match failed -- return the right kind of null. */ |
@@ -289,7 +283,6 @@ of a basic regular expression is not portable; it is being ignored", | |||
289 | else | 283 | else |
290 | v = int_value (0); | 284 | v = int_value (0); |
291 | } | 285 | } |
292 | free (re_buffer.buffer); | ||
293 | return v; | 286 | return v; |
294 | } | 287 | } |
295 | 288 | ||
diff --git a/busybox/coreutils/id.c b/busybox/coreutils/id.c index d5182b953..b10a7c1bf 100644 --- a/busybox/coreutils/id.c +++ b/busybox/coreutils/id.c | |||
@@ -68,7 +68,7 @@ extern int id_main(int argc, char **argv) | |||
68 | bb_opt_complementaly = "u~g:g~u"; | 68 | bb_opt_complementaly = "u~g:g~u"; |
69 | flags = bb_getopt_ulflags(argc, argv, "rnug"); | 69 | flags = bb_getopt_ulflags(argc, argv, "rnug"); |
70 | 70 | ||
71 | if ((flags & 0x80000000UL) | 71 | if ((flags & BB_GETOPT_ERROR) |
72 | /* Don't allow -n -r -nr */ | 72 | /* Don't allow -n -r -nr */ |
73 | || (flags <= 3 && flags > 0) | 73 | || (flags <= 3 && flags > 0) |
74 | /* Don't allow more than one username */ | 74 | /* Don't allow more than one username */ |
diff --git a/busybox/coreutils/install.c b/busybox/coreutils/install.c index 36dc1d618..345e75af0 100644 --- a/busybox/coreutils/install.c +++ b/busybox/coreutils/install.c | |||
@@ -69,7 +69,7 @@ extern int install_main(int argc, char **argv) | |||
69 | flags = bb_getopt_ulflags(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */ | 69 | flags = bb_getopt_ulflags(argc, argv, "cdpsg:m:o:", &gid_str, &mode_str, &uid_str); /* 'a' must be 2nd */ |
70 | 70 | ||
71 | /* Check valid options were given */ | 71 | /* Check valid options were given */ |
72 | if(flags & 0x80000000UL) { | 72 | if(flags & BB_GETOPT_ERROR) { |
73 | bb_show_usage(); | 73 | bb_show_usage(); |
74 | } | 74 | } |
75 | 75 | ||
diff --git a/busybox/coreutils/md5_sha1_sum.c b/busybox/coreutils/md5_sha1_sum.c index bd1c9fc29..543c2ab3f 100644 --- a/busybox/coreutils/md5_sha1_sum.c +++ b/busybox/coreutils/md5_sha1_sum.c | |||
@@ -42,41 +42,28 @@ static unsigned char *hash_bin_to_hex(unsigned char *hash_value, | |||
42 | max = (hash_length * 2) + 2; | 42 | max = (hash_length * 2) + 2; |
43 | hex_value = xmalloc(max); | 43 | hex_value = xmalloc(max); |
44 | for (x = len = 0; x < hash_length; x++) { | 44 | for (x = len = 0; x < hash_length; x++) { |
45 | len += snprintf(hex_value + len, max - len, "%02x", hash_value[x]); | 45 | len += snprintf((char*)(hex_value + len), max - len, "%02x", hash_value[x]); |
46 | } | 46 | } |
47 | return (hex_value); | 47 | return (hex_value); |
48 | } | 48 | } |
49 | 49 | ||
50 | static uint8_t *hash_file(const char *filename, uint8_t hash_algo) | 50 | static uint8_t *hash_file(const char *filename, uint8_t hash_algo) |
51 | { | 51 | { |
52 | uint8_t *hash_value_bin; | 52 | int src_fd = strcmp(filename, "-") == 0 ? STDIN_FILENO : |
53 | uint8_t *hash_value = NULL; | 53 | open(filename, O_RDONLY); |
54 | uint8_t hash_length; | 54 | if (src_fd == -1) { |
55 | int src_fd; | ||
56 | |||
57 | if (strcmp(filename, "-") == 0) { | ||
58 | src_fd = STDIN_FILENO; | ||
59 | } else { | ||
60 | src_fd = open(filename, O_RDONLY); | ||
61 | } | ||
62 | |||
63 | if (hash_algo == HASH_MD5) { | ||
64 | hash_length = 16; | ||
65 | } else { | ||
66 | hash_length = 20; | ||
67 | } | ||
68 | |||
69 | hash_value_bin = xmalloc(hash_length); | ||
70 | |||
71 | if ((src_fd != -1) && (hash_fd(src_fd, -1, hash_algo, hash_value_bin) != -2)) { | ||
72 | hash_value = hash_bin_to_hex(hash_value_bin, hash_length); | ||
73 | } else { | ||
74 | bb_perror_msg("%s", filename); | 55 | bb_perror_msg("%s", filename); |
56 | return NULL; | ||
57 | } else { | ||
58 | uint8_t *hash_value; | ||
59 | RESERVE_CONFIG_UBUFFER(hash_value_bin, 20); | ||
60 | hash_value = hash_fd(src_fd, -1, hash_algo, hash_value_bin) != -2 ? | ||
61 | hash_bin_to_hex(hash_value_bin, hash_algo == HASH_MD5 ? 16 : 20) : | ||
62 | NULL; | ||
63 | RELEASE_CONFIG_BUFFER(hash_value_bin); | ||
64 | close(src_fd); | ||
65 | return hash_value; | ||
75 | } | 66 | } |
76 | |||
77 | close(src_fd); | ||
78 | |||
79 | return(hash_value); | ||
80 | } | 67 | } |
81 | 68 | ||
82 | /* This could become a common function for md5 as well, by using md5_stream */ | 69 | /* This could become a common function for md5 as well, by using md5_stream */ |
@@ -111,7 +98,7 @@ extern int hash_files(int argc, char **argv, const uint8_t hash_algo) | |||
111 | FILE *pre_computed_stream; | 98 | FILE *pre_computed_stream; |
112 | int count_total = 0; | 99 | int count_total = 0; |
113 | int count_failed = 0; | 100 | int count_failed = 0; |
114 | unsigned char *file_ptr = argv[optind]; | 101 | char *file_ptr = argv[optind]; |
115 | char *line; | 102 | char *line; |
116 | 103 | ||
117 | if (optind + 1 != argc) { | 104 | if (optind + 1 != argc) { |
@@ -142,7 +129,7 @@ extern int hash_files(int argc, char **argv, const uint8_t hash_algo) | |||
142 | 129 | ||
143 | hash_value = hash_file(filename_ptr, hash_algo); | 130 | hash_value = hash_file(filename_ptr, hash_algo); |
144 | 131 | ||
145 | if (hash_value && (strcmp(hash_value, line) == 0)) { | 132 | if (hash_value && (strcmp((char*)hash_value, line) == 0)) { |
146 | if (!(flags & FLAG_SILENT)) | 133 | if (!(flags & FLAG_SILENT)) |
147 | printf("%s: OK\n", filename_ptr); | 134 | printf("%s: OK\n", filename_ptr); |
148 | } else { | 135 | } else { |
@@ -175,7 +162,7 @@ extern int hash_files(int argc, char **argv, const uint8_t hash_algo) | |||
175 | hash_value = xmalloc(hash_length); | 162 | hash_value = xmalloc(hash_length); |
176 | 163 | ||
177 | while (optind < argc) { | 164 | while (optind < argc) { |
178 | unsigned char *file_ptr = argv[optind++]; | 165 | char *file_ptr = argv[optind++]; |
179 | 166 | ||
180 | hash_value = hash_file(file_ptr, hash_algo); | 167 | hash_value = hash_file(file_ptr, hash_algo); |
181 | if (hash_value == NULL) { | 168 | if (hash_value == NULL) { |
diff --git a/busybox/coreutils/mv.c b/busybox/coreutils/mv.c index 4f08dedc0..e1c4529ad 100644 --- a/busybox/coreutils/mv.c +++ b/busybox/coreutils/mv.c | |||
@@ -99,10 +99,10 @@ DO_MOVE: | |||
99 | struct stat source_stat; | 99 | struct stat source_stat; |
100 | int source_exists; | 100 | int source_exists; |
101 | 101 | ||
102 | if (errno != EXDEV) { | 102 | if (errno != EXDEV || |
103 | (source_exists = cp_mv_stat(*argv, &source_stat)) < 1) { | ||
103 | bb_perror_msg("unable to rename `%s'", *argv); | 104 | bb_perror_msg("unable to rename `%s'", *argv); |
104 | } | 105 | } else { |
105 | else if ((source_exists = cp_mv_stat(*argv, &source_stat)) >= 0) { | ||
106 | if (dest_exists) { | 106 | if (dest_exists) { |
107 | if (dest_exists == 3) { | 107 | if (dest_exists == 3) { |
108 | if (source_exists != 3) { | 108 | if (source_exists != 3) { |
diff --git a/busybox/coreutils/test.c b/busybox/coreutils/test.c index 8fa6d166f..5195fafa1 100644 --- a/busybox/coreutils/test.c +++ b/busybox/coreutils/test.c | |||
@@ -304,7 +304,7 @@ static arith_t primary(enum token n) | |||
304 | return strlen(*t_wp) > 0; | 304 | return strlen(*t_wp) > 0; |
305 | } | 305 | } |
306 | 306 | ||
307 | static int binop() | 307 | static int binop(void) |
308 | { | 308 | { |
309 | const char *opnd1, *opnd2; | 309 | const char *opnd1, *opnd2; |
310 | struct t_op const *op; | 310 | struct t_op const *op; |
@@ -531,7 +531,7 @@ static int test_eaccess(char *path, int mode) | |||
531 | return (-1); | 531 | return (-1); |
532 | } | 532 | } |
533 | 533 | ||
534 | static void initialize_group_array() | 534 | static void initialize_group_array(void) |
535 | { | 535 | { |
536 | ngroups = getgroups(0, NULL); | 536 | ngroups = getgroups(0, NULL); |
537 | group_array = xrealloc(group_array, ngroups * sizeof(gid_t)); | 537 | group_array = xrealloc(group_array, ngroups * sizeof(gid_t)); |
diff --git a/busybox/coreutils/watch.c b/busybox/coreutils/watch.c index f9f40189e..31fadfb85 100644 --- a/busybox/coreutils/watch.c +++ b/busybox/coreutils/watch.c | |||
@@ -82,7 +82,7 @@ extern int watch_main(int argc, char **argv) | |||
82 | header[len] = 0; | 82 | header[len] = 0; |
83 | 83 | ||
84 | /* thanks to lye, who showed me how to redirect stdin/stdout */ | 84 | /* thanks to lye, who showed me how to redirect stdin/stdout */ |
85 | old_stdout = dup(1); | 85 | old_stdout = dup(STDOUT_FILENO); |
86 | 86 | ||
87 | while (1) { | 87 | while (1) { |
88 | time(&t); | 88 | time(&t); |
@@ -98,13 +98,11 @@ extern int watch_main(int argc, char **argv) | |||
98 | sleep(period); | 98 | sleep(period); |
99 | } else if (0 == pid) { | 99 | } else if (0 == pid) { |
100 | //child | 100 | //child |
101 | close(1); | 101 | dup2(old_stdout, STDOUT_FILENO); |
102 | dup(old_stdout); | 102 | execvp(*watched_argv, watched_argv); |
103 | if (execvp(*watched_argv, watched_argv)) { | 103 | bb_perror_msg_and_die(*watched_argv); |
104 | bb_error_msg_and_die("Couldn't run command\n"); | ||
105 | } | ||
106 | } else { | 104 | } else { |
107 | bb_error_msg_and_die("Couldn't vfork\n"); | 105 | bb_perror_msg_and_die("vfork"); |
108 | } | 106 | } |
109 | } | 107 | } |
110 | } | 108 | } |
diff --git a/busybox/coreutils/who.c b/busybox/coreutils/who.c index 9561db132..0531326bd 100644 --- a/busybox/coreutils/who.c +++ b/busybox/coreutils/who.c | |||
@@ -74,7 +74,7 @@ extern int who_main(int argc, char **argv) | |||
74 | } else | 74 | } else |
75 | printf("%-8s ", "?"); | 75 | printf("%-8s ", "?"); |
76 | 76 | ||
77 | printf("%-12.12s %s\n", ctime(&(ut->ut_tv.tv_sec)) + 4, ut->ut_host); | 77 | printf("%-12.12s %s\n", ctime((time_t*)&(ut->ut_tv.tv_sec)) + 4, ut->ut_host); |
78 | } | 78 | } |
79 | } | 79 | } |
80 | endutent(); | 80 | endutent(); |
diff --git a/busybox/debianutils/start_stop_daemon.c b/busybox/debianutils/start_stop_daemon.c index e15944c59..1eaf0d78c 100644 --- a/busybox/debianutils/start_stop_daemon.c +++ b/busybox/debianutils/start_stop_daemon.c | |||
@@ -238,7 +238,7 @@ start_stop_daemon_main(int argc, char **argv) | |||
238 | &startas, &cmdname, &signame, &userspec, &execname, &pidfile); | 238 | &startas, &cmdname, &signame, &userspec, &execname, &pidfile); |
239 | 239 | ||
240 | /* Check one and only one context option was given */ | 240 | /* Check one and only one context option was given */ |
241 | if ((opt & 0x80000000UL) || (opt & (SSD_CTX_STOP | SSD_CTX_START)) == 0) { | 241 | if ((opt & BB_GETOPT_ERROR) || (opt & (SSD_CTX_STOP | SSD_CTX_START)) == 0) { |
242 | bb_show_usage(); | 242 | bb_show_usage(); |
243 | } | 243 | } |
244 | 244 | ||
diff --git a/busybox/docs/.cvsignore b/busybox/docs/.cvsignore deleted file mode 100644 index ec9e94b27..000000000 --- a/busybox/docs/.cvsignore +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | BusyBox.txt | ||
2 | BusyBox.1 | ||
3 | BusyBox.html | ||
4 | busybox.txt | ||
5 | busybox.ps | ||
6 | busybox.pdf | ||
7 | busybox | ||
8 | busybox.pod | ||
diff --git a/busybox/docs/busybox.net/.cvsignore b/busybox/docs/busybox.net/.cvsignore deleted file mode 100644 index 393b00210..000000000 --- a/busybox/docs/busybox.net/.cvsignore +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | BusyBox.html | ||
2 | busybox.tar.gz | ||
diff --git a/busybox/docs/new-applet-HOWTO.txt b/busybox/docs/new-applet-HOWTO.txt index 2fc95d36d..605974c3a 100644 --- a/busybox/docs/new-applet-HOWTO.txt +++ b/busybox/docs/new-applet-HOWTO.txt | |||
@@ -52,10 +52,10 @@ int mu_main(int argc, char **argv) | |||
52 | char mu; | 52 | char mu; |
53 | 53 | ||
54 | if ((fd = open("/dev/random", O_RDONLY)) < 0) | 54 | if ((fd = open("/dev/random", O_RDONLY)) < 0) |
55 | perror_msg_and_die("/dev/random"); | 55 | bb_perror_msg_and_die("/dev/random"); |
56 | 56 | ||
57 | if ((n = safe_read(fd, &mu, 1)) < 1) | 57 | if ((n = safe_read(fd, &mu, 1)) < 1) |
58 | perror_msg_and_die("/dev/random"); | 58 | bb_perror_msg_and_die("/dev/random"); |
59 | 59 | ||
60 | return mu; | 60 | return mu; |
61 | } | 61 | } |
@@ -137,11 +137,6 @@ algorithm in busybox.c and the Gods of BusyBox smite you. Yea, verily: | |||
137 | /* all programs below here are alphabetically "greater than" 'mu' */ | 137 | /* all programs below here are alphabetically "greater than" 'mu' */ |
138 | 138 | ||
139 | 139 | ||
140 | Finally, add a define for your applet to include/config.h | ||
141 | |||
142 | #undef CONFIG_MU | ||
143 | |||
144 | |||
145 | Documentation | 140 | Documentation |
146 | ------------- | 141 | ------------- |
147 | 142 | ||
diff --git a/busybox/editors/awk.c b/busybox/editors/awk.c index c1cb2a2e2..ed8b0f20f 100644 --- a/busybox/editors/awk.c +++ b/busybox/editors/awk.c | |||
@@ -1084,7 +1084,7 @@ static node *parse_expr(unsigned long iexp) { | |||
1084 | cn->a.n = vn; | 1084 | cn->a.n = vn; |
1085 | xtc = TC_OPERAND | TC_UOPPRE | TC_REGEXP; | 1085 | xtc = TC_OPERAND | TC_UOPPRE | TC_REGEXP; |
1086 | if (tc & (TC_OPERAND | TC_REGEXP)) { | 1086 | if (tc & (TC_OPERAND | TC_REGEXP)) { |
1087 | xtc = TC_UOPPRE | TC_BINOP | TC_OPERAND | iexp; | 1087 | xtc = TC_UOPPRE | TC_UOPPOST | TC_BINOP | TC_OPERAND | iexp; |
1088 | /* one should be very careful with switch on tclass - | 1088 | /* one should be very careful with switch on tclass - |
1089 | * only simple tclasses should be used! */ | 1089 | * only simple tclasses should be used! */ |
1090 | switch (tc) { | 1090 | switch (tc) { |
@@ -1101,7 +1101,6 @@ static node *parse_expr(unsigned long iexp) { | |||
1101 | cn->info |= xS; | 1101 | cn->info |= xS; |
1102 | cn->r.n = parse_expr(TC_ARRTERM); | 1102 | cn->r.n = parse_expr(TC_ARRTERM); |
1103 | } | 1103 | } |
1104 | xtc = TC_UOPPOST | TC_UOPPRE | TC_BINOP | TC_OPERAND | iexp; | ||
1105 | break; | 1104 | break; |
1106 | 1105 | ||
1107 | case TC_NUMBER: | 1106 | case TC_NUMBER: |
diff --git a/busybox/editors/sed.c b/busybox/editors/sed.c index 3d6871621..992e5711d 100644 --- a/busybox/editors/sed.c +++ b/busybox/editors/sed.c | |||
@@ -34,7 +34,10 @@ | |||
34 | resulting sed_cmd_t structures are appended to a linked list | 34 | resulting sed_cmd_t structures are appended to a linked list |
35 | (sed_cmd_head/sed_cmd_tail). | 35 | (sed_cmd_head/sed_cmd_tail). |
36 | 36 | ||
37 | process_file() does actual sedding, reading data lines from an input FILE * | 37 | add_input_file() adds a FILE * to the list of input files. We need to |
38 | know them all ahead of time to find the last line for the $ match. | ||
39 | |||
40 | process_files() does actual sedding, reading data lines from each input FILE * | ||
38 | (which could be stdin) and applying the sed command list (sed_cmd_head) to | 41 | (which could be stdin) and applying the sed command list (sed_cmd_head) to |
39 | each of the resulting lines. | 42 | each of the resulting lines. |
40 | 43 | ||
@@ -112,17 +115,20 @@ typedef struct sed_cmd_s { | |||
112 | 115 | ||
113 | /* globals */ | 116 | /* globals */ |
114 | /* options */ | 117 | /* options */ |
115 | static int be_quiet = 0, in_place=0, regex_type=0; | 118 | static int be_quiet, in_place, regex_type; |
116 | FILE *nonstdout; | 119 | FILE *nonstdout; |
117 | char *outname; | 120 | char *outname,*hold_space; |
118 | 121 | ||
122 | /* List of input files */ | ||
123 | int input_file_count,current_input_file; | ||
124 | FILE **input_file_list; | ||
119 | 125 | ||
120 | static const char bad_format_in_subst[] = | 126 | static const char bad_format_in_subst[] = |
121 | "bad format in substitution expression"; | 127 | "bad format in substitution expression"; |
122 | const char *const semicolon_whitespace = "; \n\r\t\v"; | 128 | const char *const semicolon_whitespace = "; \n\r\t\v"; |
123 | 129 | ||
124 | regmatch_t regmatch[10]; | 130 | regmatch_t regmatch[10]; |
125 | static regex_t *previous_regex_ptr = NULL; | 131 | static regex_t *previous_regex_ptr; |
126 | 132 | ||
127 | /* linked list of sed commands */ | 133 | /* linked list of sed commands */ |
128 | static sed_cmd_t sed_cmd_head; | 134 | static sed_cmd_t sed_cmd_head; |
@@ -169,6 +175,11 @@ static void free_and_close_stuff(void) | |||
169 | free(sed_cmd); | 175 | free(sed_cmd); |
170 | sed_cmd = sed_cmd_next; | 176 | sed_cmd = sed_cmd_next; |
171 | } | 177 | } |
178 | |||
179 | if(hold_space) free(hold_space); | ||
180 | |||
181 | while(current_input_file<input_file_count) | ||
182 | fclose(input_file_list[current_input_file++]); | ||
172 | } | 183 | } |
173 | #endif | 184 | #endif |
174 | 185 | ||
@@ -563,6 +574,8 @@ void add_cmd(char *cmdstr) | |||
563 | } | 574 | } |
564 | } | 575 | } |
565 | 576 | ||
577 | /* Append to a string, reallocating memory as necessary. */ | ||
578 | |||
566 | struct pipeline { | 579 | struct pipeline { |
567 | char *buf; /* Space to hold string */ | 580 | char *buf; /* Space to hold string */ |
568 | int idx; /* Space used */ | 581 | int idx; /* Space used */ |
@@ -716,20 +729,29 @@ static void flush_append(void) | |||
716 | append_head=append_tail=NULL; | 729 | append_head=append_tail=NULL; |
717 | } | 730 | } |
718 | 731 | ||
719 | /* Get next line of input, flushing append buffer and noting if we hit EOF | 732 | void add_input_file(FILE *file) |
720 | * without a newline on the last line. | 733 | { |
734 | input_file_list=xrealloc(input_file_list,(input_file_count+1)*sizeof(FILE *)); | ||
735 | input_file_list[input_file_count++]=file; | ||
736 | } | ||
737 | |||
738 | /* Get next line of input from input_file_list, flushing append buffer and | ||
739 | * noting if we ran out of files without a newline on the last line we read. | ||
721 | */ | 740 | */ |
722 | static char *get_next_line(FILE * file, int *no_newline) | 741 | static char *get_next_line(int *no_newline) |
723 | { | 742 | { |
724 | char *temp; | 743 | char *temp=NULL; |
725 | int len; | 744 | int len; |
726 | 745 | ||
727 | flush_append(); | 746 | flush_append(); |
728 | temp=bb_get_line_from_file(file); | 747 | while(current_input_file<input_file_count) { |
729 | if(temp) { | 748 | temp=bb_get_line_from_file(input_file_list[current_input_file]); |
730 | len=strlen(temp); | 749 | if(temp) { |
731 | if(len && temp[len-1]=='\n') temp[len-1]=0; | 750 | len=strlen(temp); |
732 | else *no_newline=1; | 751 | *no_newline=!(len && temp[len-1]=='\n'); |
752 | if(!*no_newline) temp[len-1]=0; | ||
753 | break; | ||
754 | } else fclose(input_file_list[current_input_file++]); | ||
733 | } | 755 | } |
734 | 756 | ||
735 | return temp; | 757 | return temp; |
@@ -755,15 +777,15 @@ static int puts_maybe_newline(char *s, FILE *file, int missing_newline, int no_n | |||
755 | 777 | ||
756 | #define sed_puts(s,n) missing_newline=puts_maybe_newline(s,nonstdout,missing_newline,n) | 778 | #define sed_puts(s,n) missing_newline=puts_maybe_newline(s,nonstdout,missing_newline,n) |
757 | 779 | ||
758 | static void process_file(FILE *file) | 780 | static void process_files(void) |
759 | { | 781 | { |
760 | char *pattern_space, *next_line, *hold_space=NULL; | 782 | char *pattern_space, *next_line; |
761 | static int linenum = 0, missing_newline=0; | 783 | int linenum = 0, missing_newline=0; |
762 | int no_newline,next_no_newline=0; | 784 | int no_newline,next_no_newline=0; |
763 | 785 | ||
764 | next_line = get_next_line(file,&next_no_newline); | 786 | next_line = get_next_line(&next_no_newline); |
765 | 787 | ||
766 | /* go through every line in the file */ | 788 | /* go through every line in each file */ |
767 | for(;;) { | 789 | for(;;) { |
768 | sed_cmd_t *sed_cmd; | 790 | sed_cmd_t *sed_cmd; |
769 | int substituted=0; | 791 | int substituted=0; |
@@ -773,7 +795,7 @@ static void process_file(FILE *file) | |||
773 | no_newline=next_no_newline; | 795 | no_newline=next_no_newline; |
774 | 796 | ||
775 | /* Read one line in advance so we can act on the last line, the '$' address */ | 797 | /* Read one line in advance so we can act on the last line, the '$' address */ |
776 | next_line = get_next_line(file,&next_no_newline); | 798 | next_line = get_next_line(&next_no_newline); |
777 | linenum++; | 799 | linenum++; |
778 | restart: | 800 | restart: |
779 | /* for every line, go through all the commands */ | 801 | /* for every line, go through all the commands */ |
@@ -908,7 +930,7 @@ restart: | |||
908 | /* Cut and paste text (replace) */ | 930 | /* Cut and paste text (replace) */ |
909 | case 'c': | 931 | case 'c': |
910 | /* Only triggers on last line of a matching range. */ | 932 | /* Only triggers on last line of a matching range. */ |
911 | if (!sed_cmd->in_match) sed_puts(sed_cmd->string,1); | 933 | if (!sed_cmd->in_match) sed_puts(sed_cmd->string,0); |
912 | goto discard_line; | 934 | goto discard_line; |
913 | 935 | ||
914 | /* Read file, append contents to output */ | 936 | /* Read file, append contents to output */ |
@@ -942,7 +964,7 @@ restart: | |||
942 | free(pattern_space); | 964 | free(pattern_space); |
943 | pattern_space = next_line; | 965 | pattern_space = next_line; |
944 | no_newline=next_no_newline; | 966 | no_newline=next_no_newline; |
945 | next_line = get_next_line(file,&next_no_newline); | 967 | next_line = get_next_line(&next_no_newline); |
946 | linenum++; | 968 | linenum++; |
947 | break; | 969 | break; |
948 | } | 970 | } |
@@ -972,7 +994,7 @@ restart: | |||
972 | pattern_space[len]='\n'; | 994 | pattern_space[len]='\n'; |
973 | strcpy(pattern_space+len+1, next_line); | 995 | strcpy(pattern_space+len+1, next_line); |
974 | no_newline=next_no_newline; | 996 | no_newline=next_no_newline; |
975 | next_line = get_next_line(file,&next_no_newline); | 997 | next_line = get_next_line(&next_no_newline); |
976 | linenum++; | 998 | linenum++; |
977 | } | 999 | } |
978 | break; | 1000 | break; |
@@ -1007,10 +1029,7 @@ restart: | |||
1007 | } | 1029 | } |
1008 | case 'g': /* Replace pattern space with hold space */ | 1030 | case 'g': /* Replace pattern space with hold space */ |
1009 | free(pattern_space); | 1031 | free(pattern_space); |
1010 | if (hold_space) { | 1032 | pattern_space = strdup(hold_space ? hold_space : ""); |
1011 | pattern_space = strdup(hold_space); | ||
1012 | no_newline=0; | ||
1013 | } | ||
1014 | break; | 1033 | break; |
1015 | case 'G': /* Append newline and hold space to pattern space */ | 1034 | case 'G': /* Append newline and hold space to pattern space */ |
1016 | { | 1035 | { |
@@ -1096,9 +1115,7 @@ static void add_cmd_block(char *cmdstr) | |||
1096 | 1115 | ||
1097 | extern int sed_main(int argc, char **argv) | 1116 | extern int sed_main(int argc, char **argv) |
1098 | { | 1117 | { |
1099 | int status = EXIT_SUCCESS; | 1118 | int status = EXIT_SUCCESS, opt, getpat = 1; |
1100 | int opt; | ||
1101 | uint8_t getpat = 1; | ||
1102 | 1119 | ||
1103 | #ifdef CONFIG_FEATURE_CLEAN_UP | 1120 | #ifdef CONFIG_FEATURE_CLEAN_UP |
1104 | /* destroy command strings on exit */ | 1121 | /* destroy command strings on exit */ |
@@ -1153,8 +1170,7 @@ extern int sed_main(int argc, char **argv) | |||
1153 | } | 1170 | } |
1154 | } | 1171 | } |
1155 | 1172 | ||
1156 | /* if we didn't get a pattern from a -e and no command file was specified, | 1173 | /* if we didn't get a pattern from -e or -f, use argv[optind] */ |
1157 | * argv[optind] should be the pattern. no pattern, no worky */ | ||
1158 | if(getpat) { | 1174 | if(getpat) { |
1159 | if (argv[optind] == NULL) | 1175 | if (argv[optind] == NULL) |
1160 | bb_show_usage(); | 1176 | bb_show_usage(); |
@@ -1171,49 +1187,47 @@ extern int sed_main(int argc, char **argv) | |||
1171 | * files were specified or '-' was specified, take input from stdin. | 1187 | * files were specified or '-' was specified, take input from stdin. |
1172 | * Otherwise, we process all the files specified. */ | 1188 | * Otherwise, we process all the files specified. */ |
1173 | if (argv[optind] == NULL) { | 1189 | if (argv[optind] == NULL) { |
1174 | if(in_place) { | 1190 | if(in_place) bb_error_msg_and_die("Filename required for -i"); |
1175 | fprintf(stderr,"sed: Filename required for -i\n"); | 1191 | add_input_file(stdin); |
1176 | exit(1); | 1192 | process_files(); |
1177 | } | ||
1178 | process_file(stdin); | ||
1179 | } else { | 1193 | } else { |
1180 | int i; | 1194 | int i; |
1181 | FILE *file; | 1195 | FILE *file; |
1182 | 1196 | ||
1183 | for (i = optind; i < argc; i++) { | 1197 | for (i = optind; i < argc; i++) { |
1184 | if(!strcmp(argv[i], "-") && !in_place) { | 1198 | if(!strcmp(argv[i], "-") && !in_place) { |
1185 | process_file(stdin); | 1199 | add_input_file(stdin); |
1200 | process_files(); | ||
1186 | } else { | 1201 | } else { |
1187 | file = bb_wfopen(argv[i], "r"); | 1202 | file = bb_wfopen(argv[i], "r"); |
1188 | if (file) { | 1203 | if (file) { |
1189 | if(in_place) { | 1204 | if(in_place) { |
1190 | struct stat statbuf; | 1205 | struct stat statbuf; |
1206 | int nonstdoutfd; | ||
1207 | |||
1191 | outname=bb_xstrndup(argv[i],strlen(argv[i])+6); | 1208 | outname=bb_xstrndup(argv[i],strlen(argv[i])+6); |
1192 | strcat(outname,"XXXXXX"); | 1209 | strcat(outname,"XXXXXX"); |
1210 | if(-1==(nonstdoutfd=mkstemp(outname))) | ||
1211 | bb_error_msg_and_die("no temp file"); | ||
1212 | nonstdout=fdopen(nonstdoutfd,"w"); | ||
1193 | /* Set permissions of output file */ | 1213 | /* Set permissions of output file */ |
1194 | fstat(fileno(file),&statbuf); | 1214 | fstat(fileno(file),&statbuf); |
1195 | mkstemp(outname); | 1215 | fchmod(nonstdoutfd,statbuf.st_mode); |
1196 | nonstdout=bb_wfopen(outname,"w"); | 1216 | add_input_file(file); |
1197 | /* Set permissions of output file */ | 1217 | process_files(); |
1198 | fstat(fileno(file),&statbuf); | ||
1199 | fchmod(fileno(nonstdout),statbuf.st_mode); | ||
1200 | atexit(cleanup_outname); | ||
1201 | } | ||
1202 | process_file(file); | ||
1203 | fclose(file); | ||
1204 | if(in_place) { | ||
1205 | fclose(nonstdout); | 1218 | fclose(nonstdout); |
1206 | nonstdout=stdout; | 1219 | nonstdout=stdout; |
1207 | unlink(argv[i]); | 1220 | unlink(argv[i]); |
1208 | rename(outname,argv[i]); | 1221 | rename(outname,argv[i]); |
1209 | free(outname); | 1222 | free(outname); |
1210 | outname=0; | 1223 | outname=0; |
1211 | } | 1224 | } else add_input_file(file); |
1212 | } else { | 1225 | } else { |
1213 | status = EXIT_FAILURE; | 1226 | status = EXIT_FAILURE; |
1214 | } | 1227 | } |
1215 | } | 1228 | } |
1216 | } | 1229 | } |
1230 | if(input_file_count>current_input_file) process_files(); | ||
1217 | } | 1231 | } |
1218 | 1232 | ||
1219 | return status; | 1233 | return status; |
diff --git a/busybox/editors/vi.c b/busybox/editors/vi.c index cd6cf0ea1..5a47f5a23 100644 --- a/busybox/editors/vi.c +++ b/busybox/editors/vi.c | |||
@@ -2340,7 +2340,7 @@ static Byte readit(void) // read (maybe cursor) key from stdin | |||
2340 | } | 2340 | } |
2341 | 2341 | ||
2342 | //----- IO Routines -------------------------------------------- | 2342 | //----- IO Routines -------------------------------------------- |
2343 | static Byte get_one_char() | 2343 | static Byte get_one_char(void) |
2344 | { | 2344 | { |
2345 | static Byte c; | 2345 | static Byte c; |
2346 | 2346 | ||
@@ -2600,25 +2600,25 @@ static void place_cursor(int row, int col, int opti) | |||
2600 | } | 2600 | } |
2601 | 2601 | ||
2602 | //----- Erase from cursor to end of line ----------------------- | 2602 | //----- Erase from cursor to end of line ----------------------- |
2603 | static void clear_to_eol() | 2603 | static void clear_to_eol(void) |
2604 | { | 2604 | { |
2605 | write1(Ceol); // Erase from cursor to end of line | 2605 | write1(Ceol); // Erase from cursor to end of line |
2606 | } | 2606 | } |
2607 | 2607 | ||
2608 | //----- Erase from cursor to end of screen ----------------------- | 2608 | //----- Erase from cursor to end of screen ----------------------- |
2609 | static void clear_to_eos() | 2609 | static void clear_to_eos(void) |
2610 | { | 2610 | { |
2611 | write1(Ceos); // Erase from cursor to end of screen | 2611 | write1(Ceos); // Erase from cursor to end of screen |
2612 | } | 2612 | } |
2613 | 2613 | ||
2614 | //----- Start standout mode ------------------------------------ | 2614 | //----- Start standout mode ------------------------------------ |
2615 | static void standout_start() // send "start reverse video" sequence | 2615 | static void standout_start(void) // send "start reverse video" sequence |
2616 | { | 2616 | { |
2617 | write1(SOs); // Start reverse video mode | 2617 | write1(SOs); // Start reverse video mode |
2618 | } | 2618 | } |
2619 | 2619 | ||
2620 | //----- End standout mode -------------------------------------- | 2620 | //----- End standout mode -------------------------------------- |
2621 | static void standout_end() // send "end reverse video" sequence | 2621 | static void standout_end(void) // send "end reverse video" sequence |
2622 | { | 2622 | { |
2623 | write1(SOn); // End reverse video mode | 2623 | write1(SOn); // End reverse video mode |
2624 | } | 2624 | } |
@@ -2648,7 +2648,7 @@ static void Indicate_Error(void) | |||
2648 | 2648 | ||
2649 | //----- Screen[] Routines -------------------------------------- | 2649 | //----- Screen[] Routines -------------------------------------- |
2650 | //----- Erase the Screen[] memory ------------------------------ | 2650 | //----- Erase the Screen[] memory ------------------------------ |
2651 | static void screen_erase() | 2651 | static void screen_erase(void) |
2652 | { | 2652 | { |
2653 | memset(screen, ' ', screensize); // clear new screen | 2653 | memset(screen, ' ', screensize); // clear new screen |
2654 | } | 2654 | } |
diff --git a/busybox/findutils/grep.c b/busybox/findutils/grep.c index 29f4ecd4f..9b26add9a 100644 --- a/busybox/findutils/grep.c +++ b/busybox/findutils/grep.c | |||
@@ -98,7 +98,7 @@ static void print_line(const char *line, int linenum, char decoration) | |||
98 | } | 98 | } |
99 | last_line_printed = linenum; | 99 | last_line_printed = linenum; |
100 | #endif | 100 | #endif |
101 | if (print_filename) | 101 | if (print_filename > 0) |
102 | printf("%s%c", cur_file, decoration); | 102 | printf("%s%c", cur_file, decoration); |
103 | if (print_line_num) | 103 | if (print_line_num) |
104 | printf("%i%c", linenum, decoration); | 104 | printf("%i%c", linenum, decoration); |
@@ -219,7 +219,7 @@ static int grep_file(FILE *file) | |||
219 | 219 | ||
220 | /* grep -c: print [filename:]count, even if count is zero */ | 220 | /* grep -c: print [filename:]count, even if count is zero */ |
221 | if (print_match_counts) { | 221 | if (print_match_counts) { |
222 | if (print_filename) | 222 | if (print_filename > 0) |
223 | printf("%s:", cur_file); | 223 | printf("%s:", cur_file); |
224 | printf("%d\n", nmatches); | 224 | printf("%d\n", nmatches); |
225 | } | 225 | } |
diff --git a/busybox/include/.cvsignore b/busybox/include/.cvsignore deleted file mode 100644 index 9c68c9576..000000000 --- a/busybox/include/.cvsignore +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | config | ||
2 | config.h | ||
diff --git a/busybox/include/applets.h b/busybox/include/applets.h index 90d4195cc..21f82f57d 100644 --- a/busybox/include/applets.h +++ b/busybox/include/applets.h | |||
@@ -440,7 +440,7 @@ | |||
440 | APPLET_NOUSAGE("pipe_progress", pipe_progress_main, _BB_DIR_BIN, _BB_SUID_NEVER) | 440 | APPLET_NOUSAGE("pipe_progress", pipe_progress_main, _BB_DIR_BIN, _BB_SUID_NEVER) |
441 | #endif | 441 | #endif |
442 | #ifdef CONFIG_PIVOT_ROOT | 442 | #ifdef CONFIG_PIVOT_ROOT |
443 | APPLET(pivot_root, pivot_root_main, _BB_DIR_SBIN, _BB_SUID_NEVER) | 443 | APPLET(pivot_root, pivot_root_main, _BB_DIR_SBIN, _BB_SUID_NEVER) |
444 | #endif | 444 | #endif |
445 | #ifdef CONFIG_POWEROFF | 445 | #ifdef CONFIG_POWEROFF |
446 | APPLET(poweroff, poweroff_main, _BB_DIR_SBIN, _BB_SUID_NEVER) | 446 | APPLET(poweroff, poweroff_main, _BB_DIR_SBIN, _BB_SUID_NEVER) |
@@ -482,7 +482,7 @@ | |||
482 | APPLET(rmmod, rmmod_main, _BB_DIR_SBIN, _BB_SUID_NEVER) | 482 | APPLET(rmmod, rmmod_main, _BB_DIR_SBIN, _BB_SUID_NEVER) |
483 | #endif | 483 | #endif |
484 | #ifdef CONFIG_ROUTE | 484 | #ifdef CONFIG_ROUTE |
485 | APPLET(route, route_main, _BB_DIR_SBIN, _BB_SUID_NEVER) | 485 | APPLET(route, route_main, _BB_DIR_SBIN, _BB_SUID_NEVER) |
486 | #endif | 486 | #endif |
487 | #ifdef CONFIG_RPM | 487 | #ifdef CONFIG_RPM |
488 | APPLET(rpm, rpm_main, _BB_DIR_BIN, _BB_SUID_NEVER) | 488 | APPLET(rpm, rpm_main, _BB_DIR_BIN, _BB_SUID_NEVER) |
diff --git a/busybox/include/busybox.h b/busybox/include/busybox.h index f6f575957..3ff3d8a37 100644 --- a/busybox/include/busybox.h +++ b/busybox/include/busybox.h | |||
@@ -32,10 +32,10 @@ | |||
32 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <sys/types.h> | 33 | #include <sys/types.h> |
34 | 34 | ||
35 | #if __GNU_LIBRARY__ < 5 | 35 | #if __GNU_LIBRARY__ < 5 && \ |
36 | #ifndef __dietlibc__ | 36 | !defined(__dietlibc__) && \ |
37 | #error "Sorry, libc5 is not supported" | 37 | !defined(_NEWLIB_VERSION) |
38 | #endif | 38 | #error "Sorry, this libc version is not supported :(" |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #ifndef BB_EXTRA_VERSION | 41 | #ifndef BB_EXTRA_VERSION |
diff --git a/busybox/include/inet_common.h b/busybox/include/inet_common.h index afea5deaa..4a9c3a2d7 100644 --- a/busybox/include/inet_common.h +++ b/busybox/include/inet_common.h | |||
@@ -29,5 +29,7 @@ extern int INET_resolve(const char *name, struct sockaddr_in *s_in, int hostfirs | |||
29 | extern int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, | 29 | extern int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, |
30 | int numeric, unsigned int netmask); | 30 | int numeric, unsigned int netmask); |
31 | 31 | ||
32 | #ifdef CONFIG_FEATURE_IPV6 | ||
32 | extern int INET6_resolve(const char *name, struct sockaddr_in6 *sin6); | 33 | extern int INET6_resolve(const char *name, struct sockaddr_in6 *sin6); |
33 | extern int INET6_rresolve(char *name, size_t len, struct sockaddr_in6 *sin6, int numeric); | 34 | extern int INET6_rresolve(char *name, size_t len, struct sockaddr_in6 *sin6, int numeric); |
35 | #endif | ||
diff --git a/busybox/include/libbb.h b/busybox/include/libbb.h index 93ab5375c..467a15cb2 100644 --- a/busybox/include/libbb.h +++ b/busybox/include/libbb.h | |||
@@ -150,6 +150,7 @@ extern FILE *bb_xfopen(const char *path, const char *mode); | |||
150 | extern int bb_fclose_nonstdin(FILE *f); | 150 | extern int bb_fclose_nonstdin(FILE *f); |
151 | extern void bb_fflush_stdout_and_exit(int retval) __attribute__ ((noreturn)); | 151 | extern void bb_fflush_stdout_and_exit(int retval) __attribute__ ((noreturn)); |
152 | 152 | ||
153 | #define BB_GETOPT_ERROR 0x80000000UL | ||
153 | extern const char *bb_opt_complementaly; | 154 | extern const char *bb_opt_complementaly; |
154 | extern const struct option *bb_applet_long_options; | 155 | extern const struct option *bb_applet_long_options; |
155 | extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...); | 156 | extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...); |
@@ -323,6 +324,7 @@ extern const char * const bb_msg_full_version; | |||
323 | extern const char * const bb_msg_memory_exhausted; | 324 | extern const char * const bb_msg_memory_exhausted; |
324 | extern const char * const bb_msg_invalid_date; | 325 | extern const char * const bb_msg_invalid_date; |
325 | extern const char * const bb_msg_io_error; | 326 | extern const char * const bb_msg_io_error; |
327 | extern const char * const bb_msg_read_error; | ||
326 | extern const char * const bb_msg_write_error; | 328 | extern const char * const bb_msg_write_error; |
327 | extern const char * const bb_msg_name_longer_than_foo; | 329 | extern const char * const bb_msg_name_longer_than_foo; |
328 | extern const char * const bb_msg_unknown; | 330 | extern const char * const bb_msg_unknown; |
diff --git a/busybox/include/usage.h b/busybox/include/usage.h index 377eb10e7..ad4410196 100644 --- a/busybox/include/usage.h +++ b/busybox/include/usage.h | |||
@@ -204,7 +204,7 @@ | |||
204 | "Copies SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n" \ | 204 | "Copies SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n" \ |
205 | "\n" \ | 205 | "\n" \ |
206 | "\t-a\tSame as -dpR\n" \ | 206 | "\t-a\tSame as -dpR\n" \ |
207 | "\t-d\tPreserves links\n" \ | 207 | "\t-d,-P\tPreserves links\n" \ |
208 | "\t-p\tPreserves file attributes if possible\n" \ | 208 | "\t-p\tPreserves file attributes if possible\n" \ |
209 | "\t-f\tforce (implied; ignored) - always set\n" \ | 209 | "\t-f\tforce (implied; ignored) - always set\n" \ |
210 | "\t-i\tinteractive, prompt before overwrite\n" \ | 210 | "\t-i\tinteractive, prompt before overwrite\n" \ |
@@ -522,13 +522,13 @@ | |||
522 | "\t-e\tinterpret backslash-escaped characters (i.e., \\t=tab)\n" \ | 522 | "\t-e\tinterpret backslash-escaped characters (i.e., \\t=tab)\n" \ |
523 | "\t-E\tdisable interpretation of backslash-escaped characters") | 523 | "\t-E\tdisable interpretation of backslash-escaped characters") |
524 | #define echo_example_usage \ | 524 | #define echo_example_usage \ |
525 | "$ echo "Erik is cool"\n" \ | 525 | "$ echo \"Erik is cool\"\n" \ |
526 | "Erik is cool\n" \ | 526 | "Erik is cool\n" \ |
527 | USAGE_FANCY_ECHO("$ echo -e "Erik\\nis\\ncool"\n" \ | 527 | USAGE_FANCY_ECHO("$ echo -e \"Erik\\nis\\ncool\"\n" \ |
528 | "Erik\n" \ | 528 | "Erik\n" \ |
529 | "is\n" \ | 529 | "is\n" \ |
530 | "cool\n" \ | 530 | "cool\n" \ |
531 | "$ echo "Erik\\nis\\ncool"\n" \ | 531 | "$ echo \"Erik\\nis\\ncool\"\n" \ |
532 | "Erik\\nis\\ncool\n") | 532 | "Erik\\nis\\ncool\n") |
533 | 533 | ||
534 | #define env_trivial_usage \ | 534 | #define env_trivial_usage \ |
@@ -751,7 +751,7 @@ | |||
751 | "$ cat getopt.test\n" \ | 751 | "$ cat getopt.test\n" \ |
752 | "#!/bin/sh\n" \ | 752 | "#!/bin/sh\n" \ |
753 | "GETOPT=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \\\n" \ | 753 | "GETOPT=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \\\n" \ |
754 | " -n 'example.busybox' -- "$@"`\n" \ | 754 | " -n 'example.busybox' -- \"$@\"`\n" \ |
755 | "if [ $? != 0 ] ; then exit 1 ; fi\n" \ | 755 | "if [ $? != 0 ] ; then exit 1 ; fi\n" \ |
756 | "eval set -- "$GETOPT"\n" \ | 756 | "eval set -- "$GETOPT"\n" \ |
757 | "while true ; do\n" \ | 757 | "while true ; do\n" \ |
@@ -1940,7 +1940,7 @@ | |||
1940 | "Formats and prints ARGUMENT(s) according to FORMAT,\n" \ | 1940 | "Formats and prints ARGUMENT(s) according to FORMAT,\n" \ |
1941 | "Where FORMAT controls the output exactly as in C printf." | 1941 | "Where FORMAT controls the output exactly as in C printf." |
1942 | #define printf_example_usage \ | 1942 | #define printf_example_usage \ |
1943 | "$ printf "Val=%d\\n" 5\n" \ | 1943 | "$ printf \"Val=%d\\n\" 5\n" \ |
1944 | "Val=5\n" | 1944 | "Val=5\n" |
1945 | 1945 | ||
1946 | #ifdef CONFIG_SELINUX | 1946 | #ifdef CONFIG_SELINUX |
diff --git a/busybox/init/Config.in b/busybox/init/Config.in index 4465e75a1..521f8fe1d 100644 --- a/busybox/init/Config.in +++ b/busybox/init/Config.in | |||
@@ -35,6 +35,14 @@ config CONFIG_FEATURE_INIT_COREDUMPS | |||
35 | core file sizes. If this option is disabled, processes | 35 | core file sizes. If this option is disabled, processes |
36 | will not generate any core files. | 36 | will not generate any core files. |
37 | 37 | ||
38 | config CONFIG_FEATURE_INIT_SWAPON | ||
39 | bool " Should init run swapon if short on memory?" | ||
40 | default y | ||
41 | depends on CONFIG_INIT | ||
42 | help | ||
43 | If the system has less than one megabyte of total memory, init | ||
44 | will run '/sbin/swapon -a' to add swap memory. | ||
45 | |||
38 | config CONFIG_FEATURE_EXTRA_QUIET | 46 | config CONFIG_FEATURE_EXTRA_QUIET |
39 | bool " Should init be _extra_ quiet on boot?" | 47 | bool " Should init be _extra_ quiet on boot?" |
40 | default y | 48 | default y |
diff --git a/busybox/init/init.c b/busybox/init/init.c index 0c8dc89dc..8687b106c 100644 --- a/busybox/init/init.c +++ b/busybox/init/init.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <limits.h> | 39 | #include <limits.h> |
40 | #include <sys/fcntl.h> | 40 | #include <sys/fcntl.h> |
41 | #include <sys/ioctl.h> | 41 | #include <sys/ioctl.h> |
42 | #include <sys/mount.h> | ||
43 | #include <sys/types.h> | 42 | #include <sys/types.h> |
44 | #include <sys/wait.h> | 43 | #include <sys/wait.h> |
45 | #include <sys/reboot.h> | 44 | #include <sys/reboot.h> |
@@ -156,7 +155,7 @@ static struct init_action *init_action_list = NULL; | |||
156 | static char console[CONSOLE_BUFF_SIZE] = _PATH_CONSOLE; | 155 | static char console[CONSOLE_BUFF_SIZE] = _PATH_CONSOLE; |
157 | 156 | ||
158 | #ifndef CONFIG_SYSLOGD | 157 | #ifndef CONFIG_SYSLOGD |
159 | static char *log = VC_5; | 158 | static char *log_console = VC_5; |
160 | #endif | 159 | #endif |
161 | static sig_atomic_t got_cont = 0; | 160 | static sig_atomic_t got_cont = 0; |
162 | static const int LOG = 0x1; | 161 | static const int LOG = 0x1; |
@@ -239,9 +238,9 @@ static void message(int device, const char *fmt, ...) | |||
239 | /* Take full control of the log tty, and never close it. | 238 | /* Take full control of the log tty, and never close it. |
240 | * It's mine, all mine! Muhahahaha! */ | 239 | * It's mine, all mine! Muhahahaha! */ |
241 | if (log_fd < 0) { | 240 | if (log_fd < 0) { |
242 | if ((log_fd = device_open(log, O_RDWR | O_NDELAY | O_NOCTTY)) < 0) { | 241 | if ((log_fd = device_open(log_console, O_RDWR | O_NONBLOCK | O_NOCTTY)) < 0) { |
243 | log_fd = -2; | 242 | log_fd = -2; |
244 | bb_error_msg("Bummer, can't write to log on %s!", log); | 243 | bb_error_msg("Bummer, can't write to log on %s!", log_console); |
245 | device = CONSOLE; | 244 | device = CONSOLE; |
246 | } else { | 245 | } else { |
247 | fcntl(log_fd, F_SETFD, FD_CLOEXEC); | 246 | fcntl(log_fd, F_SETFD, FD_CLOEXEC); |
@@ -254,7 +253,7 @@ static void message(int device, const char *fmt, ...) | |||
254 | 253 | ||
255 | if (device & CONSOLE) { | 254 | if (device & CONSOLE) { |
256 | int fd = device_open(_PATH_CONSOLE, | 255 | int fd = device_open(_PATH_CONSOLE, |
257 | O_WRONLY | O_NOCTTY | O_NDELAY); | 256 | O_WRONLY | O_NOCTTY | O_NONBLOCK); |
258 | /* Always send console messages to /dev/console so people will see them. */ | 257 | /* Always send console messages to /dev/console so people will see them. */ |
259 | if (fd >= 0) { | 258 | if (fd >= 0) { |
260 | bb_full_write(fd, msg, l); | 259 | bb_full_write(fd, msg, l); |
@@ -309,6 +308,7 @@ static void set_term(int fd) | |||
309 | tcsetattr(fd, TCSANOW, &tty); | 308 | tcsetattr(fd, TCSANOW, &tty); |
310 | } | 309 | } |
311 | 310 | ||
311 | #ifdef CONFIG_FEATURE_INIT_SWAPON | ||
312 | /* How much memory does this machine have? | 312 | /* How much memory does this machine have? |
313 | Units are kBytes to avoid overflow on 4GB machines */ | 313 | Units are kBytes to avoid overflow on 4GB machines */ |
314 | static unsigned int check_free_memory(void) | 314 | static unsigned int check_free_memory(void) |
@@ -337,6 +337,7 @@ static unsigned int check_free_memory(void) | |||
337 | return(result * u); | 337 | return(result * u); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | #endif /* CONFIG_FEATURE_INIT_SWAPON */ | ||
340 | 341 | ||
341 | static void console_init(void) | 342 | static void console_init(void) |
342 | { | 343 | { |
@@ -381,7 +382,7 @@ static void console_init(void) | |||
381 | if (fd < 0) { | 382 | if (fd < 0) { |
382 | /* Perhaps we should panic here? */ | 383 | /* Perhaps we should panic here? */ |
383 | #ifndef CONFIG_SYSLOGD | 384 | #ifndef CONFIG_SYSLOGD |
384 | log = | 385 | log_console = |
385 | #endif | 386 | #endif |
386 | safe_strncpy(console, "/dev/null", sizeof(console)); | 387 | safe_strncpy(console, "/dev/null", sizeof(console)); |
387 | } else { | 388 | } else { |
@@ -393,7 +394,7 @@ static void console_init(void) | |||
393 | if (s == NULL || strcmp(s, "linux") == 0) | 394 | if (s == NULL || strcmp(s, "linux") == 0) |
394 | putenv("TERM=vt102"); | 395 | putenv("TERM=vt102"); |
395 | #ifndef CONFIG_SYSLOGD | 396 | #ifndef CONFIG_SYSLOGD |
396 | log = console; | 397 | log_console = console; |
397 | #endif | 398 | #endif |
398 | } else { | 399 | } else { |
399 | if (s == NULL) | 400 | if (s == NULL) |
@@ -423,9 +424,8 @@ static void fixup_argv(int argc, char **argv, char *new_argv0) | |||
423 | 424 | ||
424 | static pid_t run(const struct init_action *a) | 425 | static pid_t run(const struct init_action *a) |
425 | { | 426 | { |
426 | struct stat sb; | ||
427 | int i, junk; | 427 | int i, junk; |
428 | pid_t pid, pgrp, tmp_pid; | 428 | pid_t pid; |
429 | char *s, *tmpCmd, *cmd[INIT_BUFFS_SIZE], *cmdpath; | 429 | char *s, *tmpCmd, *cmd[INIT_BUFFS_SIZE], *cmdpath; |
430 | char buf[INIT_BUFFS_SIZE + 6]; /* INIT_BUFFS_SIZE+strlen("exec ")+1 */ | 430 | char buf[INIT_BUFFS_SIZE + 6]; /* INIT_BUFFS_SIZE+strlen("exec ")+1 */ |
431 | sigset_t nmask, omask; | 431 | sigset_t nmask, omask; |
@@ -441,6 +441,8 @@ static pid_t run(const struct init_action *a) | |||
441 | sigprocmask(SIG_BLOCK, &nmask, &omask); | 441 | sigprocmask(SIG_BLOCK, &nmask, &omask); |
442 | 442 | ||
443 | if ((pid = fork()) == 0) { | 443 | if ((pid = fork()) == 0) { |
444 | struct stat sb; | ||
445 | |||
444 | /* Clean up */ | 446 | /* Clean up */ |
445 | close(0); | 447 | close(0); |
446 | close(1); | 448 | close(1); |
@@ -453,6 +455,7 @@ static pid_t run(const struct init_action *a) | |||
453 | signal(SIGINT, SIG_DFL); | 455 | signal(SIGINT, SIG_DFL); |
454 | signal(SIGTERM, SIG_DFL); | 456 | signal(SIGTERM, SIG_DFL); |
455 | signal(SIGHUP, SIG_DFL); | 457 | signal(SIGHUP, SIG_DFL); |
458 | signal(SIGQUIT, SIG_DFL); | ||
456 | signal(SIGCONT, SIG_DFL); | 459 | signal(SIGCONT, SIG_DFL); |
457 | signal(SIGSTOP, SIG_DFL); | 460 | signal(SIGSTOP, SIG_DFL); |
458 | signal(SIGTSTP, SIG_DFL); | 461 | signal(SIGTSTP, SIG_DFL); |
@@ -464,11 +467,10 @@ static pid_t run(const struct init_action *a) | |||
464 | /* Open the new terminal device */ | 467 | /* Open the new terminal device */ |
465 | if ((device_open(a->terminal, O_RDWR)) < 0) { | 468 | if ((device_open(a->terminal, O_RDWR)) < 0) { |
466 | if (stat(a->terminal, &sb) != 0) { | 469 | if (stat(a->terminal, &sb) != 0) { |
467 | message(LOG | CONSOLE, "device '%s' does not exist.", | 470 | message(LOG | CONSOLE, "device '%s' does not exist.", a->terminal); |
468 | a->terminal); | 471 | } else { |
469 | _exit(1); | 472 | message(LOG | CONSOLE, "Bummer, can't open %s", a->terminal); |
470 | } | 473 | } |
471 | message(LOG | CONSOLE, "Bummer, can't open %s", a->terminal); | ||
472 | _exit(1); | 474 | _exit(1); |
473 | } | 475 | } |
474 | 476 | ||
@@ -482,6 +484,7 @@ static pid_t run(const struct init_action *a) | |||
482 | /* If the init Action requires us to wait, then force the | 484 | /* If the init Action requires us to wait, then force the |
483 | * supplied terminal to be the controlling tty. */ | 485 | * supplied terminal to be the controlling tty. */ |
484 | if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) { | 486 | if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) { |
487 | pid_t pgrp, tmp_pid; | ||
485 | 488 | ||
486 | /* Now fork off another process to just hang around */ | 489 | /* Now fork off another process to just hang around */ |
487 | if ((pid = fork()) < 0) { | 490 | if ((pid = fork()) < 0) { |
@@ -693,6 +696,7 @@ static void shutdown_system(void) | |||
693 | /* first disable all our signals */ | 696 | /* first disable all our signals */ |
694 | sigemptyset(&block_signals); | 697 | sigemptyset(&block_signals); |
695 | sigaddset(&block_signals, SIGHUP); | 698 | sigaddset(&block_signals, SIGHUP); |
699 | sigaddset(&block_signals, SIGQUIT); | ||
696 | sigaddset(&block_signals, SIGCHLD); | 700 | sigaddset(&block_signals, SIGCHLD); |
697 | sigaddset(&block_signals, SIGUSR1); | 701 | sigaddset(&block_signals, SIGUSR1); |
698 | sigaddset(&block_signals, SIGUSR2); | 702 | sigaddset(&block_signals, SIGUSR2); |
@@ -730,13 +734,12 @@ static void exec_signal(int sig) | |||
730 | for (a = init_action_list; a; a = tmp) { | 734 | for (a = init_action_list; a; a = tmp) { |
731 | tmp = a->next; | 735 | tmp = a->next; |
732 | if (a->action & RESTART) { | 736 | if (a->action & RESTART) { |
733 | struct stat sb; | ||
734 | |||
735 | shutdown_system(); | 737 | shutdown_system(); |
736 | 738 | ||
737 | /* unblock all signals, blocked in shutdown_system() */ | 739 | /* unblock all signals, blocked in shutdown_system() */ |
738 | sigemptyset(&unblock_signals); | 740 | sigemptyset(&unblock_signals); |
739 | sigaddset(&unblock_signals, SIGHUP); | 741 | sigaddset(&unblock_signals, SIGHUP); |
742 | sigaddset(&unblock_signals, SIGQUIT); | ||
740 | sigaddset(&unblock_signals, SIGCHLD); | 743 | sigaddset(&unblock_signals, SIGCHLD); |
741 | sigaddset(&unblock_signals, SIGUSR1); | 744 | sigaddset(&unblock_signals, SIGUSR1); |
742 | sigaddset(&unblock_signals, SIGUSR2); | 745 | sigaddset(&unblock_signals, SIGUSR2); |
@@ -754,6 +757,7 @@ static void exec_signal(int sig) | |||
754 | 757 | ||
755 | /* Open the new terminal device */ | 758 | /* Open the new terminal device */ |
756 | if ((device_open(a->terminal, O_RDWR)) < 0) { | 759 | if ((device_open(a->terminal, O_RDWR)) < 0) { |
760 | struct stat sb; | ||
757 | if (stat(a->terminal, &sb) != 0) { | 761 | if (stat(a->terminal, &sb) != 0) { |
758 | message(LOG | CONSOLE, "device '%s' does not exist.", a->terminal); | 762 | message(LOG | CONSOLE, "device '%s' does not exist.", a->terminal); |
759 | } else { | 763 | } else { |
@@ -907,6 +911,7 @@ static void delete_init_action(struct init_action *action) | |||
907 | } | 911 | } |
908 | } | 912 | } |
909 | 913 | ||
914 | #ifdef CONFIG_FEATURE_INIT_SWAPON | ||
910 | /* Make sure there is enough memory to do something useful. * | 915 | /* Make sure there is enough memory to do something useful. * |
911 | * Calls "swapon -a" if needed so be sure /etc/fstab is present... */ | 916 | * Calls "swapon -a" if needed so be sure /etc/fstab is present... */ |
912 | static void check_memory(void) | 917 | static void check_memory(void) |
@@ -934,6 +939,9 @@ static void check_memory(void) | |||
934 | message(CONSOLE, "Sorry, your computer does not have enough memory."); | 939 | message(CONSOLE, "Sorry, your computer does not have enough memory."); |
935 | loop_forever(); | 940 | loop_forever(); |
936 | } | 941 | } |
942 | #else | ||
943 | # define check_memory() | ||
944 | #endif /* CONFIG_FEATURE_INIT_SWAPON */ | ||
937 | 945 | ||
938 | /* NOTE that if CONFIG_FEATURE_USE_INITTAB is NOT defined, | 946 | /* NOTE that if CONFIG_FEATURE_USE_INITTAB is NOT defined, |
939 | * then parse_inittab() simply adds in some default | 947 | * then parse_inittab() simply adds in some default |
@@ -1097,6 +1105,7 @@ extern int init_main(int argc, char **argv) | |||
1097 | /* Set up sig handlers -- be sure to | 1105 | /* Set up sig handlers -- be sure to |
1098 | * clear all of these in run() */ | 1106 | * clear all of these in run() */ |
1099 | signal(SIGHUP, exec_signal); | 1107 | signal(SIGHUP, exec_signal); |
1108 | signal(SIGQUIT, exec_signal); | ||
1100 | signal(SIGUSR1, halt_signal); | 1109 | signal(SIGUSR1, halt_signal); |
1101 | signal(SIGUSR2, halt_signal); | 1110 | signal(SIGUSR2, halt_signal); |
1102 | signal(SIGINT, ctrlaltdel_signal); | 1111 | signal(SIGINT, ctrlaltdel_signal); |
diff --git a/busybox/libbb/.cvsignore b/busybox/libbb/.cvsignore deleted file mode 100644 index 2bbe016f5..000000000 --- a/busybox/libbb/.cvsignore +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | loop.h | ||
diff --git a/busybox/libbb/Makefile.in b/busybox/libbb/Makefile.in index 85d4a967b..d4c5ec14a 100644 --- a/busybox/libbb/Makefile.in +++ b/busybox/libbb/Makefile.in | |||
@@ -53,7 +53,7 @@ LIBBB_OBJS=$(patsubst %.c,$(LIBBB_DIR)%.o, $(LIBBB_SRC)) | |||
53 | LIBBB_MSRC0:=$(srcdir)/messages.c | 53 | LIBBB_MSRC0:=$(srcdir)/messages.c |
54 | LIBBB_MOBJ0:=full_version.o \ | 54 | LIBBB_MOBJ0:=full_version.o \ |
55 | memory_exhausted.o invalid_date.o io_error.o \ | 55 | memory_exhausted.o invalid_date.o io_error.o \ |
56 | write_error.o name_longer_than_foo.o unknown.o \ | 56 | read_error.o write_error.o name_longer_than_foo.o unknown.o \ |
57 | can_not_create_raw_socket.o perm_denied_are_you_root.o \ | 57 | can_not_create_raw_socket.o perm_denied_are_you_root.o \ |
58 | shadow_file.o passwd_file.o group_file.o gshadow_file.o nologin_file.o \ | 58 | shadow_file.o passwd_file.o group_file.o gshadow_file.o nologin_file.o \ |
59 | securetty_file.o motd_file.o \ | 59 | securetty_file.o motd_file.o \ |
diff --git a/busybox/libbb/concat_path_file.c b/busybox/libbb/concat_path_file.c index 77c054530..00233ad9a 100644 --- a/busybox/libbb/concat_path_file.c +++ b/busybox/libbb/concat_path_file.c | |||
@@ -34,11 +34,11 @@ extern char *concat_path_file(const char *path, const char *filename) | |||
34 | char *lc; | 34 | char *lc; |
35 | 35 | ||
36 | if (!path) | 36 | if (!path) |
37 | path=""; | 37 | path = ""; |
38 | lc = last_char_is(path, '/'); | 38 | lc = last_char_is(path, '/'); |
39 | while (*filename == '/') | 39 | while (*filename == '/') |
40 | filename++; | 40 | filename++; |
41 | bb_xasprintf(&outbuf, "%s%s%s", path, (lc==NULL)? "/" : "", filename); | 41 | bb_xasprintf(&outbuf, "%s%s%s", path, (lc==NULL ? "/" : ""), filename); |
42 | 42 | ||
43 | return outbuf; | 43 | return outbuf; |
44 | } | 44 | } |
diff --git a/busybox/libbb/copyfd.c b/busybox/libbb/copyfd.c index bf0a390a3..27d65a419 100644 --- a/busybox/libbb/copyfd.c +++ b/busybox/libbb/copyfd.c | |||
@@ -2,7 +2,7 @@ | |||
2 | /* | 2 | /* |
3 | * Utility routines. | 3 | * Utility routines. |
4 | * | 4 | * |
5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | 5 | * Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
@@ -25,6 +25,7 @@ | |||
25 | #include <unistd.h> | 25 | #include <unistd.h> |
26 | 26 | ||
27 | #include "busybox.h" | 27 | #include "busybox.h" |
28 | #include "libbb.h" | ||
28 | 29 | ||
29 | 30 | ||
30 | #if BUFSIZ < 4096 | 31 | #if BUFSIZ < 4096 |
@@ -33,46 +34,59 @@ | |||
33 | #endif | 34 | #endif |
34 | 35 | ||
35 | 36 | ||
36 | /* If size is 0 copy until EOF */ | 37 | static size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size2) |
37 | static size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size) | ||
38 | { | 38 | { |
39 | size_t read_total = 0; | 39 | int status; |
40 | RESERVE_CONFIG_BUFFER(buffer,BUFSIZ); | 40 | size_t xread, wrote, total, size = size2; |
41 | 41 | ||
42 | while ((size == 0) || (read_total < size)) { | 42 | if (src_fd < 0) { |
43 | size_t read_try; | 43 | return -1; |
44 | ssize_t read_actual; | 44 | } |
45 | 45 | ||
46 | if ((size == 0) || (size - read_total > BUFSIZ)) { | 46 | if (size == 0) { |
47 | read_try = BUFSIZ; | 47 | /* If size is 0 copy until EOF */ |
48 | } else { | 48 | size = ULONG_MAX; |
49 | read_try = size - read_total; | 49 | } |
50 | } | ||
51 | 50 | ||
52 | read_actual = safe_read(src_fd, buffer, read_try); | 51 | { |
53 | if (read_actual > 0) { | 52 | RESERVE_CONFIG_BUFFER(buffer,BUFSIZ); |
54 | if ((dst_fd >= 0) && (bb_full_write(dst_fd, buffer, (size_t) read_actual) != read_actual)) { | 53 | total = 0; |
55 | bb_perror_msg(bb_msg_write_error); /* match Read error below */ | 54 | wrote = 0; |
55 | status = -1; | ||
56 | while (total < size) | ||
57 | { | ||
58 | xread = BUFSIZ; | ||
59 | if (size < (total + BUFSIZ)) | ||
60 | xread = size - total; | ||
61 | xread = bb_full_read(src_fd, buffer, xread); | ||
62 | if (xread > 0) { | ||
63 | if (dst_fd < 0) { | ||
64 | /* A -1 dst_fd means we need to fake it... */ | ||
65 | wrote = xread; | ||
66 | } else { | ||
67 | wrote = bb_full_write(dst_fd, buffer, xread); | ||
68 | } | ||
69 | if (wrote < xread) { | ||
70 | bb_perror_msg(bb_msg_write_error); | ||
71 | break; | ||
72 | } | ||
73 | total += wrote; | ||
74 | } else if (xread < 0) { | ||
75 | bb_perror_msg(bb_msg_read_error); | ||
76 | break; | ||
77 | } else if (xread == 0) { | ||
78 | /* All done. */ | ||
79 | status = 0; | ||
56 | break; | 80 | break; |
57 | } | 81 | } |
58 | } | 82 | } |
59 | else if (read_actual == 0) { | 83 | RELEASE_CONFIG_BUFFER(buffer); |
60 | if (size) { | ||
61 | bb_error_msg("Unable to read all data"); | ||
62 | } | ||
63 | break; | ||
64 | } else { | ||
65 | /* read_actual < 0 */ | ||
66 | bb_perror_msg("Read error"); | ||
67 | break; | ||
68 | } | ||
69 | |||
70 | read_total += read_actual; | ||
71 | } | 84 | } |
72 | 85 | ||
73 | RELEASE_CONFIG_BUFFER(buffer); | 86 | if (status == 0 || total) |
74 | 87 | return total; | |
75 | return(read_total); | 88 | /* Some sortof error occured */ |
89 | return -1; | ||
76 | } | 90 | } |
77 | 91 | ||
78 | 92 | ||
diff --git a/busybox/libbb/getopt_ulflags.c b/busybox/libbb/getopt_ulflags.c index 39a7d1d29..6197e8d9f 100644 --- a/busybox/libbb/getopt_ulflags.c +++ b/busybox/libbb/getopt_ulflags.c | |||
@@ -26,146 +26,270 @@ | |||
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include "libbb.h" | 27 | #include "libbb.h" |
28 | 28 | ||
29 | /* | 29 | /* Documentation ! |
30 | You can set bb_opt_complementaly as string with one or more | 30 | |
31 | complementaly or incongruously options. | 31 | unsigned long |
32 | If sequential founded option haved from this string | 32 | bb_getopt_ulflags (int argc, char **argv, const char *applet_opts, ...) |
33 | then your incongruously pairs unsets and complementaly make add sets. | 33 | |
34 | Format: | 34 | The command line options must be declared in const char |
35 | one char - option for check, | 35 | *applet_opts as a string of chars, for example: |
36 | chars - complementaly option for add sets. | 36 | |
37 | - chars - option triggered for unsets. | 37 | flags = bb_getopt_ulflags(argc, argv, "rnug"); |
38 | ~ chars - option incongruously. | 38 | |
39 | * - option list, called add_to_list(*ptr_from_usaged, optarg) | 39 | If one of the given options is found, a flag value is added to |
40 | : - separator. | 40 | the return value (an unsigned long). |
41 | Example: du applet can have options "-s" and "-d size" | 41 | |
42 | If getopt found -s then -d option flag unset or if found -d then -s unset. | 42 | The flag value is determined by the position of the char in |
43 | For this result you must set bb_opt_complementaly = "s-d:d-s". | 43 | applet_opts string. For example, in the above case: |
44 | Result have last option flag only from called arguments. | 44 | |
45 | Warning! You can check returned flag, pointer to "d:" argument seted | 45 | flags = bb_getopt_ulflags(argc, argv, "rnug"); |
46 | to own optarg always. | 46 | |
47 | Example two: cut applet must only one type of list may be specified, | 47 | "r" will add 1 (bit 1 : 0x01) |
48 | and -b, -c and -f incongruously option, overwited option is error also. | 48 | "n" will add 2 (bit 2 : 0x02) |
49 | You must set bb_opt_complementaly = "b~cf:c~bf:f~bc". | 49 | "u will add 4 (bit 3 : 0x03) |
50 | If called have more one specified, return value have error flag - | 50 | "g" will add 8 (bit 4 : 0x04) |
51 | high bite set (0x80000000UL). | 51 | |
52 | Example three: grep applet can have one or more "-e pattern" arguments. | 52 | and so on. You can also look at the return value as a bit |
53 | You should use bb_getopt_ulflags() as | 53 | field and each option sets one of bits. |
54 | llist_t *paterns; | 54 | |
55 | bb_opt_complementaly = "e*"; | 55 | ":" If one of the options requires an argument, then add a ":" |
56 | bb_getopt_ulflags (argc, argv, "e:", &paterns); | 56 | after the char in applet_opts and provide a pointer to store |
57 | the argument. For example: | ||
58 | |||
59 | char *pointer_to_arg_for_a; | ||
60 | char *pointer_to_arg_for_b; | ||
61 | char *pointer_to_arg_for_c; | ||
62 | char *pointer_to_arg_for_d; | ||
63 | |||
64 | flags = bb_getopt_ulflags(argc, argv, "a:b:c:d:", | ||
65 | &pointer_to_arg_for_a, &pointer_to_arg_for_b, | ||
66 | &pointer_to_arg_for_c, &pointer_to_arg_for_d); | ||
67 | |||
68 | The type of the pointer (char* or llist_t *) may be controlled | ||
69 | by the "*" special character that is set in the external string | ||
70 | bb_opt_complementaly (see below for more info). | ||
71 | |||
72 | static const struct option bb_default_long_options[] | ||
73 | |||
74 | This struct allows you to define long options. The syntax for | ||
75 | declaring the array is just like that of getopt's longopts. | ||
76 | |||
77 | static const struct option applet_long_options[] = { | ||
78 | { "verbose", 0, 0, "v" }, | ||
79 | { 0, 0, 0, 0 } | ||
80 | }; | ||
81 | bb_applet_long_options = applet_long_options; | ||
82 | |||
83 | The first parameter is the long option name that you would pass | ||
84 | to the applet (without the dashes). | ||
85 | |||
86 | The second field determines whether the option has an argument. | ||
87 | You can set this to 0, 1, or 2, or you can use the long named | ||
88 | defines of no_argument, required_argument, and optional_argument. | ||
89 | |||
90 | The third argument is used only when the long option does not | ||
91 | have a corresponding short option. In that case, it should be | ||
92 | an integer pointer. Otherwise (and normally), it should just | ||
93 | bet set to NULL. | ||
94 | |||
95 | The last argument is the corresponding short option (if there | ||
96 | is one of course). | ||
97 | |||
98 | Note: a good applet will make long options configurable via the | ||
99 | config process and not a required feature. The current standard | ||
100 | is to name the config option CONFIG_FEATURE_<applet>_LONG_OPTIONS. | ||
101 | |||
102 | const char *bb_opt_complementaly | ||
103 | |||
104 | ":" The colon (":") is used to separate groups of two or more chars | ||
105 | and/or groups of chars and special characters (stating some | ||
106 | conditions to be checked). | ||
107 | |||
108 | "abc" If groups of two or more chars are specified, the first char | ||
109 | is the main option and the other chars are secondary options. | ||
110 | Their flags will be turned on if the main option is found even | ||
111 | if they are not specifed on the command line. For example: | ||
112 | |||
113 | bb_opt_complementaly = "abc"; | ||
114 | |||
115 | flags = bb_getopt_ulflags(argc, argv, "abcd") | ||
116 | |||
117 | If getopt() finds "-a" on the command line, then | ||
118 | bb_getopt_ulflags's return value will be as if "-a -b -c" were | ||
119 | found. | ||
120 | |||
121 | Special characters: | ||
122 | |||
123 | "-" A dash between two options causes the second of the two | ||
124 | to be unset (and ignored) if it is given on the command line. | ||
125 | |||
126 | For example: | ||
127 | The du applet has the options "-s" and "-d depth". If | ||
128 | bb_getopt_ulflags finds -s, then -d is unset or if it finds -d | ||
129 | then -s is unset. (Note: busybox implements the GNU | ||
130 | "--max-depth" option as "-d".) To obtain this behavior, you | ||
131 | set bb_opt_complementaly = "s-d:d-s". Only one flag value is | ||
132 | added to bb_getopt_ulflags's return value depending on the | ||
133 | position of the options on the command line. If one of the | ||
134 | two options requires an argument pointer (":" in applet_opts | ||
135 | as in "d:") optarg is set accordingly. | ||
136 | |||
137 | char *smax_print_depth; | ||
138 | |||
139 | bb_opt_complementaly = "s-d:d-s"; | ||
140 | opt = bb_getopt_ulflags(argc, argv, "sd:", &smax_print_depth); | ||
141 | |||
142 | if (opt & 2) { | ||
143 | max_print_depth = bb_xgetularg10_bnd(smax_print_depth, | ||
144 | 0, INT_MAX); | ||
145 | } | ||
146 | |||
147 | "~" A tilde between two options, or between an option and a group | ||
148 | of options, means that they are mutually exclusive. Unlike | ||
149 | the "-" case above, an error will be forced if the options | ||
150 | are used together. | ||
151 | |||
152 | For example: | ||
153 | The cut applet must have only one type of list specified, so | ||
154 | -b, -c and -f are mutally exclusive and should raise an error | ||
155 | if specified together. In this case you must set | ||
156 | bb_opt_complementaly = "b~cf:c~bf:f~bc". If two of the | ||
157 | mutually exclusive options are found, bb_getopt_ulflags's | ||
158 | return value will have the error flag set (BB_GETOPT_ERROR) so | ||
159 | that we can check for it: | ||
160 | |||
161 | if (flags & BB_GETOPT_ERROR) | ||
162 | bb_show_usage(); | ||
163 | |||
164 | "*" A star after a char in bb_opt_complementaly means that the | ||
165 | option can occur multiple times: | ||
166 | |||
167 | For example: | ||
168 | The grep applet can have one or more "-e pattern" arguments. | ||
169 | In this case you should use bb_getopt_ulflags() as follows: | ||
170 | |||
171 | llist_t *patterns = NULL; | ||
172 | |||
173 | (this pointer must be initializated to NULL if the list is empty | ||
174 | as required by *llist_add_to(llist_t *old_head, char *new_item).) | ||
175 | |||
176 | bb_opt_complementaly = "e*"; | ||
177 | |||
178 | bb_getopt_ulflags(argc, argv, "e:", &patterns); | ||
179 | $ grep -e user -e root /etc/passwd | ||
180 | root:x:0:0:root:/root:/bin/bash | ||
181 | user:x:500:500::/home/user:/bin/bash | ||
182 | |||
57 | */ | 183 | */ |
58 | 184 | ||
59 | const char *bb_opt_complementaly; | 185 | const char *bb_opt_complementaly; |
60 | 186 | ||
61 | typedef struct | 187 | typedef struct { |
62 | { | ||
63 | unsigned char opt; | 188 | unsigned char opt; |
64 | char list_flg; | 189 | char list_flg; |
65 | unsigned long switch_on; | 190 | unsigned long switch_on; |
66 | unsigned long switch_off; | 191 | unsigned long switch_off; |
67 | unsigned long incongruously; | 192 | unsigned long incongruously; |
68 | void **optarg; /* char **optarg or llist_t **optarg */ | 193 | void **optarg; /* char **optarg or llist_t **optarg */ |
69 | } t_complementaly; | 194 | } t_complementaly; |
70 | 195 | ||
71 | /* You can set bb_applet_long_options for parse called long options */ | 196 | /* You can set bb_applet_long_options for parse called long options */ |
72 | 197 | ||
73 | static const struct option bb_default_long_options[] = { | 198 | static const struct option bb_default_long_options[] = { |
74 | /* { "help", 0, NULL, '?' }, */ | 199 | /* { "help", 0, NULL, '?' }, */ |
75 | { 0, 0, 0, 0 } | 200 | { 0, 0, 0, 0 } |
76 | }; | 201 | }; |
77 | 202 | ||
78 | const struct option *bb_applet_long_options = bb_default_long_options; | 203 | const struct option *bb_applet_long_options = bb_default_long_options; |
79 | 204 | ||
80 | |||
81 | unsigned long | 205 | unsigned long |
82 | bb_getopt_ulflags (int argc, char **argv, const char *applet_opts, ...) | 206 | bb_getopt_ulflags (int argc, char **argv, const char *applet_opts, ...) |
83 | { | 207 | { |
84 | unsigned long flags = 0; | 208 | unsigned long flags = 0; |
85 | t_complementaly complementaly[sizeof(flags) * 8 + 1]; | 209 | t_complementaly complementaly[sizeof(flags) * 8 + 1]; |
86 | int c; | 210 | int c; |
87 | const unsigned char *s; | 211 | const unsigned char *s; |
88 | t_complementaly *on_off; | 212 | t_complementaly *on_off; |
89 | va_list p; | 213 | va_list p; |
90 | 214 | ||
91 | va_start (p, applet_opts); | 215 | va_start (p, applet_opts); |
92 | 216 | ||
93 | /* skip GNU extension */ | 217 | /* skip GNU extension */ |
94 | s = applet_opts; | 218 | s = applet_opts; |
95 | if(*s == '+' || *s == '-') | 219 | if(*s == '+' || *s == '-') |
96 | s++; | ||
97 | |||
98 | c = 0; | ||
99 | on_off = complementaly; | ||
100 | for (; *s; s++) { | ||
101 | if(c >= (sizeof(flags)*8)) | ||
102 | break; | ||
103 | on_off->opt = *s; | ||
104 | on_off->switch_on = (1 << c); | ||
105 | on_off->list_flg = 0; | ||
106 | on_off->switch_off = 0; | ||
107 | on_off->incongruously = 0; | ||
108 | on_off->optarg = NULL; | ||
109 | if (s[1] == ':') { | ||
110 | on_off->optarg = va_arg (p, void **); | ||
111 | do | ||
112 | s++; | 220 | s++; |
113 | while (s[1] == ':'); | 221 | |
222 | c = 0; | ||
223 | on_off = complementaly; | ||
224 | for (; *s; s++) { | ||
225 | if(c >= (sizeof(flags)*8)) | ||
226 | break; | ||
227 | on_off->opt = *s; | ||
228 | on_off->switch_on = (1 << c); | ||
229 | on_off->list_flg = 0; | ||
230 | on_off->switch_off = 0; | ||
231 | on_off->incongruously = 0; | ||
232 | on_off->optarg = NULL; | ||
233 | if (s[1] == ':') { | ||
234 | on_off->optarg = va_arg (p, void **); | ||
235 | do | ||
236 | s++; | ||
237 | while (s[1] == ':'); | ||
238 | } | ||
239 | on_off++; | ||
240 | c++; | ||
114 | } | 241 | } |
115 | on_off++; | 242 | on_off->opt = 0; |
116 | c++; | 243 | c = 0; |
117 | } | 244 | for (s = bb_opt_complementaly; s && *s; s++) { |
118 | on_off->opt = 0; | 245 | t_complementaly *pair; |
119 | c = 0; | 246 | |
120 | for (s = bb_opt_complementaly; s && *s; s++) { | 247 | if (*s == ':') { |
121 | t_complementaly *pair; | 248 | c = 0; |
122 | 249 | continue; | |
123 | if (*s == ':') { | 250 | } |
124 | c = 0; | 251 | if (c) |
125 | continue; | 252 | continue; |
126 | } | 253 | for (on_off = complementaly; on_off->opt; on_off++) |
127 | if (c) | 254 | if (on_off->opt == *s) |
128 | continue; | 255 | break; |
129 | for (on_off = complementaly; on_off->opt; on_off++) | 256 | pair = on_off; |
130 | if (on_off->opt == *s) | 257 | for(s++; *s && *s != ':'; s++) { |
131 | break; | 258 | if (*s == '-' || *s == '~') { |
132 | pair = on_off; | 259 | c = *s; |
133 | for(s++; *s && *s != ':'; s++) { | 260 | } else if(*s == '*') { |
134 | if (*s == '-' || *s == '~') { | 261 | pair->list_flg++; |
135 | c = *s; | 262 | } else { |
136 | } else if(*s == '*') { | 263 | unsigned long *pair_switch = &(pair->switch_on); |
137 | pair->list_flg++; | 264 | if(c) |
138 | } else { | 265 | pair_switch = c == '-' ? &(pair->switch_off) : &(pair->incongruously); |
139 | unsigned long *pair_switch = &(pair->switch_on); | 266 | for (on_off = complementaly; on_off->opt; on_off++) |
140 | 267 | if (on_off->opt == *s) { | |
141 | if(c) | 268 | *pair_switch |= on_off->switch_on; |
142 | pair_switch = c == '-' ? &(pair->switch_off) : &(pair->incongruously); | 269 | break; |
143 | for (on_off = complementaly; on_off->opt; on_off++) | 270 | } |
144 | if (on_off->opt == *s) { | 271 | } |
145 | *pair_switch |= on_off->switch_on; | 272 | } |
146 | break; | 273 | s--; |
147 | } | ||
148 | } | ||
149 | } | ||
150 | s--; | ||
151 | } | ||
152 | |||
153 | while ((c = getopt_long (argc, argv, applet_opts, | ||
154 | bb_applet_long_options, NULL)) > 0) { | ||
155 | for (on_off = complementaly; on_off->opt != c; on_off++) { | ||
156 | if(!on_off->opt) | ||
157 | bb_show_usage (); | ||
158 | } | 274 | } |
159 | if(flags & on_off->incongruously) | 275 | |
160 | flags |= 0x80000000UL; | 276 | while ((c = getopt_long (argc, argv, applet_opts, |
161 | flags &= ~on_off->switch_off; | 277 | bb_applet_long_options, NULL)) > 0) { |
162 | flags |= on_off->switch_on; | 278 | for (on_off = complementaly; on_off->opt != c; on_off++) { |
163 | if(on_off->list_flg) { | 279 | if(!on_off->opt) |
164 | *(llist_t **)(on_off->optarg) = | 280 | bb_show_usage (); |
165 | llist_add_to(*(llist_t **)(on_off->optarg), optarg); | 281 | } |
166 | } else if (on_off->optarg) { | 282 | if(flags & on_off->incongruously) |
167 | *(char **)(on_off->optarg) = optarg; | 283 | flags |= BB_GETOPT_ERROR; |
284 | flags &= ~on_off->switch_off; | ||
285 | flags |= on_off->switch_on; | ||
286 | if(on_off->list_flg) { | ||
287 | *(llist_t **)(on_off->optarg) = | ||
288 | llist_add_to(*(llist_t **)(on_off->optarg), optarg); | ||
289 | } else if (on_off->optarg) { | ||
290 | *(char **)(on_off->optarg) = optarg; | ||
291 | } | ||
168 | } | 292 | } |
169 | } | 293 | |
170 | return flags; | 294 | return flags; |
171 | } | 295 | } |
diff --git a/busybox/libbb/interface.c b/busybox/libbb/interface.c index fe2d0b4b2..c4aa032a4 100644 --- a/busybox/libbb/interface.c +++ b/busybox/libbb/interface.c | |||
@@ -888,6 +888,20 @@ static int sockets_open(int family) | |||
888 | return sfd; | 888 | return sfd; |
889 | } | 889 | } |
890 | 890 | ||
891 | #ifdef CONFIG_FEATURE_CLEAN_UP | ||
892 | static void sockets_close(void) | ||
893 | { | ||
894 | struct aftype **aft; | ||
895 | for (aft = aftypes; *aft != NULL; aft++) { | ||
896 | struct aftype *af = *aft; | ||
897 | if( af->fd != -1 ) { | ||
898 | close(af->fd); | ||
899 | af->fd = -1; | ||
900 | } | ||
901 | } | ||
902 | } | ||
903 | #endif | ||
904 | |||
891 | /* like strcmp(), but knows about numbers */ | 905 | /* like strcmp(), but knows about numbers */ |
892 | static int nstrcmp(const char *a, const char *b) | 906 | static int nstrcmp(const char *a, const char *b) |
893 | { | 907 | { |
@@ -1223,17 +1237,13 @@ static int if_fetch(struct interface *ife) | |||
1223 | } | 1237 | } |
1224 | #endif | 1238 | #endif |
1225 | 1239 | ||
1240 | #ifdef SIOCGIFMAP | ||
1226 | strcpy(ifr.ifr_name, ifname); | 1241 | strcpy(ifr.ifr_name, ifname); |
1227 | if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) | 1242 | if (ioctl(skfd, SIOCGIFMAP, &ifr) == 0) |
1228 | memset(&ife->map, 0, sizeof(struct ifmap)); | 1243 | ife->map = ifr.ifr_map; |
1229 | else | 1244 | else |
1230 | memcpy(&ife->map, &ifr.ifr_map, sizeof(struct ifmap)); | 1245 | #endif |
1231 | |||
1232 | strcpy(ifr.ifr_name, ifname); | ||
1233 | if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) | ||
1234 | memset(&ife->map, 0, sizeof(struct ifmap)); | 1246 | memset(&ife->map, 0, sizeof(struct ifmap)); |
1235 | else | ||
1236 | ife->map = ifr.ifr_map; | ||
1237 | 1247 | ||
1238 | #ifdef HAVE_TXQUEUELEN | 1248 | #ifdef HAVE_TXQUEUELEN |
1239 | strcpy(ifr.ifr_name, ifname); | 1249 | strcpy(ifr.ifr_name, ifname); |
@@ -1374,7 +1384,7 @@ static struct hwtype loop_hwtype = { | |||
1374 | #if HAVE_HWETHER | 1384 | #if HAVE_HWETHER |
1375 | #include <net/if_arp.h> | 1385 | #include <net/if_arp.h> |
1376 | 1386 | ||
1377 | #if __GLIBC__ >=2 && __GLIBC_MINOR >= 1 | 1387 | #if (__GLIBC__ >=2 && __GLIBC_MINOR >= 1) || defined(_NEWLIB_VERSION) |
1378 | #include <net/ethernet.h> | 1388 | #include <net/ethernet.h> |
1379 | #else | 1389 | #else |
1380 | #include <linux/if_ether.h> | 1390 | #include <linux/if_ether.h> |
@@ -2078,6 +2088,8 @@ int display_interfaces(char *ifname) | |||
2078 | 2088 | ||
2079 | /* Do we have to show the current setup? */ | 2089 | /* Do we have to show the current setup? */ |
2080 | status = if_print(ifname); | 2090 | status = if_print(ifname); |
2081 | close(skfd); | 2091 | #ifdef CONFIG_FEATURE_CLEAN_UP |
2092 | sockets_close(); | ||
2093 | #endif | ||
2082 | exit(status < 0); | 2094 | exit(status < 0); |
2083 | } | 2095 | } |
diff --git a/busybox/libbb/messages.c b/busybox/libbb/messages.c index 671c452d2..c3f307ec5 100644 --- a/busybox/libbb/messages.c +++ b/busybox/libbb/messages.c | |||
@@ -36,6 +36,9 @@ | |||
36 | #ifdef L_write_error | 36 | #ifdef L_write_error |
37 | const char * const bb_msg_write_error = "Write Error"; | 37 | const char * const bb_msg_write_error = "Write Error"; |
38 | #endif | 38 | #endif |
39 | #ifdef L_read_error | ||
40 | const char * const bb_msg_read_error = "Read Error"; | ||
41 | #endif | ||
39 | #ifdef L_name_longer_than_foo | 42 | #ifdef L_name_longer_than_foo |
40 | const char * const bb_msg_name_longer_than_foo = "Names longer than %d chars not supported."; | 43 | const char * const bb_msg_name_longer_than_foo = "Names longer than %d chars not supported."; |
41 | #endif | 44 | #endif |
diff --git a/busybox/libbb/syscalls.c b/busybox/libbb/syscalls.c index 9e89dbd39..dac90e24b 100644 --- a/busybox/libbb/syscalls.c +++ b/busybox/libbb/syscalls.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <sys/syscall.h> | 29 | #include <sys/syscall.h> |
30 | #include "libbb.h" | 30 | #include "libbb.h" |
31 | 31 | ||
32 | int sysfs( int option, unsigned int fs_index, char * buf) | 32 | int sysfs(int option, unsigned int fs_index, char * buf) |
33 | { | 33 | { |
34 | return(syscall(__NR_sysfs, option, fs_index, buf)); | 34 | return(syscall(__NR_sysfs, option, fs_index, buf)); |
35 | } | 35 | } |
@@ -39,60 +39,59 @@ int pivot_root(const char * new_root,const char * put_old) | |||
39 | #ifndef __NR_pivot_root | 39 | #ifndef __NR_pivot_root |
40 | #warning This kernel does not support the pivot_root syscall | 40 | #warning This kernel does not support the pivot_root syscall |
41 | #warning -> The pivot_root system call is being stubbed out... | 41 | #warning -> The pivot_root system call is being stubbed out... |
42 | /* BusyBox was compiled against a kernel that did not support | 42 | /* BusyBox was compiled against a kernel that did not support |
43 | * the pivot_root system call. To make this application work, | 43 | * the pivot_root system call. To make this application work, |
44 | * you will need to recompile with a kernel supporting the | 44 | * you will need to recompile with a kernel supporting the |
45 | * pivot_root system call. | 45 | * pivot_root system call. |
46 | */ | 46 | */ |
47 | bb_error_msg("\n\nTo make this application work, you will need to recompile\n" | 47 | bb_error_msg("\n\nTo make this application work, you will need to recompile\n" |
48 | "BusyBox with a kernel supporting the pivot_root system call.\n"); | 48 | "BusyBox with a kernel supporting the pivot_root system call.\n"); |
49 | errno=ENOSYS; | 49 | errno = ENOSYS; |
50 | return -1; | 50 | return -1; |
51 | #else | 51 | #else |
52 | return(syscall(__NR_pivot_root, new_root, put_old)); | 52 | return(syscall(__NR_pivot_root, new_root, put_old)); |
53 | #endif | 53 | #endif /* __NR_pivot_root */ |
54 | } | 54 | } |
55 | 55 | ||
56 | 56 | ||
57 | 57 | /* These syscalls are not included in ancient glibc versions, | |
58 | /* These syscalls are not included in ancient glibc versions */ | 58 | so we have to define them ourselves, whee ! */ |
59 | #if ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)) | 59 | #if ((__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)) |
60 | 60 | ||
61 | int bdflush(int func, int data) | 61 | int bdflush(int func, int data) |
62 | { | 62 | { |
63 | return(syscall(__NR_bdflush, func, data)); | 63 | return(syscall(__NR_bdflush, func, data)); |
64 | } | 64 | } |
65 | 65 | ||
66 | #ifndef __alpha__ | 66 | #ifndef __alpha__ |
67 | # define __NR_klogctl __NR_syslog | 67 | # define __NR_klogctl __NR_syslog |
68 | int klogctl(int type, char *b, int len) | 68 | int klogctl(int type, char *b, int len) |
69 | { | 69 | { |
70 | return(syscall(__NR_klogctl, type, b, len)); | 70 | return(syscall(__NR_klogctl, type, b, len)); |
71 | } | 71 | } |
72 | #endif | 72 | #endif /* __alpha__ */ |
73 | 73 | ||
74 | 74 | ||
75 | int umount2(const char * special_file, int flags) | 75 | int umount2(const char * special_file, int flags) |
76 | { | 76 | { |
77 | #ifndef __NR_pivot_root | 77 | #ifndef __NR_umount2 |
78 | #warning This kernel does not support the umount2 syscall | 78 | #warning This kernel does not support the umount2 syscall |
79 | #warning -> The umount2 system call is being stubbed out... | 79 | #warning -> The umount2 system call is being stubbed out... |
80 | /* BusyBox was compiled against a kernel that did not support | 80 | /* BusyBox was compiled against a kernel that did not support |
81 | * the umount2 system call. To make this application work, | 81 | * the umount2 system call. To make this application work, |
82 | * you will need to recompile with a kernel supporting the | 82 | * you will need to recompile with a kernel supporting the |
83 | * umount2 system call. | 83 | * umount2 system call. |
84 | */ | 84 | */ |
85 | bb_error_msg("\n\nTo make this application work, you will need to recompile\n" | 85 | bb_error_msg("\n\nTo make this application work, you will need to recompile\n" |
86 | "BusyBox with a kernel supporting the umount2 system call.\n"); | 86 | "BusyBox with a kernel supporting the umount2 system call.\n"); |
87 | errno=ENOSYS; | 87 | errno = ENOSYS; |
88 | return -1; | 88 | return -1; |
89 | #else | 89 | #else |
90 | return(syscall(__NR_umount2, special_file, flags)); | 90 | return(syscall(__NR_umount2, special_file, flags)); |
91 | #endif | 91 | #endif /* __NR_pivot_root */ |
92 | } | 92 | } |
93 | 93 | ||
94 | 94 | #endif /* old glibc check */ | |
95 | #endif | ||
96 | 95 | ||
97 | 96 | ||
98 | /* END CODE */ | 97 | /* END CODE */ |
diff --git a/busybox/loginutils/Config.in b/busybox/loginutils/Config.in index 5619aa9af..12c208c64 100644 --- a/busybox/loginutils/Config.in +++ b/busybox/loginutils/Config.in | |||
@@ -57,14 +57,21 @@ config CONFIG_GETTY | |||
57 | help | 57 | help |
58 | getty lets you log in on a tty, it is normally invoked by init. | 58 | getty lets you log in on a tty, it is normally invoked by init. |
59 | 59 | ||
60 | config CONFIG_FEATURE_U_W_TMP | 60 | config CONFIG_FEATURE_UTMP |
61 | bool " Support utmp and wtmp files" | 61 | bool " Support utmp file" |
62 | depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_WHO || CONFIG_LAST | 62 | depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_WHO |
63 | default n | 63 | default n |
64 | help | 64 | help |
65 | The files /var/run/utmp and /var/run/wtmp can be used to track when | 65 | The file /var/run/utmp is used to track who is currently logged in. |
66 | user's have logged into and logged out of the system, allowing programs | 66 | |
67 | such as 'who' and 'last' to list who is currently logged in. | 67 | config CONFIG_FEATURE_WTMP |
68 | bool " Support wtmp file" | ||
69 | depends on CONFIG_GETTY || CONFIG_LOGIN || CONFIG_SU || CONFIG_LAST | ||
70 | default n | ||
71 | select CONFIG_FEATURE_UTMP | ||
72 | help | ||
73 | The file /var/run/wtmp is used to track when user's have logged into | ||
74 | and logged out of the system. | ||
68 | 75 | ||
69 | config CONFIG_LOGIN | 76 | config CONFIG_LOGIN |
70 | bool "login" | 77 | bool "login" |
diff --git a/busybox/loginutils/getty.c b/busybox/loginutils/getty.c index 923432ba1..78009181d 100644 --- a/busybox/loginutils/getty.c +++ b/busybox/loginutils/getty.c | |||
@@ -25,11 +25,14 @@ | |||
25 | #include <fcntl.h> | 25 | #include <fcntl.h> |
26 | #include <stdarg.h> | 26 | #include <stdarg.h> |
27 | #include <ctype.h> | 27 | #include <ctype.h> |
28 | #include <utmp.h> | ||
29 | #include <getopt.h> | 28 | #include <getopt.h> |
30 | #include <termios.h> | 29 | #include <termios.h> |
31 | #include "busybox.h" | 30 | #include "busybox.h" |
32 | 31 | ||
32 | #ifdef CONFIG_FEATURE_UTMP | ||
33 | #include <utmp.h> | ||
34 | #endif | ||
35 | |||
33 | #define _PATH_LOGIN "/bin/login" | 36 | #define _PATH_LOGIN "/bin/login" |
34 | 37 | ||
35 | /* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */ | 38 | /* If USE_SYSLOG is undefined all diagnostics go directly to /dev/console. */ |
@@ -47,7 +50,7 @@ | |||
47 | 50 | ||
48 | #ifdef LOGIN_PROCESS /* defined in System V utmp.h */ | 51 | #ifdef LOGIN_PROCESS /* defined in System V utmp.h */ |
49 | #define SYSV_STYLE /* select System V style getty */ | 52 | #define SYSV_STYLE /* select System V style getty */ |
50 | #ifdef CONFIG_FEATURE_U_W_TMP | 53 | #ifdef CONFIG_FEATURE_WTMP |
51 | extern void updwtmp(const char *filename, const struct utmp *ut); | 54 | extern void updwtmp(const char *filename, const struct utmp *ut); |
52 | #endif | 55 | #endif |
53 | #endif /* LOGIN_PROCESS */ | 56 | #endif /* LOGIN_PROCESS */ |
@@ -85,7 +88,7 @@ extern void updwtmp(const char *filename, const struct utmp *ut); | |||
85 | #define DEF_QUIT CTL('\\') /* default quit char */ | 88 | #define DEF_QUIT CTL('\\') /* default quit char */ |
86 | #define DEF_KILL CTL('U') /* default kill char */ | 89 | #define DEF_KILL CTL('U') /* default kill char */ |
87 | #define DEF_EOF CTL('D') /* default EOF char */ | 90 | #define DEF_EOF CTL('D') /* default EOF char */ |
88 | #define DEF_EOL 0 | 91 | #define DEF_EOL '\n' |
89 | #define DEF_SWITCH 0 /* default switch char */ | 92 | #define DEF_SWITCH 0 /* default switch char */ |
90 | 93 | ||
91 | /* | 94 | /* |
@@ -231,9 +234,11 @@ static int caps_lock(const char *s); | |||
231 | static int bcode(char *s); | 234 | static int bcode(char *s); |
232 | static void error(const char *fmt, ...) __attribute__ ((noreturn)); | 235 | static void error(const char *fmt, ...) __attribute__ ((noreturn)); |
233 | 236 | ||
234 | #ifdef CONFIG_FEATURE_U_W_TMP | 237 | #ifdef SYSV_STYLE |
238 | #ifdef CONFIG_FEATURE_UTMP | ||
235 | static void update_utmp(char *line); | 239 | static void update_utmp(char *line); |
236 | #endif | 240 | #endif |
241 | #endif | ||
237 | 242 | ||
238 | /* The following is used for understandable diagnostics. */ | 243 | /* The following is used for understandable diagnostics. */ |
239 | 244 | ||
@@ -260,7 +265,11 @@ int getty_main(int argc, char **argv) | |||
260 | _PATH_LOGIN, /* default login program */ | 265 | _PATH_LOGIN, /* default login program */ |
261 | "tty1", /* default tty line */ | 266 | "tty1", /* default tty line */ |
262 | "", /* modem init string */ | 267 | "", /* modem init string */ |
268 | #ifdef ISSUE | ||
263 | ISSUE, /* default issue file */ | 269 | ISSUE, /* default issue file */ |
270 | #else | ||
271 | NULL, | ||
272 | #endif | ||
264 | 0, /* no baud rates known yet */ | 273 | 0, /* no baud rates known yet */ |
265 | }; | 274 | }; |
266 | 275 | ||
@@ -289,7 +298,7 @@ int getty_main(int argc, char **argv) | |||
289 | 298 | ||
290 | 299 | ||
291 | #ifdef SYSV_STYLE | 300 | #ifdef SYSV_STYLE |
292 | #ifdef CONFIG_FEATURE_U_W_TMP | 301 | #ifdef CONFIG_FEATURE_UTMP |
293 | update_utmp(options.tty); | 302 | update_utmp(options.tty); |
294 | #endif | 303 | #endif |
295 | #endif | 304 | #endif |
@@ -482,7 +491,7 @@ static void parse_speeds(struct options *op, char *arg) | |||
482 | } | 491 | } |
483 | 492 | ||
484 | #ifdef SYSV_STYLE | 493 | #ifdef SYSV_STYLE |
485 | #ifdef CONFIG_FEATURE_U_W_TMP | 494 | #ifdef CONFIG_FEATURE_UTMP |
486 | 495 | ||
487 | /* update_utmp - update our utmp entry */ | 496 | /* update_utmp - update our utmp entry */ |
488 | static void update_utmp(char *line) | 497 | static void update_utmp(char *line) |
@@ -533,30 +542,24 @@ static void update_utmp(char *line) | |||
533 | pututline(&ut); | 542 | pututline(&ut); |
534 | endutent(); | 543 | endutent(); |
535 | 544 | ||
536 | { | 545 | #ifdef CONFIG_FEATURE_WTMP |
537 | if (access(_PATH_WTMP, R_OK|W_OK) == -1) { | 546 | if (access(_PATH_WTMP, R_OK|W_OK) == -1) |
538 | close(creat(_PATH_WTMP, 0664)); | 547 | close(creat(_PATH_WTMP, 0664)); |
539 | } | 548 | updwtmp(_PATH_WTMP, &ut); |
540 | updwtmp(_PATH_WTMP, &ut); | 549 | #endif |
541 | } | ||
542 | } | 550 | } |
543 | 551 | ||
544 | #endif /* CONFIG_FEATURE_U_W_TMP */ | 552 | #endif /* CONFIG_FEATURE_UTMP */ |
545 | #endif /* SYSV_STYLE */ | 553 | #endif /* SYSV_STYLE */ |
546 | 554 | ||
547 | /* open_tty - set up tty as standard { input, output, error } */ | 555 | /* open_tty - set up tty as standard { input, output, error } */ |
548 | static void open_tty(char *tty, struct termio *tp, int local) | 556 | static void open_tty(char *tty, struct termio *tp, int local) |
549 | { | 557 | { |
550 | /* Get rid of the present standard { output, error} if any. */ | ||
551 | |||
552 | (void) close(1); | ||
553 | (void) close(2); | ||
554 | errno = 0; /* ignore above errors */ | ||
555 | |||
556 | /* Set up new standard input, unless we are given an already opened port. */ | 558 | /* Set up new standard input, unless we are given an already opened port. */ |
557 | 559 | ||
558 | if (strcmp(tty, "-")) { | 560 | if (strcmp(tty, "-")) { |
559 | struct stat st; | 561 | struct stat st; |
562 | int fd; | ||
560 | 563 | ||
561 | /* Sanity checks... */ | 564 | /* Sanity checks... */ |
562 | 565 | ||
@@ -569,12 +572,11 @@ static void open_tty(char *tty, struct termio *tp, int local) | |||
569 | 572 | ||
570 | /* Open the tty as standard input. */ | 573 | /* Open the tty as standard input. */ |
571 | 574 | ||
572 | (void) close(0); | ||
573 | errno = 0; /* ignore close(2) errors */ | ||
574 | |||
575 | debug("open(2)\n"); | 575 | debug("open(2)\n"); |
576 | if (open(tty, O_RDWR | O_NONBLOCK, 0) != 0) | 576 | fd = open(tty, O_RDWR | O_NONBLOCK, 0); |
577 | if (dup2(fd, STDIN_FILENO) == -1) | ||
577 | error("/dev/%s: cannot open as standard input: %m", tty); | 578 | error("/dev/%s: cannot open as standard input: %m", tty); |
579 | close(fd); | ||
578 | 580 | ||
579 | } else { | 581 | } else { |
580 | 582 | ||
@@ -587,9 +589,10 @@ static void open_tty(char *tty, struct termio *tp, int local) | |||
587 | error("%s: not open for read/write", tty); | 589 | error("%s: not open for read/write", tty); |
588 | } | 590 | } |
589 | 591 | ||
590 | /* Set up standard output and standard error file descriptors. */ | 592 | /* Replace current standard output/error fd's with new ones */ |
591 | debug("duping\n"); | 593 | debug("duping\n"); |
592 | if (dup(0) != 1 || dup(0) != 2) /* set up stdout and stderr */ | 594 | if (dup2(STDIN_FILENO, STDOUT_FILENO) == -1 || |
595 | dup2(STDIN_FILENO, STDERR_FILENO) == -1) | ||
593 | error("%s: dup problem: %m", tty); /* we have a problem */ | 596 | error("%s: dup problem: %m", tty); /* we have a problem */ |
594 | 597 | ||
595 | /* | 598 | /* |
diff --git a/busybox/loginutils/login.c b/busybox/loginutils/login.c index f3630f102..5ed10b91b 100644 --- a/busybox/loginutils/login.c +++ b/busybox/loginutils/login.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <fs_secure.h> | 23 | #include <fs_secure.h> |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | #ifdef CONFIG_FEATURE_U_W_TMP | 26 | #ifdef CONFIG_FEATURE_UTMP |
27 | // import from utmp.c | 27 | // import from utmp.c |
28 | static void checkutmp(int picky); | 28 | static void checkutmp(int picky); |
29 | static void setutmp(const char *name, const char *line); | 29 | static void setutmp(const char *name, const char *line); |
@@ -122,7 +122,7 @@ extern int login_main(int argc, char **argv) | |||
122 | if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) | 122 | if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) |
123 | return EXIT_FAILURE; /* Must be a terminal */ | 123 | return EXIT_FAILURE; /* Must be a terminal */ |
124 | 124 | ||
125 | #ifdef CONFIG_FEATURE_U_W_TMP | 125 | #ifdef CONFIG_FEATURE_UTMP |
126 | checkutmp ( !amroot ); | 126 | checkutmp ( !amroot ); |
127 | #endif | 127 | #endif |
128 | 128 | ||
@@ -134,13 +134,13 @@ extern int login_main(int argc, char **argv) | |||
134 | else | 134 | else |
135 | safe_strncpy ( tty, "UNKNOWN", sizeof( tty )); | 135 | safe_strncpy ( tty, "UNKNOWN", sizeof( tty )); |
136 | 136 | ||
137 | #ifdef CONFIG_FEATURE_U_W_TMP | 137 | #ifdef CONFIG_FEATURE_UTMP |
138 | if ( amroot ) | 138 | if ( amroot ) |
139 | memset ( utent.ut_host, 0, sizeof utent.ut_host ); | 139 | memset ( utent.ut_host, 0, sizeof utent.ut_host ); |
140 | #endif | 140 | #endif |
141 | 141 | ||
142 | if ( opt_host ) { | 142 | if ( opt_host ) { |
143 | #ifdef CONFIG_FEATURE_U_W_TMP | 143 | #ifdef CONFIG_FEATURE_UTMP |
144 | safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host )); | 144 | safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host )); |
145 | #endif | 145 | #endif |
146 | snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host ); | 146 | snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host ); |
@@ -222,7 +222,7 @@ auth_ok: | |||
222 | if ( check_nologin ( pw-> pw_uid == 0 )) | 222 | if ( check_nologin ( pw-> pw_uid == 0 )) |
223 | return EXIT_FAILURE; | 223 | return EXIT_FAILURE; |
224 | 224 | ||
225 | #ifdef CONFIG_FEATURE_U_W_TMP | 225 | #ifdef CONFIG_FEATURE_UTMP |
226 | setutmp ( username, tty ); | 226 | setutmp ( username, tty ); |
227 | #endif | 227 | #endif |
228 | #ifdef CONFIG_SELINUX | 228 | #ifdef CONFIG_SELINUX |
@@ -387,7 +387,7 @@ static int is_my_tty ( const char *tty ) | |||
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | static void motd ( ) | 390 | static void motd (void) |
391 | { | 391 | { |
392 | FILE *fp; | 392 | FILE *fp; |
393 | register int c; | 393 | register int c; |
@@ -400,7 +400,7 @@ static void motd ( ) | |||
400 | } | 400 | } |
401 | 401 | ||
402 | 402 | ||
403 | #ifdef CONFIG_FEATURE_U_W_TMP | 403 | #ifdef CONFIG_FEATURE_UTMP |
404 | // vv Taken from tinylogin utmp.c vv | 404 | // vv Taken from tinylogin utmp.c vv |
405 | 405 | ||
406 | #define NO_UTENT \ | 406 | #define NO_UTENT \ |
@@ -478,9 +478,11 @@ static void setutmp(const char *name, const char *line) | |||
478 | setutent(); | 478 | setutent(); |
479 | pututline(&utent); | 479 | pututline(&utent); |
480 | endutent(); | 480 | endutent(); |
481 | #ifdef CONFIG_FEATURE_WTMP | ||
481 | if (access(_PATH_WTMP, R_OK|W_OK) == -1) { | 482 | if (access(_PATH_WTMP, R_OK|W_OK) == -1) { |
482 | close(creat(_PATH_WTMP, 0664)); | 483 | close(creat(_PATH_WTMP, 0664)); |
483 | } | 484 | } |
484 | updwtmp(_PATH_WTMP, &utent); | 485 | updwtmp(_PATH_WTMP, &utent); |
486 | #endif | ||
485 | } | 487 | } |
486 | #endif /* CONFIG_FEATURE_U_W_TMP */ | 488 | #endif /* CONFIG_FEATURE_UTMP */ |
diff --git a/busybox/loginutils/su.c b/busybox/loginutils/su.c index ec0c16c7d..1e93aacd4 100644 --- a/busybox/loginutils/su.c +++ b/busybox/loginutils/su.c | |||
@@ -91,7 +91,7 @@ int su_main ( int argc, char **argv ) | |||
91 | opt_args = argv + optind; | 91 | opt_args = argv + optind; |
92 | 92 | ||
93 | #if defined( SYSLOG_SUCCESS ) || defined( SYSLOG_FAILURE ) | 93 | #if defined( SYSLOG_SUCCESS ) || defined( SYSLOG_FAILURE ) |
94 | #ifdef CONFIG_FEATURE_U_W_TMP | 94 | #ifdef CONFIG_FEATURE_UTMP |
95 | /* The utmp entry (via getlogin) is probably the best way to identify | 95 | /* The utmp entry (via getlogin) is probably the best way to identify |
96 | the user, especially if someone su's from a su-shell. */ | 96 | the user, especially if someone su's from a su-shell. */ |
97 | old_user = getlogin ( ); | 97 | old_user = getlogin ( ); |
diff --git a/busybox/miscutils/Config.in b/busybox/miscutils/Config.in index 77e13e84e..767b9c462 100644 --- a/busybox/miscutils/Config.in +++ b/busybox/miscutils/Config.in | |||
@@ -37,6 +37,7 @@ config CONFIG_FEATURE_CROND_CALL_SENDMAIL | |||
37 | config CONFIG_CRONTAB | 37 | config CONFIG_CRONTAB |
38 | bool "crontab" | 38 | bool "crontab" |
39 | default n | 39 | default n |
40 | select CONFIG_FEATURE_SUID | ||
40 | help | 41 | help |
41 | Crontab manipulates the crontab for a particular user. Only | 42 | Crontab manipulates the crontab for a particular user. Only |
42 | the superuser may specify a different user and/or crontab directory. | 43 | the superuser may specify a different user and/or crontab directory. |
@@ -86,7 +87,7 @@ config CONFIG_DEVFSD_VERBOSE | |||
86 | config CONFIG_LAST | 87 | config CONFIG_LAST |
87 | bool "last" | 88 | bool "last" |
88 | default n | 89 | default n |
89 | select CONFIG_FEATURE_U_W_TMP | 90 | select CONFIG_FEATURE_WTMP |
90 | help | 91 | help |
91 | 'last' displays a list of the last users that logged into the system. | 92 | 'last' displays a list of the last users that logged into the system. |
92 | 93 | ||
diff --git a/busybox/miscutils/devfsd.c b/busybox/miscutils/devfsd.c index 5e183e61f..34945c7b2 100644 --- a/busybox/miscutils/devfsd.c +++ b/busybox/miscutils/devfsd.c | |||
@@ -566,40 +566,36 @@ static void read_config_file (char *path, int optional, unsigned long *event_mas | |||
566 | #ifdef CONFIG_DEBUG | 566 | #ifdef CONFIG_DEBUG |
567 | msg_logger( NO_DIE, LOG_INFO, "read_config_file(): %s\n", path); | 567 | msg_logger( NO_DIE, LOG_INFO, "read_config_file(): %s\n", path); |
568 | #endif | 568 | #endif |
569 | if (stat (path, &statbuf) != 0 || statbuf.st_size == 0 ) | 569 | if (stat (path, &statbuf) == 0 ) |
570 | goto read_config_file_err; | ||
571 | |||
572 | if ( S_ISDIR (statbuf.st_mode) ) | ||
573 | { | ||
574 | /* strip last / from dirname so we don't need to check for it later */ | ||
575 | while( path && path[1]!='\0' && path[strlen(path)-1] == '/') | ||
576 | path[strlen(path) -1] = '\0'; | ||
577 | |||
578 | dir_operation(READ_CONFIG, path, 0, event_mask); | ||
579 | return; | ||
580 | } | ||
581 | |||
582 | if ( ( fp = fopen (path, "r") ) != NULL ) | ||
583 | { | 570 | { |
584 | while (fgets (buf, STRING_LENGTH, fp) != NULL) | 571 | /* Don't read 0 length files: ignored */ |
572 | /*if( statbuf.st_size == 0 ) | ||
573 | return;*/ | ||
574 | if ( S_ISDIR (statbuf.st_mode) ) | ||
585 | { | 575 | { |
586 | /* GETS(3) Linux Programmer's Manual | 576 | /* strip last / from dirname so we don't need to check for it later */ |
587 | fgets() reads in at most one less than size characters from stream and | 577 | while( path && path[1]!='\0' && path[strlen(path)-1] == '/') |
588 | stores them into the buffer pointed to by s. Reading stops after an | 578 | path[strlen(path) -1] = '\0'; |
589 | EOF or a newline. If a newline is read, it is stored into the buffer. | 579 | |
590 | A '\0' is stored after the last character in the buffer. | 580 | dir_operation(READ_CONFIG, path, 0, event_mask); |
591 | */ | 581 | return; |
592 | /*buf[strlen (buf) - 1] = '\0';*/ | ||
593 | /* Skip whitespace */ | ||
594 | for (line = buf; isspace (*line); ++line) | ||
595 | /*VOID*/; | ||
596 | if (line[0] == '\0' || line[0] == '#' ) | ||
597 | continue; | ||
598 | process_config_line (line, event_mask); | ||
599 | } | 582 | } |
600 | fclose (fp); | 583 | if ( ( fp = fopen (path, "r") ) != NULL ) |
601 | errno=0; | 584 | { |
602 | } | 585 | while (fgets (buf, STRING_LENGTH, fp) != NULL) |
586 | { | ||
587 | /* Skip whitespace */ | ||
588 | for (line = buf; isspace (*line); ++line) | ||
589 | /*VOID*/; | ||
590 | if (line[0] == '\0' || line[0] == '#' ) | ||
591 | continue; | ||
592 | process_config_line (line, event_mask); | ||
593 | } | ||
594 | fclose (fp); | ||
595 | } else { | ||
596 | goto read_config_file_err; | ||
597 | } | ||
598 | } else { | ||
603 | read_config_file_err: | 599 | read_config_file_err: |
604 | #ifdef CONFIG_DEVFSD_VERBOSE | 600 | #ifdef CONFIG_DEVFSD_VERBOSE |
605 | msg_logger(((optional == 0 ) && (errno == ENOENT))? DIE : NO_DIE, LOG_ERR, "read config file: %s: %m\n", path); | 601 | msg_logger(((optional == 0 ) && (errno == ENOENT))? DIE : NO_DIE, LOG_ERR, "read config file: %s: %m\n", path); |
@@ -607,6 +603,7 @@ read_config_file_err: | |||
607 | if(optional == 0 && errno == ENOENT) | 603 | if(optional == 0 && errno == ENOENT) |
608 | exit(EXIT_FAILURE); | 604 | exit(EXIT_FAILURE); |
609 | #endif | 605 | #endif |
606 | } | ||
610 | return; | 607 | return; |
611 | } /* End Function read_config_file */ | 608 | } /* End Function read_config_file */ |
612 | 609 | ||
diff --git a/busybox/miscutils/strings.c b/busybox/miscutils/strings.c index 92e9f0d11..d0a092421 100644 --- a/busybox/miscutils/strings.c +++ b/busybox/miscutils/strings.c | |||
@@ -27,99 +27,82 @@ | |||
27 | 27 | ||
28 | #include <stdio.h> | 28 | #include <stdio.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <string.h> | ||
31 | #include <getopt.h> | 30 | #include <getopt.h> |
32 | #include <unistd.h> | ||
33 | #include <ctype.h> | 31 | #include <ctype.h> |
34 | #include "busybox.h" | 32 | #include "busybox.h" |
35 | 33 | ||
36 | #define ISSTR(ch) (isprint(ch) || ch == '\t') | 34 | #define ISSTR(ch) (isprint(ch) || ch == '\t') |
37 | 35 | ||
36 | #define WHOLE_FILE 1 | ||
37 | #define PRINT_NAME 2 | ||
38 | #define PRINT_OFFSET 4 | ||
39 | #define SIZE 8 | ||
40 | |||
38 | int strings_main(int argc, char **argv) | 41 | int strings_main(int argc, char **argv) |
39 | { | 42 | { |
40 | int n=4, c, i, opt=0, status=EXIT_SUCCESS; | 43 | int n, c, i = 0, status = EXIT_SUCCESS; |
41 | long t=0, count; | 44 | unsigned long opt; |
45 | unsigned long count; | ||
42 | FILE *file = stdin; | 46 | FILE *file = stdin; |
43 | char *string=NULL; | 47 | char *string; |
44 | const char *fmt="%s: "; | 48 | const char *fmt = "%s: "; |
45 | 49 | char *n_arg = "4"; | |
46 | while ((i = getopt(argc, argv, "afon:")) > 0) | 50 | |
47 | switch(i) | 51 | opt = bb_getopt_ulflags (argc, argv, "afon:", &n_arg); |
48 | { | 52 | /* -a is our default behaviour */ |
49 | case 'a': | 53 | |
50 | break; | ||
51 | case 'f': | ||
52 | opt+=1; | ||
53 | break; | ||
54 | case 'o': | ||
55 | opt+=2; | ||
56 | break; | ||
57 | case 'n': | ||
58 | n = bb_xgetlarg(optarg, 10, 1, INT_MAX); | ||
59 | break; | ||
60 | default: | ||
61 | bb_show_usage(); | ||
62 | } | ||
63 | |||
64 | argc -= optind; | 54 | argc -= optind; |
65 | argv += optind; | 55 | argv += optind; |
66 | 56 | ||
67 | i=0; | 57 | n = bb_xgetlarg(n_arg, 10, 1, INT_MAX); |
68 | 58 | string = xcalloc(n + 1, 1); | |
69 | string=xmalloc(n+1); | 59 | n--; |
70 | string[n]='\0'; | 60 | |
71 | n-=1; | 61 | if ( argc == 0) { |
72 | 62 | fmt = "{%s}: "; | |
73 | if(argc==0) | 63 | *argv = (char *)bb_msg_standard_input; |
74 | { | 64 | goto PIPE; |
75 | fmt="{%s}: "; | ||
76 | *argv=(char *)bb_msg_standard_input; | ||
77 | goto pipe; | ||
78 | } | 65 | } |
79 | 66 | ||
80 | for( ;*argv!=NULL && argc>0;argv++) | 67 | do { |
81 | { | 68 | if ((file = bb_wfopen(*argv, "r"))) { |
82 | if((file=bb_wfopen(*argv,"r"))) | 69 | PIPE: |
83 | { | 70 | count = 0; |
84 | pipe: | 71 | do { |
85 | 72 | c = fgetc(file); | |
86 | count=0; | 73 | if (ISSTR(c)) { |
87 | do{ | 74 | if (i <= n) { |
88 | c=fgetc(file); | ||
89 | if(ISSTR(c)) | ||
90 | { | ||
91 | if(i==0) | ||
92 | t=count; | ||
93 | if(i<=n) | ||
94 | string[i]=c; | 75 | string[i]=c; |
95 | if(i==n) | 76 | } else { |
96 | { | 77 | putchar(c); |
97 | if(opt == 1 || opt == 3 ) | 78 | } |
98 | printf(fmt,*argv); | 79 | if (i == n) { |
99 | if(opt >= 2 ) | 80 | if (opt & PRINT_NAME) { |
100 | printf("%7lo ", t); | 81 | printf(fmt, *argv); |
82 | } | ||
83 | if (opt & PRINT_OFFSET) { | ||
84 | printf("%7lo ", count - n ); | ||
85 | } | ||
101 | printf("%s", string); | 86 | printf("%s", string); |
102 | } | 87 | } |
103 | if(i>n) | ||
104 | putchar(c); | ||
105 | i++; | 88 | i++; |
106 | } | 89 | } else { |
107 | else | 90 | if (i > n) { |
108 | { | ||
109 | if(i>n) | ||
110 | putchar('\n'); | 91 | putchar('\n'); |
111 | i=0; | 92 | } |
93 | i = 0; | ||
112 | } | 94 | } |
113 | count++; | 95 | count++; |
114 | }while(c!=EOF); | 96 | } while (c != EOF); |
115 | |||
116 | bb_fclose_nonstdin(file); | 97 | bb_fclose_nonstdin(file); |
117 | } | 98 | } else { |
118 | else | ||
119 | status=EXIT_FAILURE; | 99 | status=EXIT_FAILURE; |
120 | } | 100 | } |
121 | /*free(string);*/ | 101 | } while ( --argc > 0 ); |
122 | exit(status); | 102 | #ifdef CONFIG_FEATURE_CLEAN_UP |
103 | free(string); | ||
104 | #endif | ||
105 | bb_fflush_stdout_and_exit(status); | ||
123 | } | 106 | } |
124 | 107 | ||
125 | /* | 108 | /* |
diff --git a/busybox/modutils/insmod.c b/busybox/modutils/insmod.c index d88dd1be6..60f5cf1c7 100644 --- a/busybox/modutils/insmod.c +++ b/busybox/modutils/insmod.c | |||
@@ -269,8 +269,8 @@ extern int insmod_ng_main( int argc, char **argv); | |||
269 | /* X86_64 */ | 269 | /* X86_64 */ |
270 | #if defined(__x86_64__) | 270 | #if defined(__x86_64__) |
271 | #define MATCH_MACHINE(x) (x == EM_X86_64) | 271 | #define MATCH_MACHINE(x) (x == EM_X86_64) |
272 | #define SHT_RELM SHT_REL | 272 | #define SHT_RELM SHT_RELA |
273 | #define Elf64_RelM Elf64_Rel | 273 | #define Elf64_RelM Elf64_Rela |
274 | #define ELFCLASSM ELFCLASS64 | 274 | #define ELFCLASSM ELFCLASS64 |
275 | #endif | 275 | #endif |
276 | 276 | ||
@@ -3432,8 +3432,8 @@ add_ksymoops_symbols(struct obj_file *f, const char *filename, | |||
3432 | ".text", | 3432 | ".text", |
3433 | ".rodata", | 3433 | ".rodata", |
3434 | ".data", | 3434 | ".data", |
3435 | ".bss" | 3435 | ".bss", |
3436 | ".sbss" | 3436 | ".sbss" |
3437 | }; | 3437 | }; |
3438 | 3438 | ||
3439 | if (realpath(filename, real)) { | 3439 | if (realpath(filename, real)) { |
diff --git a/busybox/networking/httpd.c b/busybox/networking/httpd.c index 83ded5330..94fcfc8c1 100644 --- a/busybox/networking/httpd.c +++ b/busybox/networking/httpd.c | |||
@@ -734,7 +734,7 @@ static char *encodeString(const char *string) | |||
734 | while ((ch = *string++)) { | 734 | while ((ch = *string++)) { |
735 | // very simple check for what to encode | 735 | // very simple check for what to encode |
736 | if (isalnum(ch)) *p++ = ch; | 736 | if (isalnum(ch)) *p++ = ch; |
737 | else p += sprintf(p, "&#%d", (unsigned char) ch); | 737 | else p += sprintf(p, "&#%d;", (unsigned char) ch); |
738 | } | 738 | } |
739 | *p=0; | 739 | *p=0; |
740 | return out; | 740 | return out; |
diff --git a/busybox/networking/ifconfig.c b/busybox/networking/ifconfig.c index 4e3df2982..fc7798f2d 100644 --- a/busybox/networking/ifconfig.c +++ b/busybox/networking/ifconfig.c | |||
@@ -46,8 +46,8 @@ | |||
46 | #include <netpacket/packet.h> | 46 | #include <netpacket/packet.h> |
47 | #include <net/ethernet.h> | 47 | #include <net/ethernet.h> |
48 | #else | 48 | #else |
49 | #include <asm/types.h> | 49 | #include <sys/types.h> |
50 | #include <linux/if_ether.h> | 50 | #include <netinet/if_ether.h> |
51 | #endif | 51 | #endif |
52 | #include "inet_common.h" | 52 | #include "inet_common.h" |
53 | #include "busybox.h" | 53 | #include "busybox.h" |
@@ -177,7 +177,7 @@ struct in6_ifreq { | |||
177 | 177 | ||
178 | struct arg1opt { | 178 | struct arg1opt { |
179 | const char *name; | 179 | const char *name; |
180 | unsigned short selector; | 180 | int selector; |
181 | unsigned short ifr_offset; | 181 | unsigned short ifr_offset; |
182 | }; | 182 | }; |
183 | 183 | ||
diff --git a/busybox/networking/ifupdown.c b/busybox/networking/ifupdown.c index 1842be58b..21afe42d4 100644 --- a/busybox/networking/ifupdown.c +++ b/busybox/networking/ifupdown.c | |||
@@ -150,7 +150,7 @@ struct interfaces_file_t | |||
150 | 150 | ||
151 | static char no_act = 0; | 151 | static char no_act = 0; |
152 | static char verbose = 0; | 152 | static char verbose = 0; |
153 | static char **environ = NULL; | 153 | static char **__myenviron = NULL; |
154 | 154 | ||
155 | #ifdef CONFIG_FEATURE_IFUPDOWN_IP | 155 | #ifdef CONFIG_FEATURE_IFUPDOWN_IP |
156 | 156 | ||
@@ -961,16 +961,16 @@ static void set_environ(struct interface_defn_t *iface, char *mode) | |||
961 | const int n_env_entries = iface->n_options + 5; | 961 | const int n_env_entries = iface->n_options + 5; |
962 | char **ppch; | 962 | char **ppch; |
963 | 963 | ||
964 | if (environ != NULL) { | 964 | if (__myenviron != NULL) { |
965 | for (ppch = environ; *ppch; ppch++) { | 965 | for (ppch = __myenviron; *ppch; ppch++) { |
966 | free(*ppch); | 966 | free(*ppch); |
967 | *ppch = NULL; | 967 | *ppch = NULL; |
968 | } | 968 | } |
969 | free(environ); | 969 | free(__myenviron); |
970 | environ = NULL; | 970 | __myenviron = NULL; |
971 | } | 971 | } |
972 | environ = xmalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ )); | 972 | __myenviron = xmalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ )); |
973 | environend = environ; | 973 | environend = __myenviron; |
974 | *environend = NULL; | 974 | *environend = NULL; |
975 | 975 | ||
976 | for (i = 0; i < iface->n_options; i++) { | 976 | for (i = 0; i < iface->n_options; i++) { |
@@ -1010,7 +1010,7 @@ static int doit(char *str) | |||
1010 | case -1: /* failure */ | 1010 | case -1: /* failure */ |
1011 | return 0; | 1011 | return 0; |
1012 | case 0: /* child */ | 1012 | case 0: /* child */ |
1013 | execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, environ); | 1013 | execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, __myenviron); |
1014 | exit(127); | 1014 | exit(127); |
1015 | } | 1015 | } |
1016 | waitpid(child, &status, 0); | 1016 | waitpid(child, &status, 0); |
diff --git a/busybox/networking/inetd.c b/busybox/networking/inetd.c index 169cc8716..a1fa29ce4 100644 --- a/busybox/networking/inetd.c +++ b/busybox/networking/inetd.c | |||
@@ -560,7 +560,7 @@ static void config(int signum) | |||
560 | if (sep != 0) { | 560 | if (sep != 0) { |
561 | int i; | 561 | int i; |
562 | 562 | ||
563 | #define SWAP(type, a, b) {type c=(type)a; (type)a=(type)b; (type)b=(type)c;} | 563 | #define SWAP(type, a, b) {type c=(type)(a); (a)=(type)(b); (b)=(type)c;} |
564 | 564 | ||
565 | sigprocmask(SIG_BLOCK, &emptymask, &oldmask); | 565 | sigprocmask(SIG_BLOCK, &emptymask, &oldmask); |
566 | /* | 566 | /* |
diff --git a/busybox/networking/libiproute/utils.c b/busybox/networking/libiproute/utils.c index fa1548609..d86d4f8f5 100644 --- a/busybox/networking/libiproute/utils.c +++ b/busybox/networking/libiproute/utils.c | |||
@@ -238,7 +238,7 @@ __u32 get_addr32(char *name) | |||
238 | return addr.data[0]; | 238 | return addr.data[0]; |
239 | } | 239 | } |
240 | 240 | ||
241 | void incomplete_command() | 241 | void incomplete_command(void) |
242 | { | 242 | { |
243 | bb_error_msg("Command line is not complete. Try option \"help\""); | 243 | bb_error_msg("Command line is not complete. Try option \"help\""); |
244 | exit(-1); | 244 | exit(-1); |
diff --git a/busybox/networking/nc.c b/busybox/networking/nc.c index 3099763b1..ab8ec0cd5 100644 --- a/busybox/networking/nc.c +++ b/busybox/networking/nc.c | |||
@@ -79,7 +79,7 @@ int nc_main(int argc, char **argv) | |||
79 | #ifdef GAPING_SECURITY_HOLE | 79 | #ifdef GAPING_SECURITY_HOLE |
80 | if (pr00gie) { | 80 | if (pr00gie) { |
81 | /* won't need stdin */ | 81 | /* won't need stdin */ |
82 | close (STDIN_FILENO); | 82 | close(STDIN_FILENO); |
83 | } | 83 | } |
84 | #endif /* GAPING_SECURITY_HOLE */ | 84 | #endif /* GAPING_SECURITY_HOLE */ |
85 | 85 | ||
@@ -90,8 +90,8 @@ int nc_main(int argc, char **argv) | |||
90 | if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) | 90 | if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) |
91 | bb_perror_msg_and_die("socket"); | 91 | bb_perror_msg_and_die("socket"); |
92 | x = 1; | 92 | x = 1; |
93 | if (setsockopt (sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) | 93 | if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) |
94 | bb_perror_msg_and_die ("reuseaddr failed"); | 94 | bb_perror_msg_and_die("reuseaddr"); |
95 | address.sin_family = AF_INET; | 95 | address.sin_family = AF_INET; |
96 | 96 | ||
97 | if (lport != 0) { | 97 | if (lport != 0) { |
@@ -154,7 +154,7 @@ int nc_main(int argc, char **argv) | |||
154 | for (fd = 0; fd < FD_SETSIZE; fd++) { | 154 | for (fd = 0; fd < FD_SETSIZE; fd++) { |
155 | if (FD_ISSET(fd, &testfds)) { | 155 | if (FD_ISSET(fd, &testfds)) { |
156 | if ((nread = safe_read(fd, buf, sizeof(buf))) < 0) | 156 | if ((nread = safe_read(fd, buf, sizeof(buf))) < 0) |
157 | bb_perror_msg_and_die("read"); | 157 | bb_perror_msg_and_die(bb_msg_read_error); |
158 | 158 | ||
159 | if (fd == sfd) { | 159 | if (fd == sfd) { |
160 | if (nread == 0) | 160 | if (nread == 0) |
@@ -167,7 +167,7 @@ int nc_main(int argc, char **argv) | |||
167 | } | 167 | } |
168 | 168 | ||
169 | if (bb_full_write(ofd, buf, nread) < 0) | 169 | if (bb_full_write(ofd, buf, nread) < 0) |
170 | bb_perror_msg_and_die("write"); | 170 | bb_perror_msg_and_die(bb_msg_write_error); |
171 | if (delay > 0) { | 171 | if (delay > 0) { |
172 | sleep(delay); | 172 | sleep(delay); |
173 | } | 173 | } |
diff --git a/busybox/networking/telnetd.c b/busybox/networking/telnetd.c index 491c66fd1..b3d0a1166 100644 --- a/busybox/networking/telnetd.c +++ b/busybox/networking/telnetd.c | |||
@@ -49,6 +49,15 @@ | |||
49 | 49 | ||
50 | #define BUFSIZE 4000 | 50 | #define BUFSIZE 4000 |
51 | 51 | ||
52 | #ifdef CONFIG_FEATURE_IPV6 | ||
53 | #define SOCKET_TYPE AF_INET6 | ||
54 | typedef struct sockaddr_in6 sockaddr_type; | ||
55 | #else | ||
56 | #define SOCKET_TYPE AF_INET | ||
57 | typedef struct sockaddr_in sockaddr_type; | ||
58 | #endif | ||
59 | |||
60 | |||
52 | #ifdef CONFIG_LOGIN | 61 | #ifdef CONFIG_LOGIN |
53 | static const char *loginpath = "/bin/login"; | 62 | static const char *loginpath = "/bin/login"; |
54 | #else | 63 | #else |
@@ -373,7 +382,7 @@ int | |||
373 | telnetd_main(int argc, char **argv) | 382 | telnetd_main(int argc, char **argv) |
374 | { | 383 | { |
375 | #ifndef CONFIG_FEATURE_TELNETD_INETD | 384 | #ifndef CONFIG_FEATURE_TELNETD_INETD |
376 | struct sockaddr_in sa; | 385 | sockaddr_type sa; |
377 | int master_fd; | 386 | int master_fd; |
378 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ | 387 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ |
379 | fd_set rdfdset, wrfdset; | 388 | fd_set rdfdset, wrfdset; |
@@ -431,7 +440,7 @@ telnetd_main(int argc, char **argv) | |||
431 | 440 | ||
432 | /* Grab a TCP socket. */ | 441 | /* Grab a TCP socket. */ |
433 | 442 | ||
434 | master_fd = socket(AF_INET, SOCK_STREAM, 0); | 443 | master_fd = socket(SOCKET_TYPE, SOCK_STREAM, 0); |
435 | if (master_fd < 0) { | 444 | if (master_fd < 0) { |
436 | bb_perror_msg_and_die("socket"); | 445 | bb_perror_msg_and_die("socket"); |
437 | } | 446 | } |
@@ -440,8 +449,13 @@ telnetd_main(int argc, char **argv) | |||
440 | /* Set it to listen to specified port. */ | 449 | /* Set it to listen to specified port. */ |
441 | 450 | ||
442 | memset((void *)&sa, 0, sizeof(sa)); | 451 | memset((void *)&sa, 0, sizeof(sa)); |
452 | #ifdef CONFIG_FEATURE_IPV6 | ||
453 | sa.sin6_family = AF_INET6; | ||
454 | sa.sin6_port = htons(portnbr); | ||
455 | #else | ||
443 | sa.sin_family = AF_INET; | 456 | sa.sin_family = AF_INET; |
444 | sa.sin_port = htons(portnbr); | 457 | sa.sin_port = htons(portnbr); |
458 | #endif | ||
445 | 459 | ||
446 | if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { | 460 | if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { |
447 | bb_perror_msg_and_die("bind"); | 461 | bb_perror_msg_and_die("bind"); |
diff --git a/busybox/networking/tftp.c b/busybox/networking/tftp.c index 3c947318b..47fc3879e 100644 --- a/busybox/networking/tftp.c +++ b/busybox/networking/tftp.c | |||
@@ -458,6 +458,12 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
458 | opcode = TFTP_ACK; | 458 | opcode = TFTP_ACK; |
459 | continue; | 459 | continue; |
460 | } | 460 | } |
461 | /* in case the last ack disappeared into the ether */ | ||
462 | if ( tmp == (block_nr - 1) ) { | ||
463 | --block_nr; | ||
464 | opcode = TFTP_ACK; | ||
465 | continue; | ||
466 | } | ||
461 | } | 467 | } |
462 | 468 | ||
463 | if (cmd_put && (opcode == TFTP_ACK)) { | 469 | if (cmd_put && (opcode == TFTP_ACK)) { |
diff --git a/busybox/networking/udhcp/dhcpc.c b/busybox/networking/udhcp/dhcpc.c index 449b51763..91af9153b 100644 --- a/busybox/networking/udhcp/dhcpc.c +++ b/busybox/networking/udhcp/dhcpc.c | |||
@@ -419,6 +419,9 @@ int main(int argc, char *argv[]) | |||
419 | (unsigned long) packet.xid, xid); | 419 | (unsigned long) packet.xid, xid); |
420 | continue; | 420 | continue; |
421 | } | 421 | } |
422 | /* Ignore packets that aren't for us */ | ||
423 | if (memcmp(client_config.arp,packet.chaddr,6)) | ||
424 | continue; | ||
422 | 425 | ||
423 | if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) { | 426 | if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) { |
424 | DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring"); | 427 | DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring"); |
diff --git a/busybox/scripts/.cvsignore b/busybox/scripts/.cvsignore deleted file mode 100644 index 07fa550f5..000000000 --- a/busybox/scripts/.cvsignore +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | mkdep | ||
2 | split-include | ||
diff --git a/busybox/scripts/config/.cvsignore b/busybox/scripts/config/.cvsignore deleted file mode 100644 index e8bf7a75b..000000000 --- a/busybox/scripts/config/.cvsignore +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | conf | ||
2 | mconf | ||
3 | lkc_defs.h | ||
4 | lex.zconf.c | ||
5 | zconf.tab.h | ||
6 | zconf.tab.c | ||
7 | lex.backup | ||
8 | zconf.output | ||
diff --git a/busybox/scripts/config/Makefile b/busybox/scripts/config/Makefile index c0b5b9d35..3c4669f8c 100644 --- a/busybox/scripts/config/Makefile +++ b/busybox/scripts/config/Makefile | |||
@@ -9,7 +9,11 @@ include $(top_builddir)/Rules.mak | |||
9 | 9 | ||
10 | all: ncurses conf mconf | 10 | all: ncurses conf mconf |
11 | 11 | ||
12 | ifeq ($(shell uname),SunOS) | ||
13 | LIBS = -lcurses | ||
14 | else | ||
12 | LIBS = -lncurses | 15 | LIBS = -lncurses |
16 | endif | ||
13 | ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) | 17 | ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) |
14 | HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" | 18 | HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" |
15 | else | 19 | else |
@@ -32,14 +36,17 @@ endif | |||
32 | endif | 36 | endif |
33 | endif | 37 | endif |
34 | 38 | ||
35 | CONF_SRC =conf.c | 39 | CONF_SRC = conf.c |
36 | MCONF_SRC =mconf.c checklist.c menubox.c textbox.c yesno.c inputbox.c util.c msgbox.c | 40 | MCONF_SRC = mconf.c |
37 | SHARED_SRC=zconf.tab.c | 41 | LXD_SRC = lxdialog/checklist.c lxdialog/menubox.c lxdialog/textbox.c \ |
38 | SHARED_DEPS:=$(srcdir)/lkc.h $(srcdir)/lkc_proto.h \ | 42 | lxdialog/yesno.c lxdialog/inputbox.c lxdialog/util.c \ |
39 | lkc_defs.h $(srcdir)/expr.h zconf.tab.h | 43 | lxdialog/msgbox.c |
40 | CONF_OBJS =$(patsubst %.c,%.o, $(CONF_SRC)) | 44 | SHARED_SRC = zconf.tab.c |
41 | MCONF_OBJS=$(patsubst %.c,%.o, $(MCONF_SRC)) | 45 | SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \ |
42 | SHARED_OBJS=$(patsubst %.c,%.o, $(SHARED_SRC)) | 46 | lkc_defs.h $(srcdir)/expr.h zconf.tab.h |
47 | CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC)) | ||
48 | MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC)) | ||
49 | SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC)) | ||
43 | 50 | ||
44 | conf: $(CONF_OBJS) $(SHARED_OBJS) | 51 | conf: $(CONF_OBJS) $(SHARED_OBJS) |
45 | $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ | 52 | $(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ |
diff --git a/busybox/scripts/config/conf.c b/busybox/scripts/config/conf.c index 3b0c1c1b5..78c1af596 100644 --- a/busybox/scripts/config/conf.c +++ b/busybox/scripts/config/conf.c | |||
@@ -31,14 +31,14 @@ char *defconfig_file; | |||
31 | static int indent = 1; | 31 | static int indent = 1; |
32 | static int valid_stdin = 1; | 32 | static int valid_stdin = 1; |
33 | static int conf_cnt; | 33 | static int conf_cnt; |
34 | static char line[128]; | 34 | static signed char line[128]; |
35 | static struct menu *rootEntry; | 35 | static struct menu *rootEntry; |
36 | 36 | ||
37 | static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; | 37 | static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; |
38 | 38 | ||
39 | static void strip(char *str) | 39 | static void strip(signed char *str) |
40 | { | 40 | { |
41 | char *p = str; | 41 | signed char *p = str; |
42 | int l; | 42 | int l; |
43 | 43 | ||
44 | while ((isspace(*p))) | 44 | while ((isspace(*p))) |
diff --git a/busybox/scripts/config/confdata.c b/busybox/scripts/config/confdata.c index fd3a345e2..7b9000e84 100644 --- a/busybox/scripts/config/confdata.c +++ b/busybox/scripts/config/confdata.c | |||
@@ -23,10 +23,10 @@ const char *conf_confnames[] = { | |||
23 | NULL, | 23 | NULL, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | static char *conf_expand_value(const char *in) | 26 | static char *conf_expand_value(const signed char *in) |
27 | { | 27 | { |
28 | struct symbol *sym; | 28 | struct symbol *sym; |
29 | const char *src; | 29 | const signed char *src; |
30 | static char res_value[SYMBOL_MAXLENGTH]; | 30 | static char res_value[SYMBOL_MAXLENGTH]; |
31 | char *dst, name[SYMBOL_MAXLENGTH]; | 31 | char *dst, name[SYMBOL_MAXLENGTH]; |
32 | 32 | ||
@@ -287,7 +287,7 @@ int conf_write(const char *name) | |||
287 | } else | 287 | } else |
288 | basename = conf_def_filename; | 288 | basename = conf_def_filename; |
289 | 289 | ||
290 | sprintf(newname, "%s.tmpconfig.%d", dirname, getpid()); | 290 | sprintf(newname, "%s.tmpconfig.%d", dirname, (int)getpid()); |
291 | out = fopen(newname, "w"); | 291 | out = fopen(newname, "w"); |
292 | if (!out) | 292 | if (!out) |
293 | return 1; | 293 | return 1; |
diff --git a/busybox/scripts/config/expr.c b/busybox/scripts/config/expr.c index 10f45232b..30e4f9d69 100644 --- a/busybox/scripts/config/expr.c +++ b/busybox/scripts/config/expr.c | |||
@@ -1087,3 +1087,13 @@ void expr_fprint(struct expr *e, FILE *out) | |||
1087 | { | 1087 | { |
1088 | expr_print(e, expr_print_file_helper, out, E_NONE); | 1088 | expr_print(e, expr_print_file_helper, out, E_NONE); |
1089 | } | 1089 | } |
1090 | |||
1091 | static void expr_print_gstr_helper(void *data, const char *str) | ||
1092 | { | ||
1093 | str_append((struct gstr*)data, str); | ||
1094 | } | ||
1095 | |||
1096 | void expr_gstr_print(struct expr *e, struct gstr *gs) | ||
1097 | { | ||
1098 | expr_print(e, expr_print_gstr_helper, gs, E_NONE); | ||
1099 | } | ||
diff --git a/busybox/scripts/config/expr.h b/busybox/scripts/config/expr.h index cac51f6a8..7d39ff43e 100644 --- a/busybox/scripts/config/expr.h +++ b/busybox/scripts/config/expr.h | |||
@@ -174,6 +174,8 @@ void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, s | |||
174 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); | 174 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); |
175 | 175 | ||
176 | void expr_fprint(struct expr *e, FILE *out); | 176 | void expr_fprint(struct expr *e, FILE *out); |
177 | struct gstr; /* forward */ | ||
178 | void expr_gstr_print(struct expr *e, struct gstr *gs); | ||
177 | 179 | ||
178 | static inline int expr_is_yes(struct expr *e) | 180 | static inline int expr_is_yes(struct expr *e) |
179 | { | 181 | { |
diff --git a/busybox/scripts/config/lkc.h b/busybox/scripts/config/lkc.h index dd040f7a8..b8a67fc9d 100644 --- a/busybox/scripts/config/lkc.h +++ b/busybox/scripts/config/lkc.h | |||
@@ -56,11 +56,21 @@ void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); | |||
56 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); | 56 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); |
57 | void menu_finalize(struct menu *parent); | 57 | void menu_finalize(struct menu *parent); |
58 | void menu_set_type(int type); | 58 | void menu_set_type(int type); |
59 | |||
60 | /* util.c */ | ||
59 | struct file *file_lookup(const char *name); | 61 | struct file *file_lookup(const char *name); |
60 | int file_write_dep(const char *name); | 62 | int file_write_dep(const char *name); |
61 | 63 | ||
62 | extern struct menu *current_entry; | 64 | struct gstr { |
63 | extern struct menu *current_menu; | 65 | size_t len; |
66 | char *s; | ||
67 | }; | ||
68 | struct gstr str_new(void); | ||
69 | struct gstr str_assign(const char *s); | ||
70 | void str_free(struct gstr *gs); | ||
71 | void str_append(struct gstr *gs, const char *s); | ||
72 | void str_printf(struct gstr *gs, const char *fmt, ...); | ||
73 | const char *str_get(struct gstr *gs); | ||
64 | 74 | ||
65 | /* symbol.c */ | 75 | /* symbol.c */ |
66 | void sym_init(void); | 76 | void sym_init(void); |
diff --git a/busybox/scripts/config/lkc_proto.h b/busybox/scripts/config/lkc_proto.h index 97c79178e..6dc6d0c48 100644 --- a/busybox/scripts/config/lkc_proto.h +++ b/busybox/scripts/config/lkc_proto.h | |||
@@ -18,6 +18,7 @@ P(sym_change_count,int,); | |||
18 | 18 | ||
19 | P(sym_lookup,struct symbol *,(const char *name, int isconst)); | 19 | P(sym_lookup,struct symbol *,(const char *name, int isconst)); |
20 | P(sym_find,struct symbol *,(const char *name)); | 20 | P(sym_find,struct symbol *,(const char *name)); |
21 | P(sym_re_search,struct symbol **,(const char *pattern)); | ||
21 | P(sym_type_name,const char *,(enum symbol_type type)); | 22 | P(sym_type_name,const char *,(enum symbol_type type)); |
22 | P(sym_calc_value,void,(struct symbol *sym)); | 23 | P(sym_calc_value,void,(struct symbol *sym)); |
23 | P(sym_get_type,enum symbol_type,(struct symbol *sym)); | 24 | P(sym_get_type,enum symbol_type,(struct symbol *sym)); |
diff --git a/busybox/scripts/config/lxdialog/BIG.FAT.WARNING b/busybox/scripts/config/lxdialog/BIG.FAT.WARNING new file mode 100644 index 000000000..a8999d82b --- /dev/null +++ b/busybox/scripts/config/lxdialog/BIG.FAT.WARNING | |||
@@ -0,0 +1,4 @@ | |||
1 | This is NOT the official version of dialog. This version has been | ||
2 | significantly modified from the original. It is for use by the Linux | ||
3 | kernel configuration script. Please do not bother Savio Lam with | ||
4 | questions about this program. | ||
diff --git a/busybox/scripts/config/checklist.c b/busybox/scripts/config/lxdialog/checklist.c index 4dbd16616..71de4a191 100644 --- a/busybox/scripts/config/checklist.c +++ b/busybox/scripts/config/lxdialog/checklist.c | |||
@@ -120,7 +120,7 @@ int | |||
120 | dialog_checklist (const char *title, const char *prompt, int height, int width, | 120 | dialog_checklist (const char *title, const char *prompt, int height, int width, |
121 | int list_height, int item_no, struct dialog_list_item ** items, | 121 | int list_height, int item_no, struct dialog_list_item ** items, |
122 | int flag) | 122 | int flag) |
123 | 123 | ||
124 | { | 124 | { |
125 | int i, x, y, box_x, box_y; | 125 | int i, x, y, box_x, box_y; |
126 | int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; | 126 | int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; |
@@ -197,7 +197,7 @@ dialog_checklist (const char *title, const char *prompt, int height, int width, | |||
197 | 197 | ||
198 | /* Find length of longest item in order to center checklist */ | 198 | /* Find length of longest item in order to center checklist */ |
199 | check_x = 0; | 199 | check_x = 0; |
200 | for (i = 0; i < item_no; i++) | 200 | for (i = 0; i < item_no; i++) |
201 | check_x = MAX (check_x, + strlen (items[i]->name) + 4); | 201 | check_x = MAX (check_x, + strlen (items[i]->name) + 4); |
202 | 202 | ||
203 | check_x = (list_width - check_x) / 2; | 203 | check_x = (list_width - check_x) / 2; |
@@ -231,7 +231,7 @@ dialog_checklist (const char *title, const char *prompt, int height, int width, | |||
231 | break; | 231 | break; |
232 | 232 | ||
233 | 233 | ||
234 | if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || | 234 | if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || |
235 | key == '+' || key == '-' ) { | 235 | key == '+' || key == '-' ) { |
236 | if (key == KEY_UP || key == '-') { | 236 | if (key == KEY_UP || key == '-') { |
237 | if (!choice) { | 237 | if (!choice) { |
@@ -342,7 +342,7 @@ dialog_checklist (const char *title, const char *prompt, int height, int width, | |||
342 | } | 342 | } |
343 | wnoutrefresh (list); | 343 | wnoutrefresh (list); |
344 | wrefresh (dialog); | 344 | wrefresh (dialog); |
345 | 345 | ||
346 | for (i = 0; i < item_no; i++) { | 346 | for (i = 0; i < item_no; i++) { |
347 | items[i]->selected = status[i]; | 347 | items[i]->selected = status[i]; |
348 | } | 348 | } |
@@ -364,7 +364,7 @@ dialog_checklist (const char *title, const char *prompt, int height, int width, | |||
364 | /* Now, update everything... */ | 364 | /* Now, update everything... */ |
365 | doupdate (); | 365 | doupdate (); |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | delwin (dialog); | 369 | delwin (dialog); |
370 | free (status); | 370 | free (status); |
diff --git a/busybox/scripts/config/colors.h b/busybox/scripts/config/lxdialog/colors.h index d34dd37c6..d34dd37c6 100644 --- a/busybox/scripts/config/colors.h +++ b/busybox/scripts/config/lxdialog/colors.h | |||
diff --git a/busybox/scripts/config/dialog.h b/busybox/scripts/config/lxdialog/dialog.h index 6486cc8f7..7bab3ad0e 100644 --- a/busybox/scripts/config/dialog.h +++ b/busybox/scripts/config/lxdialog/dialog.h | |||
@@ -27,6 +27,9 @@ | |||
27 | #include <string.h> | 27 | #include <string.h> |
28 | 28 | ||
29 | #ifdef CURSES_LOC | 29 | #ifdef CURSES_LOC |
30 | #ifdef __sun__ | ||
31 | #define CURS_MACROS | ||
32 | #endif | ||
30 | #include CURSES_LOC | 33 | #include CURSES_LOC |
31 | 34 | ||
32 | /* | 35 | /* |
@@ -86,7 +89,7 @@ | |||
86 | #define ACS_DARROW 'v' | 89 | #define ACS_DARROW 'v' |
87 | #endif | 90 | #endif |
88 | 91 | ||
89 | /* | 92 | /* |
90 | * Attribute names | 93 | * Attribute names |
91 | */ | 94 | */ |
92 | #define screen_attr attributes[0] | 95 | #define screen_attr attributes[0] |
@@ -130,7 +133,7 @@ extern bool use_colors; | |||
130 | extern chtype attributes[]; | 133 | extern chtype attributes[]; |
131 | #endif | 134 | #endif |
132 | 135 | ||
133 | extern char *backtitle; | 136 | extern const char *backtitle; |
134 | 137 | ||
135 | struct dialog_list_item { | 138 | struct dialog_list_item { |
136 | char *name; | 139 | char *name; |
@@ -162,7 +165,7 @@ int dialog_msgbox (const char *title, const char *prompt, int height, | |||
162 | int width, int pause); | 165 | int width, int pause); |
163 | int dialog_textbox (const char *title, const char *file, int height, int width); | 166 | int dialog_textbox (const char *title, const char *file, int height, int width); |
164 | int dialog_menu (const char *title, const char *prompt, int height, int width, | 167 | int dialog_menu (const char *title, const char *prompt, int height, int width, |
165 | int menu_height, const char *choice, int item_no, | 168 | int menu_height, const char *choice, int item_no, |
166 | struct dialog_list_item ** items); | 169 | struct dialog_list_item ** items); |
167 | int dialog_checklist (const char *title, const char *prompt, int height, | 170 | int dialog_checklist (const char *title, const char *prompt, int height, |
168 | int width, int list_height, int item_no, | 171 | int width, int list_height, int item_no, |
diff --git a/busybox/scripts/config/inputbox.c b/busybox/scripts/config/lxdialog/inputbox.c index fa7bebc69..fa7bebc69 100644 --- a/busybox/scripts/config/inputbox.c +++ b/busybox/scripts/config/lxdialog/inputbox.c | |||
diff --git a/busybox/scripts/config/menubox.c b/busybox/scripts/config/lxdialog/menubox.c index 431f09fc9..873dc587b 100644 --- a/busybox/scripts/config/menubox.c +++ b/busybox/scripts/config/lxdialog/menubox.c | |||
@@ -26,7 +26,7 @@ | |||
26 | * | 26 | * |
27 | * *) A bugfix for the Page-Down problem | 27 | * *) A bugfix for the Page-Down problem |
28 | * | 28 | * |
29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set | 29 | * *) Formerly when I used Page Down and Page Up, the cursor would be set |
30 | * to the first position in the menu box. Now lxdialog is a bit | 30 | * to the first position in the menu box. Now lxdialog is a bit |
31 | * smarter and works more like other menu systems (just have a look at | 31 | * smarter and works more like other menu systems (just have a look at |
32 | * it). | 32 | * it). |
@@ -71,7 +71,7 @@ print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey | |||
71 | 71 | ||
72 | strncpy(menu_item, item, menu_width); | 72 | strncpy(menu_item, item, menu_width); |
73 | menu_item[menu_width] = 0; | 73 | menu_item[menu_width] = 0; |
74 | j = first_alpha(menu_item, "YyNnMm"); | 74 | j = first_alpha(menu_item, "YyNnMmHh"); |
75 | 75 | ||
76 | /* Clear 'residue' of last item */ | 76 | /* Clear 'residue' of last item */ |
77 | wattrset (win, menubox_attr); | 77 | wattrset (win, menubox_attr); |
@@ -225,7 +225,7 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
225 | 225 | ||
226 | /* | 226 | /* |
227 | * Find length of longest item in order to center menu. | 227 | * Find length of longest item in order to center menu. |
228 | * Set 'choice' to default item. | 228 | * Set 'choice' to default item. |
229 | */ | 229 | */ |
230 | item_x = 0; | 230 | item_x = 0; |
231 | for (i = 0; i < item_no; i++) { | 231 | for (i = 0; i < item_no; i++) { |
@@ -278,23 +278,23 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
278 | 278 | ||
279 | if (key < 256 && isalpha(key)) key = tolower(key); | 279 | if (key < 256 && isalpha(key)) key = tolower(key); |
280 | 280 | ||
281 | if (strchr("ynm", key)) | 281 | if (strchr("ynmh", key)) |
282 | i = max_choice; | 282 | i = max_choice; |
283 | else { | 283 | else { |
284 | for (i = choice+1; i < max_choice; i++) { | 284 | for (i = choice+1; i < max_choice; i++) { |
285 | j = first_alpha(items[scroll + i]->name, "YyNnMm>"); | 285 | j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); |
286 | if (key == tolower(items[scroll + i]->name[j])) | 286 | if (key == tolower(items[scroll + i]->name[j])) |
287 | break; | 287 | break; |
288 | } | 288 | } |
289 | if (i == max_choice) | 289 | if (i == max_choice) |
290 | for (i = 0; i < max_choice; i++) { | 290 | for (i = 0; i < max_choice; i++) { |
291 | j = first_alpha(items[scroll + i]->name, "YyNnMm>"); | 291 | j = first_alpha(items[scroll + i]->name, "YyNnMmHh"); |
292 | if (key == tolower(items[scroll + i]->name[j])) | 292 | if (key == tolower(items[scroll + i]->name[j])) |
293 | break; | 293 | break; |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | if (i < max_choice || | 297 | if (i < max_choice || |
298 | key == KEY_UP || key == KEY_DOWN || | 298 | key == KEY_UP || key == KEY_DOWN || |
299 | key == '-' || key == '+' || | 299 | key == '-' || key == '+' || |
300 | key == KEY_PPAGE || key == KEY_NPAGE) { | 300 | key == KEY_PPAGE || key == KEY_NPAGE) { |
@@ -398,6 +398,7 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
398 | case 'y': | 398 | case 'y': |
399 | case 'n': | 399 | case 'n': |
400 | case 'm': | 400 | case 'm': |
401 | case '/': | ||
401 | /* save scroll info */ | 402 | /* save scroll info */ |
402 | if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { | 403 | if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { |
403 | fprintf(f,"%d\n",scroll); | 404 | fprintf(f,"%d\n",scroll); |
@@ -411,6 +412,7 @@ dialog_menu (const char *title, const char *prompt, int height, int width, | |||
411 | case 'n': return 4; | 412 | case 'n': return 4; |
412 | case 'm': return 5; | 413 | case 'm': return 5; |
413 | case ' ': return 6; | 414 | case ' ': return 6; |
415 | case '/': return 7; | ||
414 | } | 416 | } |
415 | return 0; | 417 | return 0; |
416 | case 'h': | 418 | case 'h': |
diff --git a/busybox/scripts/config/msgbox.c b/busybox/scripts/config/lxdialog/msgbox.c index 93692e1fb..93692e1fb 100644 --- a/busybox/scripts/config/msgbox.c +++ b/busybox/scripts/config/lxdialog/msgbox.c | |||
diff --git a/busybox/scripts/config/textbox.c b/busybox/scripts/config/lxdialog/textbox.c index a5a460b5c..a5a460b5c 100644 --- a/busybox/scripts/config/textbox.c +++ b/busybox/scripts/config/lxdialog/textbox.c | |||
diff --git a/busybox/scripts/config/lxdialog/util.c b/busybox/scripts/config/lxdialog/util.c new file mode 100644 index 000000000..6f83951b9 --- /dev/null +++ b/busybox/scripts/config/lxdialog/util.c | |||
@@ -0,0 +1,375 @@ | |||
1 | /* | ||
2 | * util.c | ||
3 | * | ||
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | ||
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include "dialog.h" | ||
23 | |||
24 | |||
25 | /* use colors by default? */ | ||
26 | bool use_colors = 1; | ||
27 | |||
28 | const char *backtitle = NULL; | ||
29 | |||
30 | const char *dialog_result; | ||
31 | |||
32 | /* | ||
33 | * Attribute values, default is for mono display | ||
34 | */ | ||
35 | chtype attributes[] = | ||
36 | { | ||
37 | A_NORMAL, /* screen_attr */ | ||
38 | A_NORMAL, /* shadow_attr */ | ||
39 | A_NORMAL, /* dialog_attr */ | ||
40 | A_BOLD, /* title_attr */ | ||
41 | A_NORMAL, /* border_attr */ | ||
42 | A_REVERSE, /* button_active_attr */ | ||
43 | A_DIM, /* button_inactive_attr */ | ||
44 | A_REVERSE, /* button_key_active_attr */ | ||
45 | A_BOLD, /* button_key_inactive_attr */ | ||
46 | A_REVERSE, /* button_label_active_attr */ | ||
47 | A_NORMAL, /* button_label_inactive_attr */ | ||
48 | A_NORMAL, /* inputbox_attr */ | ||
49 | A_NORMAL, /* inputbox_border_attr */ | ||
50 | A_NORMAL, /* searchbox_attr */ | ||
51 | A_BOLD, /* searchbox_title_attr */ | ||
52 | A_NORMAL, /* searchbox_border_attr */ | ||
53 | A_BOLD, /* position_indicator_attr */ | ||
54 | A_NORMAL, /* menubox_attr */ | ||
55 | A_NORMAL, /* menubox_border_attr */ | ||
56 | A_NORMAL, /* item_attr */ | ||
57 | A_REVERSE, /* item_selected_attr */ | ||
58 | A_BOLD, /* tag_attr */ | ||
59 | A_REVERSE, /* tag_selected_attr */ | ||
60 | A_BOLD, /* tag_key_attr */ | ||
61 | A_REVERSE, /* tag_key_selected_attr */ | ||
62 | A_BOLD, /* check_attr */ | ||
63 | A_REVERSE, /* check_selected_attr */ | ||
64 | A_BOLD, /* uarrow_attr */ | ||
65 | A_BOLD /* darrow_attr */ | ||
66 | }; | ||
67 | |||
68 | |||
69 | #include "colors.h" | ||
70 | |||
71 | /* | ||
72 | * Table of color values | ||
73 | */ | ||
74 | int color_table[][3] = | ||
75 | { | ||
76 | {SCREEN_FG, SCREEN_BG, SCREEN_HL}, | ||
77 | {SHADOW_FG, SHADOW_BG, SHADOW_HL}, | ||
78 | {DIALOG_FG, DIALOG_BG, DIALOG_HL}, | ||
79 | {TITLE_FG, TITLE_BG, TITLE_HL}, | ||
80 | {BORDER_FG, BORDER_BG, BORDER_HL}, | ||
81 | {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, | ||
82 | {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, | ||
83 | {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, | ||
84 | {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL}, | ||
85 | {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL}, | ||
86 | {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, | ||
87 | BUTTON_LABEL_INACTIVE_HL}, | ||
88 | {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, | ||
89 | {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, | ||
90 | {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, | ||
91 | {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, | ||
92 | {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, | ||
93 | {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, | ||
94 | {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, | ||
95 | {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, | ||
96 | {ITEM_FG, ITEM_BG, ITEM_HL}, | ||
97 | {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, | ||
98 | {TAG_FG, TAG_BG, TAG_HL}, | ||
99 | {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, | ||
100 | {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, | ||
101 | {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, | ||
102 | {CHECK_FG, CHECK_BG, CHECK_HL}, | ||
103 | {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, | ||
104 | {UARROW_FG, UARROW_BG, UARROW_HL}, | ||
105 | {DARROW_FG, DARROW_BG, DARROW_HL}, | ||
106 | }; /* color_table */ | ||
107 | |||
108 | /* | ||
109 | * Set window to attribute 'attr' | ||
110 | */ | ||
111 | void | ||
112 | attr_clear (WINDOW * win, int height, int width, chtype attr) | ||
113 | { | ||
114 | int i, j; | ||
115 | |||
116 | wattrset (win, attr); | ||
117 | for (i = 0; i < height; i++) { | ||
118 | wmove (win, i, 0); | ||
119 | for (j = 0; j < width; j++) | ||
120 | waddch (win, ' '); | ||
121 | } | ||
122 | touchwin (win); | ||
123 | } | ||
124 | |||
125 | void dialog_clear (void) | ||
126 | { | ||
127 | attr_clear (stdscr, LINES, COLS, screen_attr); | ||
128 | /* Display background title if it exists ... - SLH */ | ||
129 | if (backtitle != NULL) { | ||
130 | int i; | ||
131 | |||
132 | wattrset (stdscr, screen_attr); | ||
133 | mvwaddstr (stdscr, 0, 1, (char *)backtitle); | ||
134 | wmove (stdscr, 1, 1); | ||
135 | for (i = 1; i < COLS - 1; i++) | ||
136 | waddch (stdscr, ACS_HLINE); | ||
137 | } | ||
138 | wnoutrefresh (stdscr); | ||
139 | } | ||
140 | |||
141 | /* | ||
142 | * Do some initialization for dialog | ||
143 | */ | ||
144 | void | ||
145 | init_dialog (void) | ||
146 | { | ||
147 | initscr (); /* Init curses */ | ||
148 | keypad (stdscr, TRUE); | ||
149 | cbreak (); | ||
150 | noecho (); | ||
151 | |||
152 | |||
153 | if (use_colors) /* Set up colors */ | ||
154 | color_setup (); | ||
155 | |||
156 | |||
157 | dialog_clear (); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * Setup for color display | ||
162 | */ | ||
163 | void | ||
164 | color_setup (void) | ||
165 | { | ||
166 | int i; | ||
167 | |||
168 | if (has_colors ()) { /* Terminal supports color? */ | ||
169 | start_color (); | ||
170 | |||
171 | /* Initialize color pairs */ | ||
172 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
173 | init_pair (i + 1, color_table[i][0], color_table[i][1]); | ||
174 | |||
175 | /* Setup color attributes */ | ||
176 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
177 | attributes[i] = C_ATTR (color_table[i][2], i + 1); | ||
178 | } | ||
179 | } | ||
180 | |||
181 | /* | ||
182 | * End using dialog functions. | ||
183 | */ | ||
184 | void | ||
185 | end_dialog (void) | ||
186 | { | ||
187 | endwin (); | ||
188 | } | ||
189 | |||
190 | |||
191 | /* | ||
192 | * Print a string of text in a window, automatically wrap around to the | ||
193 | * next line if the string is too long to fit on one line. Newline | ||
194 | * characters '\n' are replaced by spaces. We start on a new line | ||
195 | * if there is no room for at least 4 nonblanks following a double-space. | ||
196 | */ | ||
197 | void | ||
198 | print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x) | ||
199 | { | ||
200 | int newl, cur_x, cur_y; | ||
201 | int i, prompt_len, room, wlen; | ||
202 | char tempstr[MAX_LEN + 1], *word, *sp, *sp2; | ||
203 | |||
204 | strcpy (tempstr, prompt); | ||
205 | |||
206 | prompt_len = strlen(tempstr); | ||
207 | |||
208 | /* | ||
209 | * Remove newlines | ||
210 | */ | ||
211 | for(i=0; i<prompt_len; i++) { | ||
212 | if(tempstr[i] == '\n') tempstr[i] = ' '; | ||
213 | } | ||
214 | |||
215 | if (prompt_len <= width - x * 2) { /* If prompt is short */ | ||
216 | wmove (win, y, (width - prompt_len) / 2); | ||
217 | waddstr (win, tempstr); | ||
218 | } else { | ||
219 | cur_x = x; | ||
220 | cur_y = y; | ||
221 | newl = 1; | ||
222 | word = tempstr; | ||
223 | while (word && *word) { | ||
224 | sp = index(word, ' '); | ||
225 | if (sp) | ||
226 | *sp++ = 0; | ||
227 | |||
228 | /* Wrap to next line if either the word does not fit, | ||
229 | or it is the first word of a new sentence, and it is | ||
230 | short, and the next word does not fit. */ | ||
231 | room = width - cur_x; | ||
232 | wlen = strlen(word); | ||
233 | if (wlen > room || | ||
234 | (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room | ||
235 | && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { | ||
236 | cur_y++; | ||
237 | cur_x = x; | ||
238 | } | ||
239 | wmove (win, cur_y, cur_x); | ||
240 | waddstr (win, word); | ||
241 | getyx (win, cur_y, cur_x); | ||
242 | cur_x++; | ||
243 | if (sp && *sp == ' ') { | ||
244 | cur_x++; /* double space */ | ||
245 | while (*++sp == ' '); | ||
246 | newl = 1; | ||
247 | } else | ||
248 | newl = 0; | ||
249 | word = sp; | ||
250 | } | ||
251 | } | ||
252 | } | ||
253 | |||
254 | /* | ||
255 | * Print a button | ||
256 | */ | ||
257 | void | ||
258 | print_button (WINDOW * win, const char *label, int y, int x, int selected) | ||
259 | { | ||
260 | int i, temp; | ||
261 | |||
262 | wmove (win, y, x); | ||
263 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | ||
264 | waddstr (win, "<"); | ||
265 | temp = strspn (label, " "); | ||
266 | label += temp; | ||
267 | wattrset (win, selected ? button_label_active_attr | ||
268 | : button_label_inactive_attr); | ||
269 | for (i = 0; i < temp; i++) | ||
270 | waddch (win, ' '); | ||
271 | wattrset (win, selected ? button_key_active_attr | ||
272 | : button_key_inactive_attr); | ||
273 | waddch (win, label[0]); | ||
274 | wattrset (win, selected ? button_label_active_attr | ||
275 | : button_label_inactive_attr); | ||
276 | waddstr (win, (char *)label + 1); | ||
277 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | ||
278 | waddstr (win, ">"); | ||
279 | wmove (win, y, x + temp + 1); | ||
280 | } | ||
281 | |||
282 | /* | ||
283 | * Draw a rectangular box with line drawing characters | ||
284 | */ | ||
285 | void | ||
286 | draw_box (WINDOW * win, int y, int x, int height, int width, | ||
287 | chtype box, chtype border) | ||
288 | { | ||
289 | int i, j; | ||
290 | |||
291 | wattrset (win, 0); | ||
292 | for (i = 0; i < height; i++) { | ||
293 | wmove (win, y + i, x); | ||
294 | for (j = 0; j < width; j++) | ||
295 | if (!i && !j) | ||
296 | waddch (win, border | ACS_ULCORNER); | ||
297 | else if (i == height - 1 && !j) | ||
298 | waddch (win, border | ACS_LLCORNER); | ||
299 | else if (!i && j == width - 1) | ||
300 | waddch (win, box | ACS_URCORNER); | ||
301 | else if (i == height - 1 && j == width - 1) | ||
302 | waddch (win, box | ACS_LRCORNER); | ||
303 | else if (!i) | ||
304 | waddch (win, border | ACS_HLINE); | ||
305 | else if (i == height - 1) | ||
306 | waddch (win, box | ACS_HLINE); | ||
307 | else if (!j) | ||
308 | waddch (win, border | ACS_VLINE); | ||
309 | else if (j == width - 1) | ||
310 | waddch (win, box | ACS_VLINE); | ||
311 | else | ||
312 | waddch (win, box | ' '); | ||
313 | } | ||
314 | } | ||
315 | |||
316 | /* | ||
317 | * Draw shadows along the right and bottom edge to give a more 3D look | ||
318 | * to the boxes | ||
319 | */ | ||
320 | void | ||
321 | draw_shadow (WINDOW * win, int y, int x, int height, int width) | ||
322 | { | ||
323 | int i; | ||
324 | |||
325 | if (has_colors ()) { /* Whether terminal supports color? */ | ||
326 | wattrset (win, shadow_attr); | ||
327 | wmove (win, y + height, x + 2); | ||
328 | for (i = 0; i < width; i++) | ||
329 | waddch (win, winch (win) & A_CHARTEXT); | ||
330 | for (i = y + 1; i < y + height + 1; i++) { | ||
331 | wmove (win, i, x + width); | ||
332 | waddch (win, winch (win) & A_CHARTEXT); | ||
333 | waddch (win, winch (win) & A_CHARTEXT); | ||
334 | } | ||
335 | wnoutrefresh (win); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | /* | ||
340 | * Return the position of the first alphabetic character in a string. | ||
341 | */ | ||
342 | int | ||
343 | first_alpha(const char *string, const char *exempt) | ||
344 | { | ||
345 | int i, in_paren=0, c; | ||
346 | |||
347 | for (i = 0; i < strlen(string); i++) { | ||
348 | c = tolower(string[i]); | ||
349 | |||
350 | if (strchr("<[(", c)) ++in_paren; | ||
351 | if (strchr(">])", c) && in_paren > 0) --in_paren; | ||
352 | |||
353 | if ((! in_paren) && isalpha(c) && | ||
354 | strchr(exempt, c) == 0) | ||
355 | return i; | ||
356 | } | ||
357 | |||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | /* | ||
362 | * Get the first selected item in the dialog_list_item list. | ||
363 | */ | ||
364 | struct dialog_list_item * | ||
365 | first_sel_item(int item_no, struct dialog_list_item ** items) | ||
366 | { | ||
367 | int i; | ||
368 | |||
369 | for (i = 0; i < item_no; i++) { | ||
370 | if (items[i]->selected) | ||
371 | return items[i]; | ||
372 | } | ||
373 | |||
374 | return NULL; | ||
375 | } | ||
diff --git a/busybox/scripts/config/yesno.c b/busybox/scripts/config/lxdialog/yesno.c index 11fcc25f5..11fcc25f5 100644 --- a/busybox/scripts/config/yesno.c +++ b/busybox/scripts/config/lxdialog/yesno.c | |||
diff --git a/busybox/scripts/config/mconf.c b/busybox/scripts/config/mconf.c index 63b4ff72f..5bc2abdd8 100644 --- a/busybox/scripts/config/mconf.c +++ b/busybox/scripts/config/mconf.c | |||
@@ -23,18 +23,150 @@ | |||
23 | #include <termios.h> | 23 | #include <termios.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | 25 | ||
26 | #include "dialog.h" | 26 | #include "lxdialog/dialog.h" |
27 | 27 | ||
28 | #define LKC_DIRECT_LINK | 28 | #define LKC_DIRECT_LINK |
29 | #include "lkc.h" | 29 | #include "lkc.h" |
30 | 30 | ||
31 | static char menu_backtitle[128]; | 31 | static char menu_backtitle[128]; |
32 | static const char menu_instructions[] = | 32 | static const char mconf_readme[] = |
33 | "Overview\n" | ||
34 | "--------\n" | ||
35 | "Some features may be built directly into BusyBox. Some features\n" | ||
36 | "may be completely removed altogether. There are also certain\n" | ||
37 | "parameters which are not really features, but must be\n" | ||
38 | "entered in as decimal or hexadecimal numbers or possibly text.\n" | ||
39 | "\n" | ||
40 | "Menu items beginning with [*] or [ ] represent features\n" | ||
41 | "configured to be built in or removed respectively.\n" | ||
42 | "\n" | ||
43 | "To change any of these features, highlight it with the cursor\n" | ||
44 | "keys and press <Y> to build it in or <N> to removed it.\n" | ||
45 | "You may also press the <Space Bar> to cycle\n" | ||
46 | "through the available options (ie. Y->N->Y).\n" | ||
47 | "\n" | ||
48 | "Some additional keyboard hints:\n" | ||
49 | "\n" | ||
50 | "Menus\n" | ||
51 | "----------\n" | ||
52 | "o Use the Up/Down arrow keys (cursor keys) to highlight the item\n" | ||
53 | " you wish to change or submenu wish to select and press <Enter>.\n" | ||
54 | " Submenus are designated by \"--->\".\n" | ||
55 | "\n" | ||
56 | " Shortcut: Press the option's highlighted letter (hotkey).\n" | ||
57 | " Pressing a hotkey more than once will sequence\n" | ||
58 | " through all visible items which use that hotkey.\n" | ||
59 | "\n" | ||
60 | " You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n" | ||
61 | " unseen options into view.\n" | ||
62 | "\n" | ||
63 | "o To exit a menu use the cursor keys to highlight the <Exit> button\n" | ||
64 | " and press <ENTER>.\n" | ||
65 | "\n" | ||
66 | " Shortcut: Press <ESC><ESC> or <E> or <X> if there is no hotkey\n" | ||
67 | " using those letters. You may press a single <ESC>, but\n" | ||
68 | " there is a delayed response which you may find annoying.\n" | ||
69 | "\n" | ||
70 | " Also, the <TAB> and cursor keys will cycle between <Select>,\n" | ||
71 | " <Exit> and <Help>\n" | ||
72 | "\n" | ||
73 | "o To get help with an item, use the cursor keys to highlight <Help>\n" | ||
74 | " and Press <ENTER>.\n" | ||
75 | "\n" | ||
76 | " Shortcut: Press <H> or <?>.\n" | ||
77 | "\n" | ||
78 | "\n" | ||
79 | "Radiolists (Choice lists)\n" | ||
80 | "-----------\n" | ||
81 | "o Use the cursor keys to select the option you wish to set and press\n" | ||
82 | " <S> or the <SPACE BAR>.\n" | ||
83 | "\n" | ||
84 | " Shortcut: Press the first letter of the option you wish to set then\n" | ||
85 | " press <S> or <SPACE BAR>.\n" | ||
86 | "\n" | ||
87 | "o To see available help for the item, use the cursor keys to highlight\n" | ||
88 | " <Help> and Press <ENTER>.\n" | ||
89 | "\n" | ||
90 | " Shortcut: Press <H> or <?>.\n" | ||
91 | "\n" | ||
92 | " Also, the <TAB> and cursor keys will cycle between <Select> and\n" | ||
93 | " <Help>\n" | ||
94 | "\n" | ||
95 | "\n" | ||
96 | "Data Entry\n" | ||
97 | "-----------\n" | ||
98 | "o Enter the requested information and press <ENTER>\n" | ||
99 | " If you are entering hexadecimal values, it is not necessary to\n" | ||
100 | " add the '0x' prefix to the entry.\n" | ||
101 | "\n" | ||
102 | "o For help, use the <TAB> or cursor keys to highlight the help option\n" | ||
103 | " and press <ENTER>. You can try <TAB><H> as well.\n" | ||
104 | "\n" | ||
105 | "\n" | ||
106 | "Text Box (Help Window)\n" | ||
107 | "--------\n" | ||
108 | "o Use the cursor keys to scroll up/down/left/right. The VI editor\n" | ||
109 | " keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n" | ||
110 | " who are familiar with less and lynx.\n" | ||
111 | "\n" | ||
112 | "o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n" | ||
113 | "\n" | ||
114 | "\n" | ||
115 | "Alternate Configuration Files\n" | ||
116 | "-----------------------------\n" | ||
117 | "Menuconfig supports the use of alternate configuration files for\n" | ||
118 | "those who, for various reasons, find it necessary to switch\n" | ||
119 | "between different configurations.\n" | ||
120 | "\n" | ||
121 | "At the end of the main menu you will find two options. One is\n" | ||
122 | "for saving the current configuration to a file of your choosing.\n" | ||
123 | "The other option is for loading a previously saved alternate\n" | ||
124 | "configuration.\n" | ||
125 | "\n" | ||
126 | "Even if you don't use alternate configuration files, but you\n" | ||
127 | "find during a Menuconfig session that you have completely messed\n" | ||
128 | "up your settings, you may use the \"Load Alternate...\" option to\n" | ||
129 | "restore your previously saved settings from \".config\" without\n" | ||
130 | "restarting Menuconfig.\n" | ||
131 | "\n" | ||
132 | "Other information\n" | ||
133 | "-----------------\n" | ||
134 | "If you use Menuconfig in an XTERM window make sure you have your\n" | ||
135 | "$TERM variable set to point to a xterm definition which supports color.\n" | ||
136 | "Otherwise, Menuconfig will look rather bad. Menuconfig will not\n" | ||
137 | "display correctly in a RXVT window because rxvt displays only one\n" | ||
138 | "intensity of color, bright.\n" | ||
139 | "\n" | ||
140 | "Menuconfig will display larger menus on screens or xterms which are\n" | ||
141 | "set to display more than the standard 25 row by 80 column geometry.\n" | ||
142 | "In order for this to work, the \"stty size\" command must be able to\n" | ||
143 | "display the screen's current row and column geometry. I STRONGLY\n" | ||
144 | "RECOMMEND that you make sure you do NOT have the shell variables\n" | ||
145 | "LINES and COLUMNS exported into your environment. Some distributions\n" | ||
146 | "export those variables via /etc/profile. Some ncurses programs can\n" | ||
147 | "become confused when those variables (LINES & COLUMNS) don't reflect\n" | ||
148 | "the true screen size.\n" | ||
149 | "\n" | ||
150 | "Optional personality available\n" | ||
151 | "------------------------------\n" | ||
152 | "If you prefer to have all of the options listed in a single\n" | ||
153 | "menu, rather than the default multimenu hierarchy, run the menuconfig\n" | ||
154 | "with MENUCONFIG_MODE environment variable set to single_menu. Example:\n" | ||
155 | "\n" | ||
156 | "make MENUCONFIG_MODE=single_menu menuconfig\n" | ||
157 | "\n" | ||
158 | "<Enter> will then unroll the appropriate category, or enfold it if it\n" | ||
159 | "is already unrolled.\n" | ||
160 | "\n" | ||
161 | "Note that this mode can eventually be a little more CPU expensive\n" | ||
162 | "(especially with a larger number of unrolled categories) than the\n" | ||
163 | "default mode.\n", | ||
164 | menu_instructions[] = | ||
33 | "Arrow keys navigate the menu. " | 165 | "Arrow keys navigate the menu. " |
34 | "<Enter> selects submenus --->. " | 166 | "<Enter> selects submenus --->. " |
35 | "Highlighted letters are hotkeys. " | 167 | "Highlighted letters are hotkeys. " |
36 | "Pressing <Y> selectes a feature, while <N> will exclude a feature. " | 168 | "Pressing <Y> selectes a feature, while <N> will exclude a feature. " |
37 | "Press <Esc><Esc> to exit, <?> for Help. " | 169 | "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " |
38 | "Legend: [*] feature is selected [ ] feature is excluded", | 170 | "Legend: [*] feature is selected [ ] feature is excluded", |
39 | radiolist_instructions[] = | 171 | radiolist_instructions[] = |
40 | "Use the arrow keys to navigate this window or " | 172 | "Use the arrow keys to navigate this window or " |
@@ -85,23 +217,50 @@ save_config_help[] = | |||
85 | "\n" | 217 | "\n" |
86 | "If you are uncertain what all this means then you should probably\n" | 218 | "If you are uncertain what all this means then you should probably\n" |
87 | "leave this blank.\n", | 219 | "leave this blank.\n", |
88 | top_menu_help[] = | 220 | search_help[] = |
89 | "\n" | 221 | "\n" |
90 | "Use the Up/Down arrow keys (cursor keys) to highlight the item\n" | 222 | "Search for CONFIG_ symbols and display their relations.\n" |
91 | "you wish to change or submenu wish to select and press <Enter>.\n" | 223 | "Example: search for \"^FOO\"\n" |
92 | "Submenus are designated by \"--->\".\n" | 224 | "Result:\n" |
225 | "-----------------------------------------------------------------\n" | ||
226 | "Symbol: FOO [=m]\n" | ||
227 | "Prompt: Foo bus is used to drive the bar HW\n" | ||
228 | "Defined at drivers/pci/Kconfig:47\n" | ||
229 | "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" | ||
230 | "Location:\n" | ||
231 | " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n" | ||
232 | " -> PCI support (PCI [=y])\n" | ||
233 | " -> PCI access mode (<choice> [=y])\n" | ||
234 | "Selects: LIBCRC32\n" | ||
235 | "Selected by: BAR\n" | ||
236 | "-----------------------------------------------------------------\n" | ||
237 | "o The line 'Prompt:' shows the text used in the menu structure for\n" | ||
238 | " this CONFIG_ symbol\n" | ||
239 | "o The 'Defined at' line tell at what file / line number the symbol\n" | ||
240 | " is defined\n" | ||
241 | "o The 'Depends on:' line tell what symbols needs to be defined for\n" | ||
242 | " this symbol to be visible in the menu (selectable)\n" | ||
243 | "o The 'Location:' lines tell where in the menu structure this symbol\n" | ||
244 | " is located\n" | ||
245 | " A location followed by a [=y] indicate that this is a selectable\n" | ||
246 | " menu item - and current value is displayed inside brackets.\n" | ||
247 | "o The 'Selects:' line tell what symbol will be automatically\n" | ||
248 | " selected if this symbol is selected (y or m)\n" | ||
249 | "o The 'Selected by' line tell what symbol has selected this symbol\n" | ||
93 | "\n" | 250 | "\n" |
94 | "Shortcut: Press the option's highlighted letter (hotkey).\n" | 251 | "Only relevant lines are shown.\n" |
95 | "\n" | 252 | "\n\n" |
96 | "You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n" | 253 | "Search examples:\n" |
97 | "unseen options into view.\n" | 254 | "Examples: USB => find all CONFIG_ symbols containing USB\n" |
98 | ; | 255 | " ^USB => find all CONFIG_ symbols starting with USB\n" |
256 | " USB$ => find all CONFIG_ symbols ending with USB\n" | ||
257 | "\n"; | ||
99 | 258 | ||
100 | static char filename[PATH_MAX+1] = ".config"; | 259 | static char filename[PATH_MAX+1] = ".config"; |
101 | static int indent = 0; | 260 | static int indent; |
102 | static struct termios ios_org; | 261 | static struct termios ios_org; |
103 | static int rows, cols; | 262 | static int rows = 0, cols = 0; |
104 | struct menu *current_menu; | 263 | static struct menu *current_menu; |
105 | static int child_count; | 264 | static int child_count; |
106 | static int single_menu_mode; | 265 | static int single_menu_mode; |
107 | 266 | ||
@@ -116,33 +275,31 @@ static void conf_save(void); | |||
116 | static void show_textbox(const char *title, const char *text, int r, int c); | 275 | static void show_textbox(const char *title, const char *text, int r, int c); |
117 | static void show_helptext(const char *title, const char *text); | 276 | static void show_helptext(const char *title, const char *text); |
118 | static void show_help(struct menu *menu); | 277 | static void show_help(struct menu *menu); |
119 | static void show_readme(void); | 278 | static void show_file(const char *filename, const char *title, int r, int c); |
120 | 279 | ||
121 | static void init_wsize(void) | 280 | static void init_wsize(void) |
122 | { | 281 | { |
123 | struct winsize ws; | 282 | struct winsize ws; |
124 | char *env; | 283 | char *env; |
125 | 284 | ||
126 | if (ioctl(1, TIOCGWINSZ, &ws) == -1) { | 285 | if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { |
127 | rows = 24; | ||
128 | cols = 80; | ||
129 | } else { | ||
130 | rows = ws.ws_row; | 286 | rows = ws.ws_row; |
131 | cols = ws.ws_col; | 287 | cols = ws.ws_col; |
132 | if (!rows) { | 288 | } |
133 | env = getenv("LINES"); | 289 | |
134 | if (env) | 290 | if (!rows) { |
135 | rows = atoi(env); | 291 | env = getenv("LINES"); |
136 | if (!rows) | 292 | if (env) |
137 | rows = 24; | 293 | rows = atoi(env); |
138 | } | 294 | if (!rows) |
139 | if (!cols) { | 295 | rows = 24; |
140 | env = getenv("COLUMNS"); | 296 | } |
141 | if (env) | 297 | if (!cols) { |
142 | cols = atoi(env); | 298 | env = getenv("COLUMNS"); |
143 | if (!cols) | 299 | if (env) |
144 | cols = 80; | 300 | cols = atoi(env); |
145 | } | 301 | if (!cols) |
302 | cols = 80; | ||
146 | } | 303 | } |
147 | 304 | ||
148 | if (rows < 19 || cols < 80) { | 305 | if (rows < 19 || cols < 80) { |
@@ -214,6 +371,103 @@ static void cdone(void) | |||
214 | item_no = 0; | 371 | item_no = 0; |
215 | } | 372 | } |
216 | 373 | ||
374 | static void get_prompt_str(struct gstr *r, struct property *prop) | ||
375 | { | ||
376 | int i, j; | ||
377 | struct menu *submenu[8], *menu; | ||
378 | |||
379 | str_printf(r, "Prompt: %s\n", prop->text); | ||
380 | str_printf(r, " Defined at %s:%d\n", prop->menu->file->name, | ||
381 | prop->menu->lineno); | ||
382 | if (!expr_is_yes(prop->visible.expr)) { | ||
383 | str_append(r, " Depends on: "); | ||
384 | expr_gstr_print(prop->visible.expr, r); | ||
385 | str_append(r, "\n"); | ||
386 | } | ||
387 | menu = prop->menu->parent; | ||
388 | for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) | ||
389 | submenu[i++] = menu; | ||
390 | if (i > 0) { | ||
391 | str_printf(r, " Location:\n"); | ||
392 | for (j = 4; --i >= 0; j += 2) { | ||
393 | menu = submenu[i]; | ||
394 | str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu)); | ||
395 | if (menu->sym) { | ||
396 | str_printf(r, " (%s [=%s])", menu->sym->name ? | ||
397 | menu->sym->name : "<choice>", | ||
398 | sym_get_string_value(menu->sym)); | ||
399 | } | ||
400 | str_append(r, "\n"); | ||
401 | } | ||
402 | } | ||
403 | } | ||
404 | |||
405 | static void get_symbol_str(struct gstr *r, struct symbol *sym) | ||
406 | { | ||
407 | bool hit; | ||
408 | struct property *prop; | ||
409 | |||
410 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, | ||
411 | sym_get_string_value(sym)); | ||
412 | for_all_prompts(sym, prop) | ||
413 | get_prompt_str(r, prop); | ||
414 | hit = false; | ||
415 | for_all_properties(sym, prop, P_SELECT) { | ||
416 | if (!hit) { | ||
417 | str_append(r, " Selects: "); | ||
418 | hit = true; | ||
419 | } else | ||
420 | str_printf(r, " && "); | ||
421 | expr_gstr_print(prop->expr, r); | ||
422 | } | ||
423 | if (hit) | ||
424 | str_append(r, "\n"); | ||
425 | if (sym->rev_dep.expr) { | ||
426 | str_append(r, " Selected by: "); | ||
427 | expr_gstr_print(sym->rev_dep.expr, r); | ||
428 | str_append(r, "\n"); | ||
429 | } | ||
430 | str_append(r, "\n\n"); | ||
431 | } | ||
432 | |||
433 | static struct gstr get_relations_str(struct symbol **sym_arr) | ||
434 | { | ||
435 | struct symbol *sym; | ||
436 | struct gstr res = str_new(); | ||
437 | int i; | ||
438 | |||
439 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) | ||
440 | get_symbol_str(&res, sym); | ||
441 | if (!i) | ||
442 | str_append(&res, "No matches found.\n"); | ||
443 | return res; | ||
444 | } | ||
445 | |||
446 | static void search_conf(void) | ||
447 | { | ||
448 | struct symbol **sym_arr; | ||
449 | struct gstr res; | ||
450 | |||
451 | again: | ||
452 | switch (dialog_inputbox("Search Configuration Parameter", | ||
453 | "Enter Keyword", 10, 75, | ||
454 | NULL)) { | ||
455 | case 0: | ||
456 | break; | ||
457 | case 1: | ||
458 | show_helptext("Search Configuration", search_help); | ||
459 | goto again; | ||
460 | default: | ||
461 | return; | ||
462 | } | ||
463 | |||
464 | sym_arr = sym_re_search(dialog_input_result); | ||
465 | res = get_relations_str(sym_arr); | ||
466 | free(sym_arr); | ||
467 | show_textbox("Search Results", str_get(&res), 0, 0); | ||
468 | str_free(&res); | ||
469 | } | ||
470 | |||
217 | static void build_conf(struct menu *menu) | 471 | static void build_conf(struct menu *menu) |
218 | { | 472 | { |
219 | struct symbol *sym; | 473 | struct symbol *sym; |
@@ -308,6 +562,11 @@ static void build_conf(struct menu *menu) | |||
308 | return; | 562 | return; |
309 | } | 563 | } |
310 | } else { | 564 | } else { |
565 | if (menu == current_menu) { | ||
566 | cprint_tag(":%p", menu); | ||
567 | cprint_name("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); | ||
568 | goto conf_childs; | ||
569 | } | ||
311 | child_count++; | 570 | child_count++; |
312 | val = sym_get_tristate_value(sym); | 571 | val = sym_get_tristate_value(sym); |
313 | if (sym_is_choice_value(sym) && val == yes) { | 572 | if (sym_is_choice_value(sym) && val == yes) { |
@@ -376,7 +635,7 @@ static void conf(struct menu *menu) | |||
376 | while (1) { | 635 | while (1) { |
377 | indent = 0; | 636 | indent = 0; |
378 | child_count = 0; | 637 | child_count = 0; |
379 | current_menu = menu; | 638 | current_menu = menu; |
380 | cdone(); cinit(); | 639 | cdone(); cinit(); |
381 | build_conf(menu); | 640 | build_conf(menu); |
382 | if (!child_count) | 641 | if (!child_count) |
@@ -441,7 +700,7 @@ static void conf(struct menu *menu) | |||
441 | if (sym) | 700 | if (sym) |
442 | show_help(submenu); | 701 | show_help(submenu); |
443 | else | 702 | else |
444 | show_readme(); | 703 | show_helptext("README", mconf_readme); |
445 | break; | 704 | break; |
446 | case 3: | 705 | case 3: |
447 | if (type == 't') { | 706 | if (type == 't') { |
@@ -465,6 +724,9 @@ static void conf(struct menu *menu) | |||
465 | else if (type == 'm') | 724 | else if (type == 'm') |
466 | conf(submenu); | 725 | conf(submenu); |
467 | break; | 726 | break; |
727 | case 7: | ||
728 | search_conf(); | ||
729 | break; | ||
468 | } | 730 | } |
469 | } | 731 | } |
470 | } | 732 | } |
@@ -476,37 +738,39 @@ static void show_textbox(const char *title, const char *text, int r, int c) | |||
476 | fd = creat(".help.tmp", 0777); | 738 | fd = creat(".help.tmp", 0777); |
477 | write(fd, text, strlen(text)); | 739 | write(fd, text, strlen(text)); |
478 | close(fd); | 740 | close(fd); |
479 | while (dialog_textbox(title, ".help.tmp", r, c) < 0) | 741 | show_file(".help.tmp", title, r, c); |
480 | ; | ||
481 | unlink(".help.tmp"); | 742 | unlink(".help.tmp"); |
482 | } | 743 | } |
483 | 744 | ||
484 | static void show_helptext(const char *title, const char *text) | 745 | static void show_helptext(const char *title, const char *text) |
485 | { | 746 | { |
486 | show_textbox(title, text, rows, cols); | 747 | show_textbox(title, text, 0, 0); |
487 | } | 748 | } |
488 | 749 | ||
489 | static void show_help(struct menu *menu) | 750 | static void show_help(struct menu *menu) |
490 | { | 751 | { |
491 | const char *help; | 752 | struct gstr help = str_new(); |
492 | char *helptext; | ||
493 | struct symbol *sym = menu->sym; | 753 | struct symbol *sym = menu->sym; |
494 | 754 | ||
495 | help = sym->help; | 755 | if (sym->help) |
496 | if (!help) | 756 | { |
497 | help = nohelp_text; | 757 | if (sym->name) { |
498 | if (sym->name) { | 758 | str_printf(&help, "%s:\n\n", sym->name); |
499 | helptext = malloc(strlen(sym->name) + strlen(help) + 16); | 759 | str_append(&help, sym->help); |
500 | sprintf(helptext, "%s:\n\n%s", sym->name, help); | 760 | str_append(&help, "\n"); |
501 | show_helptext(menu_get_prompt(menu), helptext); | 761 | } |
502 | free(helptext); | 762 | } else { |
503 | } else | 763 | str_append(&help, nohelp_text); |
504 | show_helptext(menu_get_prompt(menu), help); | 764 | } |
765 | get_symbol_str(&help, sym); | ||
766 | show_helptext(menu_get_prompt(menu), str_get(&help)); | ||
767 | str_free(&help); | ||
505 | } | 768 | } |
506 | 769 | ||
507 | static void show_readme(void) | 770 | static void show_file(const char *filename, const char *title, int r, int c) |
508 | { | 771 | { |
509 | show_helptext("Help", top_menu_help); | 772 | while (dialog_textbox(title, filename, r ? r : rows, c ? c : cols) < 0) |
773 | ; | ||
510 | } | 774 | } |
511 | 775 | ||
512 | static void conf_choice(struct menu *menu) | 776 | static void conf_choice(struct menu *menu) |
@@ -667,9 +931,9 @@ static void winch_handler(int sig) | |||
667 | 931 | ||
668 | int main(int ac, char **av) | 932 | int main(int ac, char **av) |
669 | { | 933 | { |
670 | int stat; | ||
671 | char *mode; | ||
672 | struct symbol *sym; | 934 | struct symbol *sym; |
935 | char *mode; | ||
936 | int stat; | ||
673 | 937 | ||
674 | conf_parse(av[1]); | 938 | conf_parse(av[1]); |
675 | conf_read(NULL); | 939 | conf_read(NULL); |
@@ -697,7 +961,7 @@ int main(int ac, char **av) | |||
697 | init_dialog(); | 961 | init_dialog(); |
698 | do { | 962 | do { |
699 | stat = dialog_yesno(NULL, | 963 | stat = dialog_yesno(NULL, |
700 | "Do you wish to save your new BusyBox configuration?", 5, 60); | 964 | "Do you wish to save your new BusyBox configuration?", 5, 60); |
701 | } while (stat < 0); | 965 | } while (stat < 0); |
702 | end_dialog(); | 966 | end_dialog(); |
703 | 967 | ||
diff --git a/busybox/scripts/config/menu.c b/busybox/scripts/config/menu.c index 6425296fc..0c13156f3 100644 --- a/busybox/scripts/config/menu.c +++ b/busybox/scripts/config/menu.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include "lkc.h" | 10 | #include "lkc.h" |
11 | 11 | ||
12 | struct menu rootmenu; | 12 | struct menu rootmenu; |
13 | struct menu *current_menu, *current_entry; | ||
14 | static struct menu **last_entry_ptr; | 13 | static struct menu **last_entry_ptr; |
15 | 14 | ||
16 | struct file *file_list; | 15 | struct file *file_list; |
@@ -389,43 +388,3 @@ struct menu *menu_get_parent_menu(struct menu *menu) | |||
389 | return menu; | 388 | return menu; |
390 | } | 389 | } |
391 | 390 | ||
392 | struct file *file_lookup(const char *name) | ||
393 | { | ||
394 | struct file *file; | ||
395 | |||
396 | for (file = file_list; file; file = file->next) { | ||
397 | if (!strcmp(name, file->name)) | ||
398 | return file; | ||
399 | } | ||
400 | |||
401 | file = malloc(sizeof(*file)); | ||
402 | memset(file, 0, sizeof(*file)); | ||
403 | file->name = strdup(name); | ||
404 | file->next = file_list; | ||
405 | file_list = file; | ||
406 | return file; | ||
407 | } | ||
408 | |||
409 | int file_write_dep(const char *name) | ||
410 | { | ||
411 | struct file *file; | ||
412 | FILE *out; | ||
413 | |||
414 | if (!name) | ||
415 | name = ".config.cmd"; | ||
416 | out = fopen(".config.tmp", "w"); | ||
417 | if (!out) | ||
418 | return 1; | ||
419 | fprintf(out, "deps_config := \\\n"); | ||
420 | for (file = file_list; file; file = file->next) { | ||
421 | if (file->next) | ||
422 | fprintf(out, "\t%s \\\n", file->name); | ||
423 | else | ||
424 | fprintf(out, "\t%s\n", file->name); | ||
425 | } | ||
426 | fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n"); | ||
427 | fclose(out); | ||
428 | rename(".config.tmp", name); | ||
429 | return 0; | ||
430 | } | ||
431 | |||
diff --git a/busybox/scripts/config/symbol.c b/busybox/scripts/config/symbol.c index a9fae9c13..ea629728a 100644 --- a/busybox/scripts/config/symbol.c +++ b/busybox/scripts/config/symbol.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <ctype.h> | 6 | #include <ctype.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include <regex.h> | ||
9 | #include <sys/utsname.h> | 10 | #include <sys/utsname.h> |
10 | 11 | ||
11 | #define LKC_DIRECT_LINK | 12 | #define LKC_DIRECT_LINK |
@@ -414,7 +415,7 @@ tristate sym_toggle_tristate_value(struct symbol *sym) | |||
414 | 415 | ||
415 | bool sym_string_valid(struct symbol *sym, const char *str) | 416 | bool sym_string_valid(struct symbol *sym, const char *str) |
416 | { | 417 | { |
417 | char ch; | 418 | signed char ch; |
418 | 419 | ||
419 | switch (sym->type) { | 420 | switch (sym->type) { |
420 | case S_STRING: | 421 | case S_STRING: |
@@ -649,6 +650,43 @@ struct symbol *sym_find(const char *name) | |||
649 | return symbol; | 650 | return symbol; |
650 | } | 651 | } |
651 | 652 | ||
653 | struct symbol **sym_re_search(const char *pattern) | ||
654 | { | ||
655 | struct symbol *sym, **sym_arr = NULL; | ||
656 | int i, cnt, size; | ||
657 | regex_t re; | ||
658 | |||
659 | cnt = size = 0; | ||
660 | /* Skip if empty */ | ||
661 | if (strlen(pattern) == 0) | ||
662 | return NULL; | ||
663 | if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) | ||
664 | return NULL; | ||
665 | |||
666 | for_all_symbols(i, sym) { | ||
667 | if (sym->flags & SYMBOL_CONST || !sym->name) | ||
668 | continue; | ||
669 | if (regexec(&re, sym->name, 0, NULL, 0)) | ||
670 | continue; | ||
671 | if (cnt + 1 >= size) { | ||
672 | void *tmp = sym_arr; | ||
673 | size += 16; | ||
674 | sym_arr = realloc(sym_arr, size * sizeof(struct symbol *)); | ||
675 | if (!sym_arr) { | ||
676 | free(tmp); | ||
677 | return NULL; | ||
678 | } | ||
679 | } | ||
680 | sym_arr[cnt++] = sym; | ||
681 | } | ||
682 | if (sym_arr) | ||
683 | sym_arr[cnt] = NULL; | ||
684 | regfree(&re); | ||
685 | |||
686 | return sym_arr; | ||
687 | } | ||
688 | |||
689 | |||
652 | struct symbol *sym_check_deps(struct symbol *sym); | 690 | struct symbol *sym_check_deps(struct symbol *sym); |
653 | 691 | ||
654 | static struct symbol *sym_check_expr_deps(struct expr *e) | 692 | static struct symbol *sym_check_expr_deps(struct expr *e) |
diff --git a/busybox/scripts/config/util.c b/busybox/scripts/config/util.c index 0a2f82757..a72f5ea66 100644 --- a/busybox/scripts/config/util.c +++ b/busybox/scripts/config/util.c | |||
@@ -1,375 +1,109 @@ | |||
1 | /* | 1 | /* |
2 | * util.c | 2 | * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org> |
3 | * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org> | ||
3 | * | 4 | * |
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) | 5 | * Released under the terms of the GNU GPL v2.0. |
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include "dialog.h" | ||
23 | |||
24 | |||
25 | /* use colors by default? */ | ||
26 | bool use_colors = 1; | ||
27 | |||
28 | char *backtitle = NULL; | ||
29 | |||
30 | const char *dialog_result; | ||
31 | |||
32 | /* | ||
33 | * Attribute values, default is for mono display | ||
34 | */ | ||
35 | chtype attributes[] = | ||
36 | { | ||
37 | A_NORMAL, /* screen_attr */ | ||
38 | A_NORMAL, /* shadow_attr */ | ||
39 | A_NORMAL, /* dialog_attr */ | ||
40 | A_BOLD, /* title_attr */ | ||
41 | A_NORMAL, /* border_attr */ | ||
42 | A_REVERSE, /* button_active_attr */ | ||
43 | A_DIM, /* button_inactive_attr */ | ||
44 | A_REVERSE, /* button_key_active_attr */ | ||
45 | A_BOLD, /* button_key_inactive_attr */ | ||
46 | A_REVERSE, /* button_label_active_attr */ | ||
47 | A_NORMAL, /* button_label_inactive_attr */ | ||
48 | A_NORMAL, /* inputbox_attr */ | ||
49 | A_NORMAL, /* inputbox_border_attr */ | ||
50 | A_NORMAL, /* searchbox_attr */ | ||
51 | A_BOLD, /* searchbox_title_attr */ | ||
52 | A_NORMAL, /* searchbox_border_attr */ | ||
53 | A_BOLD, /* position_indicator_attr */ | ||
54 | A_NORMAL, /* menubox_attr */ | ||
55 | A_NORMAL, /* menubox_border_attr */ | ||
56 | A_NORMAL, /* item_attr */ | ||
57 | A_REVERSE, /* item_selected_attr */ | ||
58 | A_BOLD, /* tag_attr */ | ||
59 | A_REVERSE, /* tag_selected_attr */ | ||
60 | A_BOLD, /* tag_key_attr */ | ||
61 | A_REVERSE, /* tag_key_selected_attr */ | ||
62 | A_BOLD, /* check_attr */ | ||
63 | A_REVERSE, /* check_selected_attr */ | ||
64 | A_BOLD, /* uarrow_attr */ | ||
65 | A_BOLD /* darrow_attr */ | ||
66 | }; | ||
67 | |||
68 | |||
69 | #include "colors.h" | ||
70 | |||
71 | /* | ||
72 | * Table of color values | ||
73 | */ | ||
74 | int color_table[][3] = | ||
75 | { | ||
76 | {SCREEN_FG, SCREEN_BG, SCREEN_HL}, | ||
77 | {SHADOW_FG, SHADOW_BG, SHADOW_HL}, | ||
78 | {DIALOG_FG, DIALOG_BG, DIALOG_HL}, | ||
79 | {TITLE_FG, TITLE_BG, TITLE_HL}, | ||
80 | {BORDER_FG, BORDER_BG, BORDER_HL}, | ||
81 | {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, | ||
82 | {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, | ||
83 | {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, | ||
84 | {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL}, | ||
85 | {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL}, | ||
86 | {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, | ||
87 | BUTTON_LABEL_INACTIVE_HL}, | ||
88 | {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, | ||
89 | {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, | ||
90 | {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, | ||
91 | {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, | ||
92 | {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, | ||
93 | {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, | ||
94 | {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, | ||
95 | {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, | ||
96 | {ITEM_FG, ITEM_BG, ITEM_HL}, | ||
97 | {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, | ||
98 | {TAG_FG, TAG_BG, TAG_HL}, | ||
99 | {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, | ||
100 | {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, | ||
101 | {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, | ||
102 | {CHECK_FG, CHECK_BG, CHECK_HL}, | ||
103 | {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, | ||
104 | {UARROW_FG, UARROW_BG, UARROW_HL}, | ||
105 | {DARROW_FG, DARROW_BG, DARROW_HL}, | ||
106 | }; /* color_table */ | ||
107 | |||
108 | /* | ||
109 | * Set window to attribute 'attr' | ||
110 | */ | 6 | */ |
111 | void | ||
112 | attr_clear (WINDOW * win, int height, int width, chtype attr) | ||
113 | { | ||
114 | int i, j; | ||
115 | |||
116 | wattrset (win, attr); | ||
117 | for (i = 0; i < height; i++) { | ||
118 | wmove (win, i, 0); | ||
119 | for (j = 0; j < width; j++) | ||
120 | waddch (win, ' '); | ||
121 | } | ||
122 | touchwin (win); | ||
123 | } | ||
124 | 7 | ||
125 | void dialog_clear (void) | 8 | #include <string.h> |
126 | { | 9 | #include "lkc.h" |
127 | attr_clear (stdscr, LINES, COLS, screen_attr); | ||
128 | /* Display background title if it exists ... - SLH */ | ||
129 | if (backtitle != NULL) { | ||
130 | int i; | ||
131 | |||
132 | wattrset (stdscr, screen_attr); | ||
133 | mvwaddstr (stdscr, 0, 1, (char *)backtitle); | ||
134 | wmove (stdscr, 1, 1); | ||
135 | for (i = 1; i < COLS - 1; i++) | ||
136 | waddch (stdscr, ACS_HLINE); | ||
137 | } | ||
138 | wnoutrefresh (stdscr); | ||
139 | } | ||
140 | 10 | ||
141 | /* | 11 | /* file already present in list? If not add it */ |
142 | * Do some initialization for dialog | 12 | struct file *file_lookup(const char *name) |
143 | */ | ||
144 | void | ||
145 | init_dialog (void) | ||
146 | { | ||
147 | initscr (); /* Init curses */ | ||
148 | keypad (stdscr, TRUE); | ||
149 | cbreak (); | ||
150 | noecho (); | ||
151 | |||
152 | |||
153 | if (use_colors) /* Set up colors */ | ||
154 | color_setup (); | ||
155 | |||
156 | |||
157 | dialog_clear (); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * Setup for color display | ||
162 | */ | ||
163 | void | ||
164 | color_setup (void) | ||
165 | { | 13 | { |
166 | int i; | 14 | struct file *file; |
167 | 15 | ||
168 | if (has_colors ()) { /* Terminal supports color? */ | 16 | for (file = file_list; file; file = file->next) { |
169 | start_color (); | 17 | if (!strcmp(name, file->name)) |
170 | 18 | return file; | |
171 | /* Initialize color pairs */ | 19 | } |
172 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | ||
173 | init_pair (i + 1, color_table[i][0], color_table[i][1]); | ||
174 | 20 | ||
175 | /* Setup color attributes */ | 21 | file = malloc(sizeof(*file)); |
176 | for (i = 0; i < ATTRIBUTE_COUNT; i++) | 22 | memset(file, 0, sizeof(*file)); |
177 | attributes[i] = C_ATTR (color_table[i][2], i + 1); | 23 | file->name = strdup(name); |
178 | } | 24 | file->next = file_list; |
25 | file_list = file; | ||
26 | return file; | ||
179 | } | 27 | } |
180 | 28 | ||
181 | /* | 29 | /* write a dependency file as used by kbuild to track dependencies */ |
182 | * End using dialog functions. | 30 | int file_write_dep(const char *name) |
183 | */ | ||
184 | void | ||
185 | end_dialog (void) | ||
186 | { | 31 | { |
187 | endwin (); | 32 | struct file *file; |
33 | FILE *out; | ||
34 | |||
35 | if (!name) | ||
36 | name = ".config.cmd"; | ||
37 | out = fopen(".config.tmp", "w"); | ||
38 | if (!out) | ||
39 | return 1; | ||
40 | fprintf(out, "deps_config := \\\n"); | ||
41 | for (file = file_list; file; file = file->next) { | ||
42 | if (file->next) | ||
43 | fprintf(out, "\t%s \\\n", file->name); | ||
44 | else | ||
45 | fprintf(out, "\t%s\n", file->name); | ||
46 | } | ||
47 | fprintf(out, "\n.config include/config.h: $(deps_config)\n\n$(deps_config):\n"); | ||
48 | fclose(out); | ||
49 | rename(".config.tmp", name); | ||
50 | return 0; | ||
188 | } | 51 | } |
189 | 52 | ||
190 | 53 | ||
191 | /* | 54 | /* Allocate initial growable sting */ |
192 | * Print a string of text in a window, automatically wrap around to the | 55 | struct gstr str_new(void) |
193 | * next line if the string is too long to fit on one line. Newline | ||
194 | * characters '\n' are replaced by spaces. We start on a new line | ||
195 | * if there is no room for at least 4 nonblanks following a double-space. | ||
196 | */ | ||
197 | void | ||
198 | print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x) | ||
199 | { | 56 | { |
200 | int newl, cur_x, cur_y; | 57 | struct gstr gs; |
201 | int i, prompt_len, room, wlen; | 58 | gs.s = malloc(sizeof(char) * 64); |
202 | char tempstr[MAX_LEN + 1], *word, *sp, *sp2; | 59 | gs.len = 16; |
203 | 60 | strcpy(gs.s, "\0"); | |
204 | strcpy (tempstr, prompt); | 61 | return gs; |
205 | |||
206 | prompt_len = strlen(tempstr); | ||
207 | |||
208 | /* | ||
209 | * Remove newlines | ||
210 | */ | ||
211 | for(i=0; i<prompt_len; i++) { | ||
212 | if(tempstr[i] == '\n') tempstr[i] = ' '; | ||
213 | } | ||
214 | |||
215 | if (prompt_len <= width - x * 2) { /* If prompt is short */ | ||
216 | wmove (win, y, (width - prompt_len) / 2); | ||
217 | waddstr (win, tempstr); | ||
218 | } else { | ||
219 | cur_x = x; | ||
220 | cur_y = y; | ||
221 | newl = 1; | ||
222 | word = tempstr; | ||
223 | while (word && *word) { | ||
224 | sp = index(word, ' '); | ||
225 | if (sp) | ||
226 | *sp++ = 0; | ||
227 | |||
228 | /* Wrap to next line if either the word does not fit, | ||
229 | or it is the first word of a new sentence, and it is | ||
230 | short, and the next word does not fit. */ | ||
231 | room = width - cur_x; | ||
232 | wlen = strlen(word); | ||
233 | if (wlen > room || | ||
234 | (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room | ||
235 | && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { | ||
236 | cur_y++; | ||
237 | cur_x = x; | ||
238 | } | ||
239 | wmove (win, cur_y, cur_x); | ||
240 | waddstr (win, word); | ||
241 | getyx (win, cur_y, cur_x); | ||
242 | cur_x++; | ||
243 | if (sp && *sp == ' ') { | ||
244 | cur_x++; /* double space */ | ||
245 | while (*++sp == ' '); | ||
246 | newl = 1; | ||
247 | } else | ||
248 | newl = 0; | ||
249 | word = sp; | ||
250 | } | ||
251 | } | ||
252 | } | 62 | } |
253 | 63 | ||
254 | /* | 64 | /* Allocate and assign growable string */ |
255 | * Print a button | 65 | struct gstr str_assign(const char *s) |
256 | */ | ||
257 | void | ||
258 | print_button (WINDOW * win, const char *label, int y, int x, int selected) | ||
259 | { | 66 | { |
260 | int i, temp; | 67 | struct gstr gs; |
261 | 68 | gs.s = strdup(s); | |
262 | wmove (win, y, x); | 69 | gs.len = strlen(s) + 1; |
263 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | 70 | return gs; |
264 | waddstr (win, "<"); | ||
265 | temp = strspn (label, " "); | ||
266 | label += temp; | ||
267 | wattrset (win, selected ? button_label_active_attr | ||
268 | : button_label_inactive_attr); | ||
269 | for (i = 0; i < temp; i++) | ||
270 | waddch (win, ' '); | ||
271 | wattrset (win, selected ? button_key_active_attr | ||
272 | : button_key_inactive_attr); | ||
273 | waddch (win, label[0]); | ||
274 | wattrset (win, selected ? button_label_active_attr | ||
275 | : button_label_inactive_attr); | ||
276 | waddstr (win, (char *)label + 1); | ||
277 | wattrset (win, selected ? button_active_attr : button_inactive_attr); | ||
278 | waddstr (win, ">"); | ||
279 | wmove (win, y, x + temp + 1); | ||
280 | } | 71 | } |
281 | 72 | ||
282 | /* | 73 | /* Free storage for growable string */ |
283 | * Draw a rectangular box with line drawing characters | 74 | void str_free(struct gstr *gs) |
284 | */ | ||
285 | void | ||
286 | draw_box (WINDOW * win, int y, int x, int height, int width, | ||
287 | chtype box, chtype border) | ||
288 | { | 75 | { |
289 | int i, j; | 76 | if (gs->s) |
290 | 77 | free(gs->s); | |
291 | wattrset (win, 0); | 78 | gs->s = NULL; |
292 | for (i = 0; i < height; i++) { | 79 | gs->len = 0; |
293 | wmove (win, y + i, x); | ||
294 | for (j = 0; j < width; j++) | ||
295 | if (!i && !j) | ||
296 | waddch (win, border | ACS_ULCORNER); | ||
297 | else if (i == height - 1 && !j) | ||
298 | waddch (win, border | ACS_LLCORNER); | ||
299 | else if (!i && j == width - 1) | ||
300 | waddch (win, box | ACS_URCORNER); | ||
301 | else if (i == height - 1 && j == width - 1) | ||
302 | waddch (win, box | ACS_LRCORNER); | ||
303 | else if (!i) | ||
304 | waddch (win, border | ACS_HLINE); | ||
305 | else if (i == height - 1) | ||
306 | waddch (win, box | ACS_HLINE); | ||
307 | else if (!j) | ||
308 | waddch (win, border | ACS_VLINE); | ||
309 | else if (j == width - 1) | ||
310 | waddch (win, box | ACS_VLINE); | ||
311 | else | ||
312 | waddch (win, box | ' '); | ||
313 | } | ||
314 | } | 80 | } |
315 | 81 | ||
316 | /* | 82 | /* Append to growable string */ |
317 | * Draw shadows along the right and bottom edge to give a more 3D look | 83 | void str_append(struct gstr *gs, const char *s) |
318 | * to the boxes | ||
319 | */ | ||
320 | void | ||
321 | draw_shadow (WINDOW * win, int y, int x, int height, int width) | ||
322 | { | 84 | { |
323 | int i; | 85 | size_t l = strlen(gs->s) + strlen(s) + 1; |
324 | 86 | if (l > gs->len) { | |
325 | if (has_colors ()) { /* Whether terminal supports color? */ | 87 | gs->s = realloc(gs->s, l); |
326 | wattrset (win, shadow_attr); | 88 | gs->len = l; |
327 | wmove (win, y + height, x + 2); | ||
328 | for (i = 0; i < width; i++) | ||
329 | waddch (win, winch (win) & A_CHARTEXT); | ||
330 | for (i = y + 1; i < y + height + 1; i++) { | ||
331 | wmove (win, i, x + width); | ||
332 | waddch (win, winch (win) & A_CHARTEXT); | ||
333 | waddch (win, winch (win) & A_CHARTEXT); | ||
334 | } | 89 | } |
335 | wnoutrefresh (win); | 90 | strcat(gs->s, s); |
336 | } | ||
337 | } | 91 | } |
338 | 92 | ||
339 | /* | 93 | /* Append printf formatted string to growable string */ |
340 | * Return the position of the first alphabetic character in a string. | 94 | void str_printf(struct gstr *gs, const char *fmt, ...) |
341 | */ | ||
342 | int | ||
343 | first_alpha(const char *string, const char *exempt) | ||
344 | { | 95 | { |
345 | int i, in_paren=0, c; | 96 | va_list ap; |
346 | 97 | char s[10000]; /* big enough... */ | |
347 | for (i = 0; i < strlen(string); i++) { | 98 | va_start(ap, fmt); |
348 | c = tolower(string[i]); | 99 | vsnprintf(s, sizeof(s), fmt, ap); |
349 | 100 | str_append(gs, s); | |
350 | if (strchr("<[(", c)) ++in_paren; | 101 | va_end(ap); |
351 | if (strchr(">])", c) && in_paren > 0) --in_paren; | ||
352 | |||
353 | if ((! in_paren) && isalpha(c) && | ||
354 | strchr(exempt, c) == 0) | ||
355 | return i; | ||
356 | } | ||
357 | |||
358 | return 0; | ||
359 | } | 102 | } |
360 | 103 | ||
361 | /* | 104 | /* Retreive value of growable string */ |
362 | * Get the first selected item in the dialog_list_item list. | 105 | const char *str_get(struct gstr *gs) |
363 | */ | ||
364 | struct dialog_list_item * | ||
365 | first_sel_item(int item_no, struct dialog_list_item ** items) | ||
366 | { | 106 | { |
367 | int i; | 107 | return gs->s; |
368 | |||
369 | for (i = 0; i < item_no; i++) { | ||
370 | if (items[i]->selected) | ||
371 | return items[i]; | ||
372 | } | ||
373 | |||
374 | return NULL; | ||
375 | } | 108 | } |
109 | |||
diff --git a/busybox/scripts/config/zconf.tab.c_shipped b/busybox/scripts/config/zconf.tab.c_shipped index a5f69a026..66982c1dd 100644 --- a/busybox/scripts/config/zconf.tab.c_shipped +++ b/busybox/scripts/config/zconf.tab.c_shipped | |||
@@ -175,6 +175,8 @@ static bool zconf_endtoken(int token, int starttoken, int endtoken); | |||
175 | 175 | ||
176 | struct symbol *symbol_hash[257]; | 176 | struct symbol *symbol_hash[257]; |
177 | 177 | ||
178 | static struct menu *current_menu, *current_entry; | ||
179 | |||
178 | #define YYERROR_VERBOSE | 180 | #define YYERROR_VERBOSE |
179 | 181 | ||
180 | 182 | ||
@@ -2119,6 +2121,7 @@ void zconfdump(FILE *out) | |||
2119 | } | 2121 | } |
2120 | 2122 | ||
2121 | #include "lex.zconf.c" | 2123 | #include "lex.zconf.c" |
2124 | #include "util.c" | ||
2122 | #include "confdata.c" | 2125 | #include "confdata.c" |
2123 | #include "expr.c" | 2126 | #include "expr.c" |
2124 | #include "symbol.c" | 2127 | #include "symbol.c" |
diff --git a/busybox/scripts/config/zconf.y b/busybox/scripts/config/zconf.y index 658495cda..5ebaf0a78 100644 --- a/busybox/scripts/config/zconf.y +++ b/busybox/scripts/config/zconf.y | |||
@@ -25,6 +25,8 @@ static bool zconf_endtoken(int token, int starttoken, int endtoken); | |||
25 | 25 | ||
26 | struct symbol *symbol_hash[257]; | 26 | struct symbol *symbol_hash[257]; |
27 | 27 | ||
28 | static struct menu *current_menu, *current_entry; | ||
29 | |||
28 | #define YYERROR_VERBOSE | 30 | #define YYERROR_VERBOSE |
29 | %} | 31 | %} |
30 | %expect 40 | 32 | %expect 40 |
@@ -681,6 +683,7 @@ void zconfdump(FILE *out) | |||
681 | } | 683 | } |
682 | 684 | ||
683 | #include "lex.zconf.c" | 685 | #include "lex.zconf.c" |
686 | #include "util.c" | ||
684 | #include "confdata.c" | 687 | #include "confdata.c" |
685 | #include "expr.c" | 688 | #include "expr.c" |
686 | #include "symbol.c" | 689 | #include "symbol.c" |
diff --git a/busybox/shell/lash.c b/busybox/shell/lash.c index f454e6990..c4655acd8 100644 --- a/busybox/shell/lash.c +++ b/busybox/shell/lash.c | |||
@@ -1277,11 +1277,17 @@ static int pseudo_exec(struct child_prog *child) | |||
1277 | name = child->argv[0]; | 1277 | name = child->argv[0]; |
1278 | 1278 | ||
1279 | { | 1279 | { |
1280 | char** argv_l=child->argv; | 1280 | char** argv_l=child->argv; |
1281 | int argc_l; | 1281 | int argc_l; |
1282 | for(argc_l=0;*argv_l!=NULL; argv_l++, argc_l++); | 1282 | #ifdef _NEWLIB_VERSION |
1283 | optind = 1; | 1283 | /* newlib uses __getopt_initialized for getopt() in |
1284 | run_applet_by_name(name, argc_l, child->argv); | 1284 | * addition to optind, see newlib/libc/sys/linux/getopt.c |
1285 | */ | ||
1286 | extern int __getopt_initialized = 0; | ||
1287 | #endif | ||
1288 | for(argc_l=0;*argv_l!=NULL; argv_l++, argc_l++); | ||
1289 | optind = 1; | ||
1290 | run_applet_by_name(name, argc_l, child->argv); | ||
1285 | } | 1291 | } |
1286 | #endif | 1292 | #endif |
1287 | 1293 | ||
diff --git a/busybox/sysdeps/linux/Config.in b/busybox/sysdeps/linux/Config.in index 744a84d18..0c10de928 100644 --- a/busybox/sysdeps/linux/Config.in +++ b/busybox/sysdeps/linux/Config.in | |||
@@ -94,14 +94,14 @@ config CONFIG_FEATURE_SUID | |||
94 | 94 | ||
95 | config CONFIG_FEATURE_SUID_CONFIG | 95 | config CONFIG_FEATURE_SUID_CONFIG |
96 | bool "Runtime SUID/SGID configuration via /etc/busybox.conf" | 96 | bool "Runtime SUID/SGID configuration via /etc/busybox.conf" |
97 | default y if CONFIG_FEATURE_SUID | 97 | default n if CONFIG_FEATURE_SUID |
98 | depends on CONFIG_FEATURE_SUID | 98 | depends on CONFIG_FEATURE_SUID |
99 | help | 99 | help |
100 | Allow the SUID / SGID state of an applet to be determined runtime by | 100 | Allow the SUID / SGID state of an applet to be determined runtime by |
101 | checking /etc/busybox.conf. The format of this file is as follows: | 101 | checking /etc/busybox.conf. The format of this file is as follows: |
102 | 102 | ||
103 | <applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>) | 103 | <applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>) |
104 | 104 | ||
105 | An example might help: | 105 | An example might help: |
106 | 106 | ||
107 | [SUID] | 107 | [SUID] |
@@ -113,6 +113,13 @@ config CONFIG_FEATURE_SUID_CONFIG | |||
113 | 113 | ||
114 | cp = --- # disable applet cp for everyone | 114 | cp = --- # disable applet cp for everyone |
115 | 115 | ||
116 | The file has to be owned by user root, group root and has to be | ||
117 | writeable only by root: | ||
118 | (chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf) | ||
119 | The busybox executable has to be owned by user root, group | ||
120 | root and has to be setuid root for this to work: | ||
121 | (chown 0.0 /bin/busybox; chmod 4755 /bin/busybox) | ||
122 | |||
116 | Robert 'sandman' Griebl has more information here: | 123 | Robert 'sandman' Griebl has more information here: |
117 | <url: http://www.softforge.de/bb/suid.html >. | 124 | <url: http://www.softforge.de/bb/suid.html >. |
118 | 125 | ||
diff --git a/busybox/sysklogd/Makefile b/busybox/sysklogd/Makefile index 78b0c0090..611f46b2d 100644 --- a/busybox/sysklogd/Makefile +++ b/busybox/sysklogd/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | # Makefile for busybox | 1 | # Makefile for busybox |
2 | # | 2 | # |
3 | # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | 3 | # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> |
4 | # | 4 | # |
5 | # This program is free software; you can redistribute it and/or modify | 5 | # This program is free software; you can redistribute it and/or modify |
6 | # it under the terms of the GNU General Public License as published by | 6 | # it under the terms of the GNU General Public License as published by |
@@ -18,7 +18,7 @@ | |||
18 | # | 18 | # |
19 | 19 | ||
20 | top_srcdir=.. | 20 | top_srcdir=.. |
21 | top_buildddir=.. | 21 | top_builddir=.. |
22 | srcdir=$(top_srcdir)/sysklogd | 22 | srcdir=$(top_srcdir)/sysklogd |
23 | SYSKLOGD_DIR:=./ | 23 | SYSKLOGD_DIR:=./ |
24 | include $(top_builddir)/Rules.mak | 24 | include $(top_builddir)/Rules.mak |
@@ -29,4 +29,3 @@ all: $(libraries-y) | |||
29 | 29 | ||
30 | clean: | 30 | clean: |
31 | rm -f *.o *.a $(AR_TARGET) | 31 | rm -f *.o *.a $(AR_TARGET) |
32 | |||
diff --git a/busybox/sysklogd/logger.c b/busybox/sysklogd/logger.c index 16155316f..fee33b788 100644 --- a/busybox/sysklogd/logger.c +++ b/busybox/sysklogd/logger.c | |||
@@ -127,7 +127,7 @@ extern int logger_main(int argc, char **argv) | |||
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | openlog(name, option, (pri | LOG_FACMASK)); | 130 | openlog(name, option, 0); |
131 | if (optind == argc) { | 131 | if (optind == argc) { |
132 | do { | 132 | do { |
133 | /* read from stdin */ | 133 | /* read from stdin */ |
@@ -152,8 +152,8 @@ extern int logger_main(int argc, char **argv) | |||
152 | message = xrealloc(message, len); | 152 | message = xrealloc(message, len); |
153 | if(!i) | 153 | if(!i) |
154 | message[0] = 0; | 154 | message[0] = 0; |
155 | else | 155 | else |
156 | strcat(message, " "); | 156 | strcat(message, " "); |
157 | strcat(message, *argv); | 157 | strcat(message, *argv); |
158 | argv++; | 158 | argv++; |
159 | } | 159 | } |
diff --git a/busybox/util-linux/Config.in b/busybox/util-linux/Config.in index 24d548726..db7c8bd7d 100644 --- a/busybox/util-linux/Config.in +++ b/busybox/util-linux/Config.in | |||
@@ -221,6 +221,7 @@ config CONFIG_LOSETUP | |||
221 | config CONFIG_MKSWAP | 221 | config CONFIG_MKSWAP |
222 | bool "mkswap" | 222 | bool "mkswap" |
223 | default n | 223 | default n |
224 | select CONFIG_FEATURE_SUID | ||
224 | help | 225 | help |
225 | The mkswap utility is used to configure a file or disk partition as | 226 | The mkswap utility is used to configure a file or disk partition as |
226 | Linux swap space. This allows Linux to use the entire file or | 227 | Linux swap space. This allows Linux to use the entire file or |
@@ -234,6 +235,7 @@ config CONFIG_MKSWAP | |||
234 | config CONFIG_MORE | 235 | config CONFIG_MORE |
235 | bool "more" | 236 | bool "more" |
236 | default n | 237 | default n |
238 | select CONFIG_FEATURE_SUID | ||
237 | help | 239 | help |
238 | more is a simple utility which allows you to read text one screen | 240 | more is a simple utility which allows you to read text one screen |
239 | sized page at a time. If you want to read text that is larger than | 241 | sized page at a time. If you want to read text that is larger than |
diff --git a/busybox/util-linux/Makefile b/busybox/util-linux/Makefile index 4401fd1ed..efcf6e3bb 100644 --- a/busybox/util-linux/Makefile +++ b/busybox/util-linux/Makefile | |||
@@ -1,6 +1,6 @@ | |||
1 | # Makefile for busybox | 1 | # Makefile for busybox |
2 | # | 2 | # |
3 | # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | 3 | # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org> |
4 | # | 4 | # |
5 | # This program is free software; you can redistribute it and/or modify | 5 | # This program is free software; you can redistribute it and/or modify |
6 | # it under the terms of the GNU General Public License as published by | 6 | # it under the terms of the GNU General Public License as published by |
@@ -18,7 +18,7 @@ | |||
18 | # | 18 | # |
19 | 19 | ||
20 | top_srcdir=.. | 20 | top_srcdir=.. |
21 | top_buildddir=.. | 21 | top_builddir=.. |
22 | srcdir=$(top_srcdir)/util-linux | 22 | srcdir=$(top_srcdir)/util-linux |
23 | UTILLINUX_DIR:=./ | 23 | UTILLINUX_DIR:=./ |
24 | include $(top_builddir)/Rules.mak | 24 | include $(top_builddir)/Rules.mak |
@@ -29,4 +29,3 @@ all: $(libraries-y) | |||
29 | 29 | ||
30 | clean: | 30 | clean: |
31 | rm -f *.o *.a $(AR_TARGET) | 31 | rm -f *.o *.a $(AR_TARGET) |
32 | |||
diff --git a/busybox/util-linux/hwclock.c b/busybox/util-linux/hwclock.c index a260d7448..3c2683953 100644 --- a/busybox/util-linux/hwclock.c +++ b/busybox/util-linux/hwclock.c | |||
@@ -46,7 +46,7 @@ struct linux_rtc_time { | |||
46 | int tm_yday; | 46 | int tm_yday; |
47 | int tm_isdst; | 47 | int tm_isdst; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | #define RTC_SET_TIME _IOW('p', 0x0a, struct linux_rtc_time) /* Set RTC time */ | 50 | #define RTC_SET_TIME _IOW('p', 0x0a, struct linux_rtc_time) /* Set RTC time */ |
51 | #define RTC_RD_TIME _IOR('p', 0x09, struct linux_rtc_time) /* Read RTC time */ | 51 | #define RTC_RD_TIME _IOR('p', 0x09, struct linux_rtc_time) /* Read RTC time */ |
52 | 52 | ||
@@ -182,11 +182,11 @@ static int check_utc(void) | |||
182 | return utc; | 182 | return utc; |
183 | } | 183 | } |
184 | 184 | ||
185 | #define HWCLOCK_OPT_LOCALTIME 1 | 185 | #define HWCLOCK_OPT_LOCALTIME 0x01 |
186 | #define HWCLOCK_OPT_UTC 2 | 186 | #define HWCLOCK_OPT_UTC 0x02 |
187 | #define HWCLOCK_OPT_SHOW 4 | 187 | #define HWCLOCK_OPT_SHOW 0x04 |
188 | #define HWCLOCK_OPT_HCTOSYS 8 | 188 | #define HWCLOCK_OPT_HCTOSYS 0x08 |
189 | #define HWCLOCK_OPT_SYSTOHC 16 | 189 | #define HWCLOCK_OPT_SYSTOHC 0x10 |
190 | 190 | ||
191 | extern int hwclock_main ( int argc, char **argv ) | 191 | extern int hwclock_main ( int argc, char **argv ) |
192 | { | 192 | { |
@@ -208,16 +208,16 @@ static const struct option hwclock_long_options[] = { | |||
208 | bb_opt_complementaly = "r~ws:w~rs:s~wr:l~u:u~l"; | 208 | bb_opt_complementaly = "r~ws:w~rs:s~wr:l~u:u~l"; |
209 | opt = bb_getopt_ulflags(argc, argv, "lursw"); | 209 | opt = bb_getopt_ulflags(argc, argv, "lursw"); |
210 | /* Check only one mode was given */ | 210 | /* Check only one mode was given */ |
211 | if(opt & 0x80000000UL) { | 211 | if(opt & BB_GETOPT_ERROR) { |
212 | bb_show_usage(); | 212 | bb_show_usage(); |
213 | } | 213 | } |
214 | 214 | ||
215 | /* If -u or -l wasn't given check if we are using utc */ | 215 | /* If -u or -l wasn't given check if we are using utc */ |
216 | if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) | 216 | if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) |
217 | utc = opt & HWCLOCK_OPT_UTC; | 217 | utc = opt & HWCLOCK_OPT_UTC; |
218 | else | 218 | else |
219 | utc = check_utc(); | 219 | utc = check_utc(); |
220 | 220 | ||
221 | if (opt & HWCLOCK_OPT_HCTOSYS) { | 221 | if (opt & HWCLOCK_OPT_HCTOSYS) { |
222 | return to_sys_clock ( utc ); | 222 | return to_sys_clock ( utc ); |
223 | } | 223 | } |