// IfsCopyDiskInit.bcpl
// Copyright Xerox Corporation 1980, 1981
// Last modified November 14, 1981  4:16 PM by Taft

get "IfsRs.decl"
get "IfsCopyDisk.decl"

external
[
// outgoing procedures
EnableCopyDisk

// incoming procedures
CopyDiskJob
OpenLevel1Socket; CloseLevel1Socket
SysAllocate; SysAllocateZero; FreePointer; Enqueue; Unqueue

// outgoing statics
cdrs

// incoming statics
rsQ; lPupSoc
]

static [ cdrs = 0 ]	// zero if not enabled

//----------------------------------------------------------------------------
let EnableCopyDisk(enable) be
//----------------------------------------------------------------------------
[
if enable ne 0 & cdrs eq 0 then
   [
   cdrs = SysAllocateZero(lenRS)
   cdrs>>RS.proc = CopyDiskJob
   cdrs>>RS.soc = SysAllocate(lPupSoc)
   OpenLevel1Socket(cdrs>>RS.soc, table [ 0; 0; socketCopyDisk ])
   cdrs>>RS.type = jobTypeCopyDisk
   cdrs>>RS.extraSpace = size CDCtx/16 -3
   Enqueue(rsQ, cdrs)
   ]

if enable eq 0 & cdrs ne 0 then
   [
   CloseLevel1Socket(cdrs>>RS.soc)
   Unqueue(rsQ, cdrs)
   FreePointer(lv cdrs>>RS.soc, lv cdrs)
   ]
]