program pipes; {---------------------------------------------------------------} { pipes - change parameters of spooler driver { { date : 13-Feb-1984 { file : pipes.text { { Keith Ball { last modified : 13-Feb-1984 { {---------------------------------------------------------------} const pgmname = 'Pipes'; vrsn = '1.0a'; date = '13-Feb-1984'; SpoolDrv = 3; {spooler driver unit number} {function codes to unitstatus functions of driver} ChngPiName = 18; {change pipe name} CloseFunc = 19; {close pipe} ChngMessg = 20; {change message} SlotServer = 21; {change slot and server numbers} type str40: string[40]; var i: integer; s: string[120]; procedure DoClose; var ior: integer; begin unitstatus(SpoolDrv,ior,CloseFunc); ior := ioresult; if ior <> 0 then writeln('Pipe close failed. Error = ',ior); end; procedure CallDriver(fnccode: integer; errmsg: str40;); var ior,eq: integer; begin eq := pos('=',s); if (eq = 0) or (eq+1 >= length(s)) then exit(CallDriver); s := copy(s,eq+1,length(s)); unitstatus(SpoolDrv,s,fnccode); ior := ioresult; if ior <> 0 then writeln(errmsg,' Error = ',ior); end; procedure DoMessage; begin CallDriver(ChngMessg,'Message change failed.'); end; procedure DoPipeName; begin CallDriver(ChngPiName,'Pipe name change failed.'); end; function ConvertInt(st: str40): integer; begin temp := 0; i := 1; Stop := FALSE; while (i <= length(st)) and (NOT Stop) do begin if (st[i] >= '0') and (st[i] <= '9') then temp := (temp * 10) + (ord(st[i]) - ord('0')) else Stop := TRUE; i := i + 1; end; if Stop then ConvertInt := -1 else ConvertInt := temp; end; procedure DoServerSlot; var i,eq,l: integer slt,srv: str40; ss: record slot,server: integer; end; begin eq := pos('=',s); if (eq = 0) or (eq+1 >= length(s)) then exit(DoServerSlot); s := copy(s,eq+1,length(s)); l := pos('/',s); if (l = 0) then l := length(s); slt := copy(s,1,l); if (l+1 < length(s)) then srv := copy(s,l+1,length(s)) else srv := ''; with ss do begin slot := ConvertInt(slt); if (slot < 1) or (slot > 5) then begin writeln('Invalid slot number : ',slt); exit(DoServerSlot); end; server := ConvertInt(srv); if (server < 0) or (slot > 63) then begin writeln('Invalid server number : ',srv); exit(DoServerSlot); end; end; unitstatus(SpoolDrv,ss,SlotServer); ior := ioresult; if ior <> 0 then writeln('Slot/Server number change failed.' Error = ',ior); end; begin if argc = 0 then begin writeln(pgmname,' - ',vrsn,' ',date); writeln('Valid command line parameters :'); writeln(' close - close the current pipe.'); writeln(' m= - change the message to what follows =.'); writeln(' n= - change the pipe name to what follows =.'); writeln(' s= - change the slot/server numbers to what follows =.'); writeln; writeln('Examples :'); writeln(' pipes m=This_is_a_message'); writeln(' pipes n=NEC'); exit(pipes); end; for i := 1 to argc do begin s := argv[i]^; if (s[1] >= 'a') and (s[1] <= 'z') then s[1] := chr(ord(s[1]) - $20); if (s[1] = 'C') then DoClose else if (s[1] = 'M') then DoMessage else if (s[1] = 'N') then DoPipeName else if (s[1] = 'S') then DoServerSlot; end; end.