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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,35ee0472de38e833 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-11 19:33:05 PST Path: supernews.google.com!sn-xit-02!supernews.com!isdnet!enst!enst.fr!not-for-mail From: "Beard, Frank" Newsgroups: comp.lang.ada Subject: RE: Variable length raw-byte data Date: Mon, 11 Dec 2000 22:30:12 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: avanie.enst.fr 976591928 45851 137.194.161.2 (12 Dec 2000 03:32:08 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 12 Dec 2000 03:32:08 +0000 (UTC) To: "'comp.lang.ada@ada.eu.org'" Return-Path: X-Mailer: Internet Mail Service (5.5.2448.0) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0beta5 Precedence: bulk List-Id: comp.lang.ada mail<->news gateway Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: supernews.google.com comp.lang.ada:2972 Date: 2000-12-11T22:30:12-05:00 Try looking at Interfaces.C and Interfaces.C.Pointers. If it's string data, look at Interfaces.C.Strings. I've used this successfully to interface to C. Or In your interface routine, receive the pointer as an address, and then unchecked convert it. type Byte is mod 2**8; type Byte_Array is array (positive range <>) of Byte; type Byte_Array_Pointer is access Byte_Array; buffer_Address : System.Address; buffer_Pointer : Byte_Array_Pointer; begin ... status := Get_C_Stuff(length => length, buffer_Address => buffer_Address); if (length > 0) then declare subtype Constrained_Byte_Array is Byte_Array(1..length); function To_Buffer_Pointer is new Ada.Unchecked_Conversion(System.Address,Constrained_Byte_Array); begin buffer_Pointer := To_Buffer_Pointer(buffer_Address); end; ... end if; ... Something like that. (Constructive corrections only please!) I haven't done it this way in a while. Frank -----Original Message----- From: Julian Morrison [mailto:julian.morrison@virgin.net] Sent: Monday, December 11, 2000 2:38 PM To: comp.lang.ada@ada.eu.org Subject: Variable length raw-byte data I'm trying to shim to a C library that returns some data as a length in bytes and a pointer to the first byte. The length is not known at compile time. Is there any way I can morph this into an array of mod 2**8? I'm using the latest Linux GNAT. _______________________________________________ comp.lang.ada mailing list comp.lang.ada@ada.eu.org http://ada.eu.org/mailman/listinfo/comp.lang.ada