stumpless 2.2.0
Loading...
Searching...
No Matches
facility.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: Apache-2.0 */
2
3/*
4 * Copyright 2018-2024 Joel E. Anderson
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
28#ifndef __STUMPLESS_FACILITY_H
29# define __STUMPLESS_FACILITY_H
30
31# include <stumpless/config.h>
32# include <stumpless/generator.h>
33# include <stddef.h>
34
35# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
36# include <syslog.h>
37# endif
38
44# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
45# define STUMPLESS_FACILITY_KERN_VALUE LOG_KERN
46# else
47# define STUMPLESS_FACILITY_KERN_VALUE 0
48# endif
49
55# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
56# define STUMPLESS_FACILITY_USER_VALUE LOG_USER
57# else
58# define STUMPLESS_FACILITY_USER_VALUE ( 1 << 3 )
59# endif
60
66# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
67# define STUMPLESS_FACILITY_MAIL_VALUE LOG_MAIL
68# else
69# define STUMPLESS_FACILITY_MAIL_VALUE ( 2 << 3 )
70# endif
71
77# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
78# define STUMPLESS_FACILITY_DAEMON_VALUE LOG_DAEMON
79# else
80# define STUMPLESS_FACILITY_DAEMON_VALUE ( 3 << 3 )
81# endif
82
89# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
90# define STUMPLESS_FACILITY_AUTH_VALUE LOG_AUTH
91# else
92# define STUMPLESS_FACILITY_AUTH_VALUE ( 4 << 3 )
93# endif
94
101# define STUMPLESS_FACILITY_SYSLOG_VALUE ( 5 << 3 )
102
108# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
109# define STUMPLESS_FACILITY_LPR_VALUE LOG_LPR
110# else
111# define STUMPLESS_FACILITY_LPR_VALUE ( 6 << 3 )
112# endif
113
119# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
120# define STUMPLESS_FACILITY_NEWS_VALUE LOG_NEWS
121# else
122# define STUMPLESS_FACILITY_NEWS_VALUE ( 7 << 3 )
123# endif
124
130# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
131# define STUMPLESS_FACILITY_UUCP_VALUE LOG_UUCP
132# else
133# define STUMPLESS_FACILITY_UUCP_VALUE ( 8 << 3 )
134# endif
135
141# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
142# define STUMPLESS_FACILITY_CRON_VALUE LOG_CRON
143# else
144# define STUMPLESS_FACILITY_CRON_VALUE ( 9 << 3 )
145# endif
146
152# define STUMPLESS_FACILITY_AUTH2_VALUE ( 10 << 3 )
153
159# define STUMPLESS_FACILITY_FTP_VALUE ( 11 << 3 )
160
166# define STUMPLESS_FACILITY_NTP_VALUE ( 12 << 3 )
167
173# define STUMPLESS_FACILITY_AUDIT_VALUE ( 13 << 3 )
174
180# define STUMPLESS_FACILITY_ALERT_VALUE ( 14 << 3 )
181
187# define STUMPLESS_FACILITY_CRON2_VALUE ( 15 << 3 )
188
194# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
195# define STUMPLESS_FACILITY_LOCAL0_VALUE LOG_LOCAL0
196# else
197# define STUMPLESS_FACILITY_LOCAL0_VALUE ( 16 << 3 )
198# endif
199
205# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
206# define STUMPLESS_FACILITY_LOCAL1_VALUE LOG_LOCAL1
207# else
208# define STUMPLESS_FACILITY_LOCAL1_VALUE ( 17 << 3 )
209# endif
210
216# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
217# define STUMPLESS_FACILITY_LOCAL2_VALUE LOG_LOCAL2
218# else
219# define STUMPLESS_FACILITY_LOCAL2_VALUE ( 18 << 3 )
220# endif
221
227# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
228# define STUMPLESS_FACILITY_LOCAL3_VALUE LOG_LOCAL3
229# else
230# define STUMPLESS_FACILITY_LOCAL3_VALUE ( 19 << 3 )
231# endif
232
238# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
239# define STUMPLESS_FACILITY_LOCAL4_VALUE LOG_LOCAL4
240# else
241# define STUMPLESS_FACILITY_LOCAL4_VALUE ( 20 << 3 )
242# endif
243
249# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
250# define STUMPLESS_FACILITY_LOCAL5_VALUE LOG_LOCAL5
251# else
252# define STUMPLESS_FACILITY_LOCAL5_VALUE ( 21 << 3 )
253# endif
254
260# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
261# define STUMPLESS_FACILITY_LOCAL6_VALUE LOG_LOCAL6
262# else
263# define STUMPLESS_FACILITY_LOCAL6_VALUE ( 22 << 3 )
264# endif
265
271# ifdef STUMPLESS_SYSLOG_H_COMPATIBLE
272# define STUMPLESS_FACILITY_LOCAL7_VALUE LOG_LOCAL7
273# else
274# define STUMPLESS_FACILITY_LOCAL7_VALUE ( 23 << 3 )
275# endif
276
285# define STUMPLESS_FOREACH_FACILITY( ACTION ) \
286 \
287ACTION( STUMPLESS_FACILITY_KERN, STUMPLESS_FACILITY_KERN_VALUE ) \
288 \
289ACTION( STUMPLESS_FACILITY_USER, STUMPLESS_FACILITY_USER_VALUE ) \
290 \
291ACTION( STUMPLESS_FACILITY_MAIL, STUMPLESS_FACILITY_MAIL_VALUE ) \
292 \
293ACTION( STUMPLESS_FACILITY_DAEMON, STUMPLESS_FACILITY_DAEMON_VALUE ) \
294 \
295ACTION( STUMPLESS_FACILITY_AUTH, STUMPLESS_FACILITY_AUTH_VALUE ) \
296 \
297ACTION( STUMPLESS_FACILITY_SYSLOG, STUMPLESS_FACILITY_SYSLOG_VALUE ) \
298 \
299ACTION( STUMPLESS_FACILITY_LPR, STUMPLESS_FACILITY_LPR_VALUE ) \
300 \
301ACTION( STUMPLESS_FACILITY_NEWS, STUMPLESS_FACILITY_NEWS_VALUE ) \
302 \
303ACTION( STUMPLESS_FACILITY_UUCP, STUMPLESS_FACILITY_UUCP_VALUE ) \
304 \
305ACTION( STUMPLESS_FACILITY_CRON, STUMPLESS_FACILITY_CRON_VALUE ) \
306 \
307ACTION( STUMPLESS_FACILITY_AUTH2, STUMPLESS_FACILITY_AUTH2_VALUE ) \
308 \
309ACTION( STUMPLESS_FACILITY_FTP, STUMPLESS_FACILITY_FTP_VALUE ) \
310 \
311ACTION( STUMPLESS_FACILITY_NTP, STUMPLESS_FACILITY_NTP_VALUE ) \
312 \
313ACTION( STUMPLESS_FACILITY_AUDIT, STUMPLESS_FACILITY_AUDIT_VALUE ) \
314 \
315ACTION( STUMPLESS_FACILITY_ALERT, STUMPLESS_FACILITY_ALERT_VALUE ) \
316 \
317ACTION( STUMPLESS_FACILITY_CRON2, STUMPLESS_FACILITY_CRON2_VALUE ) \
318 \
319ACTION( STUMPLESS_FACILITY_LOCAL0, STUMPLESS_FACILITY_LOCAL0_VALUE ) \
320 \
321ACTION( STUMPLESS_FACILITY_LOCAL1, STUMPLESS_FACILITY_LOCAL1_VALUE ) \
322 \
323ACTION( STUMPLESS_FACILITY_LOCAL2, STUMPLESS_FACILITY_LOCAL2_VALUE ) \
324 \
325ACTION( STUMPLESS_FACILITY_LOCAL3, STUMPLESS_FACILITY_LOCAL3_VALUE ) \
326 \
327ACTION( STUMPLESS_FACILITY_LOCAL4, STUMPLESS_FACILITY_LOCAL4_VALUE ) \
328 \
329ACTION( STUMPLESS_FACILITY_LOCAL5, STUMPLESS_FACILITY_LOCAL5_VALUE ) \
330 \
331ACTION( STUMPLESS_FACILITY_LOCAL6, STUMPLESS_FACILITY_LOCAL6_VALUE ) \
332 \
333ACTION( STUMPLESS_FACILITY_LOCAL7, STUMPLESS_FACILITY_LOCAL7_VALUE )
334
335# ifdef __cplusplus
336extern "C" {
337# endif
338
350
373const char *
375
398stumpless_get_facility_enum( const char *facility_string );
399
424stumpless_get_facility_enum_from_buffer( const char *facility_string, size_t facility_buffer_length );
425
426# ifdef __cplusplus
427} /* extern "C" */
428# endif
429
430#endif /* __STUMPLESS_FACILITY_H */
#define STUMPLESS_PUBLIC_FUNCTION
Marks functions that are provided for use by the library.
Definition config.h:31
STUMPLESS_PUBLIC_FUNCTION enum stumpless_facility stumpless_get_facility_enum(const char *facility_string)
Gets the enum value corresponding to the given facility string.
#define STUMPLESS_FOREACH_FACILITY(ACTION)
A macro function that runs the provided action once for each facility, providing the symbol and value...
Definition facility.h:285
STUMPLESS_PUBLIC_FUNCTION enum stumpless_facility stumpless_get_facility_enum_from_buffer(const char *facility_string, size_t facility_buffer_length)
Gets the enum value corresponding to the given facility string.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_facility_string(enum stumpless_facility facility)
Gets the string representation of the given facility.
stumpless_facility
All possible facility codes available to log entries.
Definition facility.h:347
@ STUMPLESS_GENERATE_ENUM
Kernel messages.
Definition facility.h:348
Generic functionality to be used with STUMPLESS_FOREACH macros to allow for more generic definition o...