comp.lang.ada
 help / color / mirror / Atom feed
From: Eryndlia Mavourneen <eryndlia@gmail.com>
Subject: Re: reading from a pipe
Date: Wed, 27 Feb 2013 11:22:14 -0800 (PST)
Date: 2013-02-27T11:22:14-08:00	[thread overview]
Message-ID: <b722f052-80c3-42b7-b94d-34a5395b4c14@googlegroups.com> (raw)
In-Reply-To: <8975ebc3-3198-43e6-be68-f3e2ee84bc37@googlegroups.com>

On Wednesday, February 27, 2013 11:36:32 AM UTC-6, milouz wrote:
> Hi,
> 
> 
> 
> I'd like to know how to read some bytes from a pipe or some other non-regular file such as device. I had a look at streams_io, direct_io, etc. but was not able to code something working.
> 
> 
> 
> How do we do that in Ada ?

The following is a partial solution to the question, but gives the general idea:

-------------------------------

   with Ada.Text_IO, Ada.Text_IO.Text_Streams;
   use  Ada.Text_IO, Ada.Text_IO.Text_Streams;
   procedure Write_It is
      type My_Record_Type is ...;
      The_Record : My_Record_Type;
      Cmd_Stream : Text_Streams.Stream_Access := Stream (Standard_Output);
   begin
      My_Record_Type'Write (Cmd_Stream, The_Record);
   end Write_It;

--------------------------------

   with Ada.Text_IO, Ada.Text_IO.Text_Streams;
   use  Ada.Text_IO, Ada.Text_IO.Text_Streams;
   procedure Read_It is
      type My_Record_Type is ...;
      The_Record : My_Record_Type;
      Cmd_Stream : Text_Streams.Stream_Access := Stream (Standard_Input);
   begin
      My_Record_Type'Read (Cmd_Stream, The_Record);
   end Read_It;

--------------------------------

Build as two processes and invoke within .exe directory as:

   $ ./write_it | ./read_it

--------------------------------

  -- Eryndlia



  reply	other threads:[~2013-02-27 19:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-27 17:36 reading from a pipe milouz
2013-02-27 19:22 ` Eryndlia Mavourneen [this message]
2013-02-27 19:39 ` Dmitry A. Kazakov
2013-02-28  2:59 ` ytomino
2013-02-28 12:00   ` milouz
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox