Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / solenv / bin / modules / pre2par / parameter.pm
blobe889abfa68f84b84c91cb0c696379ab0f6cff670
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 package pre2par::parameter;
22 use Cwd;
23 use pre2par::files;
24 use pre2par::globals;
25 use pre2par::systemactions;
27 ############################################
28 # Parameter Operations
29 ############################################
31 sub usage
33 print <<Ende;
34 ---------------------------------------------------------
35 $pre2par::globals::prog
36 The following parameter are needed:
37 -s: path to the pre file
38 -o: path to the par file
39 -l: path to the ulf file (mlf or jlf file)
40 -v: log process (optional)
42 Example:
44 perl pre2par.pl -l test.mlf -s readme.pre -o readme.par -v
46 ---------------------------------------------------------
47 Ende
48 exit(-1);
51 #####################################
52 # Reading parameter
53 #####################################
55 sub getparameter
57 while ( $#ARGV >= 0 )
59 my $param = shift(@ARGV);
61 if ($param eq "-s") { $pre2par::globals::prefilename = shift(@ARGV); }
62 elsif ($param eq "-o") { $pre2par::globals::parfilename = shift(@ARGV); }
63 elsif ($param eq "-l") { $pre2par::globals::langfilename = shift(@ARGV); }
64 elsif ($param eq "-v") { $pre2par::globals::logging = 1; }
65 else
67 print("\n*************************************\n");
68 print("Sorry, unknown parameter: $param");
69 print("\n*************************************\n");
70 usage();
71 exit(-1);
76 ############################################
77 # Controlling the fundamental parameter
78 # (required for every process)
79 ############################################
81 sub control_parameter
83 if ($pre2par::globals::prefilename eq "")
85 print "\n************************************************\n";
86 print "Error: Name of the input file not set (-s)!";
87 print "\n************************************************\n";
88 usage();
89 exit(-1);
92 if ($pre2par::globals::parfilename eq "")
94 print "\n************************************************\n";
95 print "Error: Name of the output file not set (-o)!";
96 print "\n************************************************\n";
97 usage();
98 exit(-1);
101 if (!($pre2par::globals::prefilename =~ /\.pre\s*$/))
103 print "\n************************************************\n";
104 print "Error: Input file is no .pre file!";
105 print "\n************************************************\n";
106 usage();
107 exit(-1);
110 if (!($pre2par::globals::parfilename =~ /\.par\s*$/))
112 print "\n************************************************\n";
113 print "Error: Output file is no .par file!";
114 print "\n************************************************\n";
115 usage();
116 exit(-1);
119 # The input file has to exist
121 pre2par::files::check_file($pre2par::globals::prefilename);
124 #####################################
125 # Writing parameter to shell
126 #####################################
128 sub outputparameter
130 $pre2par::globals::logging ? ($logoption = " -v") : ($logoption = "");
131 print "\n$pre2par::globals::prog -l $pre2par::globals::langfilename -s $pre2par::globals::prefilename -o $pre2par::globals::parfilename$logoption\n";
133 # print "\n********************************************************\n";
134 # print "This is $pre2par::globals::prog, version 1.0\n";
135 # print "Input file: $pre2par::globals::prefilename\n";
136 # print "Output file: $pre2par::globals::parfilename\n";
137 # print "********************************************************\n";