libsir 2.2.5
Standard Incident Reporter
Loading...
Searching...
No Matches
filecache.h
1/*
2 * filecache.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_FILECACHE_H_INCLUDED
34# define _SIR_FILECACHE_H_INCLUDED
35
36# include "sir/types.h"
37
38typedef bool (*sir_fcache_pred)(const void* match, const sirfile* iter);
39
40sirfileid _sir_addfile(const char* path, sir_levels levels, sir_options opts);
41bool _sir_updatefile(sirfileid id, const sir_update_config_data* data);
42bool _sir_remfile(sirfileid id);
43
44sirfile* _sirfile_create(const char* path, sir_levels levels, sir_options opts);
45bool _sirfile_open(sirfile* sf);
46void _sirfile_close(sirfile* sf);
47bool _sirfile_write(sirfile* sf, const char* output);
48bool _sirfile_writeheader(sirfile* sf, const char* msg);
49bool _sirfile_needsroll(sirfile* sf);
50bool _sirfile_roll(sirfile* sf, char** newpath);
51void _sirfile_rollifneeded(sirfile* sf);
52bool _sirfile_archive(sirfile* sf, const char* newpath);
53bool _sirfile_splitpath(const sirfile* sf, char** name, char** ext);
54void _sirfile_destroy(sirfile** sf);
55bool _sirfile_validate(const sirfile* sf);
56bool _sirfile_update(sirfile* sf, const sir_update_config_data* data);
57
58sirfileid _sir_fcache_add(sirfcache* sfc, const char* path, sir_levels levels,
59 sir_options opts);
60bool _sir_fcache_update(const sirfcache* sfc, sirfileid id, const sir_update_config_data* data);
61bool _sir_fcache_rem(sirfcache* sfc, sirfileid id);
62void _sir_fcache_shift(sirfcache* sfc, size_t idx);
63
64bool _sir_fcache_pred_path(const void* match, const sirfile* iter);
65bool _sir_fcache_pred_id(const void* match, const sirfile* iter);
66sirfile* _sir_fcache_find(const sirfcache* sfc, const void* match, sir_fcache_pred pred);
67
68bool _sir_fcache_destroy(sirfcache* sfc);
69bool _sir_fcache_dispatch(const sirfcache* sfc, sir_level level, sirbuf* buf,
70 size_t* dispatched, size_t* wanted);
71
72void _sir_fflush(FILE* f);
73
74#endif /* !_SIR_FILECACHE_H_INCLUDED */
uint16_t sir_level
The sir_level type.
Definition types.h:71
uint32_t sirfileid
Log file identifier type.
Definition types.h:49
uint16_t sir_levels
sir_level bitmask type.
Definition types.h:74
uint32_t sir_options
sir_option bitmask type.
Definition types.h:96
Encapsulates dynamic updating of current configuration.
Definition types.h:478
Formatted output container.
Definition types.h:412
Log file cache.
Definition types.h:323
Internally-used log file data.
Definition types.h:313