1*cdf0e10cSrcweirpackage oshelper; 2*cdf0e10cSrcweir 3*cdf0e10cSrcweir#************************************************************************* 4*cdf0e10cSrcweir# 5*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6*cdf0e10cSrcweir# 7*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 8*cdf0e10cSrcweir# 9*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite 10*cdf0e10cSrcweir# 11*cdf0e10cSrcweir# This file is part of OpenOffice.org. 12*cdf0e10cSrcweir# 13*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify 14*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3 15*cdf0e10cSrcweir# only, as published by the Free Software Foundation. 16*cdf0e10cSrcweir# 17*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful, 18*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of 19*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details 21*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code). 22*cdf0e10cSrcweir# 23*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License 24*cdf0e10cSrcweir# version 3 along with OpenOffice.org. If not, see 25*cdf0e10cSrcweir# <http://www.openoffice.org/license.html> 26*cdf0e10cSrcweir# for a copy of the LGPLv3 License. 27*cdf0e10cSrcweir# 28*cdf0e10cSrcweir#************************************************************************* 29*cdf0e10cSrcweir 30*cdf0e10cSrcweiruse English; 31*cdf0e10cSrcweiruse warnings; 32*cdf0e10cSrcweiruse strict; 33*cdf0e10cSrcweir 34*cdf0e10cSrcweirBEGIN { 35*cdf0e10cSrcweir use Exporter (); 36*cdf0e10cSrcweir our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir $VERSION = 1.00; 39*cdf0e10cSrcweir # if using RCS/CVS, this may be preferred 40*cdf0e10cSrcweir $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker 41*cdf0e10cSrcweir @ISA = qw(Exporter); 42*cdf0e10cSrcweir @EXPORT = qw(&getEnvironment &isWindowsEnvironment &isUnixEnvironment &getUsername); 43*cdf0e10cSrcweir %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], 44*cdf0e10cSrcweir # your exported package globals go here, 45*cdf0e10cSrcweir # as well as any optionally exported functions 46*cdf0e10cSrcweir @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); 47*cdf0e10cSrcweir} 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir# ------------------------------------------------------------------------------ 51*cdf0e10cSrcweirsub getEnvironment() 52*cdf0e10cSrcweir{ 53*cdf0e10cSrcweir my $sEnvironment; 54*cdf0e10cSrcweir if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin") 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir $sEnvironment = "wntmsci"; 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir elsif ( $OSNAME eq "linux") 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir $sEnvironment = "unxlngi"; 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir elsif ( $OSNAME eq "solaris") 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir $sEnvironment = "unxsoli"; 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir else 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir print "Unknown Environment please check OSNAME: '$OSNAME'\n"; 69*cdf0e10cSrcweir $sEnvironment = "unknown"; 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir return $sEnvironment; 72*cdf0e10cSrcweir} 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir# ------------------------------------------------------------------------------ 75*cdf0e10cSrcweir 76*cdf0e10cSrcweirsub isWindowsEnvironment() 77*cdf0e10cSrcweir{ 78*cdf0e10cSrcweir if ($OSNAME eq "MSWin32" || 79*cdf0e10cSrcweir $OSNAME eq "cygwin") 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir return 1; 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir return 0; 84*cdf0e10cSrcweir} 85*cdf0e10cSrcweir 86*cdf0e10cSrcweirsub isUnixEnvironment() 87*cdf0e10cSrcweir{ 88*cdf0e10cSrcweir if ($OSNAME eq "linux" || 89*cdf0e10cSrcweir $OSNAME eq "solaris") 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir return 1; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir return 0; 94*cdf0e10cSrcweir} 95*cdf0e10cSrcweir 96*cdf0e10cSrcweirsub getUsername() 97*cdf0e10cSrcweir{ 98*cdf0e10cSrcweir my $sUser = $ENV{USER}; 99*cdf0e10cSrcweir if (!$sUser) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir $sUser = $ENV{USERNAME}; 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir if (!$sUser) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir die "Username not set.\n"; 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir return $sUser; 108*cdf0e10cSrcweir} 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir1; 111