-- Source code for an article published at the Ada Home
--
-- A Thick Ada 95 Binding for Unix Child Processes and Pipes
-- by Jim Rogers
-- February 1998
--
-- See
--------------------------------------------------------------------------------
-- This package defines a thick Ada binding to the UNIX popen and pclose
-- commands
--------------------------------------------------------------------------------
with Interfaces.C_Streams; use Interfaces.C_Streams;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Ada_Home.Unix.Pipe_Commands is
type stream is private;
type IO_MODE is (read_file, write_file);
function execute (Command : in string; IO_type : in IO_Mode)
return stream;
function read_next (FromFile : in stream)
return unbounded_string;
procedure write_next (ToFile : in stream; Message : in string);
procedure close (OpenFile : in stream);
Access_Error : exception; -- Raised when attempt is made to violate IO_MODE
End_Of_File : exception; -- Raised on detection of End_of_file during read
private
type stream is record
FileStream : Files;
Mode : IO_Mode;
end record;
end Ada_Home.Unix.Pipe_Commands;