From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,d4101555aa2cd72c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.224.18.199 with SMTP id x7mr4715302qaa.1.1361992935001; Wed, 27 Feb 2013 11:22:15 -0800 (PST) X-Received: by 10.49.35.77 with SMTP id f13mr437066qej.4.1361992934975; Wed, 27 Feb 2013 11:22:14 -0800 (PST) Path: y6ni7qaj.0!nntp.google.com!dd2no3548339qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 27 Feb 2013 11:22:14 -0800 (PST) In-Reply-To: <8975ebc3-3198-43e6-be68-f3e2ee84bc37@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=129.59.203.209; posting-account=7Oy7OQoAAABhVYFOo553Cn1-AaU-bSfl NNTP-Posting-Host: 129.59.203.209 References: <8975ebc3-3198-43e6-be68-f3e2ee84bc37@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: reading from a pipe From: Eryndlia Mavourneen Injection-Date: Wed, 27 Feb 2013 19:22:14 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2013-02-27T11:22:14-08:00 List-Id: 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