From: Jerry van Dijk <jvandyk@attglobal.net>
Subject: Re: HELP: PC System Call
Date: 08 Jun 2002 09:59:36 +0200
Date: 2002-06-08T09:59:36+02:00 [thread overview]
Message-ID: <wkadq6qjyv.fsf@attglobal.net> (raw)
In-Reply-To: ZtcM8.49323$KD3.980836@typhoon.ne.ipsvc.net
> 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
next prev parent reply other threads:[~2002-06-08 7:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-08 0:46 HELP: PC System Call John Cupak
2002-06-08 6:40 ` Adrian Knoth
2002-06-09 4:04 ` Chad R. Meiners
2002-06-08 7:59 ` Jerry van Dijk [this message]
2002-06-08 12:16 ` Robert Dewar
2002-06-08 12:17 ` Robert Dewar
2002-06-09 10:51 ` Simon Wright
2002-06-08 12:42 ` Preben Randhol
2002-06-09 3:09 ` David Botton
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox