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