Remove building with NOCRYPTO option
[minix3.git] / lib / libc / compat / gen / compat_syslog.c
blobe653463d4e8c4a2213fe9a32db6a457eaa70c7aa
1 /* $NetBSD: compat_syslog.c,v 1.2 2012/10/11 17:09:55 christos Exp $ */
3 /*-
4 * Copyright (c) 2012 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include "namespace.h"
33 #include <sys/cdefs.h>
35 #define __LIBC12_SOURCE__
36 #include <stdarg.h>
38 #include <sys/types.h>
39 #include <sys/syslog.h>
40 #include <compat/sys/syslog.h>
42 void syslog_ss(int, struct syslog_data60 *, const char *, ...)
43 __printflike(3, 4);
44 void vsyslog_ss(int, struct syslog_data60 *, const char *, va_list)
45 __printflike(3, 0);
46 void syslogp_ss(int, struct syslog_data60 *, const char *, const char *,
47 const char *, ...) __printflike(5, 0);
48 void vsyslogp_ss(int, struct syslog_data60 *, const char *, const char *,
49 const char *, va_list) __printflike(5, 0);
51 #ifdef __weak_alias
52 __weak_alias(closelog_r,_closelog_r)
53 __weak_alias(openlog_r,_openlog_r)
54 __weak_alias(setlogmask_r,_setlogmask_r)
55 __weak_alias(syslog_r,_syslog_r)
56 __weak_alias(vsyslog_r,_vsyslog_r)
57 __weak_alias(syslogp_r,_syslogp_r)
58 __weak_alias(vsyslogp_r,_vsyslogp_r)
60 __weak_alias(syslog_ss,_syslog_ss)
61 __weak_alias(vsyslog_ss,_vsyslog_ss)
62 __weak_alias(syslogp_ss,_syslogp_ss)
63 __weak_alias(vsyslogp_ss,_vsyslogp_ss)
64 #endif /* __weak_alias */
66 __warn_references(closelog_r,
67 "warning: reference to compatibility closelog_r();"
68 " include <sys/syslog.h> for correct reference")
69 __warn_references(openlog_r,
70 "warning: reference to compatibility openlog_r();"
71 " include <sys/syslog.h> for correct reference")
72 __warn_references(setlogmask_r,
73 "warning: reference to compatibility setlogmask_r();"
74 " include <sys/syslog.h> for correct reference")
75 __warn_references(syslog_r,
76 "warning: reference to compatibility syslog_r();"
77 " include <sys/syslog.h> for correct reference")
78 __warn_references(vsyslog_r,
79 "warning: reference to compatibility vsyslog_r();"
80 " include <sys/syslog.h> for correct reference")
81 __warn_references(syslogp_r,
82 "warning: reference to compatibility syslogp_r();"
83 " include <sys/syslog.h> for correct reference")
84 __warn_references(vsyslogp_r,
85 "warning: reference to compatibility vsyslogp_r();"
86 " include <sys/syslog.h> for correct reference")
88 static void
89 syslog_data_convert(struct syslog_data *d, const struct syslog_data60 *s)
91 d->log_file = s->log_file;
92 d->log_connected = s->connected;
93 d->log_opened = s->opened;
94 d->log_stat = s->log_stat;
95 d->log_tag = s->log_tag;
96 d->log_fac = s->log_fac;
97 d->log_mask = s->log_mask;
100 void
101 closelog_r(struct syslog_data60 *data60)
103 struct syslog_data data = SYSLOG_DATA_INIT;
104 syslog_data_convert(&data, data60);
105 __closelog_r60(&data);
108 void
109 openlog_r(const char *ident, int logstat, int logfac,
110 struct syslog_data60 *data60)
112 struct syslog_data data = SYSLOG_DATA_INIT;
113 syslog_data_convert(&data, data60);
114 __openlog_r60(ident, logstat, logfac, &data);
118 setlogmask_r(int pmask, struct syslog_data60 *data60)
120 struct syslog_data data = SYSLOG_DATA_INIT;
121 syslog_data_convert(&data, data60);
122 return __setlogmask_r60(pmask, &data);
125 void
126 syslog_r(int pri, struct syslog_data60 *data60, const char *fmt, ...)
128 va_list ap;
129 struct syslog_data data = SYSLOG_DATA_INIT;
130 syslog_data_convert(&data, data60);
132 va_start(ap, fmt);
133 __vsyslog_r60(pri, &data, fmt, ap);
134 va_end(ap);
137 void
138 vsyslog_r(int pri, struct syslog_data60 *data60, const char *fmt, __va_list ap)
140 struct syslog_data data = SYSLOG_DATA_INIT;
141 syslog_data_convert(&data, data60);
142 __vsyslog_r60(pri, &data, fmt, ap);
145 void
146 syslogp_r(int pri, struct syslog_data60 *data60, const char *msgid,
147 const char *sdfmt, const char *msgfmt, ...)
149 va_list ap;
150 struct syslog_data data = SYSLOG_DATA_INIT;
151 syslog_data_convert(&data, data60);
153 va_start(ap, msgfmt);
154 __vsyslogp_r60(pri, &data, msgid, sdfmt, msgfmt, ap);
155 va_end(ap);
158 void
159 vsyslogp_r(int pri, struct syslog_data60 *data60, const char *msgid,
160 const char *sdfmt, const char *msgfmt, __va_list ap)
162 struct syslog_data data = SYSLOG_DATA_INIT;
163 syslog_data_convert(&data, data60);
165 __vsyslogp_r60(pri, &data, msgid, sdfmt, msgfmt, ap);
169 * These are semi-private
171 #define LOG_SIGNAL_SAFE (int)0x80000000
173 void
174 syslog_ss(int pri, struct syslog_data60 *data, const char *fmt, ...)
176 va_list ap;
178 va_start(ap, fmt);
179 vsyslog_r(pri | LOG_SIGNAL_SAFE, data, fmt, ap);
180 va_end(ap);
183 void
184 syslogp_ss(int pri, struct syslog_data60 *data, const char *msgid,
185 const char *sdfmt, const char *msgfmt, ...)
187 va_list ap;
189 va_start(ap, msgfmt);
190 vsyslogp_r(pri | LOG_SIGNAL_SAFE, data, msgid, sdfmt, msgfmt, ap);
191 va_end(ap);
194 void
195 vsyslog_ss(int pri, struct syslog_data60 *data, const char *fmt, va_list ap)
197 vsyslog_r(pri | LOG_SIGNAL_SAFE, data, fmt, ap);
200 void
201 vsyslogp_ss(int pri, struct syslog_data60 *data, const char *msgid,
202 const char *sdfmt, const char *msgfmt, va_list ap)
204 vsyslogp_r(pri | LOG_SIGNAL_SAFE, data, msgid, sdfmt, msgfmt, ap);