// IfsFtpInit.bcpl - File Server initialization
// Copyright Xerox Corporation 1979, 1980, 1982
// Last modified May 13, 1982 2:10 PM by Boggs

get "IfsFtpProt.decl"
get "Streams.d"

external
[
// outgoing procedures
InitFtpServ

// incoming procedures
IfsFtpServ
Allocate; Enqueue; OpenLevel1Socket
InitFtpUtil; InitFtpPList
SetBlock; Zero; Noop; SysErr

// procedures external only for OEP declarations
FtpSVersion; FtpSDirectory; FtpSRename
FtpSRetrieve; FtpSRetrieveFile
FtpSStore; FtpSStoreFile; FtpSStoreCleanup
FtpSDelete; FtpSDeleteFile; FtpSNotImpl

// outgoing statics
dFTPI

// incoming statics
sysZone; rsQ; lPupSoc
]

static dFTPI

//---------------------------------------------------------------------------
let InitFtpServ() be
//---------------------------------------------------------------------------
[
// register the FTP socket with the socket manager
let rs = Allocate(sysZone, lenRS); Zero(rs, lenRS)
rs>>RS.proc = IfsFtpServ
rs>>RS.soc = Allocate(sysZone, lPupSoc)
OpenLevel1Socket(rs>>RS.soc, table [ 0; 0; socketFTP ])
rs>>RS.extraSpace = lenExtraFtpCtx
rs>>RS.type = jobTypeFTP
Enqueue(rsQ, rs)

// Ftp package initialization
InitFtpUtil()
InitFtpPList()

// build the default Ftp Interface
dFTPI = Allocate(sysZone, lenFTPI); Zero(dFTPI, lenFTPI)
dFTPI>>FTPI.dspStream = lv Noop - offset ST.puts/16
dFTPI>>FTPI.lst = lv Noop - offset ST.puts/16
dFTPI>>FTPI.dls = lv Noop - offset ST.puts/16
dFTPI>>FTPI.Version = FtpSVersion
dFTPI>>FTPI.Store = FtpSStore
dFTPI>>FTPI.StoreFile = FtpSStoreFile
dFTPI>>FTPI.StoreCleanup = FtpSStoreCleanup
dFTPI>>FTPI.Retrieve = FtpSRetrieve
dFTPI>>FTPI.RetrieveFile = FtpSRetrieveFile
dFTPI>>FTPI.RetrieveCleanup = Noop
dFTPI>>FTPI.Delete = FtpSDelete
dFTPI>>FTPI.DeleteFile = FtpSDeleteFile
dFTPI>>FTPI.Directory = FtpSDirectory
dFTPI>>FTPI.Rename = FtpSRename
dFTPI>>FTPI.StoreMail = FtpSNotImpl
dFTPI>>FTPI.RetrieveMail = FtpSNotImpl
]