diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-09-20 19:22:26 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-09-20 19:22:26 +0000 |
commit | cff3fe3ae9696584f0c4bdad6860e8d94d5e99f9 (patch) | |
tree | 11ccadd6495c9e4fbd920896e94935551af4c14d | |
parent | 0cccdfaf363171c9f0761fbdb2028db0ea73e6b5 (diff) | |
download | busybox-w32-cff3fe3ae9696584f0c4bdad6860e8d94d5e99f9.tar.gz busybox-w32-cff3fe3ae9696584f0c4bdad6860e8d94d5e99f9.tar.bz2 busybox-w32-cff3fe3ae9696584f0c4bdad6860e8d94d5e99f9.zip |
Added dos2unix, unix2dos, and unrpm.c thanks to robotti@metconnect.com.
-Erik
-rw-r--r-- | Changelog | 1 | ||||
-rw-r--r-- | applets/busybox.c | 9 | ||||
-rw-r--r-- | applets/usage.c | 27 | ||||
-rw-r--r-- | busybox.c | 9 | ||||
-rw-r--r-- | busybox.def.h | 7 | ||||
-rw-r--r-- | coreutils/dos2unix.c | 45 | ||||
-rw-r--r-- | docs/busybox.pod | 47 | ||||
-rw-r--r-- | docs/busybox.sgml | 42 | ||||
-rw-r--r-- | dos2unix.c | 45 | ||||
-rw-r--r-- | internal.h | 12 | ||||
-rw-r--r-- | unix2dos.c | 49 | ||||
-rw-r--r-- | unrpm.c | 140 | ||||
-rw-r--r-- | usage.c | 27 |
13 files changed, 442 insertions, 18 deletions
@@ -20,6 +20,7 @@ | |||
20 | * Added 'getopt' from "Alfred M. Szmidt" <ams@trillian.itslinux.org> | 20 | * Added 'getopt' from "Alfred M. Szmidt" <ams@trillian.itslinux.org> |
21 | * Fixed chmod option parsing so things like 'chmod -r /tmp/file' | 21 | * Fixed chmod option parsing so things like 'chmod -r /tmp/file' |
22 | wouldn't work (since it thought -r was an option). Doh! | 22 | wouldn't work (since it thought -r was an option). Doh! |
23 | * Added dos2unix, unix2dos, and unrpm.c thanks to robotti@metconnect.com. | ||
23 | 24 | ||
24 | 25 | ||
25 | 26 | ||
diff --git a/applets/busybox.c b/applets/busybox.c index a7c5d37a0..43871b781 100644 --- a/applets/busybox.c +++ b/applets/busybox.c | |||
@@ -64,6 +64,9 @@ const struct BB_applet applets[] = { | |||
64 | #ifdef BB_DMESG | 64 | #ifdef BB_DMESG |
65 | {"dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage}, | 65 | {"dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage}, |
66 | #endif | 66 | #endif |
67 | #ifdef BB_DOS2UNIX | ||
68 | {"dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage}, | ||
69 | #endif | ||
67 | #ifdef BB_DU | 70 | #ifdef BB_DU |
68 | {"du", du_main, _BB_DIR_USR_BIN, du_usage}, | 71 | {"du", du_main, _BB_DIR_USR_BIN, du_usage}, |
69 | #endif | 72 | #endif |
@@ -313,6 +316,12 @@ const struct BB_applet applets[] = { | |||
313 | #ifdef BB_UNIQ | 316 | #ifdef BB_UNIQ |
314 | {"uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage}, | 317 | {"uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage}, |
315 | #endif | 318 | #endif |
319 | #ifdef BB_UNIX2DOS | ||
320 | {"unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage}, | ||
321 | #endif | ||
322 | #ifdef BB_UNRPM | ||
323 | {"unrpm", unrpm_main, _BB_DIR_USR_BIN, unrpm_usage}, | ||
324 | #endif | ||
316 | #ifdef BB_UPDATE | 325 | #ifdef BB_UPDATE |
317 | {"update", update_main, _BB_DIR_SBIN, update_usage}, | 326 | {"update", update_main, _BB_DIR_SBIN, update_usage}, |
318 | #endif | 327 | #endif |
diff --git a/applets/usage.c b/applets/usage.c index cee270220..4a3d7346a 100644 --- a/applets/usage.c +++ b/applets/usage.c | |||
@@ -207,6 +207,15 @@ const char dmesg_usage[] = | |||
207 | ; | 207 | ; |
208 | #endif | 208 | #endif |
209 | 209 | ||
210 | #if defined BB_DOS2UNIX | ||
211 | const char dos2unix_usage[] = | ||
212 | "dos2unix < dosfile > unixfile\n" | ||
213 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
214 | "\nConverts a text file from dos format to unix format.\n" | ||
215 | #endif | ||
216 | ; | ||
217 | #endif | ||
218 | |||
210 | #if defined BB_DU | 219 | #if defined BB_DU |
211 | const char du_usage[] = | 220 | const char du_usage[] = |
212 | "du [OPTION]... [FILE]...\n" | 221 | "du [OPTION]... [FILE]...\n" |
@@ -1307,6 +1316,24 @@ const char uniq_usage[] = | |||
1307 | ; | 1316 | ; |
1308 | #endif | 1317 | #endif |
1309 | 1318 | ||
1319 | #if defined BB_UNIX2DOS | ||
1320 | const char unix2dos_usage[] = | ||
1321 | "unix2dos < unixfile > dosfile\n" | ||
1322 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
1323 | "\nConverts a text file from unix format to dos format.\n" | ||
1324 | #endif | ||
1325 | ; | ||
1326 | #endif | ||
1327 | |||
1328 | #if defined BB_UNRPM | ||
1329 | const char unrpm_usage[] = | ||
1330 | "unrpm < package.rpm | gzip -d | cpio -idmuv\n" | ||
1331 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
1332 | "\nExtracts an rpm archive.\n" | ||
1333 | #endif | ||
1334 | ; | ||
1335 | #endif | ||
1336 | |||
1310 | #if defined BB_UPDATE | 1337 | #if defined BB_UPDATE |
1311 | const char update_usage[] = | 1338 | const char update_usage[] = |
1312 | "update [options]\n" | 1339 | "update [options]\n" |
@@ -64,6 +64,9 @@ const struct BB_applet applets[] = { | |||
64 | #ifdef BB_DMESG | 64 | #ifdef BB_DMESG |
65 | {"dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage}, | 65 | {"dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage}, |
66 | #endif | 66 | #endif |
67 | #ifdef BB_DOS2UNIX | ||
68 | {"dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage}, | ||
69 | #endif | ||
67 | #ifdef BB_DU | 70 | #ifdef BB_DU |
68 | {"du", du_main, _BB_DIR_USR_BIN, du_usage}, | 71 | {"du", du_main, _BB_DIR_USR_BIN, du_usage}, |
69 | #endif | 72 | #endif |
@@ -313,6 +316,12 @@ const struct BB_applet applets[] = { | |||
313 | #ifdef BB_UNIQ | 316 | #ifdef BB_UNIQ |
314 | {"uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage}, | 317 | {"uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage}, |
315 | #endif | 318 | #endif |
319 | #ifdef BB_UNIX2DOS | ||
320 | {"unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage}, | ||
321 | #endif | ||
322 | #ifdef BB_UNRPM | ||
323 | {"unrpm", unrpm_main, _BB_DIR_USR_BIN, unrpm_usage}, | ||
324 | #endif | ||
316 | #ifdef BB_UPDATE | 325 | #ifdef BB_UPDATE |
317 | {"update", update_main, _BB_DIR_SBIN, update_usage}, | 326 | {"update", update_main, _BB_DIR_SBIN, update_usage}, |
318 | #endif | 327 | #endif |
diff --git a/busybox.def.h b/busybox.def.h index c70948d06..9d046ab73 100644 --- a/busybox.def.h +++ b/busybox.def.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #define BB_DF | 23 | #define BB_DF |
24 | #define BB_DIRNAME | 24 | #define BB_DIRNAME |
25 | #define BB_DMESG | 25 | #define BB_DMESG |
26 | #define BB_DOS2UNIX | ||
26 | #define BB_DUTMP | 27 | #define BB_DUTMP |
27 | #define BB_DU | 28 | #define BB_DU |
28 | #define BB_DUMPKMAP | 29 | #define BB_DUMPKMAP |
@@ -98,6 +99,7 @@ | |||
98 | #define BB_TR | 99 | #define BB_TR |
99 | #define BB_TRUE_FALSE | 100 | #define BB_TRUE_FALSE |
100 | #define BB_TTY | 101 | #define BB_TTY |
102 | #define BB_UNRPM | ||
101 | #define BB_UPTIME | 103 | #define BB_UPTIME |
102 | #define BB_USLEEP | 104 | #define BB_USLEEP |
103 | #define BB_WC | 105 | #define BB_WC |
@@ -109,6 +111,7 @@ | |||
109 | #define BB_UMOUNT | 111 | #define BB_UMOUNT |
110 | #define BB_UNIQ | 112 | #define BB_UNIQ |
111 | #define BB_UNAME | 113 | #define BB_UNAME |
114 | #define BB_UNIX2DOS | ||
112 | #define BB_UPDATE | 115 | #define BB_UPDATE |
113 | #define BB_YES | 116 | #define BB_YES |
114 | // End of Applications List | 117 | // End of Applications List |
@@ -173,7 +176,7 @@ | |||
173 | #define BB_FEATURE_USE_INITTAB | 176 | #define BB_FEATURE_USE_INITTAB |
174 | // | 177 | // |
175 | //Enable init being called as /linuxrc | 178 | //Enable init being called as /linuxrc |
176 | //#define BB_FEATURE_LINUXRC | 179 | #define BB_FEATURE_LINUXRC |
177 | // | 180 | // |
178 | //Have init enable core dumping for child processes (for debugging only) | 181 | //Have init enable core dumping for child processes (for debugging only) |
179 | //#define BB_FEATURE_INIT_COREDUMPS | 182 | //#define BB_FEATURE_INIT_COREDUMPS |
@@ -203,7 +206,7 @@ | |||
203 | //#define BB_FEATURE_MOUNT_MTAB_SUPPORT | 206 | //#define BB_FEATURE_MOUNT_MTAB_SUPPORT |
204 | // | 207 | // |
205 | // Enable support for mounting remote NFS volumes | 208 | // Enable support for mounting remote NFS volumes |
206 | //#define BB_FEATURE_NFSMOUNT | 209 | #define BB_FEATURE_NFSMOUNT |
207 | // | 210 | // |
208 | // Enable support forced filesystem unmounting | 211 | // Enable support forced filesystem unmounting |
209 | // (i.e. in case of an unreachable NFS system). | 212 | // (i.e. in case of an unreachable NFS system). |
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c new file mode 100644 index 000000000..9634687eb --- /dev/null +++ b/coreutils/dos2unix.c | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | Mini dos2unix implementation for busybox | ||
3 | |||
4 | Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA | ||
5 | All rights reserved. | ||
6 | |||
7 | Redistribution and use of this source code, with or without modification, is | ||
8 | permitted provided that the following condition is met: | ||
9 | |||
10 | 1. Redistributions of this source code must retain the above copyright | ||
11 | notice, this condition, and the following disclaimer. | ||
12 | |||
13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
15 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
16 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
17 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
18 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
19 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
20 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
21 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
22 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | |||
25 | #include "internal.h" | ||
26 | #include <stdio.h> | ||
27 | |||
28 | int dos2unix_main( int argc, char **argv ) { | ||
29 | int c; | ||
30 | if (argc > 1) { | ||
31 | c = *argv[1]; | ||
32 | if (c == '-') { | ||
33 | usage(dos2unix_usage); | ||
34 | } | ||
35 | } | ||
36 | c = getchar(); | ||
37 | while (c != EOF) { | ||
38 | /* Eat any \r's... they shouldn't be here */ | ||
39 | while (c == '\r') c = getchar(); | ||
40 | if (c == EOF) break; | ||
41 | putchar(c); | ||
42 | c = getchar(); | ||
43 | } | ||
44 | return 0; | ||
45 | } | ||
diff --git a/docs/busybox.pod b/docs/busybox.pod index fed8b57a6..5fd15cab5 100644 --- a/docs/busybox.pod +++ b/docs/busybox.pod | |||
@@ -55,16 +55,17 @@ terse runtime description of their behavior. | |||
55 | 55 | ||
56 | Currently defined functions include: | 56 | Currently defined functions include: |
57 | 57 | ||
58 | ar, basename, cat, chgrp, chmod, chown, chroot, chvt, clear, cp, cut, date, | 58 | ar, basename, cat, chgrp, chmod, chown, chroot, chvt, clear, cp, cut, date, dc, |
59 | dc, dd, deallocvt, df, dirname, dmesg, du, dumpkmap, dutmp, echo, false, fbset, | 59 | dd, deallocvt, df, dirname, dmesg, dos2unix, du, dumpkmap, dutmp, echo, false, |
60 | fdflush, find, free, freeramdisk, fsck.minix, getopt, grep, gunzip, gzip, halt, | 60 | fbset, fdflush, find, free, freeramdisk, fsck.minix, getopt, grep, gunzip, |
61 | head, hostid, hostname, id, init, insmod, kill, killall, length, ln, | 61 | gzip, halt, head, hostid, hostname, id, init, insmod, kill, killall, length, |
62 | loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, mkdir, | 62 | ln, loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, mkdir, |
63 | mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, | 63 | mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, nslookup, |
64 | nslookup, ping, poweroff, printf, ps, pwd, rdate, reboot, renice, reset, rm, rmdir, rmmod, sed, | 64 | ping, poweroff, printf, ps, pwd, rdate, reboot, renice, reset, rm, rmdir, |
65 | setkeycodes, sh, sleep, sort, swapoff, swapon, sync, syslogd, tail, | 65 | rmmod, sed, setkeycodes, sh, sleep, sort, swapoff, swapon, sync, syslogd, tail, |
66 | tar, tee, telnet, test, touch, tr, true, tty, umount, uname, uniq, update, | 66 | tar, tee, telnet, test, touch, tr, true, tty, umount, uname, uniq, unix2dos, |
67 | uptime, usleep, uudecode, uuencode, wc, which, whoami, yes, zcat, [ | 67 | unrpm, update, uptime, usleep, uudecode, uuencode, wc, which, whoami, yes, |
68 | zcat, [ | ||
68 | 69 | ||
69 | ------------------------------- | 70 | ------------------------------- |
70 | 71 | ||
@@ -412,6 +413,14 @@ Print or controls the kernel ring buffer. | |||
412 | 413 | ||
413 | ------------------------------- | 414 | ------------------------------- |
414 | 415 | ||
416 | =item dos2unix | ||
417 | |||
418 | Usage: dos2unix < dosfile > unixfile | ||
419 | |||
420 | Converts a text file from dos format to unix format. | ||
421 | |||
422 | ------------------------------- | ||
423 | |||
415 | =item du | 424 | =item du |
416 | 425 | ||
417 | Usage: du [OPTION]... [FILE]... | 426 | Usage: du [OPTION]... [FILE]... |
@@ -1929,6 +1938,22 @@ Example: | |||
1929 | 1938 | ||
1930 | ------------------------------- | 1939 | ------------------------------- |
1931 | 1940 | ||
1941 | =item unix2dos | ||
1942 | |||
1943 | Usage: unix2dos < unixfile > dosfile | ||
1944 | |||
1945 | Converts a text file from unix format to dos format. | ||
1946 | |||
1947 | ------------------------------- | ||
1948 | |||
1949 | =item unrpm | ||
1950 | |||
1951 | Usage: unrpm < package.rpm | gzip -d | cpio -idmuv | ||
1952 | |||
1953 | Extracts an rpm archive. | ||
1954 | |||
1955 | ------------------------------- | ||
1956 | |||
1932 | =item update | 1957 | =item update |
1933 | 1958 | ||
1934 | Usage: update [options] | 1959 | Usage: update [options] |
@@ -2157,4 +2182,4 @@ Enrique Zanardi <ezanardi@ull.es> | |||
2157 | 2182 | ||
2158 | =cut | 2183 | =cut |
2159 | 2184 | ||
2160 | # $Id: busybox.pod,v 1.68 2000/09/15 17:24:13 proski Exp $ | 2185 | # $Id: busybox.pod,v 1.69 2000/09/20 19:22:26 andersen Exp $ |
diff --git a/docs/busybox.sgml b/docs/busybox.sgml index f4161f59e..e8a91fa05 100644 --- a/docs/busybox.sgml +++ b/docs/busybox.sgml | |||
@@ -1,5 +1,4 @@ | |||
1 | <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [ | 1 | <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [ ]> |
2 | ]> | ||
3 | <book id="BusyBoxDocumentation"> | 2 | <book id="BusyBoxDocumentation"> |
4 | <bookinfo> | 3 | <bookinfo> |
5 | <title>BusyBox - The Swiss Army Knife of Embedded Linux</title> | 4 | <title>BusyBox - The Swiss Army Knife of Embedded Linux</title> |
@@ -746,6 +745,19 @@ | |||
746 | </para> | 745 | </para> |
747 | </sect1> | 746 | </sect1> |
748 | 747 | ||
748 | <sect1 id="dos2unix"> | ||
749 | <title>dos2unix</title> | ||
750 | |||
751 | <para> | ||
752 | Usage: dos2unix < dosfile > unixfile | ||
753 | </para> | ||
754 | |||
755 | <para> | ||
756 | Converts a text file from dos format to unix format. | ||
757 | </para> | ||
758 | |||
759 | </sect1> | ||
760 | |||
749 | <sect1 id="du"> | 761 | <sect1 id="du"> |
750 | <title>du</title> | 762 | <title>du</title> |
751 | 763 | ||
@@ -3394,6 +3406,32 @@ | |||
3394 | </screen> | 3406 | </screen> |
3395 | </para> | 3407 | </para> |
3396 | </sect1> | 3408 | </sect1> |
3409 | |||
3410 | <sect1 id="unix2dos"> | ||
3411 | <title>unix2dos</title> | ||
3412 | |||
3413 | <para> | ||
3414 | Usage: unix2dos < unixfile > dosfile | ||
3415 | </para> | ||
3416 | |||
3417 | <para> | ||
3418 | Converts a text file from unix format to dos format. | ||
3419 | </para> | ||
3420 | |||
3421 | </sect1> | ||
3422 | |||
3423 | <sect1 id="unrpm"> | ||
3424 | <titleunrpmuniq</title> | ||
3425 | |||
3426 | <para> | ||
3427 | Usage: unrpm < package.rpm | gzip -d | cpio -idmuv | ||
3428 | </para> | ||
3429 | |||
3430 | <para> | ||
3431 | Extracts an rpm archive. | ||
3432 | </para> | ||
3433 | |||
3434 | </sect1> | ||
3397 | 3435 | ||
3398 | <sect1 id="update"> | 3436 | <sect1 id="update"> |
3399 | <title>update</title> | 3437 | <title>update</title> |
diff --git a/dos2unix.c b/dos2unix.c new file mode 100644 index 000000000..9634687eb --- /dev/null +++ b/dos2unix.c | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | Mini dos2unix implementation for busybox | ||
3 | |||
4 | Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA | ||
5 | All rights reserved. | ||
6 | |||
7 | Redistribution and use of this source code, with or without modification, is | ||
8 | permitted provided that the following condition is met: | ||
9 | |||
10 | 1. Redistributions of this source code must retain the above copyright | ||
11 | notice, this condition, and the following disclaimer. | ||
12 | |||
13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
15 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
16 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
17 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
18 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
19 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
20 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
21 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
22 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | |||
25 | #include "internal.h" | ||
26 | #include <stdio.h> | ||
27 | |||
28 | int dos2unix_main( int argc, char **argv ) { | ||
29 | int c; | ||
30 | if (argc > 1) { | ||
31 | c = *argv[1]; | ||
32 | if (c == '-') { | ||
33 | usage(dos2unix_usage); | ||
34 | } | ||
35 | } | ||
36 | c = getchar(); | ||
37 | while (c != EOF) { | ||
38 | /* Eat any \r's... they shouldn't be here */ | ||
39 | while (c == '\r') c = getchar(); | ||
40 | if (c == EOF) break; | ||
41 | putchar(c); | ||
42 | c = getchar(); | ||
43 | } | ||
44 | return 0; | ||
45 | } | ||
diff --git a/internal.h b/internal.h index b2034da5e..8d8e8ab77 100644 --- a/internal.h +++ b/internal.h | |||
@@ -126,6 +126,7 @@ extern int dirname_main(int argc, char** argv); | |||
126 | extern int deallocvt_main(int argc, char** argv); | 126 | extern int deallocvt_main(int argc, char** argv); |
127 | extern int df_main(int argc, char** argv); | 127 | extern int df_main(int argc, char** argv); |
128 | extern int dmesg_main(int argc, char** argv); | 128 | extern int dmesg_main(int argc, char** argv); |
129 | extern int dos2unix_main(int argc, char** argv); | ||
129 | extern int du_main(int argc, char** argv); | 130 | extern int du_main(int argc, char** argv); |
130 | extern int dumpkmap_main(int argc, char** argv); | 131 | extern int dumpkmap_main(int argc, char** argv); |
131 | extern int dutmp_main(int argc, char** argv); | 132 | extern int dutmp_main(int argc, char** argv); |
@@ -206,14 +207,16 @@ extern int true_main(int argc, char** argv); | |||
206 | extern int tput_main(int argc, char** argv); | 207 | extern int tput_main(int argc, char** argv); |
207 | extern int tryopen_main(int argc, char** argv); | 208 | extern int tryopen_main(int argc, char** argv); |
208 | extern int tty_main(int argc, char** argv); | 209 | extern int tty_main(int argc, char** argv); |
209 | extern int uuencode_main(int argc, char** argv); | ||
210 | extern int uudecode_main(int argc, char** argv); | ||
211 | extern int umount_main(int argc, char** argv); | 210 | extern int umount_main(int argc, char** argv); |
212 | extern int uname_main(int argc, char** argv); | 211 | extern int uname_main(int argc, char** argv); |
213 | extern int uptime_main(int argc, char** argv); | ||
214 | extern int uniq_main(int argc, char** argv); | 212 | extern int uniq_main(int argc, char** argv); |
213 | extern int unix2dos_main(int argc, char** argv); | ||
214 | extern int unrpm_main(int argc, char** argv); | ||
215 | extern int update_main(int argc, char** argv); | 215 | extern int update_main(int argc, char** argv); |
216 | extern int uptime_main(int argc, char** argv); | ||
216 | extern int usleep_main(int argc, char** argv); | 217 | extern int usleep_main(int argc, char** argv); |
218 | extern int uuencode_main(int argc, char** argv); | ||
219 | extern int uudecode_main(int argc, char** argv); | ||
217 | extern int wc_main(int argc, char** argv); | 220 | extern int wc_main(int argc, char** argv); |
218 | extern int wget_main(int argc, char** argv); | 221 | extern int wget_main(int argc, char** argv); |
219 | extern int which_main(int argc, char** argv); | 222 | extern int which_main(int argc, char** argv); |
@@ -238,6 +241,7 @@ extern const char deallocvt_usage[]; | |||
238 | extern const char df_usage[]; | 241 | extern const char df_usage[]; |
239 | extern const char dirname_usage[]; | 242 | extern const char dirname_usage[]; |
240 | extern const char dmesg_usage[]; | 243 | extern const char dmesg_usage[]; |
244 | extern const char dos2unix_usage[]; | ||
241 | extern const char du_usage[]; | 245 | extern const char du_usage[]; |
242 | extern const char dumpkmap_usage[]; | 246 | extern const char dumpkmap_usage[]; |
243 | extern const char dutmp_usage[]; | 247 | extern const char dutmp_usage[]; |
@@ -316,6 +320,8 @@ extern const char tty_usage[]; | |||
316 | extern const char umount_usage[]; | 320 | extern const char umount_usage[]; |
317 | extern const char uname_usage[]; | 321 | extern const char uname_usage[]; |
318 | extern const char uniq_usage[]; | 322 | extern const char uniq_usage[]; |
323 | extern const char unix2dos_usage[]; | ||
324 | extern const char unrpm_usage[]; | ||
319 | extern const char update_usage[]; | 325 | extern const char update_usage[]; |
320 | extern const char uptime_usage[]; | 326 | extern const char uptime_usage[]; |
321 | extern const char usleep_usage[]; | 327 | extern const char usleep_usage[]; |
diff --git a/unix2dos.c b/unix2dos.c new file mode 100644 index 000000000..c6cf81bb0 --- /dev/null +++ b/unix2dos.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | Mini unix2dos implementation for busybox | ||
3 | |||
4 | Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA | ||
5 | All rights reserved. | ||
6 | |||
7 | Redistribution and use of this source code, with or without modification, is | ||
8 | permitted provided that the following condition is met: | ||
9 | |||
10 | 1. Redistributions of this source code must retain the above copyright | ||
11 | notice, this condition, and the following disclaimer. | ||
12 | |||
13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
15 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
16 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
17 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
18 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
19 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
20 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
21 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
22 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
23 | */ | ||
24 | |||
25 | #include "internal.h" | ||
26 | #include <stdio.h> | ||
27 | |||
28 | int unix2dos_main( int argc, char **argv ) { | ||
29 | int c; | ||
30 | if (argc > 1) { | ||
31 | c = *argv[1]; | ||
32 | if (c == '-') { | ||
33 | usage(unix2dos_usage); | ||
34 | } | ||
35 | } | ||
36 | c = getchar(); | ||
37 | while (c != EOF) { | ||
38 | /* Eat any \r's... they shouldn't be here */ | ||
39 | while (c == '\r') c = getchar(); | ||
40 | if (c == EOF) break; | ||
41 | if (c != '\n') { | ||
42 | putchar(c); | ||
43 | } else { | ||
44 | printf("\r\n"); | ||
45 | } | ||
46 | c = getchar(); | ||
47 | } | ||
48 | return 0; | ||
49 | } | ||
diff --git a/unrpm.c b/unrpm.c new file mode 100644 index 000000000..cfcc0d1ee --- /dev/null +++ b/unrpm.c | |||
@@ -0,0 +1,140 @@ | |||
1 | /* | ||
2 | * Mini unrpm implementation for busybox | ||
3 | * | ||
4 | * rpmunpack.c - Utility program to unpack an RPM archive | ||
5 | * | ||
6 | * Gero Kuhlmann <gero@gkminix.han.de> 1998 | ||
7 | * | ||
8 | * This program is public domain software; you can do whatever you like | ||
9 | * with this source, including modifying and redistributing it. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
14 | */ | ||
15 | |||
16 | #include "internal.h" | ||
17 | #include <unistd.h> | ||
18 | #include <stdio.h> | ||
19 | #include <stdlib.h> | ||
20 | #include <fcntl.h> | ||
21 | #include <string.h> | ||
22 | |||
23 | /* | ||
24 | * Some general definitions | ||
25 | */ | ||
26 | #define BUFSIZE 512 | ||
27 | #define RPM_MAGIC "\355\253\356\333" | ||
28 | #define GZ_MAGIC_1 '\037' | ||
29 | #define GZ_MAGIC_2 '\213' | ||
30 | |||
31 | /* | ||
32 | * Global variables | ||
33 | */ | ||
34 | static char buffer[BUFSIZE]; | ||
35 | static char *progname; | ||
36 | static int infile, outfile; | ||
37 | |||
38 | /* | ||
39 | * Read a specified number of bytes from input file | ||
40 | */ | ||
41 | static void myread(int num) | ||
42 | { | ||
43 | int err; | ||
44 | |||
45 | if ((err = read(infile, buffer, num)) != num) { | ||
46 | if (err < 0) | ||
47 | perror(progname); | ||
48 | else | ||
49 | fprintf(stderr, "unexpected end of input file\n"); | ||
50 | exit(1); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | /* | ||
55 | * Main program | ||
56 | */ | ||
57 | int unrpm_main(int argc, char **argv) | ||
58 | { | ||
59 | int len, status = 0; | ||
60 | |||
61 | /* Get our own program name */ | ||
62 | if ((progname = strrchr(argv[0], '/')) == NULL) | ||
63 | progname = argv[0]; | ||
64 | else | ||
65 | progname++; | ||
66 | |||
67 | /* Check for command line parameters */ | ||
68 | if (argc>=2 && *argv[1]=='-') { | ||
69 | usage(unrpm_usage); | ||
70 | } | ||
71 | |||
72 | /* Open input file */ | ||
73 | if (argc == 1) | ||
74 | infile = STDIN_FILENO; | ||
75 | else if ((infile = open(argv[1], O_RDONLY)) < 0) { | ||
76 | perror(progname); | ||
77 | exit(1); | ||
78 | } | ||
79 | |||
80 | /* Read magic ID and output filename */ | ||
81 | myread(4); | ||
82 | if (strncmp(buffer, RPM_MAGIC, 4)) { | ||
83 | fprintf(stderr, "input file is not in RPM format\n"); | ||
84 | exit(1); | ||
85 | } | ||
86 | myread(6); /* Skip flags */ | ||
87 | myread(64); | ||
88 | buffer[64] = '\0'; | ||
89 | |||
90 | /* Open output file */ | ||
91 | strcat(buffer, ".cpio.gz"); | ||
92 | if (infile == STDIN_FILENO) | ||
93 | outfile = STDOUT_FILENO; | ||
94 | else if ((outfile = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) { | ||
95 | perror(progname); | ||
96 | exit(1); | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * Now search for the GZIP signature. This is rather awkward, but I don't | ||
101 | * know any other way how to find out the exact starting position of the | ||
102 | * archive within the input file. There are a couple of data structures | ||
103 | * and texts (obviously descriptions, installation shell scripts etc.) | ||
104 | * coming before the archive, but even they start at different offsets | ||
105 | * with different RPM files. However, it looks like the GZIP signature | ||
106 | * never appears before offset 0x200, so we skip these first couple of | ||
107 | * bytes to make the signature scan a little more reliable. | ||
108 | */ | ||
109 | myread(0x200 - 74); | ||
110 | while (status < 2) { | ||
111 | myread(1); | ||
112 | if (status == 0 && buffer[0] == GZ_MAGIC_1) | ||
113 | status++; | ||
114 | else if (status == 1 && buffer[0] == GZ_MAGIC_2) | ||
115 | status++; | ||
116 | else | ||
117 | status = 0; | ||
118 | } | ||
119 | buffer[0] = GZ_MAGIC_1; | ||
120 | buffer[1] = GZ_MAGIC_2; | ||
121 | if (write(outfile, buffer, 2) < 0) { | ||
122 | perror(progname); | ||
123 | exit(1); | ||
124 | } | ||
125 | |||
126 | /* Now simply copy the GZIP archive into the output file */ | ||
127 | while ((len = read(infile, buffer, BUFSIZE)) > 0) { | ||
128 | if (write(outfile, buffer, len) < 0) { | ||
129 | perror(progname); | ||
130 | exit(1); | ||
131 | } | ||
132 | } | ||
133 | if (len < 0) { | ||
134 | perror(progname); | ||
135 | exit(1); | ||
136 | } | ||
137 | close(outfile); | ||
138 | close(infile); | ||
139 | exit(0); | ||
140 | } | ||
@@ -207,6 +207,15 @@ const char dmesg_usage[] = | |||
207 | ; | 207 | ; |
208 | #endif | 208 | #endif |
209 | 209 | ||
210 | #if defined BB_DOS2UNIX | ||
211 | const char dos2unix_usage[] = | ||
212 | "dos2unix < dosfile > unixfile\n" | ||
213 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
214 | "\nConverts a text file from dos format to unix format.\n" | ||
215 | #endif | ||
216 | ; | ||
217 | #endif | ||
218 | |||
210 | #if defined BB_DU | 219 | #if defined BB_DU |
211 | const char du_usage[] = | 220 | const char du_usage[] = |
212 | "du [OPTION]... [FILE]...\n" | 221 | "du [OPTION]... [FILE]...\n" |
@@ -1307,6 +1316,24 @@ const char uniq_usage[] = | |||
1307 | ; | 1316 | ; |
1308 | #endif | 1317 | #endif |
1309 | 1318 | ||
1319 | #if defined BB_UNIX2DOS | ||
1320 | const char unix2dos_usage[] = | ||
1321 | "unix2dos < unixfile > dosfile\n" | ||
1322 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
1323 | "\nConverts a text file from unix format to dos format.\n" | ||
1324 | #endif | ||
1325 | ; | ||
1326 | #endif | ||
1327 | |||
1328 | #if defined BB_UNRPM | ||
1329 | const char unrpm_usage[] = | ||
1330 | "unrpm < package.rpm | gzip -d | cpio -idmuv\n" | ||
1331 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
1332 | "\nExtracts an rpm archive.\n" | ||
1333 | #endif | ||
1334 | ; | ||
1335 | #endif | ||
1336 | |||
1310 | #if defined BB_UPDATE | 1337 | #if defined BB_UPDATE |
1311 | const char update_usage[] = | 1338 | const char update_usage[] = |
1312 | "update [options]\n" | 1339 | "update [options]\n" |