DIRECTORY Atom USING [PropList], BasicTime USING [GMT, nullGMT], FTP, IO USING [STREAM], PupName USING [Code], PupStream USING [CloseReason], Rope USING [ROPE]; FTPInternal: CEDAR DEFINITIONS = BEGIN OPEN FTP; maxStringLength: CARDINAL = 100; Handle: TYPE = REF Object; Object: TYPE = RECORD [ byteStream: IO.STREAM _ NIL, pList: ARRAY LocalOrRemote OF PList, clientData: REF ANY _ NIL, buffer: REF TEXT _ NIL]; FilenameType: TYPE = {alto, tenex}; PList: TYPE = REF PListObject; PListObject: TYPE = RECORD [ date: ARRAY DateProperty OF BasicTime.GMT _ ALL[BasicTime.nullGMT], enumerated: ARRAY EnumeratedProperty OF EnumPropValue _ ALL[nullEnumPropValue], number: ARRAY NumberProperty OF INT _ ALL[0], text: ARRAY TextProperty OF ROPE _ ALL[NIL], userDefined: Atom.PropList _ NIL, desiredProps: PropertySet _ ALL[FALSE], desiredUserDefinedProps: LIST OF ATOM _ NIL]; GetCommand: PROCEDURE [h: Handle] RETURNS [mark: Mark, code: ReplyCode]; GetText: PROCEDURE [h: Handle, gobbleEOC: BOOLEAN _ FALSE] RETURNS [text: ROPE]; GetPList: PROCEDURE [h: Handle, gobbleEOC: BOOLEAN _ FALSE, endOfPropertiesOK: BOOLEAN _ FALSE] RETURNS [pList: PList]; GetYesNo: PROCEDURE [h: Handle, gobbleEOC: BOOLEAN _ FALSE, resumable: BOOLEAN _ FALSE] RETURNS [ok: BOOLEAN]; GetEOC: PROCEDURE [h: Handle]; PutCommand: PROCEDURE [h: Handle, mark: Mark, code: ReplyCode _ unspecified, text: ROPE _ NIL, sendEOC: BOOLEAN _ FALSE]; PutPList: PROCEDURE [h: Handle, pList: PList, sendEOC: BOOLEAN _ FALSE]; PutCommandAndPList: PROCEDURE [h: Handle, mark: Mark, pList: PList, sendEOC: BOOLEAN _ FALSE]; PutEOC: PROCEDURE [h: Handle]; GetBuffer: PROCEDURE [h: Handle] RETURNS [buffer: REF TEXT]; ReleaseBuffer: PROCEDURE [h: Handle, buffer: REF TEXT]; NameToPList: PROCEDURE [plist: PList, name: Rope.ROPE, type: FilenameType]; PListToName: PROCEDURE [plist: PList, type: FilenameType] RETURNS[name: Rope.ROPE]; GenerateFailed: PROCEDURE [h: Handle, code: FailureCode, text: Rope.ROPE _ NIL, resumable: BOOLEAN _ FALSE]; GenerateNo: PROCEDURE [h: Handle, code: FailureCode, text: Rope.ROPE _ NIL, sendEOC: BOOLEAN _ FALSE]; GenerateNoAndFailed: PROCEDURE [h: Handle, code: FailureCode, text: Rope.ROPE _ NIL, resumable: BOOLEAN _ FALSE]; GenerateStreamClosingError: PROCEDURE [h: Handle, why: PupStream.CloseReason]; GenerateProtocolError: PROCEDURE [h: Handle, type: ProtocolError, mark: Mark, code: CHARACTER _ 0C, resumable: BOOLEAN _ FALSE] ; MapNameLookupError: PROCEDURE [error: PupName.Code] RETURNS [FailureCode]; MapStreamClosingError: PROCEDURE [error: PupStream.CloseReason] RETURNS [FailureCode]; Mark: TYPE = MACHINE DEPENDENT {retrieve (1), store (2), yes (3), no (4), hereIsFile (5), endOfCommand (6), comment (7), version (8), newStore (9), enumerate (10), hereIsPList (11), newEnumerate (12), delete (14), rename (15), storeMail (16), retrieveMail (17), flushMailbox (18), mailboxException (19), (255)}; ftpVersion: CARDINAL = 1; -- FTP protocol version END. rFTPInternal.mesa Last edited by: Taft, October 7, 1983 2:14 pm Bob Hagmann March 24, 1985 2:29:34 pm PST Hal Murray, April 10, 1986 1:18:21 pm PST Constants Types Procedures for sending and receiving FTP protocol commands First, if the FTP stream is not already positioned at a mark, consumes and discards data from the stream until a mark is reached. Then consumes and returns the mark, and if the mark is one of those that has a code byte, also consumes and returns the code byte. Consumes and discards any comment commands encountered. Consumes data from the stream up to but not including the next mark and returns it as a ROPE. Then, if gobbleEOC=TRUE, consumes and discards the mark byte, raising Failed[protocolError] if it is not an endOfCommand. Consumes data from the stream and interprets it as a property list, stopping at the end of that property list. Then, if gobbleEOC=TRUE, consumes and discards the following mark byte, raising Failed[protocolError] if a mark byte does not immediately follow or if it is not an endOfCommand. Ordinarily, if the stream is positioned at a mark at the time of the call, raises Failed[protocolError]; however, if endOfPropertiesOK=TRUE then returns NIL in that case. Calls GetCommand followed by GetText, in expectation of the next command being a Yes or No. If it is Yes, it simply returns TRUE. If it is No, it raises Failed[code, text, resumable], where code and text are from the No reply and resumable is as specified in the call to GetYesNo; if the signal is resumed, GetYesNo returns FALSE. Any other response results in a protocol error. Calls GetCommand in expectation of the next command being an End-of-command. If it is not, an error results. Sends the specified mark byte, and if the mark is one of those that has a code byte, also sends the specified code byte. Then, if text#NIL, sends the specified text. Finally, if sendEOC=TRUE, sends an endOfCommand mark byte. Unparses and sends the specified property list. Then, if sendEOC=TRUE, sends an endOfCommand mark byte. Combines the effects of PutCommand and PutPList. Sends an endOfCommand mark byte. Utility routines PList Utilities -- most probably obsolete now Error handling Raises h.Failed[code, text, resumable] after first fabricating a text argument based on code if text=NIL. Generates a "No" response with the specified code and text, after first fabricating a text argument based on code if text=NIL. Combines the actions of GenerateNo and GenerateFailed. Maps a NameLookupErrorCode to a FailureCode. Maps a CloseReason to a FailureCode. FTP protocol definitions Bob Hagmann February 11, 1985 1:43:22 pm PST changes to: DIRECTORY Κω– "cedar" style˜Jšœ™™Jšœ™Icode™)K™)—unitšΟk ˜ Jšœœ ˜Jšœ œœ ˜Jšœ˜Jšœœœ˜Jšœœ˜Jšœ œ˜Jšœœœ˜—šœ œ œ˜ Kšœœ˜J˜—Jšœ ™ ˜Kšœœ˜ J˜—Jšœ™˜Kšœœœ˜šœœœ˜Kšœ œœœ˜Kšœœœ˜$Kšœ œœœ˜Kšœœœœ˜K˜—Kšœœ˜#Kšœœœ ˜šœ œœ˜Kšœœœœ˜CKšœ œœœ˜OKš œœœœœ˜-Kš œœœœœœ˜,Kšœœ˜!Kšœœœ˜'Kš œœœœœ˜-—K˜J˜—šœ<™<šΟn œ œ œ˜HJšœΌ™Ό—š žœ œœœœœ˜PJšœXœœb™Χ—šžœ œœœœœœ˜wJšœ‚œ’œœ™Λ—šžœ œœœ œœœœ˜nJšœ}œΕœ2™ύ—šžœ œ ˜J™m—š ž œ œ>œœ œœ˜yJšœˆœ1œ"™β—šžœ œ$œœ˜HJšœBœ"™h—šžœ œ0œœ˜^J™0—šžœ œ ˜Jšœ ™ —J˜—J™šœ™Lš ž œ œ œ œœ˜