eudora-mac/ctb.c

1 line
29 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. */ #include "ctb.h" #define FILE_NUM 9 #ifdef CTB /* Copyright (c) 1990-1992 by the University of Illinois Board of Trustees */ /************************************************************************ * functions for i/o over a pseudo-telnet ctb stream * these functions are oriented toward CONVENIENCE, not performance ************************************************************************/ #pragma segment CTBTrans #include <stdio.h> static short CTBErr; TransStream gCTBStream; /************************************************************************ * private functions ************************************************************************/ typedef struct { short pending; short errCode; CMBufferSizes asyncCount; short inUse; } AsyncStuff, *AsyncStuffPtr; Boolean CTBExists(void); short ConfigureCTB(Boolean makeUser); short CTBNavigateString(Uptr string); short MyCMOpen(ConnHandle cn,long timeout); short MyCMClose(ConnHandle cn); short MyCMWrite(ConnHandle cn,UPtr buffer,long *size,AsyncStuffPtr callerStuff); short MyCMBreak(ConnHandle cn,long howLong); short MyCMRead(ConnHandle cn,UPtr buffer,long *size,long timeout); typedef pascal void MyCTBCompleteType(ConnHandle cn); SIMPLE_UPP(MyCTBComplete,ConnectionCompletion); Handle GetNavResource(short id); void CheckNavPWRes(Boolean *primary,Boolean *secondary,Handle resH); long CTBDataCount(void); void CTBAuxConfig(ConnHandle cnH, PStr toolName); Boolean SilentCTB=False; PStr StripHi(PStr string); #define CTBTrouble(err) CTBTR(err,FNAME_STRN+FILE_NUM,__LINE__) short CTBTR(short err,short file,short line); #define ESC_AUXUSR 1 #define ESC_AUXUSRERR 2 #define ESC_AUXPW 4 #define ESC_USR 8 #define ESC_PW 16 short EscapeCopy(PStr to,PStr from,PStr expect,PStr hangup); /************************************************************************ * InitCTB - initialize the CommToolbox ************************************************************************/ Boolean InitCTB(Boolean makeUser) { static int CTBInitted=0; ASSERT(gCTBStream); CTBInitted = MIN(CTBInitted,4); CTBSilenceTrans(gCTBStream,False); switch (CTBInitted) { case 0: if (!CTBExists()) { WarnUser(NO_CTB,0); return(False); } CTBInitted++; case 1: if (CTBErr = InitCTBUtilities()) { WarnUser(NO_CTBU,CTBErr); return(False); } CTBInitted++; case 2: if (CTBErr = InitCRM()) { WarnUser(NO_CTBRM,CTBErr); return(False