libsir 2.2.5
Standard Incident Reporter
Loading...
Searching...
No Matches
console.h
1/*
2 * console.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 *
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#ifndef _SIR_CONSOLE_H_INCLUDED
33# define _SIR_CONSOLE_H_INCLUDED
34
35# include "sir/types.h"
36# include "sir/helpers.h"
37
38# if !defined(__WIN__)
39bool _sir_write_stdio(FILE* stream, const char* message);
40
41static inline
42bool _sir_write_stdout(const char* message, size_t len) {
43 SIR_UNUSED(len);
44 return _sir_write_stdio(stdout, message);
45}
46
47static inline
48bool _sir_write_stderr(const char* message, size_t len) {
49 SIR_UNUSED(len);
50 return _sir_write_stdio(stderr, message);
51}
52# else /* __WIN__ */
53extern HANDLE __sir_stdout;
54extern HANDLE __sir_stderr;
55
56void _sir_initialize_stdio(void);
57bool _sir_write_stdio(HANDLE console, const char* message, size_t len);
58
59static inline
60bool _sir_write_stdout(const char* message, size_t len) {
61 return _sir_write_stdio(__sir_stdout, message, len);
62}
63
64static inline
65bool _sir_write_stderr(const char* message, size_t len) {
66 return _sir_write_stdio(__sir_stderr, message, len);
67}
68# endif /* !__WIN__ */
69
70#endif /* !_SIR_CONSOLE_H_INCLUDED */