1 /*
2 * sirmaps.c
3 *
4 * Version: 2.2.6
5 *
6 * -----------------------------------------------------------------------------
7 *
8 * SPDX-License-Identifier: MIT
9 *
10 * Copyright (c) 2018-2024 Ryan M. Lederman <lederman@gmail.com>
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a copy of
13 * this software and associated documentation files (the "Software"), to deal in
14 * the Software without restriction, including without limitation the rights to
15 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
16 * the Software, and to permit persons to whom the Software is furnished to do so,
17 * subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included in all
20 * copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
25 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * -----------------------------------------------------------------------------
30 */
31
32 #include "sir/maps.h"
33 #include "sir/defaults.h"
34
35 /**
36 * @brief Mapping of ::sir_level <-> ::sir_textstyle & ANSI escape codes.
37 *
38 * ::sir_settextstyle and ::sir_resettextstyles modify the style
39 * values in this array at runtime; only the SIRL_* values are constant.
40 */
41 #if !defined(SIR_NO_TEXT_STYLING)
42 sir_level_style_tuple sir_level_to_style_map[SIR_NUMLEVELS] = {
43 {SIRL_EMERG, {0}, {0}},
44 {SIRL_ALERT, {0}, {0}},
45 {SIRL_CRIT, {0}, {0}},
46 {SIRL_ERROR, {0}, {0}},
47 {SIRL_WARN, {0}, {0}},
48 {SIRL_NOTICE, {0}, {0}},
49 {SIRL_INFO, {0}, {0}},
50 {SIRL_DEBUG, {0}, {0}}
51 };
52 #endif
53
54 /**
55 * @brief Mapping of ::sir_level <-> human-readable string forms.
56 *
57 * ::_sir_formattedlevelstr retrieves values from this array.
58 */
59 sir_level_str_pair sir_level_to_str_map[SIR_NUMLEVELS] = {
60 {SIRL_EMERG, SIR_LEVELPREFIX SIRL_S_EMERG SIR_LEVELSUFFIX},
61 {SIRL_ALERT, SIR_LEVELPREFIX SIRL_S_ALERT SIR_LEVELSUFFIX},
62 {SIRL_CRIT, SIR_LEVELPREFIX SIRL_S_CRIT SIR_LEVELSUFFIX},
63 {SIRL_ERROR, SIR_LEVELPREFIX SIRL_S_ERROR SIR_LEVELSUFFIX},
64 {SIRL_WARN, SIR_LEVELPREFIX SIRL_S_WARN SIR_LEVELSUFFIX},
65 {SIRL_NOTICE, SIR_LEVELPREFIX SIRL_S_NOTICE SIR_LEVELSUFFIX},
66 {SIRL_INFO, SIR_LEVELPREFIX SIRL_S_INFO SIR_LEVELSUFFIX},
67 {SIRL_DEBUG, SIR_LEVELPREFIX SIRL_S_DEBUG SIR_LEVELSUFFIX}
68 };