1778c7b1cSBill Paul /* 2778c7b1cSBill Paul * Copyright (c) 1995 3778c7b1cSBill Paul * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4778c7b1cSBill Paul * 5778c7b1cSBill Paul * Redistribution and use in source and binary forms, with or without 6778c7b1cSBill Paul * modification, are permitted provided that the following conditions 7778c7b1cSBill Paul * are met: 8778c7b1cSBill Paul * 1. Redistributions of source code must retain the above copyright 9778c7b1cSBill Paul * notice, this list of conditions and the following disclaimer. 10778c7b1cSBill Paul * 2. Redistributions in binary form must reproduce the above copyright 11778c7b1cSBill Paul * notice, this list of conditions and the following disclaimer in the 12778c7b1cSBill Paul * documentation and/or other materials provided with the distribution. 13778c7b1cSBill Paul * 3. All advertising materials mentioning features or use of this software 14778c7b1cSBill Paul * must display the following acknowledgement: 15778c7b1cSBill Paul * This product includes software developed by Bill Paul. 16778c7b1cSBill Paul * 4. Neither the name of the author nor the names of any co-contributors 17778c7b1cSBill Paul * may be used to endorse or promote products derived from this software 18778c7b1cSBill Paul * without specific prior written permission. 19778c7b1cSBill Paul * 20778c7b1cSBill Paul * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 21778c7b1cSBill Paul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22778c7b1cSBill Paul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23778c7b1cSBill Paul * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE 24778c7b1cSBill Paul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25778c7b1cSBill Paul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26778c7b1cSBill Paul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27778c7b1cSBill Paul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28778c7b1cSBill Paul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29778c7b1cSBill Paul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30778c7b1cSBill Paul * SUCH DAMAGE. 31778c7b1cSBill Paul * 32778c7b1cSBill Paul */ 3398834523SPhilippe Charnier 3498834523SPhilippe Charnier #ifndef lint 3598834523SPhilippe Charnier static const char rcsid[] = 3697d92980SPeter Wemm "$FreeBSD$"; 3798834523SPhilippe Charnier #endif /* not lint */ 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 <stdio.h> 45778c7b1cSBill Paul #include <sys/types.h> 46778c7b1cSBill Paul #include <syslog.h> 472c0643afSKris Kennaway #include "yp_extern.h" 48778c7b1cSBill Paul 49778c7b1cSBill Paul int debug; 50778c7b1cSBill Paul extern int _rpcpmstart; 51778c7b1cSBill Paul 52778c7b1cSBill Paul extern char *progname; 53778c7b1cSBill Paul 54778c7b1cSBill Paul #if __STDC__ 55778c7b1cSBill Paul #include <stdarg.h> 56778c7b1cSBill Paul #else 57778c7b1cSBill Paul #include <varargs.h> 58778c7b1cSBill Paul #endif 59778c7b1cSBill Paul 602c0643afSKris Kennaway static void __verr(const char *fmt, _BSD_VA_LIST_ ap) __printflike(1, 0); 612c0643afSKris Kennaway 62ce5b7be8SBill Paul static void __verr(fmt, ap) 63778c7b1cSBill Paul const char *fmt; 64778c7b1cSBill Paul _BSD_VA_LIST_ ap; 65778c7b1cSBill Paul 66778c7b1cSBill Paul { 67778c7b1cSBill Paul if (debug && !_rpcpmstart) { 68778c7b1cSBill Paul fprintf(stderr,"%s: ",progname); 69778c7b1cSBill Paul vfprintf(stderr, fmt, ap); 70778c7b1cSBill Paul fprintf(stderr, "\n"); 71778c7b1cSBill Paul } else { 72778c7b1cSBill Paul vsyslog(LOG_NOTICE, fmt, ap); 73778c7b1cSBill Paul } 74778c7b1cSBill Paul } 75778c7b1cSBill Paul 76778c7b1cSBill Paul void 77778c7b1cSBill Paul #ifdef __STDC__ 78778c7b1cSBill Paul yp_error(const char *fmt, ...) 79778c7b1cSBill Paul #else 80778c7b1cSBill Paul yp_error(fmt, va_list) 81778c7b1cSBill Paul const char *fmt; 82778c7b1cSBill Paul va_dcl 83778c7b1cSBill Paul #endif 84778c7b1cSBill Paul { 85778c7b1cSBill Paul va_list ap; 86778c7b1cSBill Paul #ifdef __STDC__ 87778c7b1cSBill Paul va_start(ap, fmt); 88778c7b1cSBill Paul #else 89778c7b1cSBill Paul va_start(ap); 90778c7b1cSBill Paul #endif 91ce5b7be8SBill Paul __verr(fmt,ap); 92778c7b1cSBill Paul va_end(ap); 93778c7b1cSBill Paul } 94