cid#1606940 Check of thread-shared field evades lock acquisition
[LibreOffice.git] / solenv / bin / modules / pre2par / parameter.pm
blobaa9fe3399a57038064b14e20a58f78676dafe3ea
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::globals;
24 use pre2par::systemactions;
26 ############################################
27 # Parameter Operations
28 ############################################
30 sub usage
32 print <<End;
33 ---------------------------------------------------------
34 $pre2par::globals::prog
35 The following parameter are needed:
36 -s: path to the pre file
37 -o: path to the par file
38 -l: path to the ulf file (mlf or jlf file)
39 -v: log process (optional)
41 Example:
43 perl pre2par.pl -l test.mlf -s readme.pre -o readme.par -v
45 ---------------------------------------------------------
46 End
47 exit(-1);
50 #####################################
51 # Reading parameter
52 #####################################
54 sub getparameter
56 while ( $#ARGV >= 0 )
58 my $param = shift(@ARGV);
60 if ($param eq "-s") { $pre2par::globals::prefilename = shift(@ARGV); }
61 elsif ($param eq "-o") { $pre2par::globals::parfilename = shift(@ARGV); }
62 elsif ($param eq "-l") { $pre2par::globals::langfilename = shift(@ARGV); }
63 elsif ($param eq "-v") { $pre2par::globals::logging = 1; }
64 else
66 print("\n*************************************\n");
67 print("Sorry, unknown parameter: $param");
68 print("\n*************************************\n");
69 usage();
70 exit(-1);
75 ############################################
76 # Controlling the fundamental parameter
77 # (required for every process)
78 ############################################
80 sub control_parameter
82 if ($pre2par::globals::prefilename eq "")
84 print "\n************************************************\n";
85 print "Error: Name of the input file not set (-s)!";
86 print "\n************************************************\n";
87 usage();
88 exit(-1);
91 if (!(-f $pre2par::globals::prefilename))
93 print "\n************************************************\n";
94 print "Error: Input file does not exist!";
95 print "\n************************************************\n";
96 usage();
97 exit(-1);
100 if ($pre2par::globals::parfilename eq "")
102 print "\n************************************************\n";
103 print "Error: Name of the output file not set (-o)!";
104 print "\n************************************************\n";
105 usage();
106 exit(-1);
109 if (!($pre2par::globals::prefilename =~ /\.pre\s*$/))
111 print "\n************************************************\n";
112 print "Error: Input file is no .pre file!";
113 print "\n************************************************\n";
114 usage();
115 exit(-1);
118 if (!($pre2par::globals::parfilename =~ /\.par\s*$/))
120 print "\n************************************************\n";
121 print "Error: Output file is no .par file!";
122 print "\n************************************************\n";
123 usage();
124 exit(-1);
128 #####################################
129 # Writing parameter to shell
130 #####################################
132 sub outputparameter
134 $pre2par::globals::logging ? ($logoption = " -v") : ($logoption = "");
135 print "\n$pre2par::globals::prog -l $pre2par::globals::langfilename -s $pre2par::globals::prefilename -o $pre2par::globals::parfilename$logoption\n";
137 # print "\n********************************************************\n";
138 # print "This is $pre2par::globals::prog, version 1.0\n";
139 # print "Input file: $pre2par::globals::prefilename\n";
140 # print "Output file: $pre2par::globals::parfilename\n";
141 # print "********************************************************\n";