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-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news3.google.com!feeder.news-service.com!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!npeer.de.kpn-eurorings.net!npeer-ng1.kpn.DE!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Directory Operations Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-5" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <91990db2-68b4-4710-ba9b-b3a9d8375cad@e38g2000prn.googlegroups.com> <1b1xmaowns246.x8v3yiu0yo6g.dlg@40tude.net> Date: Tue, 4 Nov 2008 15:44:31 +0100 Message-ID: NNTP-Posting-Date: 04 Nov 2008 15:44:31 CET NNTP-Posting-Host: 239a146c.newsspool1.arcor-online.net X-Trace: DXC=ecnb`kgb=3dcngmh0hj X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:2566 Date: 2008-11-04T15:44:31+01:00 List-Id: On Tue, 4 Nov 2008 04:57:17 -0800 (PST), AndreiK wrote: > On 3 ����, 19:33, "Dmitry A. Kazakov" > wrote: > >> 2. Should you keep it non-Ada, then >> >> 2.a. how is this supposed to work? >> 2.b. Where is the string allocated? >> 2.c. Who will dispose it? When? >> 2.d. What happens when called from multiple threads? > > Yes I have to keep it in non-Ada, more exact I have to use it in the > "NI LabVIEW" > 2.a The LabVIEW calls the functions from DLL. > 2.b,c LabVIEW allocates the string. > 2.d --- I don't now In this case it should be something like this. LabVIEW passes a buffer to Ada (Path, equivalent to char *), and the length of the buffer (Length). Then with Ada.Characters.Latin_1; with Ada.Directories; use Ada.Directories; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; procedure Pwd (Path : chars_ptr; Length : size_t) is Result : constant String := Current_Directory & Ada.Characters.Latin_1.NUL; begin if Result'Length > Length then ... -- What do you do when the buffer is too short? else Update (Path, 0, Result, False); end if; end Pwd; >From C it is called like: { char buffer [1024]; pwd (buffer, sizeof (buffer)); ... } However, you should really refer to LabVIEW documentation regarding the way it passes strings around. Once you know it, you can interface Ada. The code above is merely a wild guess about how the interface might look like. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de