(****************************************************************) (* *) (* Gardens Point Modula-2 Library Definition *) (* *) (* *) (* (c) Copyright 1996 Faculty of Information Technology *) (* Queensland University of Technology *) (* *) (* Permission is granted to use, copy and change this *) (* program as long as the copyright message is left intact *) (* *) (****************************************************************) FOREIGN DEFINITION MODULE ShellPipes; IMPORT IMPLEMENTATION FROM "shellpipes.o"; FROM UxFiles IMPORT File; PROCEDURE PipeInput(command : ARRAY OF CHAR; VAR stream : File; VAR opened : BOOLEAN); (* An input stream is returned, or opened is retured false *) (* The standard output of the shell command is piped to the *) (* stream, where it may be read by standard input operations *) PROCEDURE PipeOutput(command : ARRAY OF CHAR; VAR stream : File; VAR opened : BOOLEAN); (* An output stream is returned, or opened is retured false *) (* Output to the stream is piped as standard input to the *) (* specified shell command *) PROCEDURE ClosePipe(stream : File); (* closes the pipe associated with the specified stream *) (* typical usage : * * FROM ShellPipes IMPORT PipeInput, ClosePipe; * ... * PipeInput("ls -1 *.def", inFile, ok); * IF ok THEN * WHILE NOT EndFile(inFile) DO * ... * END; * ClosePipe(inFile); * ELSE ... *) END ShellPipes.