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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,130283ad9c6c2e69,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-13 06:34:44 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!msuinfo!harbinger.cc.monash.edu.au!aggedor.rmit.EDU.AU!goanna.cs.rmit.oz.au!macdale.cs.rmit.edu.au!dale From: Dale Stanbrough Newsgroups: comp.lang.ada Subject: Interfacing Ada to Unix/execl var. arg. list function? Date: 13 Oct 1994 07:44:37 GMT Organization: RMIT, Melbourne, Australia Distribution: world Message-ID: <37ioh5$h9v@goanna.cs.rmit.oz.au> NNTP-Posting-Host: macdale.cs.rmit.edu.au X-UserAgent: Version 1.1.3 X-XXMessage-ID: X-XXDate: Thu, 13 Oct 94 17:46:17 GMT Date: 1994-10-13T07:44:37+00:00 List-Id: I am currently trying to develop a simple Ada/Unix binding (not Posix!) that will allow students to use the packages with a minimum of fuss. (i.e. reading the Unix man page/Unix programming text would give them a fair idea of how to use the Ada version). I've got stuck on how to implement Ada calls to the corresponding variable parameter list C functions, specifically execl. Also the solutions I have written currently look clunky. I was wondering if there was a better way to implement these features. Problem #1. ----------- Passing in a list of variable length strings... The possible options for passing in strings would be... type string_ptr is access all string; type string_array is array(natural range <>) of string_ptr; then... #1 ...execv(pathname, strings'("a","bb","cccc")); #2 ...execv(pathname, strings_array'("a"'access, "bb"'access, "ccc"'access)); #3 ...execv(pathname, strings_array'(a'access,b'access,c'access)); #4 ...execv(pathname, ?); #1 won't work because arrays elements have to be the same size #2 won't work because I don't know why ?:-/ (I wish Gnat gave me LRM ref's!). #3 seems awfully clunky, esp. as you have to alias all the strings before hand. #4 is there a better one? Problem #2. ----------- Defining a constant null array seems to require the declaration of a superfluous variable just to make the compiler happy... ------------------------------------------------------------ package unix is type string_ptr is access all string; type string_array is array(natural range <>) of string_ptr; null_arg_list :constant string_array; function execl( path :string; arg_list:string_array := null_arg_list) return integer; private dummy :aliased constant string := ""; --?? superfluous? null_arg_list :constant string_array := (1..0 => dummy'access); end unix.process; ------------------------------------------------------------ Problem #3. ----------- How to specify and pass in a variable list of pointers to a C program. (Yes, I know we've been down this path before, but generally w.r.t. printf, which has varying types of parameters, as well as number). ----------------------------------------------------------- -- Calling profile for execl in C. -- -- int execl(path, arg0 [ , arg1,... , argn ] (char *)0) -- char *path, *arg0, *arg1, ..., *argn; -- function execl( path :string; arg_list :string_array) return integer is --------------------------------------------- function C_execl( path :system.address; C_arg_list: --?? What type here? return interfaces.c.int; pragma import(C, C_execl, "execl"); begin -- how to do this? end; ----------------------------------------------------------- Thanks for any help you can give... Dale ------------------------------------------------------------- Dale Stanbrough, RMIT, Melbourne, Australia, dale@rmit.edu.au GNU Ada 94 (GNAT) => the best $0 you'll ever spend. Available for DOS, Linux, OS/2, Sun Sparc, Sun Solaris, ... Coming to a GNU supported platform near you soon...