1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: parameter.pm,v $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
33 package pre2par
::parameter
;
38 use pre2par
::systemactions
;
40 ############################################
41 # Parameter Operations
42 ############################################
47 ---------------------------------------------------------
48 $pre2par::globals::prog
49 The following parameter are needed:
50 -s: path to the pre file
51 -o: path to the par file
52 -l: path to the ulf file (mlf or jlf file)
53 -v: log process (optional)
57 perl pre2par.pl -l test.mlf -s readme.pre -o readme.par -v
59 ---------------------------------------------------------
64 #####################################
66 #####################################
72 my $param = shift(@ARGV);
74 if ($param eq "-s") { $pre2par::globals
::prefilename
= shift(@ARGV); }
75 elsif ($param eq "-o") { $pre2par::globals
::parfilename
= shift(@ARGV); }
76 elsif ($param eq "-l") { $pre2par::globals
::langfilename
= shift(@ARGV); }
77 elsif ($param eq "-v") { $pre2par::globals
::logging
= 1; }
80 print("\n*************************************\n");
81 print("Sorry, unknown parameter: $param");
82 print("\n*************************************\n");
89 ############################################
90 # Controlling the fundamental parameter
91 # (required for every process)
92 ############################################
96 if ($pre2par::globals
::prefilename
eq "")
98 print "\n************************************************\n";
99 print "Error: Name of the input file not set (-s)!";
100 print "\n************************************************\n";
105 if ($pre2par::globals
::parfilename
eq "")
107 print "\n************************************************\n";
108 print "Error: Name of the output file not set (-o)!";
109 print "\n************************************************\n";
114 if (!($pre2par::globals
::prefilename
=~ /\.pre\s*$/))
116 print "\n************************************************\n";
117 print "Error: Input file is no .pre file!";
118 print "\n************************************************\n";
123 if (!($pre2par::globals
::parfilename
=~ /\.par\s*$/))
125 print "\n************************************************\n";
126 print "Error: Output file is no .par file!";
127 print "\n************************************************\n";
132 # The input file has to exist
134 pre2par
::files
::check_file
($pre2par::globals
::prefilename
);
137 ##########################################################
138 # The path parameters can be relative or absolute.
139 # This function creates absolute pathes.
140 ##########################################################
142 sub make_path_absolute
146 if ( $pre2par::globals
::isunix
)
148 if (!($$pathref =~ /^\s*\//)) # this is a relative unix path
150 $$pathref = cwd
() . $pre2par::globals
::separator
. $$pathref;
154 if ( $pre2par::globals
::iswin
)
156 if (!($$pathref =~ /^\s*\w\:/)) # this is a relative windows path
158 $$pathref = cwd
() . $pre2par::globals
::separator
. $$pathref;
159 $$pathref =~ s/\//\\/g
;
163 $$pathref =~ s/\Q$pre2par::globals::separator\E\s*$//; # removing ending slashes
166 #####################################
167 # Writing parameter to shell
168 #####################################
172 $pre2par::globals
::logging ?
($logoption = " -v") : ($logoption = "");
173 print "\n$pre2par::globals::prog -l $pre2par::globals::langfilename -s $pre2par::globals::prefilename -o $pre2par::globals::parfilename$logoption\n";
175 # print "\n********************************************************\n";
176 # print "This is $pre2par::globals::prog, version 1.0\n";
177 # print "Input file: $pre2par::globals::prefilename\n";
178 # print "Output file: $pre2par::globals::parfilename\n";
179 # print "********************************************************\n";