eudora-mac/uudecode.c

1 line
42 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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. */ #include "uudecode.h" #define FILE_NUM 46 /* Copyright (c) 1990-1992 by the University of Illinois Board of Trustees */ /* Major modifications Copyright (c)1991-1992, Apple Computer Inc. */ /* More modifications Copyright (c)1993, QUALCOMM Incorporated */ /************************************************************************ * functions to convert files from uuencoded applesingle (yuck!) * Major modifications (c)1991-1992, Apple Computer Inc. * released to public domain. ************************************************************************/ #pragma segment Abomination #define SINGLE_MAGIC 0x00051600 #define DOUBLE_MAGIC 0x00051607 #define OLD_VERSION 0x00010000 #define MAP_NAME 3 #define MAP_RFORK 2 #define MAP_DFORK 1 #define MAP_DATES 8 #define MAP_INFO 9 #define NEW_VERSION 0x00020000 typedef struct { uLong type; uLong offset; uLong length; } Map, *MapPtr; typedef struct { uLong magic; uLong version; char homefs[16]; uShort mapCount; Map maps[9]; } UUHeader; typedef struct UUGlobals_ UUGlobals, **UUGlobalsHandle; struct UUGlobals_ { UUHeader header; /* AppleSingle header */ AbStates state; /* Current decoder state */ UHandle buffer; /* receive map buffer */ short bSpot; /* current point in receive map buffer */ short bSize; /* Size of receive map buffer */ FSSpec spec; /* FSSpec */ short refN; /* file ref number */ Str63 tmpName; /* temporary file name */ Str255 name; /* file name */ long offset; /* Offset into the stream */ long currmap; /* Current map that we are working on, set in AbNextState */ Boolean seenFinfo; /* Have we found the Finfo in the stream yet? */ Boolean seenName; /* Have we found the real file name in the stream yet? */ Boolean hasName; /* Are we going to find the real file name in the stream ? */ Boolean usedTemp; /* Did we use a temporary name? */ Boolean noteAttached; /* Did we attache the enclosure note yet? */ Boolean invalState; /* have we told the user things have gone awry? */ FInfo info; /* Macintosh file information */ FXInfo xInfo; /* More Macintosh file information */ short mailboxRefN; /* ref number of mailbox */ long origOffset; /* offset where we found first indication of file */ Boolean isText; /* is this text data? */ Boolean wasCR; /* was the last char a CR? */ Boolean hasDates; uLong dates[4]; HeaderDHandle hdh; }; #define Hdh (*UUG)->hdh #define Header (*UUG)->header #define HeaderData ((UPtr)&Head