From: tmoran@acm.org
Subject: Re: C lib returns char** - How in ADA?
Date: Thu, 30 May 2002 07:57:22 GMT
Date: 2002-05-30T07:57:22+00:00 [thread overview]
Message-ID: <CXkJ8.1185$dH4.192562205@newssvr13.news.prodigy.com> (raw)
In-Reply-To: pan.2002.05.30.02.29.15.879907.5334@cowgar.com
> char **ldap_get_values(...)
> Can anyone help me out with this and let me know what it should look like
> in the .ads and on the implementing .adb side?
Your mention of "the implementing .adb side" suggests you are trying
to make an Ada function callable from C. OTOH, asking about a C lib
suggests the C function exists already and you are trying to call it
from Ada. Assuming the latter is the case, using Interfaces.C.Strings
you could do something like:
with Interfaces.C.Strings,
Ada.Text_Io;
procedure ppc is
use type Interfaces.C.Strings.Chars_Ptr;
subtype Indefinite_List_Of_Chars_Ptr
is Interfaces.C.Strings.Chars_Ptr_Array(Interfaces.C.Size_T);
type Ptr_To_Indefinite_List is access all Indefinite_List_Of_Chars_Ptr;
function Ldap_Get_Values(Dummy : Integer) return Ptr_To_Indefinite_List;
pragma Import(Stdcall, Ldap_Get_Values, "ldap_get_values");
P : Ptr_To_Indefinite_List;
begin
P := Ldap_Get_Values(Dummy => 0);
for I in Interfaces.C.Size_T loop
exit when P(I) = Interfaces.C.Strings.Null_Ptr;
Ada.Text_Io.Put_Line(Interfaces.C.Strings.Value(P(I)));
end loop;
end ppc;
next prev parent reply other threads:[~2002-05-30 7:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-30 6:34 C lib returns char** - How in ADA? Jeremy Cowgar
2002-05-30 7:42 ` sk
2002-05-30 7:56 ` sk
2002-05-30 7:57 ` tmoran [this message]
2002-05-30 16:32 ` Pascal Obry
2002-05-31 0:28 ` Jeremy Cowgar
2002-05-31 18:46 ` Pascal Obry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox