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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f890526de6a8a218 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!proxad.net!newsfeed.stueberl.de!news-nue1.dfn.de!news-stu1.dfn.de!news.belwue.de!news.informatik.uni-stuttgart.de!not-for-mail From: Stefan Bellon Newsgroups: comp.lang.ada Subject: Re: How to detect OS type and version? Date: Thu, 13 Oct 2005 11:50:01 +0200 Organization: Bauhaus Software Technologies Message-ID: <20051013115001.60b6a695@pscube.informatik.uni-stuttgart.de> References: NNTP-Posting-Host: pscube.informatik.uni-stuttgart.de Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: inf2.informatik.uni-stuttgart.de 1129197001 8372 129.69.217.201 (13 Oct 2005 09:50:01 GMT) X-Complaints-To: usenet@news.informatik.uni-stuttgart.de NNTP-Posting-Date: 13 Oct 2005 09:50:01 GMT X-Newsreader: Sylpheed-Claws 1.9.14 (GTK+ 2.6.10; i486-pc-linux-gnu) Xref: g2news1.google.com comp.lang.ada:5591 Date: 2005-10-13T09:50:01+00:00 List-Id: Martin Dowie wrote: > I think that you will be able to do this with "package=20 > Ada.Environment_Variables" come Ada200Y, e.g. >=20 > if Ada.Environment_Variables.Exists ("OS") > and Ada.Environment_Variables.Value ("OS") =3D "Windows_NT" then > ... > elsif Ada.Environment_Variables.Exists ("OSTYPE") > and Ada.Environment_Variables.Value ("OSTYPE") =3D "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. --=20 Dipl.-Inf. Stefan Bellon Bauhaus Software Technologies | TTI GmbH TGZ Softwareanalysen c/o ISTE Tel.: +49 711 78 16 221 | Universit=E4tsstra=DFe 38 Fax.: +49 711 78 16 380 | 70569 Stuttgart