1*9780544fSAndrew Rist#**************************************************************
2*9780544fSAndrew Rist#
3*9780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
4*9780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
5*9780544fSAndrew Rist#  distributed with this work for additional information
6*9780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
7*9780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
8*9780544fSAndrew Rist#  "License"); you may not use this file except in compliance
9*9780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
10*9780544fSAndrew Rist#
11*9780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12*9780544fSAndrew Rist#
13*9780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
14*9780544fSAndrew Rist#  software distributed under the License is distributed on an
15*9780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
17*9780544fSAndrew Rist#  specific language governing permissions and limitations
18*9780544fSAndrew Rist#  under the License.
19*9780544fSAndrew Rist#
20*9780544fSAndrew Rist#**************************************************************
21*9780544fSAndrew Rist
22*9780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir
25cdf0e10cSrcweirpackage par2script::exiter;
26cdf0e10cSrcweir
27cdf0e10cSrcweiruse par2script::files;
28cdf0e10cSrcweiruse par2script::globals;
29cdf0e10cSrcweir
30cdf0e10cSrcweir############################################
31cdf0e10cSrcweir# Exiting the program with an error
32cdf0e10cSrcweir# This function is used instead of "die"
33cdf0e10cSrcweir############################################
34cdf0e10cSrcweir
35cdf0e10cSrcweirsub exit_program
36cdf0e10cSrcweir{
37cdf0e10cSrcweir	my ($message, $function) = @_;
38cdf0e10cSrcweir
39cdf0e10cSrcweir	my $infoline;
40cdf0e10cSrcweir
41cdf0e10cSrcweir	$infoline = "\n***************************************************************\n";
42cdf0e10cSrcweir	push(@par2script::globals::logfileinfo, $infoline);
43cdf0e10cSrcweir	print("$infoline");
44cdf0e10cSrcweir
45cdf0e10cSrcweir	$infoline = "$message\n";
46cdf0e10cSrcweir	push(@par2script::globals::logfileinfo, $infoline);
47cdf0e10cSrcweir	print("$infoline");
48cdf0e10cSrcweir
49cdf0e10cSrcweir	$infoline = "in function: $function\n";
50cdf0e10cSrcweir	push(@par2script::globals::logfileinfo, $infoline);
51cdf0e10cSrcweir	print("$infoline");
52cdf0e10cSrcweir
53cdf0e10cSrcweir	$infoline = "***************************************************************\n";
54cdf0e10cSrcweir	push(@par2script::globals::logfileinfo, $infoline);
55cdf0e10cSrcweir
56cdf0e10cSrcweir	if ($par2script::globals::logging)
57cdf0e10cSrcweir	{
58cdf0e10cSrcweir		par2script::files::save_file($par2script::globals::logfilename, \@par2script::globals::logfileinfo);
59cdf0e10cSrcweir		print("Saved logfile: $par2script::globals::logfilename\n");
60cdf0e10cSrcweir	}
61cdf0e10cSrcweir
62cdf0e10cSrcweir	print("$infoline");
63cdf0e10cSrcweir
64cdf0e10cSrcweir	exit(-1);
65cdf0e10cSrcweir}
66cdf0e10cSrcweir
67cdf0e10cSrcweir#####################################
68cdf0e10cSrcweir# Error, because a gid is defined
69cdf0e10cSrcweir# more than once
70cdf0e10cSrcweir#####################################
71cdf0e10cSrcweir
72cdf0e10cSrcweirsub multidefinitionerror
73cdf0e10cSrcweir{
74cdf0e10cSrcweir	my ( $multidefinitiongids ) = @_;
75cdf0e10cSrcweir	print "************************************************\n";
76cdf0e10cSrcweir	print "ERROR: multiple definition of gids:\n";
77cdf0e10cSrcweir	print "************************************************\n";
78cdf0e10cSrcweir
79cdf0e10cSrcweir	my $gid;
80cdf0e10cSrcweir	foreach $gid ( @{$multidefinitiongids} ) { print "\t$gid\n"; }
81cdf0e10cSrcweir	exit(-1);
82cdf0e10cSrcweir}
83cdf0e10cSrcweir
84cdf0e10cSrcweir#####################################
85cdf0e10cSrcweir# Error, because a gid is assigned
86cdf0e10cSrcweir# more than once
87cdf0e10cSrcweir#####################################
88cdf0e10cSrcweir
89cdf0e10cSrcweirsub multiassignmenterror
90cdf0e10cSrcweir{
91cdf0e10cSrcweir	my ( $multiassignmentgids ) = @_;
92cdf0e10cSrcweir	#print "************************************************\n";
93cdf0e10cSrcweir	#print "ERROR: multiple assignments of gids:\n";
94cdf0e10cSrcweir	#print "************************************************\n";
95cdf0e10cSrcweir
96cdf0e10cSrcweir	my $line;
97cdf0e10cSrcweir	foreach $line ( @{$multiassignmentgids} ) { print "\t$line\n"; }
98cdf0e10cSrcweir	# exit(-1);
99cdf0e10cSrcweir}
100cdf0e10cSrcweir
101cdf0e10cSrcweir#####################################
102cdf0e10cSrcweir# Error, because a defined gid
103cdf0e10cSrcweir# is not assigned
104cdf0e10cSrcweir#####################################
105cdf0e10cSrcweir
106cdf0e10cSrcweirsub missingassignmenterror
107cdf0e10cSrcweir{
108cdf0e10cSrcweir	my ( $missingassignmentgids ) = @_;
109cdf0e10cSrcweir	print "********************************************************\n";
110cdf0e10cSrcweir	print "ERROR: Missing assignments for the following GIDs:\n";
111cdf0e10cSrcweir	print "********************************************************\n";
112cdf0e10cSrcweir
113cdf0e10cSrcweir	my $gid;
114cdf0e10cSrcweir	foreach $gid ( @{$missingassignmentgids} ) { print "\t$gid\n"; }
115cdf0e10cSrcweir	exit(-1);
116cdf0e10cSrcweir}
117cdf0e10cSrcweir
118cdf0e10cSrcweir1;
119