1 /*
2   zperr.c - "stderr" output stuff
3   Copyright (C) 1996, 1997 Uwe Ohse
4 
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 2, or (at your option)
8   any later version.
9 
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18   02111-1307, USA.
19 
20   originally written by Uwe Ohse
21 */
22 #include "zglobal.h"
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <errno.h>
26 
27 #ifdef __STDC__
28 #  define WAYTOGO
29 #  include <stdarg.h>
30 #  define VA_START(args, lastarg) va_start(args, lastarg)
31 #else
32 #  include <varargs.h>
33 #  define VA_START(args, lastarg) va_start(args)
34 #endif
35 
36 void
37 #ifdef WAYTOGO
zperr(const char * fmt,...)38 zperr(const char *fmt, ...)
39 #else
40 zperr(fmt, va_alist)
41 	const char *fmt;
42 	va_dcl
43 #endif
44 {
45     va_list ap;
46 
47 	if (Verbose<=0)
48 		return;
49 	fprintf(stderr,_("Retry %d: "),errors);
50     VA_START(ap, fmt);
51     vfprintf(stderr,fmt, ap);
52     va_end(ap);
53     putc('\n',stderr);
54 }
55 
56 void
57 #ifdef WAYTOGO
zpfatal(const char * fmt,...)58 zpfatal(const char *fmt, ...)
59 #else
60 zpfatal(fmt, va_alist)
61 	const char *fmt;
62 	va_dcl
63 #endif
64 {
65     va_list ap;
66     int err=errno;
67 
68 	if (Verbose<=0)
69 		return;
70 	fprintf(stderr,"%s: ",program_name);
71     VA_START(ap, fmt);
72     vfprintf(stderr,fmt, ap);
73     va_end(ap);
74 	fprintf(stderr,": %s\n",strerror(err));
75 }
76 
77 void
78 #ifdef WAYTOGO
vfile(const char * format,...)79 vfile(const char *format, ...)
80 #else
81 vfile(format, va_alist)
82 	const char *format;
83 	va_dcl
84 #endif
85 {
86     va_list ap;
87 
88 	if (Verbose < 3)
89 		return;
90     VA_START(ap, format);
91     vfprintf(stderr,format, ap);
92     va_end(ap);
93     putc('\n',stderr);
94 }
95 
96 #ifndef vstringf
97 /* if using gcc this function is not needed */
98 void
99 #ifdef WAYTOGO
vstringf(const char * format,...)100 vstringf(const char *format, ...)
101 #else
102 vstringf(format, va_alist)
103 	const char *format;
104 	va_dcl
105 #endif
106 {
107     va_list ap;
108 
109     VA_START(ap, format);
110     vfprintf(stderr,format, ap);
111     va_end(ap);
112 }
113 #endif
114