From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Windows LDAP group-user checking in Ada 95
Date: Thu, 16 Feb 2012 21:55:22 +0100
Date: 2012-02-16T21:55:22+01:00 [thread overview]
Message-ID: <1e2tjheyqye1a.1msarege98c4g$.dlg@40tude.net> (raw)
In-Reply-To: 29156956.1684.1329424734114.JavaMail.geo-discussion-forums@yndy9
On Thu, 16 Feb 2012 12:38:54 -0800 (PST), Rego, P. wrote:
> For getting the username, I have the function (in Ada 95):
>
> function GetUsername return String is
> function GetEnv (Variable : String) return Interfaces.C.Strings.chars_ptr;
> pragma Import (C, GetEnv, "getenv");
>
> Command : constant String := "USERNAME";
> Answer_Ptr : constant Interfaces.C.Strings.chars_ptr := GetEnv (Command);
> Answer : constant String := Interfaces.C.Strings.Value (Answer_Ptr);
> begin
> return Answer;
> end GetUsername;
This is wrong, you cannot pass String to a C program. Then the user name
variable is named USER.
with Interfaces.C.Strings;
use Interfaces.C;
use Interfaces.C.Strings;
function GetUsername return String is -- Constraint_Error when undefined
function GetEnv (Variable : char_array) return chars_ptr;
pragma Import (C, GetEnv, "getenv");
begin
return Value (GetEnv (To_C ("USER")));
end GetUsername;
But you don't need that because there already exist the package
Ada.Environment_Variables.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2012-02-16 20:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-16 20:38 Windows LDAP group-user checking in Ada 95 Rego, P.
2012-02-16 20:55 ` Dmitry A. Kazakov [this message]
2012-02-21 14:34 ` Rego, P.
2012-02-21 14:57 ` Dmitry A. Kazakov
2012-02-23 12:43 ` Rego, P.
2012-02-21 16:51 ` Pascal Obry
2012-02-23 12:58 ` Rego, P.
2012-02-23 17:44 ` Pascal Obry
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox