xref: /netbsd-src/external/mpl/bind/dist/bin/confgen/util.c (revision cef8759bd76c1b621f8eab8faa6f208faabc2e15)
1 /*	$NetBSD: util.c,v 1.4 2020/05/24 19:46:11 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9  *
10  * See the COPYRIGHT file distributed with this work for additional
11  * information regarding copyright ownership.
12  */
13 
14 /*! \file */
15 
16 #include "util.h"
17 #include <stdarg.h>
18 #include <stdbool.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 
22 #include <isc/print.h>
23 
24 extern bool verbose;
25 extern const char *progname;
26 
27 void
28 notify(const char *fmt, ...) {
29 	va_list ap;
30 
31 	if (verbose) {
32 		va_start(ap, fmt);
33 		vfprintf(stderr, fmt, ap);
34 		va_end(ap);
35 		fputs("\n", stderr);
36 	}
37 }
38 
39 void
40 fatal(const char *format, ...) {
41 	va_list args;
42 
43 	fprintf(stderr, "%s: ", progname);
44 	va_start(args, format);
45 	vfprintf(stderr, format, args);
46 	va_end(args);
47 	fprintf(stderr, "\n");
48 	exit(1);
49 }
50