Use GNU style like the rest of the file for my last commit.
[dragonfly/vkernel-mp.git] / usr.sbin / atm / atmarpd / atmarp_log.c
blob3369f6786423d4d80f9bc13031712dbd5159dc42
1 /*
3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * @(#) $FreeBSD: src/usr.sbin/atm/atmarpd/atmarp_log.c,v 1.3 1999/08/28 01:15:30 peter Exp $
27 * @(#) $DragonFly: src/usr.sbin/atm/atmarpd/atmarp_log.c,v 1.3 2003/11/15 21:33:42 eirikn Exp $
32 * Server Cache Synchronization Protocol (SCSP) Support
33 * ----------------------------------------------------
35 * SCSP-ATMARP server interface: logging routines
39 #include <sys/types.h>
40 #include <sys/param.h>
41 #include <sys/socket.h>
42 #include <net/if.h>
43 #include <netinet/in.h>
44 #include <netatm/queue.h>
45 #include <netatm/atm.h>
46 #include <netatm/atm_if.h>
47 #include <netatm/atm_sap.h>
48 #include <netatm/atm_sys.h>
49 #include <netatm/atm_ioctl.h>
51 #include <errno.h>
52 #include <libatm.h>
53 #if __STDC__
54 #include <stdarg.h>
55 #else
56 #include <varargs.h>
57 #endif
58 #include <stdio.h>
59 #include <syslog.h>
61 #include "../scspd/scsp_msg.h"
62 #include "../scspd/scsp_if.h"
63 #include "../scspd/scsp_var.h"
64 #include "atmarp_var.h"
67 * Write a message to atmarpd's log
69 * Arguments:
70 * level the level (error, info, etc.) of the message
71 * fmt printf-style format string
72 * ... parameters for printf-style use according to fmt
74 * Returns:
75 * none
78 void
79 atmarp_log(const int level, const char *fmt, ...)
81 va_list ap;
83 va_start(ap, fmt);
86 * In debug mode, just write to stdout
88 if (atmarp_debug_mode) {
89 vprintf(fmt, ap);
90 printf("\n");
91 return;
95 * Check whether we have a log file set up
97 if (!atmarp_log_file) {
99 * Write to syslog
101 vsyslog(level, fmt, ap);
102 } else {
104 * Write to the log file
106 vfprintf(atmarp_log_file, fmt, ap);
107 fprintf(atmarp_log_file, "\n");
110 va_end(ap);
115 * Log a memory error and exit
117 * Arguments:
118 * cp message to log
120 * Returns:
121 * exits, does not return
124 void
125 atmarp_mem_err(char *cp)
127 atmarp_log(LOG_CRIT, "out of memory: %s", cp);
128 exit(2);