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