1package oshelper;
2
3#**************************************************************
4#
5#  Licensed to the Apache Software Foundation (ASF) under one
6#  or more contributor license agreements.  See the NOTICE file
7#  distributed with this work for additional information
8#  regarding copyright ownership.  The ASF licenses this file
9#  to you under the Apache License, Version 2.0 (the
10#  "License"); you may not use this file except in compliance
11#  with the License.  You may obtain a copy of the License at
12#
13#    http://www.apache.org/licenses/LICENSE-2.0
14#
15#  Unless required by applicable law or agreed to in writing,
16#  software distributed under the License is distributed on an
17#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18#  KIND, either express or implied.  See the License for the
19#  specific language governing permissions and limitations
20#  under the License.
21#
22#**************************************************************
23
24
25
26use English;
27use warnings;
28use strict;
29
30BEGIN {
31    use Exporter   ();
32    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
33
34    $VERSION     = 1.00;
35    # if using RCS/CVS, this may be preferred
36    $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker
37    @ISA         = qw(Exporter);
38    @EXPORT      = qw(&getEnvironment &isWindowsEnvironment &isUnixEnvironment &getUsername);
39    %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
40    # your exported package globals go here,
41    # as well as any optionally exported functions
42    @EXPORT_OK   = ( ); # qw($Var1 %Hashit &func3);
43}
44
45
46# ------------------------------------------------------------------------------
47sub getEnvironment()
48{
49    my $sEnvironment;
50    if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin")
51    {
52        $sEnvironment = "wntmsci";
53    }
54    elsif ( $OSNAME eq "linux")
55    {
56        $sEnvironment = "unxlngi";
57    }
58    elsif ( $OSNAME eq "solaris")
59    {
60        $sEnvironment = "unxsoli";
61    }
62    else
63    {
64        print "Unknown Environment please check OSNAME: '$OSNAME'\n";
65        $sEnvironment = "unknown";
66    }
67    return $sEnvironment;
68}
69
70# ------------------------------------------------------------------------------
71
72sub isWindowsEnvironment()
73{
74    if ($OSNAME eq "MSWin32" ||
75        $OSNAME eq "cygwin")
76    {
77        return 1;
78    }
79    return 0;
80}
81
82sub isUnixEnvironment()
83{
84    if ($OSNAME eq "linux" ||
85        $OSNAME eq "solaris")
86    {
87        return 1;
88    }
89    return 0;
90}
91
92sub getUsername()
93{
94    my $sUser = $ENV{USER};
95    if (!$sUser)
96    {
97        $sUser = $ENV{USERNAME};
98    }
99    if (!$sUser)
100    {
101        die "Username not set.\n";
102    }
103    return $sUser;
104}
105
1061;
107