comp.lang.ada
 help / color / mirror / Atom feed
From: "Alex R. Mosteo" <devnull@mailinator.com>
Subject: Re: binding to C: popen
Date: Tue, 21 Feb 2006 17:12:04 +0100
Date: 2006-02-21T17:12:04+01:00	[thread overview]
Message-ID: <43FB3BD4.7050700@mailinator.com> (raw)
In-Reply-To: <43fb35a4$0$178$edfadb0f@dread11.news.tele.dk>

Poul-Erik Andreasen wrote:
> jimmaureenrogers@worldnet.att.net wrote:
> 
>> Poul-Erik Andreasen wrote:
>>
>>> 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?
>>
>>
>>
>> The popen man page describes the command as:
>> FILE *popen(const char *command, const char *mode);
>>
>> Note that popen returns a file pointer. Upon failure it returns a null
>> pointer.
>>
>> It seems that you might be able to test if the return value is null.
>>
>> Jim Rogers
>>
> 
> Yes but a C pointer is in Ada represented as system.address (...)

Not necessarily. Have a look at Interfaces.C, Interfaces.C.Pointers and 
Interfaces.C.Strings.

Also with Gnat an access type with pragma Convention (C, ...) can do the 
trick. You can easily check for null pointers that way.



  parent reply	other threads:[~2006-02-21 16:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-21 14:37 binding to C: popen Poul-Erik Andreasen
2006-02-21 15:25 ` jimmaureenrogers
2006-02-21 15:45   ` Poul-Erik Andreasen
2006-02-21 15:52     ` Georg Bauhaus
2006-02-21 16:16       ` Poul-Erik Andreasen
2006-02-21 16:12     ` Alex R. Mosteo [this message]
2006-02-21 23:51     ` Jeffrey R. Carter
2006-02-22 13:50 ` Marc A. Criley
2006-02-23  1:10   ` poulerik
replies disabled

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