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,15d349644a4a019d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-08 01:13:17 PST Sender: jerry@JVDSYS Newsgroups: comp.lang.ada Subject: Re: HELP: PC System Call References: From: Jerry van Dijk Date: 08 Jun 2002 09:59:36 +0200 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 139.92.238.240 X-Trace: 8 Jun 2002 08:07:33 GMT, 139.92.238.240 Organization: Global Network Services - Remote Access Mail & News Services X-Complaints-To: abuse@prserv.net Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.us.prserv.net!prserv.net!news3.prserv.net!139.92.238.240 Xref: archiver1.google.com comp.lang.ada:25511 Date: 2002-06-08T09:59:36+02:00 List-Id: > In the past, the students used UNIX workstations, and I assigned them > the GETENV problem from them book. You know, call the UNIX > getenv function with an environment variable, and get the mapped > results back. We used all the C interface libraries, and it work just > like in the book! Hmmmm, I can't find such an exercise in the book, only 19.7, asking a body for a system call. Since you mentioned DLL's, I gather that you are running Windows on the PC's. Although I do not understand what it is that does not work, the following works fine with GNAT 3.14p for NT: with Ada.Text_IO; use Ada.Text_IO; with Interfaces.C.Strings; use Interfaces.C.Strings; procedure Check is function getenv (Name : chars_ptr) return chars_ptr; pragma Import (C, getenv, "getenv"); function Get_Env (Name : String) return String is Result : chars_ptr; C_Name : chars_ptr := New_String (Name); begin Result := getenv (C_Name); Free (C_Name); return Value (Result); end Get_Env; begin Put_Line ("COMSPEC = " & Get_Env ("COMSPEC")); end Check; -- -- Jerry van Dijk | email: jvandyk@attglobal.net -- Leiden, Holland | web: users.ncrvnet.nl/gmvdijk