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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,56e5e06428166864 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!news.netcologne.de!newsfeed-fusi2.netcologne.de!newsfeed.straub-nv.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: problems with interfacing c Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <8b6a5b24-5ab0-4d38-9be8-86911aba7fcf@k22g2000yqh.googlegroups.com> <13d5wy5ni51xh$.xnhoi3uhm9ql.dlg@40tude.net> <85c958cc-8cd3-46be-b14d-3519ff207d87@b8g2000vbi.googlegroups.com> Date: Fri, 28 Jan 2011 10:44:58 +0100 Message-ID: <1dfd4mpvmtkt2.aqwiaoz63qli$.dlg@40tude.net> NNTP-Posting-Date: 28 Jan 2011 10:44:58 CET NNTP-Posting-Host: 8555f161.newsspool1.arcor-online.net X-Trace: DXC=HZB>K3jZ5WUV0Pe9PRnbJ\ic==]BZ:af^4Fo<]lROoRQ<`=YMgDjhgRniX0T=6Vh`X[6LHn;2LCV^7enW;^6ZC`T\`mfM[68DCSIU On Thu, 27 Jan 2011 16:39:50 -0800 (PST), Stoik wrote: > The other question is - how to use the C bindings properly in such a > case? You should probably use _read, because fread needs a file descriptor rather than just number. with Interfaces.C; use Interfaces.C; with System; use System; ... function Read (FD : int; Buffer : Address; Count : size_t) return int; pragma Import (C, Read, "_read"); ... Now actual reading: Buffer : String (1..100_000); Bytes : int; begin Bytes := Read (0, Buffer'Address, Buffer'Length); Buffer (1..Integer (Bytes)) is the data read, empty when error. Here I assume that Character = char, so it might be non-portable, but who cares in these meaningless contests? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de