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.7 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f02a96c85b47538d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.35.68 with SMTP id f4mr4101388pbj.5.1320888162667; Wed, 09 Nov 2011 17:22:42 -0800 (PST) Path: h5ni19012pba.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: "Rego, P." Newsgroups: comp.lang.ada Subject: Re: Read Windows login username in Ada 95 Date: Wed, 9 Nov 2011 17:21:31 -0800 (PST) Organization: http://groups.google.com Message-ID: <18650574.2609.1320888091484.JavaMail.geo-discussion-forums@yqjc16> References: <9192369.445.1320801564794.JavaMail.geo-discussion-forums@yqbl36> <268750.2183.1320871677246.JavaMail.geo-discussion-forums@yqan20> Reply-To: comp.lang.ada@googlegroups.com NNTP-Posting-Host: 200.148.121.196 Mime-Version: 1.0 X-Trace: posting.google.com 1320888091 25427 127.0.0.1 (10 Nov 2011 01:21:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 10 Nov 2011 01:21:31 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=200.148.121.196; posting-account=TRgI1QoAAABSsYi-ox3Pi6N-JEKKU0cu User-Agent: G2/1.0 X-Google-Web-Client: true Xref: news1.google.com comp.lang.ada:18895 Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-11-09T17:21:31-08:00 List-Id: > This no doubt expects a NUL-terminated string. I would use Char_Array for the > parameter and To_C to convert an Ada string passed to it. > > > pragma Import (C, GetEnv, "getenv"); > > > > Command : constant String := "USERNAME"; > > Answer_Ptr : constant Interfaces.C.Strings.chars_ptr := GetEnv (Command); > > You're not giving it a NUL-terminated string. You're right, I'm gonna check the result. > Who is responsible for freeing Answer_Ptr? If I included an Free(Answer_Ptr), would it solve this? > As Obry suggested, Ada.Environment_Variables is an all-Ada way to do this. That's the Ada 2005 problem I explained above. Thank you.