yp_error.c revision 12891
174462Salfred/*
274462Salfred * Copyright (c) 1995
3259118Shrs *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
4259118Shrs *
58870Srgrimes * Redistribution and use in source and binary forms, with or without
6259118Shrs * modification, are permitted provided that the following conditions
7259118Shrs * are met:
8259118Shrs * 1. Redistributions of source code must retain the above copyright
98870Srgrimes *    notice, this list of conditions and the following disclaimer.
10259118Shrs * 2. Redistributions in binary form must reproduce the above copyright
11259118Shrs *    notice, this list of conditions and the following disclaimer in the
12259118Shrs *    documentation and/or other materials provided with the distribution.
13259118Shrs * 3. All advertising materials mentioning features or use of this software
14259118Shrs *    must display the following acknowledgement:
15259118Shrs *	This product includes software developed by Bill Paul.
16259118Shrs * 4. Neither the name of the author nor the names of any co-contributors
17259118Shrs *    may be used to endorse or promote products derived from this software
18259118Shrs *    without specific prior written permission.
198870Srgrimes *
20259118Shrs * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21259118Shrs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22259118Shrs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23259118Shrs * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
24259118Shrs * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25259118Shrs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26259118Shrs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27259118Shrs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28259118Shrs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29259118Shrs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30259118Shrs * SUCH DAMAGE.
31259118Shrs *
321902Swollman */
331902Swollman/*
341902Swollman * error logging/reporting facilities
35136582Sobrien * stolen from /usr/libexec/mail.local via ypserv
3692986Sobrien *
371902Swollman * $Id: yp_error.c,v 1.2 1995/12/06 16:02:56 wpaul Exp $
3892986Sobrien */
3992986Sobrien
401902Swollman#include <stdio.h>
411902Swollman#include <sys/types.h>
421902Swollman#include <syslog.h>
431902Swollman
441902Swollmanint debug;
451902Swollmanextern int _rpcpmstart;
461902Swollman
471902Swollmanextern char *progname;
4874462Salfred
4974462Salfred#if __STDC__
50101067Snectar#include <stdarg.h>
511902Swollman#else
521902Swollman#include <varargs.h>
5311669Sphk#endif
5474462Salfred
551902Swollmanvoid verr(fmt, ap)
561902Swollman	const char *fmt;
5774462Salfred	_BSD_VA_LIST_ ap;
581902Swollman
591902Swollman{
601902Swollman	if (debug && !_rpcpmstart) {
611902Swollman		fprintf(stderr,"%s: ",progname);
621902Swollman		vfprintf(stderr, fmt, ap);
631902Swollman		fprintf(stderr, "\n");
641902Swollman	} else {
651902Swollman		vsyslog(LOG_NOTICE, fmt, ap);
661902Swollman	}
671902Swollman}
6874462Salfred
691902Swollmanvoid
701902Swollman#ifdef __STDC__
711902Swollmanyp_error(const char *fmt, ...)
721902Swollman#else
731902Swollmanyp_error(fmt, va_list)
741902Swollman	const char *fmt;
7574462Salfred	va_dcl
7674462Salfred#endif
7774462Salfred{
7874462Salfred	va_list ap;
7974462Salfred#ifdef __STDC__
801902Swollman	va_start(ap, fmt);
811902Swollman#else
82101045Sdarrenr	va_start(ap);
831902Swollman#endif
841902Swollman	verr(fmt,ap);
851902Swollman	va_end(ap);
86101147Snectar}
87101045Sdarrenr