home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------- Start REXX Source ----------------------------*/
-
- /* *************************/
- /* * Print_spooler program */
- /* * using ARexx v1.06 */
- /* * by */
- /* * Dan Schenck */
- /* * 22-SEP-88 */
- /* * v 1.00 */
- /* **********************/
- true = 1
- false = 0
- ok = 0
- error = 20
- infile = "in"
- address command
- spool_names = 'vd0:$$spooler'
- copy_cntl = "rexx:spooler.copydir"
- prnt_done = true
- call open(infile,copy_cntl,'Read')
- copy_dir = readln(infile)
- cc = readln(infile)
- cc = translate(cc,'15'X,' ')
- call close(infile)
- count = 0
- time2exit = false
- say "ARexx Print Spooler"
- say " by Dan Schenck"
- if copy_dir ~= "IN-PLACE/" then
- do
- copy_dir = copy_dir || "$$rxspool"
- if exists(copy_dir) then 'delete' copy_dir || "/* Quiet"
- else 'makedir' copy_dir
- say "Print Files Will Be Copied To Spooler Directory """ || copy_dir || """"
- end
- else say "Print Files To Be Copied ""In-Place"""
- call openport("SPOOLER")
- do forever
- call waitpkt("SPOOLER")
- packet = getpkt("SPOOLER")
- instring = getarg(packet)
- parse VAR instring command ' ' file2print
-
- select
- when command = "EXIT" then
- do
- call reply(packet,ok)
- if ~prnt_done then
- do
- say "Waiting on print to terminate before spooler exits"
- time2exit = true
- end
- else call End_All()
- end
- when command = "PRINT" then
- do
- bad_file = false
- if left(statef(file2print),1) = "F" then call reply(packet,ok)
- else
- do
- call reply(packet,error)
- bad_file = true
- end
- if bad_file then break
- orig_file = file2print
- if copy_dir ~= "IN-PLACE/" then
- do
- count = count + 1
- copy_file = copy_dir || "/$$" || count
- 'copy' file2print " TO " copy_file
- file2print = copy_file
- end
- if ~prnt_done then
- do
- if ~exists(spool_names) then mode = 'Write'
- else mode = 'Append'
- call open('out',spool_names,mode)
- call writeln('out',file2print || ' ' || orig_file)
- call close('out')
- say '"' || orig_file || '" Queued To Print At ' || time()
- end
- else
- do
- address command
- say '"' || orig_file || '" Queued To Print At ' || time()
- 'arun' "rx printit" file2print orig_file cc
- prnt_done = false
- end
- end
- when command = "DONE" then
- do
- call reply(packet,ok)
- if time2exit then call End_All()
- prnt_done = true
- end
- when command = "NFS" then
- do
- call reply(packet,ok)
- cc = translate(file2print,' ','15'X)
- say 'New file separator installed'
- end
- otherwise call reply(packet,error)
- end
- end
-
- End_All: procedure expose copy_dir spool_names
- address command
- if copy_dir ~= "IN-PLACE/" then
- do
- 'delete' copy_dir || "/* Quiet"
- 'delete' copy_dir || " Quiet"
- end
- if exists(spool_names) then 'delete' spool_names " Quiet"
- call closeport("SPOOLER")
- exit
-
- /*----------------------------- End REXX Source -----------------------------*/
-