X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=uuencode.c;h=35a533309f84e96f6116dda3bda09aead4b4060e;hb=30592a54514ca52253ed5f2eff64684e32d7ff05;hp=97801aa097ec8b400e029ab2478bd18a619038b0;hpb=b610615be9aedfac07d1e01f12575707fa3a227c;p=oweals%2Fbusybox.git diff --git a/uuencode.c b/uuencode.c index 97801aa09..35a533309 100644 --- a/uuencode.c +++ b/uuencode.c @@ -15,59 +15,30 @@ * along with this product; see the file COPYING. If not, write to * the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. - */ - -/* Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * Original copyright notice is retained at the end of this file. */ - /* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */ /* Hacked to work with BusyBox by Alfred M. Szmidt */ -#include "internal.h" + #include #include -#include +#include +#include +#include "busybox.h" #define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) static void encode __P ((void)); /* Pointer to the translation table we currently use. */ -const char *trans_ptr; +static const char *trans_ptr; /* The two currently defined translation tables. The first is the standard uuencoding, the second is base64 encoding. */ -const char uu_std[64] = { +static const char uu_std[64] = { '`', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', @@ -78,7 +49,7 @@ const char uu_std[64] = { 'X', 'Y', 'Z', '[', '\\', ']', '^', '_' }; -const char uu_base64[64] = { +static const char uu_base64[64] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', @@ -171,7 +142,7 @@ static void encode() } if (ferror (stdin)) - errorMsg("Read error\n"); + error_msg("Read error"); if (trans_ptr == uu_std) { putchar (ENC ('\0')); @@ -179,15 +150,6 @@ static void encode() } } -static const char uuencode_usage[] = - "uuencode [OPTION] [INFILE] REMOTEFILE\n" -#ifndef BB_FEATURE_TRIVIAL_HELP - "\nUuencode a file.\n\n" - "Options:\n" - "\t-m\tuse base64 encoding as of RFC1521\n" -#endif -; - int uuencode_main (int argc, char **argv) { @@ -198,17 +160,14 @@ int uuencode_main (int argc, trans_ptr = uu_std; /* Standard encoding is old uu format */ /* Parse any options */ - while ((opt = getopt (argc, argv, "m")) != EOF) { + while ((opt = getopt (argc, argv, "m")) > 0) { switch (opt) { case 'm': trans_ptr = uu_base64; break; - case 0: - break; - default: - usage(uuencode_usage); + show_usage(); } } @@ -216,8 +175,8 @@ int uuencode_main (int argc, case 2: /* Optional first argument is input file. */ if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) { - errorMsg("uuencode: %s: %s\n", argv[optind], strerror(errno)); - exit FALSE; + perror_msg("%s", argv[optind]); + return EXIT_FAILURE; } mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); optind++; @@ -229,7 +188,7 @@ int uuencode_main (int argc, case 0: default: - usage(uuencode_usage); + show_usage(); } printf("begin%s %o %s\n", trans_ptr == uu_std ? "" : "-base64", @@ -237,8 +196,42 @@ int uuencode_main (int argc, encode(); printf(trans_ptr == uu_std ? "end\n" : "====\n"); if (ferror (stdout)) { - errorMsg("Write error\n"); - exit FALSE; + error_msg("Write error"); + return EXIT_FAILURE; } - return( TRUE); + return EXIT_SUCCESS; } + +/* Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. + * + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +