2362N/A * Copyright (c) 1995, 2001, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class implements a Berkeley uu character decoder. This decoder 0N/A * was made famous by the uudecode program. 0N/A * The basic character coding is algorithmic, taking 6 bits of binary 0N/A * data and adding it to an ASCII ' ' (space) character. This converts 0N/A * these six bits into a printable representation. Note that it depends 0N/A * on the ASCII character encoding standard for english. Groups of three 0N/A * bytes are converted into 4 characters by treating the three bytes 0N/A * a four 6 bit groups, group 1 is byte 1's most significant six bits, 0N/A * group 2 is byte 1's least significant two bits plus byte 2's four 0N/A * most significant bits. etc. 0N/A * In this encoding, the buffer prefix is: 0N/A * begin [mode] [filename] 0N/A * This is followed by one or more lines of the form: 0N/A * (len)(data)(data)(data) ... 0N/A * where (len) is the number of bytes on this line. Note that groupings 0N/A * are always four characters, even if length is not a multiple of three 0N/A * bytes. When less than three characters are encoded, the values of the 0N/A * last remaining bytes is undefined and should be ignored. 0N/A * The last line of data in a uuencoded buffer is represented by a single 0N/A * space character. This is translated by the decoding engine to a line 0N/A * length of zero. This is immediately followed by a line which contains 0N/A * the word 'end[newline]' 0N/A * If an error is encountered during decoding this class throws a 0N/A * CEFormatException. The specific detail messages are: 0N/A * "UUDecoder: No begin line." 0N/A * "UUDecoder: Malformed begin line." 0N/A * "UUDecoder: Short Buffer." 0N/A * "UUDecoder: Bad Line Length." 0N/A * "UUDecoder: Missing 'end' line." 0N/A * @author Chuck McManis 0N/A * @see CharacterDecoder 0N/A * This string contains the name that was in the buffer being decoded. 0N/A * Represents UNIX(tm) mode bits. Generally three octal digits 0N/A * representing read, write, and execute permission of the owner, 0N/A * group owner, and others. They should be interpreted as the bit groups: 0N/A * (owner) (group) (others) 0N/A * rwx rwx rwx (r = read, w = write, x = execute) 0N/A * UU encoding specifies 3 bytes per atom. 0N/A * All UU lines have 45 bytes on them, for line length of 15*4+1 or 61 0N/A * characters per line. 0N/A /** This is used to decode the atoms */ 0N/A * Decode a UU atom. Note that if l is less than 3 we don't write 0N/A * the extra bits, however the encoder always encodes 4 character 0N/A * groups even when they are not needed. 0N/A for (i =
0; i <
4; i++) {
0N/A * For uuencoded buffers, the data begins with a line of the form: 0N/A * begin MODE FILENAME 0N/A * This line always starts in column 1. 0N/A * This works by ripping through the buffer until it finds a 'begin' 0N/A * line or the end of the buffer. 0N/A * Now we think its begin, (we've seen ^be) so verify it here. 0N/A while ((c !=
'\n') && (c !=
'\r')) {
0N/A if ((c !=
'\n') && (c !=
'\r')) {
0N/A * Check for \n after \r 0N/A if ((c !=
'\n') && (c != -
1))
0N/A * In uuencoded buffers, encoded lines start with a character that 0N/A * represents the number of bytes encoded in this line. The last 0N/A * line of input is always a line that starts with a single space 0N/A * character, which would be a zero length line. 0N/A if ((c !=
'\n') && (c != -
1))
0N/A }
else if (c == -
1) {
0N/A c = (c -
' ') &
0x3f;
0N/A * Find the end of the line for the next operation. 0N/A * The following sequences are recognized as end-of-line 0N/A if ((c !=
'\n') && (c != -
1)) {
0N/A * UUencoded files have a buffer suffix which consists of the word 0N/A * end. This line should immediately follow the line with a single