libaltq2.c revision 1.1 1 1.1 thorpej /*
2 1.1 thorpej * this file contains functions and variables needed to use libaltq.
3 1.1 thorpej * since these are defined in rsvpd, they should be separated in order
4 1.1 thorpej * to link libaltq to rsvpd.
5 1.1 thorpej */
6 1.1 thorpej #include <sys/param.h>
7 1.1 thorpej
8 1.1 thorpej #include <altq/altq.h>
9 1.1 thorpej
10 1.1 thorpej #include <stdio.h>
11 1.1 thorpej #include <errno.h>
12 1.1 thorpej #include <syslog.h>
13 1.1 thorpej #ifdef __STDC__
14 1.1 thorpej #include <stdarg.h>
15 1.1 thorpej #else
16 1.1 thorpej #include <varargs.h>
17 1.1 thorpej #endif
18 1.1 thorpej
19 1.1 thorpej #include "altq_qop.h"
20 1.1 thorpej
21 1.1 thorpej /* from rsvp_main.c */
22 1.1 thorpej char *altqconfigfile = "/etc/altq.conf";
23 1.1 thorpej
24 1.1 thorpej /* from rsvp_global.h */
25 1.1 thorpej int if_num; /* number of phyints */
26 1.1 thorpej int m_debug; /* Debug output control bits */
27 1.1 thorpej int l_debug; /* Logging severity level */
28 1.1 thorpej
29 1.1 thorpej int daemonize = 1;
30 1.1 thorpej
31 1.1 thorpej /* taken from rsvp_debug.c and modified. */
32 1.1 thorpej void
33 1.1 thorpej log_write(int severity, int syserr, const char *format, ...)
34 1.1 thorpej {
35 1.1 thorpej va_list ap;
36 1.1 thorpej
37 1.1 thorpej #ifdef __STDC__
38 1.1 thorpej va_start(ap, format);
39 1.1 thorpej #else
40 1.1 thorpej va_start(ap);
41 1.1 thorpej #endif
42 1.1 thorpej
43 1.1 thorpej if (severity <= l_debug) {
44 1.1 thorpej if (!daemonize)
45 1.1 thorpej vfprintf(stderr, format, ap);
46 1.1 thorpej else
47 1.1 thorpej vsyslog(severity, format, ap);
48 1.1 thorpej }
49 1.1 thorpej
50 1.1 thorpej va_end(ap);
51 1.1 thorpej
52 1.1 thorpej if (syserr == 0) {
53 1.1 thorpej /* Do nothing for now */
54 1.1 thorpej } else if (syserr < sys_nerr) {
55 1.1 thorpej if (severity <= l_debug) {
56 1.1 thorpej if (!daemonize)
57 1.1 thorpej fprintf(stderr, ": %s\n", sys_errlist[syserr]);
58 1.1 thorpej else
59 1.1 thorpej syslog(severity, ": %s", sys_errlist[syserr]);
60 1.1 thorpej }
61 1.1 thorpej } else {
62 1.1 thorpej if (severity <= l_debug) {
63 1.1 thorpej if (!daemonize)
64 1.1 thorpej fprintf(stderr, ": errno %d\n", syserr);
65 1.1 thorpej else
66 1.1 thorpej syslog(severity, ": errno %d", syserr);
67 1.1 thorpej }
68 1.1 thorpej }
69 1.1 thorpej }
70