comp.lang.ada
 help / color / mirror / Atom feed
From: jerry@jvdsys.stuyts.nl
Subject: Re: gnat and user
Date: 1999/06/23
Date: 1999-06-23T00:00:00+00:00	[thread overview]
Message-ID: <FDsw5o.8E@stuyts.nl> (raw)
In-Reply-To: 01bebdae$bd385f60$1511a8c0@fermion.extern.uni-ulm.de

argavargf <hallo@hallo.org> wrote:

: is there a package for gnat (linux) including a procedure or function which
: returns the user name?

Florist (the POSIX binding) should include this. Meanwhile, you can do
this yourself by calling the appropriate C library function, like:

	--  display the name of the user logged in

	with Ada.Text_IO;          use Ada.Text_IO;
	with Interfaces.C.Strings; use Interfaces.C.Strings;

	procedure Display_Me is

	   function User_Name return String is
	      function Getlogin return chars_ptr;
	      pragma Import (C, Getlogin, "getlogin");
	      Name : chars_ptr;
	   begin
	      Name := Getlogin;
	      if Name = Null_Ptr then
	         return "";
	      else
	         return Value (Name);
	      end if;
	   end User_Name;
   
	begin
	   Put_Line (User_Name);
	end Display_Me;

But check the difference between getlogin and cuserid to make sure you
get the name you actually need.

-- 
-- Jerry van Dijk | Leiden, Holland
-- Team Ada       | jdijk@acm.org
-- see http://stad.dsl.nl/~jvandyk




           reply	other threads:[~1999-06-23  0:00 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <01bebdae$bd385f60$1511a8c0@fermion.extern.uni-ulm.de>]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox