1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28
29package par2script::exiter;
30
31use par2script::files;
32use par2script::globals;
33
34############################################
35# Exiting the program with an error
36# This function is used instead of "die"
37############################################
38
39sub exit_program
40{
41	my ($message, $function) = @_;
42
43	my $infoline;
44
45	$infoline = "\n***************************************************************\n";
46	push(@par2script::globals::logfileinfo, $infoline);
47	print("$infoline");
48
49	$infoline = "$message\n";
50	push(@par2script::globals::logfileinfo, $infoline);
51	print("$infoline");
52
53	$infoline = "in function: $function\n";
54	push(@par2script::globals::logfileinfo, $infoline);
55	print("$infoline");
56
57	$infoline = "***************************************************************\n";
58	push(@par2script::globals::logfileinfo, $infoline);
59
60	if ($par2script::globals::logging)
61	{
62		par2script::files::save_file($par2script::globals::logfilename, \@par2script::globals::logfileinfo);
63		print("Saved logfile: $par2script::globals::logfilename\n");
64	}
65
66	print("$infoline");
67
68	exit(-1);
69}
70
71#####################################
72# Error, because a gid is defined
73# more than once
74#####################################
75
76sub multidefinitionerror
77{
78	my ( $multidefinitiongids ) = @_;
79	print "************************************************\n";
80	print "ERROR: multiple definition of gids:\n";
81	print "************************************************\n";
82
83	my $gid;
84	foreach $gid ( @{$multidefinitiongids} ) { print "\t$gid\n"; }
85	exit(-1);
86}
87
88#####################################
89# Error, because a gid is assigned
90# more than once
91#####################################
92
93sub multiassignmenterror
94{
95	my ( $multiassignmentgids ) = @_;
96	#print "************************************************\n";
97	#print "ERROR: multiple assignments of gids:\n";
98	#print "************************************************\n";
99
100	my $line;
101	foreach $line ( @{$multiassignmentgids} ) { print "\t$line\n"; }
102	# exit(-1);
103}
104
105#####################################
106# Error, because a defined gid
107# is not assigned
108#####################################
109
110sub missingassignmenterror
111{
112	my ( $missingassignmentgids ) = @_;
113	print "********************************************************\n";
114	print "ERROR: Missing assignments for the following GIDs:\n";
115	print "********************************************************\n";
116
117	my $gid;
118	foreach $gid ( @{$missingassignmentgids} ) { print "\t$gid\n"; }
119	exit(-1);
120}
121
1221;
123