comp.lang.ada
 help / color / mirror / Atom feed
* reading from a pipe
@ 2013-02-27 17:36 milouz
  2013-02-27 19:22 ` Eryndlia Mavourneen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: milouz @ 2013-02-27 17:36 UTC (permalink / raw)


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 ?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: reading from a pipe
  2013-02-27 17:36 reading from a pipe milouz
@ 2013-02-27 19:22 ` Eryndlia Mavourneen
  2013-02-27 19:39 ` Dmitry A. Kazakov
  2013-02-28  2:59 ` ytomino
  2 siblings, 0 replies; 5+ messages in thread
From: Eryndlia Mavourneen @ 2013-02-27 19:22 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: reading from a pipe
  2013-02-27 17:36 reading from a pipe milouz
  2013-02-27 19:22 ` Eryndlia Mavourneen
@ 2013-02-27 19:39 ` Dmitry A. Kazakov
  2013-02-28  2:59 ` ytomino
  2 siblings, 0 replies; 5+ messages in thread
From: Dmitry A. Kazakov @ 2013-02-27 19:39 UTC (permalink / raw)


On Wed, 27 Feb 2013 09:36:32 -0800 (PST), milouz wrote:

> 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 ?

There is no Ada way of doing that, because such operations are OS-specific.

Otherwise, you use the services provided by the OS at hand. E.g. under
Windows you call CreateFile, then do ReadFile. These are provided by
Win32Ada bindings.

There are also some libraries available that provide some layer of OS
abstraction, e.g. Glib. For these there exist Ada bindings as well.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: reading from a pipe
  2013-02-27 17:36 reading from a pipe milouz
  2013-02-27 19:22 ` Eryndlia Mavourneen
  2013-02-27 19:39 ` Dmitry A. Kazakov
@ 2013-02-28  2:59 ` ytomino
  2013-02-28 12:00   ` milouz
  2 siblings, 1 reply; 5+ messages in thread
From: ytomino @ 2013-02-28  2:59 UTC (permalink / raw)


On Thursday, February 28, 2013 2:36:32 AM UTC+9, 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 ?

Use Florist.
See http://en.wikibooks.org/wiki/Ada_Programming/Platform/POSIX



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: reading from a pipe
  2013-02-28  2:59 ` ytomino
@ 2013-02-28 12:00   ` milouz
  0 siblings, 0 replies; 5+ messages in thread
From: milouz @ 2013-02-28 12:00 UTC (permalink / raw)


> Use Florist.
> 
> See http://en.wikibooks.org/wiki/Ada_Programming/Platform/POSIX

It looks great. Thanks ! 



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-28 12:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-27 17:36 reading from a pipe milouz
2013-02-27 19:22 ` Eryndlia Mavourneen
2013-02-27 19:39 ` Dmitry A. Kazakov
2013-02-28  2:59 ` ytomino
2013-02-28 12:00   ` milouz

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