1*df57947fSPedro F. Giffuni /*- 2*df57947fSPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 3*df57947fSPedro F. Giffuni * 4778c7b1cSBill Paul * Copyright (c) 1995 5778c7b1cSBill Paul * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 6778c7b1cSBill Paul * 7778c7b1cSBill Paul * Redistribution and use in source and binary forms, with or without 8778c7b1cSBill Paul * modification, are permitted provided that the following conditions 9778c7b1cSBill Paul * are met: 10778c7b1cSBill Paul * 1. Redistributions of source code must retain the above copyright 11778c7b1cSBill Paul * notice, this list of conditions and the following disclaimer. 12778c7b1cSBill Paul * 2. Redistributions in binary form must reproduce the above copyright 13778c7b1cSBill Paul * notice, this list of conditions and the following disclaimer in the 14778c7b1cSBill Paul * documentation and/or other materials provided with the distribution. 15778c7b1cSBill Paul * 3. All advertising materials mentioning features or use of this software 16778c7b1cSBill Paul * must display the following acknowledgement: 17778c7b1cSBill Paul * This product includes software developed by Bill Paul. 18778c7b1cSBill Paul * 4. Neither the name of the author nor the names of any co-contributors 19778c7b1cSBill Paul * may be used to endorse or promote products derived from this software 20778c7b1cSBill Paul * without specific prior written permission. 21778c7b1cSBill Paul * 22778c7b1cSBill Paul * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 23778c7b1cSBill Paul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24778c7b1cSBill Paul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25778c7b1cSBill Paul * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE 26778c7b1cSBill Paul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27778c7b1cSBill Paul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28778c7b1cSBill Paul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29778c7b1cSBill Paul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30778c7b1cSBill Paul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31778c7b1cSBill Paul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32778c7b1cSBill Paul * SUCH DAMAGE. 33778c7b1cSBill Paul * 34778c7b1cSBill Paul */ 3598834523SPhilippe Charnier 36b728350eSDavid E. O'Brien #include <sys/cdefs.h> 37b728350eSDavid E. O'Brien __FBSDID("$FreeBSD$"); 3898834523SPhilippe Charnier 39778c7b1cSBill Paul /* 40778c7b1cSBill Paul * error logging/reporting facilities 41778c7b1cSBill Paul * stolen from /usr/libexec/mail.local via ypserv 42778c7b1cSBill Paul */ 43778c7b1cSBill Paul 44778c7b1cSBill Paul #include <sys/types.h> 45dc584ddbSDag-Erling Smørgrav #include <stdio.h> 46dc584ddbSDag-Erling Smørgrav #include <stdarg.h> 47778c7b1cSBill Paul #include <syslog.h> 482c0643afSKris Kennaway #include "yp_extern.h" 49778c7b1cSBill Paul 50778c7b1cSBill Paul int debug; 51033af09dSMarcelo Araujo 52778c7b1cSBill Paul extern int _rpcpmstart; 53778c7b1cSBill Paul extern char *progname; 54dc584ddbSDag-Erling Smørgrav static void __verr(const char *fmt, va_list ap) __printflike(1, 0); 55778c7b1cSBill Paul 56033af09dSMarcelo Araujo static void 57033af09dSMarcelo Araujo __verr(const char *fmt, va_list ap) 58778c7b1cSBill Paul { 59778c7b1cSBill Paul if (debug && !_rpcpmstart) { 60778c7b1cSBill Paul fprintf(stderr,"%s: ",progname); 61778c7b1cSBill Paul vfprintf(stderr, fmt, ap); 62778c7b1cSBill Paul fprintf(stderr, "\n"); 63778c7b1cSBill Paul } else { 64778c7b1cSBill Paul vsyslog(LOG_NOTICE, fmt, ap); 65778c7b1cSBill Paul } 66778c7b1cSBill Paul } 67778c7b1cSBill Paul 68778c7b1cSBill Paul void 69778c7b1cSBill Paul yp_error(const char *fmt, ...) 70778c7b1cSBill Paul { 71778c7b1cSBill Paul va_list ap; 72778c7b1cSBill Paul va_start(ap, fmt); 73ce5b7be8SBill Paul __verr(fmt,ap); 74778c7b1cSBill Paul va_end(ap); 75778c7b1cSBill Paul } 76