libsir 2.2.5
Standard Incident Reporter
Loading...
Searching...
No Matches
internal.h
1/*
2 * internal.h
3 *
4 * Version: 2.2.5
5 *
6 * -----------------------------------------------------------------------------
7 *
8 * SPDX-License-Identifier: MIT
9 *
10 * Copyright (c) 2018-2024 Ryan M. Lederman <lederman@gmail.com>
11 * Copyright (c) 2018-2024 Jeffrey H. Johnson <trnsz@pobox.com>
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy of
14 * this software and associated documentation files (the "Software"), to deal in
15 * the Software without restriction, including without limitation the rights to
16 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
17 * the Software, and to permit persons to whom the Software is furnished to do so,
18 * subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included in all
21 * copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
25 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
26 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
27 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 *
30 * -----------------------------------------------------------------------------
31 */
32
33#ifndef _SIR_INTERNAL_H_INCLUDED
34# define _SIR_INTERNAL_H_INCLUDED
35
36# include "sir/helpers.h"
37# include "sir/maps.h"
38# include "sir/errors.h"
39
40# if defined(__cplusplus)
41extern "C" {
42# endif
43
48bool _sir_makeinit(sirinit* si);
49
51bool _sir_init(sirinit* si);
52
54bool _sir_cleanup(void);
55
57bool _sir_isinitialized(void);
58
63bool _sir_sanity(void);
64
66bool _sir_init_sanity(const sirinit* si);
67
69void _sir_reset_tls(void);
70
72bool _sir_stdoutlevels(sirinit* si, const sir_update_config_data* data);
73
75bool _sir_stdoutopts(sirinit* si, const sir_update_config_data* data);
76
78bool _sir_stderrlevels(sirinit* si, const sir_update_config_data* data);
79
81bool _sir_stderropts(sirinit* si, const sir_update_config_data* data);
82
84bool _sir_sysloglevels(sirinit* si, const sir_update_config_data* data);
85
87bool _sir_syslogopts(sirinit* si, const sir_update_config_data* data);
88
90bool _sir_syslogid(sirinit* si, const sir_update_config_data* data);
91
93bool _sir_syslogcat(sirinit* si, const sir_update_config_data* data);
94
96typedef bool (*sirinit_update)(sirinit*, const sir_update_config_data*);
97
99bool _sir_writeinit(const sir_update_config_data* data, sirinit_update update);
100
102void* _sir_locksection(sir_mutex_id mid);
103
105void _sir_unlocksection(sir_mutex_id mid);
106
108bool _sir_mapmutexid(sir_mutex_id mid, sir_mutex** m, void** section);
109
110# if !defined(__WIN__)
112void _sir_init_static_once(void);
113# else /* __WIN__ */
115BOOL CALLBACK _sir_init_static_once(PINIT_ONCE ponce, PVOID param, PVOID* ctx);
116# endif
117
119bool _sir_init_common_static(void);
120
122bool _sir_once(sir_once* once, sir_once_fn func);
123
125PRINTF_FORMAT_ATTR(2, 0)
126bool _sir_logv(sir_level level, PRINTF_FORMAT const char* format, va_list args);
127
129bool _sir_dispatch(const sirinit* si, sir_level level, sirbuf* buf);
130
132const char* _sir_format(bool styling, sir_options opts, sirbuf* buf);
133
135bool _sir_syslog_init(const char* name, sir_syslog_dest* ctx);
136
144bool _sir_syslog_open(sir_syslog_dest* ctx);
145
150bool _sir_syslog_write(sir_level level, const sirbuf* buf, const sir_syslog_dest* ctx);
151
156bool _sir_syslog_updated(sirinit* si, const sir_update_config_data* data);
157
165bool _sir_syslog_close(sir_syslog_dest* ctx);
166
168void _sir_syslog_reset(sir_syslog_dest* ctx);
169
171const char* _sir_formattedlevelstr(sir_level level);
172
174bool _sir_clock_gettime(int clock, time_t* tbuf, long* msecbuf);
175
180double _sir_msec_since(const sir_time* when, sir_time* out);
181
183pid_t _sir_getpid(void);
184
186pid_t _sir_gettid(void);
187
189bool _sir_getthreadname(char name[SIR_MAXPID]);
190
192bool _sir_setthreadname(const char* name);
193
195bool _sir_gethostname(char name[SIR_MAXHOST]);
196
198long __sir_nprocs(bool test_mode);
199# define _sir_nprocs() __sir_nprocs(0)
200# define _sir_nprocs_test() __sir_nprocs(1)
201
202# if defined(__cplusplus)
203}
204# endif
205
206#endif /* !_SIR_INTERNAL_H_INCLUDED */
uint16_t sir_level
The sir_level type.
Definition types.h:71
uint32_t sir_options
sir_option bitmask type.
Definition types.h:96
Configuration for the system logger destination.
Definition types.h:195
libsir initialization and configuration data.
Definition types.h:244
Internally-used time value type.
Definition types.h:281
Encapsulates dynamic updating of current configuration.
Definition types.h:478
Formatted output container.
Definition types.h:412