comp.lang.ada
 help / color / mirror / Atom feed
From: Stefan Bellon <bellon@bauhaus-tec.com>
Subject: Re: How to detect OS type and version?
Date: Thu, 13 Oct 2005 11:50:01 +0200
Date: 2005-10-13T09:50:01+00:00	[thread overview]
Message-ID: <20051013115001.60b6a695@pscube.informatik.uni-stuttgart.de> (raw)
In-Reply-To: diktfs$8ne$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com

Martin Dowie wrote:

> I think that you will be able to do this with "package 
> Ada.Environment_Variables" come Ada200Y, e.g.
> 
> if Ada.Environment_Variables.Exists ("OS")
>     and Ada.Environment_Variables.Value ("OS") = "Windows_NT" then
>     ...
> elsif Ada.Environment_Variables.Exists ("OSTYPE")
>        and Ada.Environment_Variables.Value ("OSTYPE") = "linux-gnu"
> then ...
> else
>     -- Unknown OS
>     ...
> end if;

This approach has one problem: Those environment variables can be set
by the user, so that the user can fake the setting to select wrong OS
dependent code.

What we are doing is this: We configure our project for the target
operating system and during that configuration, a small file with
content similar to the following is generated:

separate (Bauhaus.OS)
function Get_OS return String is
begin
   return "GNU/Linux";
end Get_OS;

This way, we have the OS type compiled in our executables and can
check wherever necessary without the fear that the user may change it.
It would be nice if this was available via some language defined
package, I agree.

-- 
Dipl.-Inf. Stefan Bellon
Bauhaus Software Technologies | TTI GmbH TGZ Softwareanalysen c/o ISTE
Tel.: +49 711 78 16 221       | Universitätsstraße 38
Fax.: +49 711 78 16 380       | 70569 Stuttgart



  reply	other threads:[~2005-10-13  9:50 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-13  2:35 How to detect OS type and version? Roger Blum
2005-10-13  6:05 ` Martin Dowie
2005-10-13  9:50   ` Stefan Bellon [this message]
2005-10-13 10:39     ` Martin Dowie
2005-10-13 18:12     ` Jeffrey R. Carter
2005-10-13 18:37       ` Stefan Bellon
2005-10-13 21:21         ` Robert A Duff
2005-10-13 21:25           ` Stefan Bellon
2005-10-13 21:52             ` Robert A Duff
2005-10-16  0:13       ` Ray Blaak
2005-10-16  0:29         ` Robert A Duff
2005-10-16  4:48           ` Ray Blaak
2005-10-16 14:16             ` Larry Kilgallen
2005-10-16 15:55               ` Robert A Duff
2005-10-16 20:06               ` Pascal Obry
2005-10-18 16:58                 ` Ray Blaak
2005-10-16 15:59             ` Robert A Duff
2005-10-17 17:19               ` Ray Blaak
2005-10-13 18:11   ` Jeffrey R. Carter
2005-10-13 19:44   ` Simon Wright
2005-10-13 21:04   ` Michael Bode
2005-10-14  1:33     ` Steve
2005-10-13 12:06 ` Rob Norris
2005-10-13 11:59   ` Martin Dowie
2005-10-14  0:21     ` Randy Brukardt
2005-10-14  8:02       ` Martin Dowie
2005-10-14 23:27         ` Randy Brukardt
2005-10-15 12:28           ` Larry Kilgallen
2005-10-15 14:12             ` Martin Dowie
2005-10-14  9:52     ` Rob Norris
2005-10-13 20:25 ` Bernd Specht
2005-10-13 20:36   ` Michael Bode
2005-10-13 20:41     ` Bernd Specht
2005-10-13 20:58       ` Stefan Bellon
2005-10-14  0:27         ` Randy Brukardt
2005-10-15 19:48           ` Bernd Specht
2005-10-14  6:30 ` Roger Blum
replies disabled

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