forked from jhenin/spiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.c
120 lines (106 loc) · 1.93 KB
/
misc.c
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
117
118
119
120
/* Copyright (c) 1988 Bellcore
** All Rights Reserved
** Permission is granted to copy or use this program, EXCEPT that it
** may not be sold for profit, the copyright notice must be reproduced
** on copies, and credit should be given to Bellcore where it is due.
** BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
*/
#ifndef lint
static char rcsid[]= "$Header: misc.c,v 1.1 88/09/15 11:34:01 daniel Rel $";
#endif
#include <stdio.h>
#include <stdlib.h>
#include "misc.h"
#include "visual.h"
#include "output.h"
/*
** various routines used throughout the program
*/
static int _Z_qflag = 0;
void
Z_setquiet()
{
_Z_qflag = 1;
}
char Z_err_buf[Z_LINELEN];
#ifndef NOCHATTER
/*
** I/O coverup to reassure users with HUGE files
** that spiff is doing something
*/
void
Z_chatter(str)
char *str;
{
if (!_Z_qflag)
{
(void) fputs("spiff -- ",stderr);
(void) fputs(str,stderr);
}
}
#endif
/*
** complain unless you've been told to be quiet
*/
void
Z_complain(str)
char *str;
{
if (!_Z_qflag)
(void) fputs(str,stderr);
}
/*
** quit with an error code
*/
static void
_Z_errexit()
{
(void) exit(2);
}
/*
** complain and die
*/
void
_Z_qfatal(str)
char *str;
{
V_cleanup(); /* try reset the device to normal */
O_cleanup(); /* " " " " " " */
Z_complain(str);
_Z_errexit();
}
/*
** scream and die
*/
void
Z_fatal(str)
char *str;
{
V_cleanup(); /* try reset the device to normal */
O_cleanup(); /* " " " " " " */
(void) fputs(str,stderr);
_Z_errexit();
}
/*
** allocate memory with error checking
*/
int*
_Z_myalloc(k)
int k;
{
int *tmp;
if (tmp = (int*) calloc((unsigned)k,(unsigned)1))
{
return(tmp);
}
Z_fatal("Out of Memory\n");
return(tmp); /* boilerplate to shut up lint */
}
void
Z_exceed(d)
int d;
{
(void) sprintf(Z_err_buf,
"The files differ in more than %d places\n", d);
_Z_qfatal(Z_err_buf);
}