libsquashfs: include/sqfs/predef.h Source File

libsquashfs 1.3.2 A new set of tools and libraries for working with SquashFS images

Loading...
Searching...
No Matches
predef.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-3.0-or-later */
2/*
3 * predef.h - This file is part of libsquashfs
4 *
5 * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20#ifndef SQFS_PREDEF_H
21#define SQFS_PREDEF_H
22
29
30#include <stdbool.h>
31#include <stddef.h>
32#include <stdint.h>
33
34#if defined(_WIN32) || defined(__CYGWIN__)
35 #if defined(SQFS_STATIC)
36 #define SQFS_API
37 #elif defined(SQFS_BUILDING_DLL)
38 #if defined(__GNUC__) || defined(__clang__)
39 #define SQFS_API __attribute__ ((dllexport))
40 #else
41 #define SQFS_API __declspec(dllexport)
42 #endif
43 #else
44 #if defined(__GNUC__) || defined(__clang__)
45 #define SQFS_API __attribute__ ((dllimport))
46 #else
47 #define SQFS_API __declspec(dllimport)
48 #endif
49 #endif
50
51 #define SQFS_INTERNAL
52#else
53 #if defined(__GNUC__) || defined(__clang__)
54 #define SQFS_API __attribute__ ((visibility ("default")))
55 #define SQFS_INTERNAL __attribute__ ((visibility ("hidden")))
56 #else
57 #define SQFS_API
58 #define SQFS_INTERNAL
59 #endif
60#endif
61
62#ifdef _MSC_VER
63 #define SQFS_INLINE __forceinline
64#else
65 #define SQFS_INLINE __inline__ __attribute__((always_inline))
66#endif
67
68typedef uint8_t sqfs_u8;
69typedef uint16_t sqfs_u16;
70typedef uint32_t sqfs_u32;
71typedef uint64_t sqfs_u64;
72
73typedef int8_t sqfs_s8;
74typedef int16_t sqfs_s16;
75typedef int32_t sqfs_s32;
76typedef int64_t sqfs_s64;
77
78typedef struct sqfs_block_processor_t sqfs_block_processor_t;
79typedef struct sqfs_compressor_config_t sqfs_compressor_config_t;
80typedef struct sqfs_compressor_t sqfs_compressor_t;
81typedef struct sqfs_dir_writer_t sqfs_dir_writer_t;
82typedef struct sqfs_dir_reader_t sqfs_dir_reader_t;
83typedef struct sqfs_id_table_t sqfs_id_table_t;
84typedef struct sqfs_meta_reader_t sqfs_meta_reader_t;
85typedef struct sqfs_meta_writer_t sqfs_meta_writer_t;
86typedef struct sqfs_xattr_reader_t sqfs_xattr_reader_t;
87typedef struct sqfs_file_t sqfs_file_t;
88typedef struct sqfs_tree_node_t sqfs_tree_node_t;
89typedef struct sqfs_data_reader_t sqfs_data_reader_t;
90typedef struct sqfs_block_hooks_t sqfs_block_hooks_t;
91typedef struct sqfs_xattr_writer_t sqfs_xattr_writer_t;
92typedef struct sqfs_frag_table_t sqfs_frag_table_t;
93typedef struct sqfs_block_writer_t sqfs_block_writer_t;
94typedef struct sqfs_block_writer_stats_t sqfs_block_writer_stats_t;
95typedef struct sqfs_block_processor_stats_t sqfs_block_processor_stats_t;
96typedef struct sqfs_block_processor_desc_t sqfs_block_processor_desc_t;
97typedef struct sqfs_readdir_state_t sqfs_readdir_state_t;
98
99typedef struct sqfs_fragment_t sqfs_fragment_t;
100typedef struct sqfs_dir_header_t sqfs_dir_header_t;
101typedef struct sqfs_dir_entry_t sqfs_dir_entry_t;
102typedef struct sqfs_dir_index_t sqfs_dir_index_t;
103typedef struct sqfs_inode_t sqfs_inode_t;
104typedef struct sqfs_inode_dev_t sqfs_inode_dev_t;
105typedef struct sqfs_inode_dev_ext_t sqfs_inode_dev_ext_t;
106typedef struct sqfs_inode_ipc_t sqfs_inode_ipc_t;
107typedef struct sqfs_inode_ipc_ext_t sqfs_inode_ipc_ext_t;
108typedef struct sqfs_inode_slink_t sqfs_inode_slink_t;
109typedef struct sqfs_inode_slink_ext_t sqfs_inode_slink_ext_t;
110typedef struct sqfs_inode_file_t sqfs_inode_file_t;
111typedef struct sqfs_inode_file_ext_t sqfs_inode_file_ext_t;
112typedef struct sqfs_inode_dir_t sqfs_inode_dir_t;
113typedef struct sqfs_inode_dir_ext_t sqfs_inode_dir_ext_t;
114typedef struct sqfs_inode_generic_t sqfs_inode_generic_t;
115typedef struct sqfs_super_t sqfs_super_t;
116typedef struct sqfs_xattr_entry_t sqfs_xattr_entry_t;
117typedef struct sqfs_xattr_value_t sqfs_xattr_value_t;
118typedef struct sqfs_xattr_id_t sqfs_xattr_id_t;
119typedef struct sqfs_xattr_id_table_t sqfs_xattr_id_table_t;
120
126 typedef struct sqfs_object_t {
127 void (*destroy)(struct sqfs_object_t *instance);
128
129 struct sqfs_object_t *(*copy)(const struct sqfs_object_t *orig);
130} sqfs_object_t;
131
139 static SQFS_INLINE void sqfs_destroy(void *obj)
140{
141 if (obj)
142 ((sqfs_object_t *)obj)->destroy((sqfs_object_t *)obj);
143}
144
155 static SQFS_INLINE void *sqfs_copy(const void *obj)
156{
157 if (((const sqfs_object_t *)obj)->copy != NULL) {
158 return ((const sqfs_object_t *)obj)->
159 copy((const sqfs_object_t *)obj);
160 }
161
162 return NULL;
163}
164
165#ifdef __cplusplus
166extern "C" {
167#endif
168
202SQFS_API void sqfs_free(void *ptr);
203
204#ifdef __cplusplus
205}
206#endif
207
208#endif /* SQFS_PREDEF_H */
sqfs_free
SQFS_API void sqfs_free(void *ptr)
Free a block of memory created by the squashfs library.
sqfs_block_processor_desc_t
Encapsulates a description for an sqfs_block_processor_t.
Definition block_processor.h:121
sqfs_block_processor_stats_t
Used to store runtime statistics about the sqfs_block_processor_t.
Definition block_processor.h:56
sqfs_block_processor_t
Abstracts generating of file data and fragment blocks.
sqfs_block_writer_t
Abstracts writing and deduplicating of data and fragment blocks.
Definition block_writer.h:42
sqfs_compressor_config_t
Configuration parameters for instantiating a compressor backend.
Definition compressor.h:106
sqfs_compressor_t
Encapsultes a compressor with a simple interface to compress or extract chunks of data.
Definition compressor.h:40
sqfs_data_reader_t
Abstracts access to data blocks stored in a SquashFS image.
sqfs_dir_entry_t
On-disk data structure of a directory entry. Many of these follow a single sqfs_dir_header_t.
Definition dir.h:74
sqfs_dir_header_t
On-disk data structure of a directory header.
Definition dir.h:42
sqfs_dir_index_t
On-disk data structure of a directory index. A series of those can follow an sqfs_inode_dir_ext_t.
Definition dir.h:115
sqfs_dir_reader_t
Abstracts reading of directory entries.
sqfs_dir_writer_t
Abstracts generating of directory entries.
sqfs_file_t
Abstracts file I/O to make it easy to embedd SquashFS.
Definition io.h:94
sqfs_frag_table_t
Abstracts reading, writing and management of the fragment table.
sqfs_fragment_t
Data structure that makes up the fragment table entries.
Definition block.h:42
sqfs_id_table_t
A simple data structure that encapsulates ID to index mapping for user and group IDs.
sqfs_inode_dev_ext_t
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_BDEV or SQFS_INODE_EXT_CDEV.
Definition inode.h:196
sqfs_inode_dev_t
Follows a sqfs_inode_t if type is SQFS_INODE_BDEV or SQFS_INODE_CDEV.
Definition inode.h:178
sqfs_inode_dir_ext_t
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_DIR.
Definition inode.h:433
sqfs_inode_dir_t
Follows a sqfs_inode_t if type is SQFS_INODE_DIR.
Definition inode.h:389
sqfs_inode_file_ext_t
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_FILE.
Definition inode.h:343
sqfs_inode_file_t
Follows a sqfs_inode_t if type is SQFS_INODE_FILE.
Definition inode.h:311
sqfs_inode_generic_t
A generic inode structure that combines all others and provides additional information.
Definition inode.h:488
sqfs_inode_ipc_ext_t
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_FIFO or SQFS_INODE_EXT_SOCKET.
Definition inode.h:232
sqfs_inode_ipc_t
Follows a sqfs_inode_t if type is SQFS_INODE_FIFO or SQFS_INODE_SOCKET.
Definition inode.h:219
sqfs_inode_slink_ext_t
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_SLINK.
Definition inode.h:276
sqfs_inode_slink_t
Follows a sqfs_inode_t if type is SQFS_INODE_SLINK.
Definition inode.h:253
sqfs_inode_t
Common inode structure.
Definition inode.h:133
sqfs_meta_reader_t
Abstracts reading of meta data blocks.
sqfs_meta_writer_t
Abstracts generating of meta data blocks, either in memory or directly on disk.
sqfs_object_t
Base interface for all libsquashfs in-memory data structures.
Definition predef.h:126
sqfs_object_t::sqfs_copy
static SQFS_INLINE void * sqfs_copy(const void *obj)
Create a deep copy of an object if possible.
Definition predef.h:155
sqfs_object_t::sqfs_destroy
static SQFS_INLINE void sqfs_destroy(void *obj)
Destroy an object and free all its memory.
Definition predef.h:139
sqfs_readdir_state_t
Encapsulates state for simple directory reading.
Definition meta_reader.h:56
sqfs_super_t
The SquashFS super block, located at the beginning of the file system to describe the layout of the f...
Definition super.h:47
sqfs_tree_node_t
Encapsulates a node in the filesystem tree read by sqfs_dir_reader_get_full_hierarchy.
Definition dir_reader.h:114
sqfs_xattr_entry_t
On-disk data structure that holds a single xattr key.
Definition xattr.h:53
sqfs_xattr_id_t
On-disk data structure that describes a set of key-value pairs.
Definition xattr.h:94
sqfs_xattr_id_table_t
On-disk data structure that the super block points to.
Definition xattr.h:127
sqfs_xattr_reader_t
Abstracts read access to extended attributes in a SquashFS filesystem.
sqfs_xattr_value_t
On-disk data structure that holds a single xattr value.
Definition xattr.h:78
sqfs_xattr_writer_t
Abstracts writing of extended attributes to a SquashFS filesystem.