/usr/share/mhonarc/osinit.pl is in mhonarc 2.6.18-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | ##---------------------------------------------------------------------------##
## File:
## $Id: osinit.pl,v 2.8 2005/06/21 22:10:53 ehood Exp $
## Author:
## Earl Hood mhonarc@mhonarc.org
## Description:
## A library for setting up a script based upon the OS the script
## is running under. The main routine defined is OSinit. See
## the routine for specific information.
##---------------------------------------------------------------------------##
## MHonArc -- Internet mail-to-HTML converter
## Copyright (C) 1995-1999 Earl Hood, mhonarc@mhonarc.org
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA
##---------------------------------------------------------------------------##
use File::Basename;
package mhonarc;
##---------------------------------------------------------------------------##
## OSinit() checks what operating system we are running on set
## some global variables that can be used by the calling routine.
## All global variables are exported to package main.
##
## Variables set:
##
## $MSDOS => Set to 1 if running under MS-DOS/Windows
## $MACOS => Set to 1 if running under Mac
## $UNIX => Set to 1 if running under Unix
## $VMS => Set to 1 if running under VMS
## $DIRSEP => Directory separator character
## $DIRSEPREX => Directory separator character for use in
## regular expressions.
## $PATHSEP => Recommend path list separator
## $CURDIR => Current working directory
## $PROG => Program name with leading pathname component
## stripped off.
##
## If running under a Mac and the script is a droplet, command-line
## options will be prompted for unless $noOptions argument is
## set to true.
##
sub OSinit {
my($noOptions) = shift;
## Check what system we are executing under
my($tmp);
if ($^O =~ /vms/i) {
$MSDOS = 0; $MACOS = 0; $UNIX = 0; $VMS = 1;
$DIRSEP = '/'; $CURDIR = '.';
$PATHSEP = ':';
fileparse_set_fstype('VMS');
} elsif (($^O !~ /cygwin/i) &&
(($^O =~ /mswin/i) ||
($^O =~ /\bdos\b/i) ||
($^O =~ /\bos2\b/i) ||
(($tmp = $ENV{'COMSPEC'}) &&
($tmp =~ /^[a-zA-Z]:\\/) &&
(-e $tmp))) ) {
$MSDOS = 1; $MACOS = 0; $UNIX = 0; $VMS = 0;
$DIRSEP = '\\'; $CURDIR = '.';
$PATHSEP = ';';
fileparse_set_fstype(($^O =~ /mswin/i) ? 'MSWin32' : 'MSDOS');
} elsif (defined($MacPerl::Version)) {
$MSDOS = 0; $MACOS = 1; $UNIX = 0; $VMS = 0;
$DIRSEP = ':'; $CURDIR = ':';
$PATHSEP = "\n";
fileparse_set_fstype('MacOS');
} else {
$MSDOS = 0; $MACOS = 0; $UNIX = 1; $VMS = 0;
$DIRSEP = '/'; $CURDIR = '.';
$PATHSEP = ':';
fileparse_set_fstype('UNIX');
}
## Store name of program
if ($MSDOS) {
$DIRSEPREX = "\\\\\\/";
} else {
($DIRSEPREX = $DIRSEP) =~ s/(\W)/\\$1/g;
}
($PROG = $0) =~ s%.*[$DIRSEPREX]%%o;
## Ask for command-line options if script is a Mac droplet
## Code taken from the MacPerl FAQ
if (!$noOptions &&
defined($MacPerl::Version) &&
( $MacPerl::Version =~ /Application$/ )) {
# we're running from the app
local( $cmdLine, @args );
$cmdLine = &MacPerl::Ask( "Enter command line options:" );
require "shellwords.pl";
@args = &shellwords( $cmdLine );
unshift( @ARGV, @args );
}
}
##---------------------------------------------------------------------------##
## OSis_absolute_path() returns true if a string is an absolute path
##
sub OSis_absolute_path {
if ($MSDOS) {
return $_[0] =~ /^([a-z]:)?[\\\/]/i;
}
if ($MACOS) { ## Not sure about Mac
return $_[0] =~ /^:/o;
}
$_[0] =~ m|^/|o; ## Unix (fallback)
}
##---------------------------------------------------------------------------##
1;
|