%external %routine testinit ! Note: Version of PRINTINIT7 for transfer of HP Laser Jet files to ! APM Filestore (Appleton Tower) Spooler. ! Only commands "PRINT", "QUEUE", "STOP", "QUIT", "EXIT" available ! under program operation. No permission checks other than on ! global process running program. No accounting/profile kept. %record %format crrf(%integer conad, filetype, datastart, dataend) %record (crrf) crname %record %format fhf(%integer end, start, size, type, fhole, dt, sp1, sp2) %record %format infof(%integer vsn, state, %string (7) ident, user, %string (15) dest, srce, output, %string (31) name, delivery, %string (63) message, %integer dtrec, dtst, dtopst, dtdel, start, length, time, (%integer oplim %or %integer cc), %integer size, (%integer prior %or %integer pc), %integer aftdt, ahead, %byte %integer forms, mode, copies, order, rerun, decks, drives, fails) {256 bytes} %record (infof) %name info %record %format pe(%integer dest, srce, p1, p2, p3, p4, p5, p6) %record %format reqf(%integer dest, srce, flag, %string (6) user, file, %integer p6) %record %format iostatf(%integer inpos, %string (15) intmess) %record (iostatf) %name iostat %record %format itf(%integer inbase, inlength, inpointer, outbase, outlength, outpointer, outbusy, omwaiting, intt waiting, jnbase, jncur, last free, sp5, sp6, sp7) %record (itf) %name it %constant %integer ncommands=10 %switch act(1:ncommands) %constant %string (7) %array commands(1:ncommands)="PRINT","P","STOP","QUIT", "S","QUEUE","Q","EXIT","E","APM" %string(2) snl %const %string(6) hpljowner="ECSC01" ;!Temporary for development %const %string(4) hpljproc="DP??" ;! "" %constant %integer hplj=2, hpljcode=6 %constant %integer true=1, false=0, tilde=126, on=1, off=0 %constant %integer bs=8,ff=12,cr=13,sub=x'1A',esc=x'1B',csi=x'5B',vpr=x'65', cpl=x'78',tbc=x'67',hpa=x'60',lsl=x'7B',spl=x'76',sss=x'79', rm=x'6c',sm=x'68',snv=x'77',ltof=x'3d',sgr=x'6d' {Codes for GP300} %constant %string (1) studk="^" %constant %integer sudk='^' %constant %integer prog vsn=4 %string (63) fileident %string (63) reply, action, param, file, user, ident %string (6) owner, printerst %string (8) chdev %string (4) cursor up, chhost %integer cv, ownerno, entries, f, conad, flag, lead in, pstate, n, i, oldcv %integer prtype, mode, feb285 %integer own fsys %integer pmode, bpass, printer %external %routine %spec console %alias "S#CONSOLE"(%integer ep, %integer %name a, b) %external %integer %function %spec exist(%string (31) file) %external %integer %function %spec ddelay(%integer n) %external %integer %function %spec dpon2(%string (6) user, %record (reqf) %name p, %integer msgtype, outno) %external %integer %function %spec dfsys(%string(6) user, %integername fsys) %external %integer %function %spec dtransfer(%string(6) user1, user2, %string(11) file, newname, %integer fsys1, fsys2, type) %external %integer %function %spec dsfi(%string (6) user, %integer fsys, type, set, adr) %external %integer %function %spec dspool(%record (pe) %name p, %integer len, adr) %external %integer %function %spec x29call %external %routine %spec connect %alias "S#CONNECT"(%string (31) s, %integer a, m, p, %record (crrf) %name r, %integer %name flag) %external %routine %spec rename %alias "S#RENAME"(%string (63) old, new, %integer %name flag) %external %routine %spec newgen %alias "S#NEWGEN"(%string (63) old, new, %integer %name flag) %external %routine %spec destroy %alias "S#DESTROY"(%string (63) s, %integer %name flag) %external %routine %spec disconnect %alias "S#DISCONNECT"(%string (63) s, %integer %name flag) %external %routine %spec trim %alias "S#TRIM"(%string (63) s, %integer %name flag) %external %routine %spec sdisconnect %alias "S#SDISCONNECT"(%string (31) s, %integer fsys, %integer %name flag) %external %routine %spec define(%string (255) s) %external %routine %spec list(%string (255) s) %external %routine %spec setmode(%string(255) s) %external %routine %spec messages(%string (63) s) %external %routine %spec outfile %alias "S#OUTFILE"(%string (31) s, %integer s, h, p, %integer %name conad, flag) %external %routine %spec prompt(%string (15) s) %external %integer %function %spec pstoi %alias "S#PSTOI"(%string (63) s) %external %string (*) %function %spec itos %alias "S#ITOS"(%integer i) %external %routine %spec psysmes %alias "S#PSYSMES"(%integer root, flag) %external %routine %spec stop(%string (255) s) %external %string (*) %function %spec uinfs(%integer type) %external %string (*) %function %spec date %external %string (*) %function %spec time %external %string (8) %function %spec unpack date %c %alias "S#UNPACKDATE"(%integer p) %external %string (8) %function %spec unpack time %c %alias "S#UNPACKTIME"(%integer p) %external %integer %function %spec current packed dt %c %alias "S#CURRENTPACKEDDT" %external %integer %function %spec dtword %alias "S#DTWORD"(%integer d) %external %integer %function %spec pack date and time %c %alias "S#PACKDATEANDTIME"(%string(8) date, time) %routine printstring(%string (255) s) %integer i printch(charno(s,i)) %for i = 1, 1, length(s) %end; ! Of %routine printstring. %routine gpad %string(40) st ! Sets TCP (or PAD) and FEP, to Graph mode. Switches echoing off. ! Switches flow on if not a PAD connection (already on if it is). st = "GRAPH=ON,ECHO=OFF" %if x29call=0 %then st = st.",FLOW=ON" setmode(st) %end; ! Of %routine gpad. %routine read as a string(%string %name s) %integer i %if mode=1 {endless printing} %and iostat_inpos=it_inpointer %start s = "PRINT"; ! Causes endless printing to resume. %return %finish s = "" printch(cr); printstring("Command:") %cycle read ch(i) %if i=nl %start printch(cr); printch(nl) %return %finish printch(i) %continue %if (i=' ' %and s="") %or i<' '; ! i.e. ignore other control characters. i = i&95 %if 'a'<=i<='z' s = s.tostring(i) %repeat %end; ! Of %routine read as a string. %routine get queue(%integer %name no, ad, f) %integer i %string (31) message %record (fhf) %name fh %record (infof) %name info %record (crrf) crr %record %format pe(%integer dest, srce, p1, p2, p3, p4, p5, p6) %record (pe) rp destroy("QINF", f) no = 0 message = "COMMAND *QUEUE ".printerst.",QINF" rp = 0 f = dspool(rp, length(message), addr(message)+1) %if f#0 %start printstring("Failed to access SPOOLER: ".itos(f).snl) %return %finish connect("QINF", 3, 0, 0, crr, f) %if f#0 %start psysmes(8, f) %return %finish fh == record(crr_conad) no = (fh_end-fh_start)//256; ! 256 is length of Spooler doc ad = crr_conad %end %routine get queued file(%string (6) ident, %integer %name flag) %record (reqf) req req = 0 req_dest = X'FFFF003C' req_flag = 1 req_user = owner; ! owner is global - process listing the queue. req_p6 = 1 req_file = ident flag = dpon2("SPOOLR", req, 1, 7) flag = 1 %and %return %if flag#0 flag = req_flag>>24 flag = 2 %if flag#0 %end; ! Of %routine get queued file. %routine remove queued file(%string (6) ident, %integer %name f) %record (reqf) req %integer fsys ! On return, f=0: File deleted ok ! f=1: Failed to access SPOOLR ! f=2: Failed to delete file fsys = pstoi(substring(ident, 1, 2)) sdisconnect("SPOOLR.".ident, fsys, f) req = 0 req_dest = X'FFFF003D' req_flag = 0 req_user = owner; ! owner is global - process listing the queue. req_file = ident f = dpon2("SPOOLR", req, 1, 7) f = 1 %and %return %if f#0 f = req_flag>>24 f = 2 %if f#0 %end; ! Of %routine remove queued file. %routine delete queued file(%string (6) ident, %integer %name flag) get queued file(ident, flag) remove queued file(ident, flag) %if flag=0 %end; ! Of %routine delete queued file. !******************************************************************! ! Check leadin sequence for von poff, voff pon ! !******************************************************************! %routine voff pon %return %if pstate=on; ! Printer on already. printch(leadin); printch('*'); printch(0); printch(0) pstate = on %end; ! Of %routine voff pon. %routine von poff ! Printer is always in default state if switched off. %return %if pstate=off ! Printer port is on - set printer to default values before switching off. !%if printer=gp300 %start ! printch(esc); printch(csi); printstring("100") ! printch(hpa); ! Move printhead off paper, to print 'tilde ?'. !%finish printch(leadin); printch('?'); printch(0); printch(0); ! Switch to video only. ! On X2700, this causes 'esc ?' to go to the printer, which generates an error ! message. Since, however, we are not using the (Xerox) Start Job command ! the error report does not get printed, and the user is not left with a ! mysterious sheet of error codes (very user-unfriendly!). pstate = off %end; ! Of %routine von poff. !***************************************************************************! !***************************************************************************! %routine apm transfer(%record(crrf)%name crname) %integer i,fptr,blockcnt %string(6) uno,xno %byteintegerarray buffer(0:511) ! von poff %if crname_filetype#3 %start printstring(fileident." is not a character file".snl) %return %finish %else %if crname_dataend>9+1 setmode("-G") printstring("L0LJPR") ; prompt("Uno:") ; read as a string(uno) printstring("T".uno."!LJP".itos(blockcnt)) ; prompt("Xno:") read as a string(xno) ! voff pon fptr=crname_conad+crname_datastart %while fptr+511<=crname_conad+crname_dataend %cycle %for i=0,1,511 %cycle buffer(i)=byteinteger(fptr) fptr=fptr+1 %repeat printstring("Y".xno) ; printsymbol(buffer(i)) %for i=0,1,511 %repeat %if fptr<=crname_conad+crname_dataend %start buffer(i)=0 %for i=0,1,511 %for i=fptr,1,crname_conad+crname_dataend %cycle buffer(i-fptr)=byteinteger(i) %repeat printstring("Y".xno) ; printsymbol(buffer(i)) %for i=0,1,511 printstring("K".xno) ; printstring("M".uno) ; newlines(2) %finish write(blockcnt,2) ; printstring(" Blocks transferred".snl.snl) gpad console(13,i,f) ; it==record(i) ; iostat==record(f) ! von poff newlines(2) printstring("File printed".snl) %end !**********************************************************************! %routine print next file(%record (infof) %name info, %integer %name f) ! Meaning of f on return from routine: ! 0 file printed ! 1 file not available ! 2 operator input detected %record (crrf) crr %record (infof) %name si %string (31) st, ident %integer i, s, filead, flag, p, fsys %routine print doc(%record (infof) %name info) %integer copies, cc0, f, i, pages, sdt, fdt copies = 1 info_copies = copies ! Device limit. messages("OFF") von poff %if pstate=on printstring("Printing ".info_name) printstring(" for ".info_user) spaces(14-length(info_name)) printstring("Length ="); write(info_length, 4) printstring(", Ident = ".info_ident) printstring(snl) sdt = current packed dt voff pon !*************************************************************! ! Code to transfer to APM FS goes here ! !*************************************************************! ! 1) Log to SPOOL process on FStore ! ! 2) %if error %exit and message ! ! 3) Transfer file at connect address ! ! 4) Close Transaction ! ! ! ! NB No accounting/copy kept ! !*************************************************************! ! list("DP".info_ident) ! disconnect("DP".info_ident, i) von poff printstring(cursor up."Printed:".snl) ! Enable video & disable printer. fdt = current packed dt messages("ON") %end; ! Of %routine print doc. ! ***Start of main code for %routine print next file*** f = 1 %and %return %if info==record(0) ident = info_ident get queued file(ident, flag) %if flag#0 %start %if flag=1 %start; ! Serious. printstring("Failed to access SPOOLR: ".itos(flag).snl) stop("") %finish f = 1; %return %finish ! Now connect file. fsys = pstoi(substring(ident, 1, 2)) p = (fsys<<8)!X'80' connect("SPOOLR.".ident, 0, 0, p, crr, flag) %if flag#0 %or crr_filetype#3 {char} %or crr_dataend>8, 1); write(i&255, 1) printstring(", at line ".itos(event line).snl) printstring("Please log off if you get this message repeatedly.".snl) ->restart %finish ! ***Start of code for %routine initialise*** ! Check EMAS process is accreditted as a special Printer snl = tostring(cr).tostring(nl) owner = uinfs(1) %if owner=hpljowner %start printer=hplj printerst = hpljproc own fsys = -1; f = dfsys(owner, own fsys) %finishelsestart printstring("Printer not accreditted".snl) stop("") %finish feb285 = pack date and time("02/02/85","00.00.00") lead in = esc {%else lead in = tilde ; check this for terminal} mode = 0; ! Command mode. "Endless printing" is mode 1. gpad; ! = SETMODE(GRAPH=ON,ECHO=OFF), and FLOW=ON if a TCP. ! The following codes assume a Hazeltine Esprit II terminal, with a GP300 or X2700 ! connected as auxiliary printer. The Esprit must have lead-in set to be tilde ! if the printer is a GP300, and to escape if the printer is a X2700. cursor up = tostring(lead in).tostring(ff) console(13, i, f) it == record(i) iostat == record(f) printch(leadin); printch('?'); printch(0); printch(0) pstate = off; ! Printer state. param = "?" voff pon %if pstate=off restart: von poff; printstring(snl); ! This sets the printer to its defaults. prompt(snl."Command:") reply = "" cv = 0 %cycle oldcv = cv %cycle; ! to find which printer service is required read as a string(reply) %while reply="" param = "" %unless reply->action.(" ").param %then action = reply reply = "" %for cv = 1, 1, ncommands %cycle %if action=commands(cv) %then ->act(cv) %repeat printstring("Illegal command".snl) %repeat act(1): ! PRINT act(2): ! P ident = ""; user = ""; file = "" mode = 1; ! "Endless print" mode (causes input routine to return "PRINT"). flag = 0 %cycle get queue(entries, conad, f) %unless 6<=old cv<=7 {QUEUE or Q} old cv = 1 %if entries=0 %start ! Nothing to print at present. f = ddelay(1); ! Wait 2 minutes. flag = 2 %if iostat_inpos#it_inpointer; ! Operator input. setmode("-G") write(iostat_inpos,2) ; write(it_inpointer,2) ; newline %continue %finish n = 0 %if entries>0 %start %for i = 1, 1, entries %cycle info == record(conad+32+(i-1)*256) print next file(info, flag) ! flag return values: ! 0 file printed ! 1 specified file not available n = n+1 %if flag=0 %repeat %finish %if n=0 %and flag#2 %start ! Unexpected failure to print any files - put in a delay (2 minutes). f = ddelay(120) flag = 2 %if iostat_inpos#it_inpointer %finish %repeat %until flag=2 %continue act(3): ! STOP act(4): ! QUIT act(5): ! S setmode("-G") stop("") act(6): ! QUEUE act(7): ! Q ident = ""; user = ""; file = "" %unless param->user.(".").file %then user = param get queue(entries, conad, f) %continue %if f#0; ! Message already printed. printstring("Printer queue is currently empty.".snl) %and %c %continue %if entries=0 printstring(snl) printstring(" User Filename Date/time listed ") printstring("Length Identifier Copies Forms Barred".snl) %for i = 1, 1, entries %cycle info == record(conad+32+(i-1)*256) printstring(info_user) spaces(12-length(info_name)); printstring(info_name." ") printstring(unpackdate(info_dtrec)." ".unpacktime(info_dtrec)) write(info_length, 7); printstring(" ".info_ident) printstring(snl) %repeat printstring(snl) %continue act(8): ! EXIT act(9): ! E mode = 0; ! Terminate "endless printing" mode. %continue act(10): ! APM {Development only, use PRINT when spool proc. implemented} mode =0 von poff prompt("File:") read as a string(fileident) prompt("Command:") connect(fileident, 0, 0, ownfsys, crname, flag) %if flag#0 %start printstring("Failed to connect file ".fileident.snl) %continue %finish printstring("Connected file ".fileident.snl) apm transfer(crname) prompt("Command:") %repeat %end; ! OF INITIALISE %external %integer %function allowcommand %alias "S#ALLOWCOMMAND"(%string (31) command) %result = 1 %unless command="STOP" %or command="QUIT" %result = 0 %end %external %integer %function allowconnect %alias "S#ALLOWCONNECT"(%string (6) user, %string (11) file) %result = 1 %end %end %of %file