-- File: FTPSample.mesa, Edit: HGM November 8, 1979 3:40 PM -- Copyright Xerox Corporation 1979, 1980 DIRECTORY FTPDefs: FROM "FTPDefs" USING [ FTPCloseConnection, FTPCreateUser, FTPDestroyUser, FTPError, FTPFinalize, FTPInitialize, FTPOpenConnection, FTPSetCredentials, FTPStoreFile, FTPUser, PupCommunicationPrimitives, AltoFilePrimitives], ImageDefs: FROM "ImageDefs" USING [StopMesa], IODefs: FROM "IODefs" USING [WriteLine], OsStaticDefs: FROM "OsStaticDefs" USING [OsStatics], StringDefs: FROM "StringDefs" USING [BcplToMesaString]; FTPSample: PROGRAM -- import list IMPORTS FTPDefs, ImageDefs, IODefs, StringDefs = BEGIN OPEN FTPDefs, ImageDefs, IODefs, OsStaticDefs, StringDefs; -- variables ftpInitialized: BOOLEAN _ FALSE; ftpuser, copy: FTPUser _ NIL; user: STRING _ [40]; password: STRING _ [40]; -- intercept errors BEGIN ENABLE BEGIN FTPError => BEGIN IF message # NIL THEN WriteLine[message]; CONTINUE; END; UNWIND => BEGIN IF ftpuser # NIL THEN FTPDestroyUser[ftpuser]; IF ftpInitialized THEN FTPFinalize[]; END; END; -- initialize ftp FTPInitialize[]; ftpInitialized _ TRUE; -- create ftp user ftpuser _ FTPCreateUser[AltoFilePrimitives[], PupCommunicationPrimitives[]]; -- set credentials to login user and password BcplToMesaString[OsStatics^.UserName, user]; BcplToMesaString[OsStatics^.UserPassword, password]; FTPSetCredentials[ftpuser, primary, user, password]; -- open connection, store self, and close connection FTPOpenConnection[ftpuser, "Iris"L, files, NIL]; [] _ FTPStoreFile[ftpuser, "FTPCSample.BCD"L, "FTPCSample.BCD"L, binary]; FTPCloseConnection[ftpuser]; -- destroy ftp user copy _ ftpuser; ftpuser _ NIL; FTPDestroyUser[copy]; -- finalize ftp ftpInitialized _ FALSE; FTPFinalize[]; END; -- enable -- return to exec StopMesa[]; END. -- of FTPSample