File: err.c

package info (click to toggle)
clippoly 0.11-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,124 kB
  • sloc: cpp: 2,207; ansic: 1,504; makefile: 48; sh: 9
file content (116 lines) | stat: -rw-r--r-- 2,794 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 *    tutvis library

 *    Copyright (C) 1993  University of Twente

 *    klamer@mi.el.utwente.nl

 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Library General Public
 *    License as published by the Free Software Foundation; either
 *    version 2 of the License, or (at your option) any later version.

 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Library General Public License for more details.

 *    You should have received a copy of the GNU Library General Public
 *    License along with this library; if not, write to the Free
 *    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
static const char rcs_id[] = "$Header: /cvsroot/clippoly/clippoly/err.c,v 1.2 2005/02/28 21:12:05 klamer Exp $";
/*
 * $Log: err.c,v $
 * Revision 1.2  2005/02/28 21:12:05  klamer
 * Made changes such that gcc 3.4.2 compiles silent with -ansi -pedantic -Wall.
 *
 * Revision 1.2  2003/11/11 12:57:38  kscp1
 * Made changes such that linux/gcc-3.3 compiles without warnings.
 &
 * Revision 1.2  2000/11/10 08:05:43  kscp1
 * ANSI C version
 *
 * Revision 1.1  1994/06/07  14:30:35  schutte
 * Initial revision
 *
 *
 *	error.c				Klamer Schutte 25/7/90
 *
 *	handle errors in a consistent way.
 */

#include	<stdio.h>
#include	<stdarg.h>
#include	<setjmp.h>
#include <stdlib.h>

#include "err.h"

int	err_nr_errors, err_nr_warnings;
/* what is the type of a pointer to a jmp_buf? On sun4 int * will do */
int	*err_warning_jmpbuf, *err_error_jmpbuf, *err_fatal_jmpbuf;

void
/*VARARGS1*/
warning( const char *fmt, ... )
{
	va_list	args;

	va_start( args, fmt );
	vfprintf(stderr, fmt, args );
	va_end(args );

	err_nr_warnings++;

	if (err_warning_jmpbuf != NULL)
		longjmp( (void *) err_warning_jmpbuf, 1 );
}

void
/*VARARGS1*/
error( const char *fmt, ... )
{
	va_list	args;

	va_start( args, fmt );
	vfprintf(stderr, fmt, args );
	va_end(args );

	err_nr_errors++;

	if (err_error_jmpbuf != NULL)
		longjmp( (void *) err_error_jmpbuf, 1 );
}	

void
/*VARARGS2*/
fatal_exit_nr( int nr, const char *fmt, ... )
{
	va_list	args;

	va_start( args, fmt );
	vfprintf(stderr, fmt, args );
	va_end(args );

	if (err_fatal_jmpbuf != NULL)
		longjmp( (void *) err_fatal_jmpbuf, 1 );

	exit( nr );
}	

void
/*VARARGS1*/
fatal( const char *fmt, ... )
{
	va_list	args;

	va_start( args, fmt );
	vfprintf(stderr, fmt, args );
	va_end(args );

	if (err_fatal_jmpbuf != NULL)
		longjmp(  (void *) err_fatal_jmpbuf, 1 );

	exit( 1 );
}