1 line
30 KiB
C
1 line
30 KiB
C
|
/* 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 "acap.h"
#define FILE_NUM 103
#pragma segment ACAP
/************************************************************************
* Simplified ACAP handling
* There are lots of things not up to snuff here. If we're really
* going to use ACAP as intended by ACAP Nazis, it will have to be made
* much less efficient.
************************************************************************/
typedef enum
{
adOK = 1,
adManual,
adQuit,
adCancel,
adServer,
adUser,
adPassword,
adCapsLockWarning,
adLimit
} ACAPDlogEnum;
typedef enum
{
acsTag, // expecting tag
acsResponse, // expecting response
acsText, // expecting open paren
acsFlush, // flush to newline
acsLimit
} ACAPCmdState, *ACAPCmdStatePtr, **ACAPCmdStateHandle;
typedef enum
{
alsFree, // not looking at anything yet
alsAtom, // collecting atom
alsQuote, // collecting quote
alsEscapedQuote, // collecting quote, just saw a backslash
alsDigit, // saw an open brace
alsCloseBrace, // saw a close brace
alsBraceCR, // saw the cr after the close brace
alsLiteral, // inside a literal
alsCR, // just saw a CR
alsLF, // just saw an LF
alsLimit
} ACAPLexState, *ACAPLexStatePtr, **ACAPLexStateHandle;
typedef enum
{
acaptString,
acaptOpenParen,
acaptCloseParen,
acaptNewline,
acaptLimit
} ACAPToken, *ACAPTokenPtr, **ACAPTokenHandle;
typedef struct AccuLL **AccuLLHandle;
typedef struct AccuLL
{
Accumulator strings;
AccuLLHandle next;
} AccuLL, *AccuLLPtr, **AccuLLHandle;
typedef struct
{
TransStream stream; // open stream
ACAPCmdState state; // current command state
long tag; // current tag
ACAPEnum response; // current response
Str255 responseValue; // text of the response
Str255 tokenValue; // text of the token
ACAPToken token; // token type
Accumulator text; // lists of strings of the result. Each list is separated by a nul.
UHandle buffer; // incoming data buffer
long spot; // spot in the buffer
long end; // end of the buffer
Boolean hasPlain; // has plaintext authentication
Boolean hasAPOP; // has apop authentication
Boolean hasCram; // has cram-md5 authentication
} ACAPState, *ACAPStatePtr, **ACAPStateHandle;
typedef struct
{
short pref;
short type;
long reserved;
Str255 name;
} ACAPResTemplate, *ACAPResTemplatePtr, **ACAPResTemplateHandle;
#define ACAPDone(r) (r==acapBad || r==acapOK || r==acapNo || r==acapBye)
OSErr GetACAPLogin(PStr server, PStr user, PStr
|