!***********************************************************************
!*
!* Command to examine users' files
!*
!* R.D. Eager University of Kent MCMLXXXIII
!*
!***********************************************************************
!
!
!***********************************************************************
!*
!* Constants
!*
!***********************************************************************
!
constantinteger no = 0, yes = 1
constantstring (1) snl = "
"
constantstring (10) todefault = "T#SNOOP"
!
!
!***********************************************************************
!*
!* Subsystem references
!*
!***********************************************************************
!
systemstringfunctionspec failuremessage(integer mess)
systemstringfunctionspec itos(integer n)
systemintegerfunctionspec parmap
externalroutinespec prompt(string (255) s)
systemroutinespec setpar(string (255) s)
externalroutinespec set return code(integer i)
systemstringfunctionspec spar(integer n)
systemroutinespec uctranslate(integer ad,len)
externalintegerfunctionspec uinfi(integer entry)
!
!
!***********************************************************************
!*
!* Director references
!*
!***********************************************************************
!
externalintegerfunctionspec dfstatus(string (6) user,string (11) file,
integer fsys,act,value)
externalintegerfunctionspec dtransfer(string (6) user1,user2,
string (11) file,newname,
integer fsys1,fsys2,type)
!
!
!***********************************************************************
!*
!* Forward references
!*
!***********************************************************************
!
routinespec readline(stringname s)
!
!
!***********************************************************************
!*
!* Service routines
!*
!***********************************************************************
!
routine getfile(string (7) pr,stringname file,integer paramno,
string (31) default,string (255) help)
file = spar(paramno)
while file = "" cycle
if file = "" then start
prompt(pr)
readline(file)
finish
if file = "?" then start
printstring(help.snl)
file = ""
continue
finish
if file = "" and default # "" then file = default
repeat
end ; ! of getfile
!
!-----------------------------------------------------------------------
!
routine readline(stringname s)
integer c
!
s = ""
cycle
readsymbol(c)
exit if c = nl
s <- s.tostring(c)
repeat
while length(s) > 0 and charno(s,length(s)) = ' ' cycle
length(s) = length(s) - 1
repeat
uctranslate(addr(s)+1,length(s))
end ; ! of readline
!
!
!***********************************************************************
!*
!* S N O O P
!*
!***********************************************************************
!
externalroutine snoop(string (255) parms)
integer flag,myfsys,tempfile
string (255) from,to
!
setpar(parms)
if parmap > 3 then start
flag = 263; ! Wrong number of parameters
-> err
finish
!
if parmap = 1 and spar(1) = "?" then start
printstring("Parameters are: fromfile,tofile".snl)
flag = 0
else
myfsys = uinfi(1)
getfile("From: ",from,1,"",
"Give the name of the file you wish to examine")
getfile("To: ",to,2,todefault,
"Give the name of the file where the copy is to be placed".snl.c
"The default is ".todefault)
!
if length(to) >= 2 and substring(to,1,2) = "T#" then start
to <- to.itos(uinfi(13))
tempfile = yes
finish else tempfile = no
!
flag = dtransfer("","",from,to,-1,myfsys,3)
! Make copy
if flag = 0 then start
flag = dfstatus("",to,myfsys,5,0) if tempfile = yes
! Make temporary
flag = dfstatus("",to,myfsys,0,0)
! Hazard
printstring("OK".snl)
finish
!
if flag # 0 then start
flag = flag + 500; ! Form Subsystem code
-> err
finish
finish
!
set return code(0)
return
!
err:
set return code(flag)
printstring(snl."SNOOP fails -".failuremessage(flag))
stop
end ; ! of snoop
endoffile