Sync usage with man page.
[netbsd-mini2440.git] / usr.sbin / altq / altqd / libaltq2.c
blob75788fdf0503263d14f5c10f56e914b1d16aa9c3
1 /* $NetBSD: libaltq2.c,v 1.5 2002/03/05 04:11:51 itojun Exp $ */
2 /* $KAME: libaltq2.c,v 1.6 2002/02/20 10:43:35 kjc Exp $ */
3 /*
4 * Copyright (C) 1997-2000
5 * Sony Computer Science Laboratories, Inc. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
30 * this file contains functions and variables needed to use libaltq.
31 * since these are defined in rsvpd, they should be separated in order
32 * to link libaltq to rsvpd.
34 #include <sys/param.h>
36 #include <altq/altq.h>
38 #include <stdio.h>
39 #include <errno.h>
40 #include <syslog.h>
41 #include <stdarg.h>
42 #include <string.h>
44 #include "altq_qop.h"
46 /* from rsvp_main.c */
47 const char *altqconfigfile = "/etc/altq.conf";
49 /* from rsvp_global.h */
50 int if_num; /* number of phyints */
51 int m_debug; /* Debug output control bits */
52 int l_debug; /* Logging severity level */
54 int daemonize = 1;
56 /* taken from rsvp_debug.c and modified. */
57 void
58 log_write(int severity, int syserr, const char *format, ...)
60 va_list ap;
62 va_start(ap, format);
64 if (severity <= l_debug) {
65 if (!daemonize) {
66 vfprintf(stderr, format, ap);
67 if (syserr != 0)
68 fprintf(stderr, ": %s", strerror(syserr));
69 fprintf(stderr, "\n");
70 } else {
71 if (syserr == 0)
72 vsyslog(severity, format, ap);
73 else {
74 char buf[512];
76 strlcpy(buf, format, sizeof(buf));
77 strlcat(buf, ": %m", sizeof(buf));
78 vsyslog(severity, buf, ap);
83 va_end(ap);