// IfsTelnetListAux.bcpl -- Overflow from the List command
// Copyright Xerox Corporation 1979, 1981

// Last modified April 25, 1981  4:29 PM by Taft

get "IfsRs.decl"
get "IfsTelnet.decl"

external
[
// outgoing procedures
CollectListSubcommands; ListHeaders

// incoming procedures
CreateKeywordTable; InsertKeyword; DestroyKeywordTable
TelnetCommandLoop; TelnetSubcommandPrompt
Ws
]

//---------------------------------------------------------------------------
let CollectListSubcommands() = valof
//---------------------------------------------------------------------------
// Collects subcommands for the List command and returns the options word.
[
let kt = CreateKeywordTable(15)
InsertKeyword(kt, "Type")!0 = listType
InsertKeyword(kt, "Length")!0 = listLength
InsertKeyword(kt, "Bytes")!0 = listLength
InsertKeyword(kt, "Size")!0 = listSize
InsertKeyword(kt, "Pages")!0 = listSize
InsertKeyword(kt, "Creation")!0 = listCreation
InsertKeyword(kt, "Write")!0 = listWrite
InsertKeyword(kt, "Read")!0 = listRead
InsertKeyword(kt, "Backup")!0 = listBackup
InsertKeyword(kt, "Times")!0 = listTimes
InsertKeyword(kt, "Author")!0 = listAuthor
InsertKeyword(kt, "Protection")!0 = listProtection
InsertKeyword(kt, "Verbose")!0 =
 listType+listSize+listCreation+listRead+listAuthor
InsertKeyword(kt, "Everything")!0 = -1
let options = 0
TelnetCommandLoop(kt, TelnetSubcommandPrompt(), true, lv options,
 0, 0, ListSubcommand)
DestroyKeywordTable(kt)
resultis options
]

//---------------------------------------------------------------------------
and ListSubcommand(cs, entry, lvOptions) be @lvOptions = @lvOptions % entry!0
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
and ListHeaders(options) be
//---------------------------------------------------------------------------
// Prints headers for List command output
[
Ws("*n                       ")
if (options&listType) ne 0 then Ws(" Type ")
if (options&listLength) ne 0 then Ws("   Bytes")
if (options&listSize) ne 0 then Ws(" Pgs")
let timeSpace = (options&listTimes) ne 0? "      ", ""
if (options&listCreation) ne 0 then [ Ws("  Creation"); Ws(timeSpace) ]
if (options&listWrite) ne 0 then [ Ws("   Write  "); Ws(timeSpace) ]
if (options&listRead) ne 0 then [ Ws("    Read  "); Ws(timeSpace) ]
if (options&listBackup) ne 0 then [ Ws("   Backup "); Ws(timeSpace) ]
if (options&listAuthor) ne 0 then Ws(" Author")
if (options&listProtection) ne 0 then Ws("  Protection")
]