-- FTPUtilities.mesa, Edited by: HGM July 31, 1980 5:51 PM -- Copyright Xerox Corporation 1979, 1980 DIRECTORY Stream USING [Block], ByteBlt USING [ByteBlt], FTPDefs, FTPPrivateDefs; FTPUtilities: PROGRAM IMPORTS ByteBlt, FTPPrivateDefs EXPORTS FTPPrivateDefs SHARES FTPDefs = BEGIN OPEN FTPDefs, FTPPrivateDefs; -- **********************! Transmission Primitives !*********************** -- Note: These transmission primitives increment the connection's total byte count -- and do not trace the transmitted data. SendBlock: PUBLIC PROCEDURE [ ftper: FTPer, source: POINTER, byteCount: CARDINAL] = BEGIN OPEN ftper; -- Note: Forces transmission. -- local variables bytePointerObject: BytePointerObject _ [source, FALSE, byteCount]; -- send block communicationPrimitives.SendBytes[ communicationSystem, connection, @bytePointerObject]; -- force transmission communicationPrimitives.ForceOutput[communicationSystem, connection]; -- increment total byte count for connection totalByteCount _ totalByteCount + byteCount; END; ReceiveBlock: PUBLIC PROCEDURE [ ftper: FTPer, destination: POINTER, maxWordCount: CARDINAL] RETURNS [actualByteCount: CARDINAL] = BEGIN OPEN ftper; -- local variables bytePointerObject: BytePointerObject _ [destination, FALSE, bytesPerWord*maxWordCount]; -- receive next block communicationPrimitives.ReceiveBytes[ communicationSystem, connection, @bytePointerObject, TRUE]; actualByteCount _ bytesPerWord*maxWordCount - bytePointerObject.count; -- increment total byte count for connection totalByteCount _ totalByteCount + actualByteCount; END; SendBytes: PUBLIC PROCEDURE [ftper: FTPer, bytePointer: BytePointer] = BEGIN OPEN ftper; -- Note: No operation if bytePointer.count=0. -- local constants byteCount: CARDINAL = bytePointer.count; -- nop if no bytes IF bytePointer.count = 0 THEN RETURN; -- send bytes communicationPrimitives.SendBytes[ communicationSystem, connection, bytePointer]; -- increment total byte count for connection totalByteCount _ totalByteCount + byteCount; END; ReceiveBytes: PUBLIC PROCEDURE [ftper: FTPer, bytePointer: BytePointer] = BEGIN OPEN ftper; -- Note: No operation if bytePointer.count=0. -- local constants byteCount: CARDINAL = bytePointer.count; -- nop if no bytes IF bytePointer.count = 0 THEN RETURN; -- receive bytes communicationPrimitives.ReceiveBytes[ communicationSystem, connection, bytePointer, FALSE]; -- increment total byte count for connection totalByteCount _ totalByteCount + byteCount; END; SendWord: PUBLIC PROCEDURE [ftper: FTPer, word: WORD] = BEGIN OPEN ftper; -- local constants wordPointer: Word = LOOPHOLE[@word]; -- send word communicationPrimitives.SendByte[ communicationSystem, connection, wordPointer.lhByte]; communicationPrimitives.SendByte[ communicationSystem, connection, wordPointer.rhByte]; -- increment total byte count for connection totalByteCount _ totalByteCount + bytesPerWord; END; ReceiveWord: PUBLIC PROCEDURE [ftper: FTPer] RETURNS [word: WORD] = BEGIN OPEN ftper; -- local constants wordPointer: Word = LOOPHOLE[@word]; -- receive word [wordPointer.lhByte, ] _ communicationPrimitives.ReceiveByte[ communicationSystem, connection, FALSE]; [wordPointer.rhByte, ] _ communicationPrimitives.ReceiveByte[ communicationSystem, connection, FALSE]; -- increment total byte count for connection totalByteCount _ totalByteCount + bytesPerWord; END; SendByte: PUBLIC PROCEDURE [ftper: FTPer, byte: Byte] = BEGIN OPEN ftper; -- send byte communicationPrimitives.SendByte[communicationSystem, connection, byte]; -- increment total byte count for connection totalByteCount _ totalByteCount + 1; END; ReceiveByte: PUBLIC PROCEDURE [ftper: FTPer] RETURNS [byte: Byte] = BEGIN OPEN ftper; -- receive byte [byte, ] _ communicationPrimitives.ReceiveByte[ communicationSystem, connection, FALSE]; -- increment total byte count for connection totalByteCount _ totalByteCount + 1; END; -- **********************! Byte Primitives !*********************** TransferBytes: PUBLIC PROCEDURE [srcBytePointer, dstBytePointer: BytePointer] = BEGIN to, from: Stream.Block; bytes: CARDINAL; from.blockPointer _ srcBytePointer.address; from.startIndex _ IF srcBytePointer.offset THEN 1 ELSE 0; from.stopIndexPlusOne _ from.startIndex + srcBytePointer.count; to.blockPointer _ dstBytePointer.address; to.startIndex _ IF dstBytePointer.offset THEN 1 ELSE 0; to.stopIndexPlusOne _ to.startIndex + dstBytePointer.count; bytes _ ByteBlt.ByteBlt[to: to, from: from]; AdvanceBytePointer[srcBytePointer, bytes]; AdvanceBytePointer[dstBytePointer, bytes]; END; -- **********************! Main Program !*********************** -- no operation END. -- of FTPUtilities