// FtpPListInit.bcpl - 'Standard' property list initialization
//		companion file to FtpPlistImpl.bcpl
// Copyright Xerox Corporation 1979, 1980, 1981, 1982
// Last modified November 25, 1982  10:55 AM by Taft

get "FtpProt.decl"

external
[
// outgoing procedures
InitFtpPList; LoadPLKT
GenProp; ScanProp; InitProp; FreeProp  //actually statics

// incoming procedures
GenStringProp; ScanStringProp; InitStringProp; FreeStringProp
GenNumberProp; ScanNumberProp; InitNumberProp
GenKeywordProp; ScanKeywordProp; InitKeywordProp
GenDateProp; ScanDateProp
GenBitProp; ScanBitProp

CreateKeywordTable; InsertKeyword; TruePredicate; Noop; DefaultArgs
Call0; Call1; Call2; Call3

// outgoing statics
pListKT; typeKT; eolcKT
]

static
[
pListKT; eolcKT; typeKT
GenProp; ScanProp; InitProp; FreeProp
]

manifest
[
//property list types
plString = 1
plDate = 2
plNumber = 3
plKeyword = 4
plBit = 5
plIgnore = 6
]

//-----------------------------------------------------------------------------------------
let InitFtpPList() be
//-----------------------------------------------------------------------------------------
[
// End of Line Convention keyword table
eolcKT = CreateKeywordTable(4, 1)
LoadPLKT(eolcKT, "Unspecified", Unspecified)
LoadPLKT(eolcKT, "CR", CR)
LoadPLKT(eolcKT, "CRLF", CRLF)
LoadPLKT(eolcKT, "Transparent", Transparent)

// Type keyword table
typeKT = CreateKeywordTable(3, 1)
LoadPLKT(typeKT, "Unspecified", Unspecified)
LoadPLKT(typeKT, "Text", Text)
LoadPLKT(typeKT, "Binary", Binary)

// define the property object operations
ScanProp = Call0
GenProp = Call1
FreeProp = Call2
InitProp = Call3

// File Property List Keyword Table and object initialization
pListKT = CreateKeywordTable((MTP? 24, 20), lenProp)
MakeProp("Author", plString, offset PL.AUTH, 30b, offset DPRP.AUTH)
MakeProp("Byte-size", plNumber, offset PL.BYTE, 16b, offset DPRP.BYTE)
MakeProp("Connect-name", plString, offset PL.CNAM, 23b)
MakeProp("Connect-password", plString, offset PL.CPSW, 24b)
MakeProp("Creation-date", plDate, offset PL.CDAT, 25b, offset DPRP.CDAT)
MakeProp("Desired-property", plBit, offset PL.DPRP)
MakeProp("Device", plString, offset PL.DEVI, 31b, offset DPRP.DEVI)
MakeProp("Directory", plString, offset PL.DIRE, 12b, offset DPRP.DIRE)
MakeProp("End-of-line-convention", plKeyword, offset PL.EOLC, 17b, offset DPRP.EOLC, eolcKT)
MakeProp("Name-body", plString, offset PL.NAMB, 13b, offset DPRP.NAMB)
MakeProp("Read-date", plDate, offset PL.RDAT, 27b, offset DPRP.RDAT)
MakeProp("Server-filename", plString, offset PL.SFIL, 11b, offset DPRP.SFIL)
MakeProp("Size", plNumber, offset PL.SIZE, 0, offset DPRP.SIZE, true)
MakeProp("Type", plKeyword, offset PL.TYPE, 15b, offset DPRP.TYPE, typeKT)
MakeProp("User-account", plIgnore, nil, 22b)
MakeProp("User-name", plString, offset PL.UNAM, 20b)
MakeProp("User-password", plString, offset PL.UPSW, 21b)
MakeProp("Version", plString, offset PL.VERS, 14b, offset DPRP.VERS)
MakeProp("Write-date", plDate, offset PL.WDAT, 26b, offset DPRP.WDAT)
MakeProp("Checksum", plNumber, offset PL.CSUM, 0, offset DPRP.CSUM)
compileif MTP then
   [
   MakeProp("MailBox", plString, offset PL.MLBX, 41b)
   MakeProp("Sender", plString, offset PL.SNDR, 42b)
   MakeProp("Length", plNumber, offset PL.LGTH, 44b, 0, true)
   MakeProp("Date-Received", plDate, offset PL.RCVD, 45b)
   ]
]

//-----------------------------------------------------------------------------------------
and MakeProp(name, type, Offset, subCode, dprp, extra; numargs na) be
//-----------------------------------------------------------------------------------------
[
DefaultArgs(lv na, -3, 0, 0, 0)
let prop = InsertKeyword(pListKT, name)
prop>>Prop.pOffset = Offset/16
prop>>Prop.pErrSubCode = subCode
prop>>Prop.pDPRP = 1b15 rshift dprp
prop>>Prop.pExtra = extra
prop>>Prop.Scan = selecton type into
   [
   case plString: ScanStringProp
   case plDate: ScanDateProp
   case plNumber: ScanNumberProp
   case plKeyword: ScanKeywordProp
   case plBit: ScanBitProp
   case plIgnore: TruePredicate
   ]
prop>>Prop.Gen = selecton type into
   [
   case plString: GenStringProp
   case plDate: GenDateProp
   case plNumber: GenNumberProp
   case plKeyword: GenKeywordProp
   case plBit: GenBitProp
   case plIgnore: Noop
   ]
prop>>Prop.Init = selecton type into
   [
   case plString: InitStringProp
   case plDate: Noop
   case plNumber: InitNumberProp
   case plKeyword: InitKeywordProp
   case plBit: Noop
   case plIgnore: Noop
   ]
prop>>Prop.Free = selecton type into
   [
   case plString: FreeStringProp
   case plDate: Noop
   case plNumber: Noop
   case plKeyword: Noop
   case plBit: Noop
   case plIgnore: Noop
   ]
]

//----------------------------------------------------------------------------------------
and LoadPLKT(kt, string, arg1, arg2; numargs na) be
//----------------------------------------------------------------------------------------
[
let kte = InsertKeyword(kt, string)
for i = 0 to na-3 do kte!i = (lv arg1)!i
]