eudora-mac/html.c

1 line
31 KiB
C
Raw 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. */ #ifdef OLDHTML #pragma segment HTML #pragma optimization_level 1 short FindSTRNIndexCase(short resId,PStr string); short FindSTRNIndexResCase(UHandle resource,PStr string); void HiddenLinkStyle(PETEStyleListHandle slh); OSErr HTMLColorParam(RGBColor *color, PStr text); /********************************************************************** * HTML interpretation **********************************************************************/ #define htmlUnknown (0) #define htmlText (-1) #define htmlCR (-2) #define htmlParamText (-3) #define htmlDoubleLess (-4) #define htmlLiteral (-5) #define htmlIgnore (-6) #define htmlStrayChar (-7) #define htmlURL (-8) /************************************************************************ * PeteHTML - interpret HTML in a PETE record ************************************************************************/ OSErr PeteHTML(PETEHandle pte,long start,long stop,Boolean unwrap) { //variables related to the current command short cmdId; long tStart,tStop; Boolean neg; short lastCmd; //interpreter state variables short noFill = 0; short inRich = 0; short inParam = 0; short listType = -1; short listItemNum = 0; short specialChar = -1; long position = -1; long tempPos = -1; long tempPos2 = -1; long tempStart = -1; short defList = 0; short defDef = 0; short doingList = 0; Boolean doingPre = false; Boolean doingLink = false; Boolean doneWithTag; short sizeInc = 0; Boolean softBreak=0; short styleCounters[3]; StackHandle fontStack=nil; StackHandle justStack=nil; StackHandle margStack=nil; StackHandle colorStack=nil; StackHandle listStack = nil; StackHandle listItemStack = nil; Str255 paramText; //global prefs //uLong validMask = ~GetPrefLong(PREF_INTERPRET_ENRICHED); uLong validMask = ~GetPrefLong(PREF_INTERPRET_HTML); //the text UHandle html=nil; long len; Uhandle text=nil; UHandle baseRef = nil; long baseLen = 0L; //scratch variables OSErr err = noErr; PETETextStyle style; Str255 scratch; PETEParaInfo pinfo; PeteSaneMargin marg, curMarg; PETEStyleEntry pse; unsigned char literal[5]; /* * initialize state */ styleCounters[0] = styleCounters[1] = styleCounters[2] = 0; if (!(err=StackInit(sizeof(style.tsFont),&fontStack)) && !(err=StackInit(sizeof(pinfo.justification),&justStack)) && !(err=StackInit(sizeof(PeteSaneMargin),&margStack)) && !(err=StackInit(sizeof(RGBColor),&colorStack)) && !(err=Stac