eudora-mac/buildtoc.c

1 line
39 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 "buildtoc.h" #define FILE_NUM 45 /* Copyright (c) 1991-1992 by the University of Illinois Board of Trustees */ #pragma segment BuildTOC void GleanFrom(UPtr line,MSumPtr sum); short SalvageTOC(TOCHandle old, TOCHandle new); PStr TrimWrap(UPtr str,int openC,int closeC); PStr TrimNonWord(PStr str); short MonthNum(CStr cp); void FixOrigOffset(MSumPtr sum); long CStr2Zone(char *s); Boolean IsBulk(UPtr line); /************************************************************************ * RebuildTOC - rebuild a corrupt or out-of-date toc, salvaging what we * can. ************************************************************************/ TOCHandle RebuildTOC(FSSpecPtr spec,TOCHandle oldTocH, Boolean resource, Boolean tempBox) { TOCHandle newTocH=nil; short oldCount, newCount, salvCount; if (oldTocH) DamagedTOC = oldTocH; else { if (resource) ReadRForkTOC(spec,&DamagedTOC); else ReadDForkTOC(spec,&DamagedTOC); } if (DamagedTOC || tempBox || !PrefIsSet(PREF_TOC_REBUILD_ALERTS) && AlertStr(TOC_SALV_ALRT,Stop,spec->name)==OK) { /* * build the new one */ ComposeLogR(LOG_ALRT|LOG_TOC,nil,REBUILDING_TOC,spec->name); if ((newTocH = BuildTOC(spec)) && DamagedTOC) { oldCount = (*DamagedTOC)->count; newCount = (*newTocH)->count; if (oldCount && newCount) { Str255 s; salvCount = SalvageTOC(DamagedTOC,newTocH); /* and salvage */ #ifdef IMAP if ((*newTocH)->imapTOC) SalvageIMAPTOC(DamagedTOC, newTocH, &newCount); // salvage the minimal headers and clean it up. #endif if (!tempBox) { #ifdef IMAP if ((*newTocH)->imapTOC) ComposeRString(s,IMAP_SALV_REPORT,newCount,oldCount,oldCount,oldCount-newCount,oldCount-newCount); else #endif ComposeRString(s,SALV_REPORT,salvCount,oldCount,oldCount,newCount-salvCount,newCount-salvCount); Log(LOG_ALRT|LOG_TOC,s); } } BMD((*DamagedTOC)->sorts,(*newTocH)->sorts,sizeof((*newTocH)->sorts)); (*newTocH)->unused = (*DamagedTOC)->unused; (*newTocH)->listFocus = (*DamagedTOC)->listFocus; (*newTocH)->laurence = (*DamagedTOC)->laurence; (*newTocH)->lastSort = (*DamagedTOC)->lastSort; (*newTocH)->pluginKey = (*newTocH)->pluginKey; (*newTocH)->pluginValue = (*DamagedTOC)->pluginValue; (*newTocH)->previewHi = (*DamagedTOC)->previewHi; (*newTocH)->nextSerialNum = (*DamagedTOC)->nextSerialNum; (*newTocH)->unreadBase = (*DamagedTOC)->unreadBase;