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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1c1739e9e6a4a7c5,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!newsfeed.hanau.net!news-fra1.dfn.de!news.tele.dk!feed118.news.tele.dk!not-for-mail Date: Tue, 21 Feb 2006 15:37:02 +0100 From: Poul-Erik Andreasen User-Agent: Debian Thunderbird 1.0.2 (X11/20051002) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: binding to C: popen Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <43fb258f$0$170$edfadb0f@dread11.news.tele.dk> Organization: TDC Totalloesninger NNTP-Posting-Host: 80.166.145.174 X-Trace: 1140532623 dread11.news.tele.dk 170 80.166.145.174:36898 X-Complaints-To: abuse@post.tele.dk Xref: g2news1.google.com comp.lang.ada:3037 Date: 2006-02-21T15:37:02+01:00 List-Id: Hi i am trying to make a biding to the C function popen, it goes like this: with System.Address_To_Access_Conversions; with Interfaces.C_Streams; package Pipe_Pkg is subtype Command_Pipe is Interfaces.C_Streams.FILEs; procedure Pipe_Open (Pipe : in out Command_Pipe; Command : in String); private function To_C (Input : in String) return Interfaces.C_Streams.Chars; end Pipe_Pkg; package body Pipe_Pkg is procedure Pipe_Open (Pipe : in out Command_Pipe; Command : in String) is use Interfaces.C_Streams; function C_Popen (C_Command : Chars; C_Type : Chars) return Command_Pipe; pragma Import (C, C_Popen, "popen"); begin Pipe := C_Popen ((To_C (Command)), To_C ("w")); end Pipe_Open; function To_C (Input : in String) return Interfaces.C_Streams.Chars is package String_Conversion is new System.Address_To_Access_Conversions (String); String_Pointer : String_Conversion.Object_Pointer := new String'(Input & ascii.nul); begin return String_Conversion.To_Address (String_Pointer); end; end Pipe_Pkg; This ictually going as it is suppose to, but i would like set in an exception if the piping dosn't have succes. Acording to the C manual popen returns null if it fails. But how do i test on that in the FILEs type?