Denis Vlasenko | bd1aeeb | 2008-06-11 15:43:19 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * prioritynames[] and facilitynames[] |
| 4 | * |
| 5 | * Copyright (C) 2008 by Denys Vlasenko <vda.linux@gmail.com> |
| 6 | * |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
Denis Vlasenko | bd1aeeb | 2008-06-11 15:43:19 +0000 | [diff] [blame] | 8 | */ |
Denis Vlasenko | bd1aeeb | 2008-06-11 15:43:19 +0000 | [diff] [blame] | 9 | #include "libbb.h" |
Denys Vlasenko | e6a2f4c | 2016-04-21 16:26:30 +0200 | [diff] [blame] | 10 | #include "common_bufsiz.h" |
Denis Vlasenko | bd1aeeb | 2008-06-11 15:43:19 +0000 | [diff] [blame] | 11 | #define SYSLOG_NAMES |
| 12 | #define SYSLOG_NAMES_CONST |
| 13 | #include <syslog.h> |
| 14 | |
| 15 | #if 0 |
| 16 | /* For the record: with SYSLOG_NAMES <syslog.h> defines |
| 17 | * (not declares) the following: |
| 18 | */ |
| 19 | typedef struct _code { |
| 20 | /*const*/ char *c_name; |
| 21 | int c_val; |
| 22 | } CODE; |
| 23 | /*const*/ CODE prioritynames[] = { |
| 24 | { "alert", LOG_ALERT }, |
| 25 | ... |
| 26 | { NULL, -1 } |
| 27 | }; |
| 28 | /* same for facilitynames[] */ |
| 29 | |
| 30 | /* This MUST occur only once per entire executable, |
| 31 | * therefore we can't just do it in syslogd.c and logger.c - |
| 32 | * there will be two copies of it. |
| 33 | * |
| 34 | * We cannot even do it in separate file and then just reference |
| 35 | * prioritynames[] from syslogd.c and logger.c - bare <syslog.h> |
| 36 | * will not emit extern decls for prioritynames[]! Attempts to |
| 37 | * emit "matching" struct _code declaration defeat the whole purpose |
| 38 | * of <syslog.h>. |
| 39 | * |
| 40 | * For now, syslogd.c and logger.c are simply compiled into |
| 41 | * one object file. |
| 42 | */ |
| 43 | #endif |
| 44 | |
Denys Vlasenko | cf686ae | 2017-08-16 15:05:36 +0200 | [diff] [blame] | 45 | /* musl decided to be funny and it implements these as giant defines |
| 46 | * of the form: ((CODE *)(const CODE []){ ... }) |
| 47 | * Which works, but causes _every_ function using them |
| 48 | * to have a copy on stack (at least with gcc-6.3.0). |
| 49 | * If we reference them just once, this saves 150 bytes. |
| 50 | * The pointers themselves are optimized out |
| 51 | * (no size change on uclibc). |
| 52 | */ |
| 53 | static const CODE *const bb_prioritynames = prioritynames; |
| 54 | static const CODE *const bb_facilitynames = facilitynames; |
| 55 | |
Denys Vlasenko | e1b1b79 | 2018-03-06 18:11:47 +0100 | [diff] [blame] | 56 | |
Denis Vlasenko | bd1aeeb | 2008-06-11 15:43:19 +0000 | [diff] [blame] | 57 | #if ENABLE_SYSLOGD |
| 58 | #include "syslogd.c" |
| 59 | #endif |
| 60 | |
| 61 | #if ENABLE_LOGGER |
| 62 | #include "logger.c" |
| 63 | #endif |