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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.yTvCNOh9TRCAIcX40YItlQ.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: differences between Ada and C in gnat forcing me to use C instead of Ada Date: Mon, 25 Mar 2019 19:18:44 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <6ffc660f-07a5-4f07-95ad-8abec510b00b@googlegroups.com> NNTP-Posting-Host: yTvCNOh9TRCAIcX40YItlQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:55962 Date: 2019-03-25T19:18:44+01:00 List-Id: On 2019-03-25 17:42, matthewbrentmccarty@gmail.com wrote: > This function can be used to query the list of devices that are available. If the function executes successfully, it stores a pointer to a NULL terminated array of pointers to SANE_Device structures in *device_list. The returned list is guaranteed to remain unchanged and valid until (a) another call to this function is performed or (b) a call to sane_exit() is performed. This function can be called repeatedly to detect when new devices become available. If argument local_only is true, only local devices are returned (devices directly attached to the machine that SANE is running on). If it is false, the device list includes all remote devices that are accessible to the SANE library. > > SANE_Status sane_get_devices (const SANE_Device *** device_list, > SANE_Bool local_only); > > This function may fail with SANE_STATUS_NO_MEM if an insufficient amount of memory is available. > > Backend Implementation Note > SANE does not require that this function is called before a sane_open() call is performed. A device name may be specified explicitly by a user which would make it unnecessary and undesirable to call this function first. type SANE_Device is record name : chars_ptr; vendor : chars_ptr; model : chars_ptr; c_type : chars_ptr; end record; pragma Convention (C, SANE_Device); type SANE_Device_Ptr is access all SANE_Device; pragma Convention (C, SANE_Device_Ptr); -- Flat array of devices type SANE_Device_Array is array (size_t) of SANE_Device_Ptr; pragma Convention (C, SANE_Device_Array); type SANE_Device_Array_Ptr is access all SANE_Device_Array; pragma Convention (C, SANE_Device_Array_Ptr); function SANE_get_devices ( device_list : not null access SANE_Device_Array_Ptr; local_only : SANE_Bool ) return SANE_Status; pragma Import (C, SANE_get_devices); --------------------------------- List_Ptr : SANE_Device_Array_Ptr; begin SANE_get_devices (List, 0); declare List : SANE_Device_Array renames List.all; begin for Index in List'Range loop -- "Infinite" loop exit when List (Index) = null; -- Null-terminated Put_Line ("Device: " Value (List (Index).name); end loop; end; end; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de