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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,463c5796782db6d8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-09 00:50:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news-xfer.cox.net!cox.net!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail From: "Eric G. Miller" Subject: Re: [Spark] Arrays of Strings User-Agent: Pan/0.13.4 (She had eyes like strange sins. (Debian GNU/Linux)) Message-ID: Newsgroups: comp.lang.ada References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Wed, 09 Apr 2003 07:50:16 GMT NNTP-Posting-Host: 216.119.12.84 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1049874616 216.119.12.84 (Wed, 09 Apr 2003 00:50:16 PDT) NNTP-Posting-Date: Wed, 09 Apr 2003 00:50:16 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:36005 Date: 2003-04-09T07:50:16+00:00 List-Id: In , Lutz Donnerhacke wrote: > In order to implement thin an execve binding, I wonder how to emulate the > C-Type "char const * const x []". Any bright ideas? Errm, my local definition of execve looks like: int execve(const char *filename, char *const argv [], char *const envp[]); What'd the const pointer be for? Even if your definition had such, that'd be a burden upon the C function, but shouldn't much affect the Ada side of things. Try the following out (rename "/tmp/hello" as appropriate)... -- executor.ads with Interfaces.C.Strings; package Executor is package C renames Interfaces.C; function Execve (Filename : C.Strings.Chars_Ptr; Argv : C.Strings.Chars_Ptr_Array; Envp : C.Strings.Chars_Ptr_Array) return C.Int; pragma Import (Convention => C, Entity => Execve, External_Name => "execve"); end Executor; -- try_exec.adb with Ada.Text_Io; use Ada.Text_Io; with Executor; with Interfaces.C.Strings; procedure Try_Exec is package C renames Interfaces.C; Argv : C.Strings.Chars_Ptr_Array := (C.Strings.New_String("John"), C.Strings.New_String("Bill"), C.Strings.New_String("Bob"), C.Strings.Null_Ptr); -- GNAT says there can't only be one?? Envp : C.Strings.Chars_Ptr_Array := (C.Strings.Null_Ptr, C.Strings.Null_Ptr); FileName : C.Strings.Chars_Ptr := C.Strings.New_String("/tmp/hello"); Status : C.Int; begin Status := Executor.Execve(FileName => FileName, Argv => Argv, Envp => Envp); -- Got here? Put_Line ("That didn't work! Got " & C.Int'Image(Status)); end Try_Exec; -- hello.c #include int main (int argc, char *argv[]) { int i; for (i = 0; i < argc; ++i) { printf ("Hello %s!\n", argv[i]); } return 0; } -- echo ">gra.fcw@2ztr< eryyvZ .T pveR" | rot13 | reverse