Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/fmt/lspc/util/path.h

raw
1 /*
2 * Copyright (C) 2022 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2022 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 24 окт. 2022 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_FMT_LSPC_UTIL_PATH_H_
23 #define LSP_PLUG_IN_FMT_LSPC_UTIL_PATH_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26
27 #include <lsp-plug.in/common/status.h>
28 #include <lsp-plug.in/fmt/lspc/File.h>
29 #include <lsp-plug.in/io/Path.h>
30 #include <lsp-plug.in/runtime/LSPString.h>
31
32 namespace lsp
33 {
34 namespace lspc
35 {
36 /**
37 * Allocate path entry and fill it's fields
38 * @param path relative path of the file
39 * @param flags path entry flags
40 * @param reference_id refere
41 * @return pointer to allocated path entry or NULL if error occurred
42 */
43 LSP_RUNTIME_LIB_PUBLIC
44 path_entry_t *alloc_path(const char *path, size_t flags, chunk_id_t reference_id);
45
46 LSP_RUNTIME_LIB_PUBLIC
47 path_entry_t *alloc_path(const io::Path *path, size_t flags, chunk_id_t reference_id);
48
49 LSP_RUNTIME_LIB_PUBLIC
50 path_entry_t *alloc_path(const LSPString *path, size_t flags, chunk_id_t reference_id);
51
52 /**
53 * Allocate path entry with specified path length in bytes
54 * @param path_len path length without trailing zero counted
55 * @return allocated path entry or NULL if error occurred
56 */
57 LSP_RUNTIME_LIB_PUBLIC
58 path_entry_t *alloc_path(size_t path_len);
59
60 /**
61 * Free previously allocated path entry
62 * @param path path entry to free
63 */
64 LSP_RUNTIME_LIB_PUBLIC
65 void free_path(path_entry_t * path);
66
67 /**
68 * Write path entry to LSPC file
69 * @param chunk_id pointer to return chunk identifier, can be NULL
70 * @param file the LSPC file to create chunk
71 * @param path path entry
72 * @return status of operation
73 */
74 LSP_RUNTIME_LIB_PUBLIC
75 status_t write_path(chunk_id_t *chunk_id, File *file, const path_entry_t *path);
76
77 /**
78 * Write path entry to LSPC file
79 * @param chunk_id pointer to store allocated chunk identifier, can be NULL
80 * @param file the LSPC file to write the chunk
81 * @param path the path string
82 * @param flags path flags
83 * @param reference_id the identifier of chunk referenced by the path entry
84 * @return status of operation
85 */
86 LSP_RUNTIME_LIB_PUBLIC
87 status_t write_path(chunk_id_t *chunk_id, File *file, const char *path, size_t flags, chunk_id_t reference_id);
88
89 LSP_RUNTIME_LIB_PUBLIC
90 status_t write_path(chunk_id_t *chunk_id, File *file, const io::Path *path, size_t flags, chunk_id_t reference_id);
91
92 LSP_RUNTIME_LIB_PUBLIC
93 status_t write_path(chunk_id_t *chunk_id, File *file, const LSPString *path, size_t flags, chunk_id_t reference_id);
94
95
96 /**
97 * Read path entry from the LSPC file
98 * @param chunk_id chunk identifier
99 * @param file the LSPC fiel to read the chunk
100 * @param path the pointer to store the allocated path entry record, can be NULL
101 * @return status of operation
102 */
103 LSP_RUNTIME_LIB_PUBLIC
104 status_t read_path(chunk_id_t chunk_id, File *file, path_entry_t **path);
105
106 /**
107 * Read path entry from the LSPC file
108 * @param chunk_id chunk identifier
109 * @param file the LSPC fiel to read the chunk
110 * @param path the pointer to store the pointer to allocated string, can be NULL, should be free()'d after use
111 * @param flags chunk flags, can be NULL
112 * @param reference_id referenced chunk identifier, can be NULL
113 * @return status of operation
114 */
115 LSP_RUNTIME_LIB_PUBLIC
116 status_t read_path(chunk_id_t chunk_id, File *file, char **path, size_t *flags, chunk_id_t *reference_id);
117
118 /**
119 * Read path entry from the LSPC file
120 * @param chunk_id chunk identifier
121 * @param file the LSPC fiel to read the chunk
122 * @param path the pointer to store the path data
123 * @param flags chunk flags, can be NULL
124 * @param reference_id referenced chunk identifier, can be NULL
125 * @return status of operation
126 */
127 LSP_RUNTIME_LIB_PUBLIC
128 status_t read_path(chunk_id_t chunk_id, File *file, io::Path *path, size_t *flags, chunk_id_t *reference_id);
129
130 LSP_RUNTIME_LIB_PUBLIC
131 status_t read_path(chunk_id_t chunk_id, File *file, LSPString *path, size_t *flags, chunk_id_t *reference_id);
132 } /* namespace lspc */
133 } /* namespace lsp */
134
135
136 #endif /* LSP_PLUG_IN_FMT_LSPC_UTIL_PATH_H_ */