libsquashfs 1.3.0
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
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
83typedef struct sqfs_id_table_t sqfs_id_table_t;
87typedef struct sqfs_file_t sqfs_file_t;
90typedef struct sqfs_block_hooks_t sqfs_block_hooks_t;
94typedef struct sqfs_block_writer_stats_t sqfs_block_writer_stats_t;
98
99typedef struct sqfs_fragment_t sqfs_fragment_t;
103typedef struct sqfs_inode_t sqfs_inode_t;
115typedef struct sqfs_super_t sqfs_super_t;
118typedef struct sqfs_xattr_id_t sqfs_xattr_id_t;
120
126typedef 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);
131
139static SQFS_INLINE void sqfs_destroy(void *obj)
140{
141 if (obj)
142 ((sqfs_object_t *)obj)->destroy((sqfs_object_t *)obj);
143}
144
155static 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_API void sqfs_free(void *ptr)
Free a block of memory created by the squashfs library.
Encapsulates a description for an sqfs_block_processor_t.
Used to store runtime statistics about the sqfs_block_processor_t.
Abstracts generating of file data and fragment blocks.
Abstracts writing and deduplicating of data and fragment blocks.
Definition: block_writer.h:42
Configuration parameters for instantiating a compressor backend.
Definition: compressor.h:106
Encapsultes a compressor with a simple interface to compress or extract chunks of data.
Definition: compressor.h:40
Abstracts access to data blocks stored in a SquashFS image.
On-disk data structure of a directory entry. Many of these follow a single sqfs_dir_header_t.
Definition: dir.h:74
On-disk data structure of a directory header.
Definition: dir.h:42
On-disk data structure of a directory index. A series of those can follow an sqfs_inode_dir_ext_t.
Definition: dir.h:115
Abstracts reading of directory entries.
Abstracts generating of directory entries.
Abstracts file I/O to make it easy to embedd SquashFS.
Definition: io.h:94
Abstracts reading, writing and management of the fragment table.
Data structure that makes up the fragment table entries.
Definition: block.h:42
A simple data structure that encapsulates ID to index mapping for user and group IDs.
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_BDEV or SQFS_INODE_EXT_CDEV.
Definition: inode.h:196
Follows a sqfs_inode_t if type is SQFS_INODE_BDEV or SQFS_INODE_CDEV.
Definition: inode.h:178
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_DIR.
Definition: inode.h:433
Follows a sqfs_inode_t if type is SQFS_INODE_DIR.
Definition: inode.h:389
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_FILE.
Definition: inode.h:343
Follows a sqfs_inode_t if type is SQFS_INODE_FILE.
Definition: inode.h:311
A generic inode structure that combines all others and provides additional information.
Definition: inode.h:488
Follows a sqfs_inode_t if type is SQFS_INODE_EXT_FIFO or SQFS_INODE_EXT_SOCKET.
Definition: inode.h:232
Follows a sqfs_inode_t if type is SQFS_INODE_FIFO or SQFS_INODE_SOCKET.
Definition: inode.h:219
Common inode structure.
Definition: inode.h:133
Abstracts reading of meta data blocks.
Abstracts generating of meta data blocks, either in memory or directly on disk.
Base interface for all libsquashfs in-memory data structures.
Definition: predef.h:126
static SQFS_INLINE void * sqfs_copy(const void *obj)
Create a deep copy of an object if possible.
Definition: predef.h:155
static SQFS_INLINE void sqfs_destroy(void *obj)
Destroy an object and free all its memory.
Definition: predef.h:139
Encapsulates state for simple directory reading.
Definition: meta_reader.h:56
The SquashFS super block, located at the beginning of the file system to describe the layout of the f...
Definition: super.h:47
Encapsulates a node in the filesystem tree read by sqfs_dir_reader_get_full_hierarchy.
Definition: dir_reader.h:114
On-disk data structure that holds a single xattr key.
Definition: xattr.h:53
On-disk data structure that describes a set of key-value pairs.
Definition: xattr.h:94
On-disk data structure that the super block points to.
Definition: xattr.h:127
Abstracts read access to extended attributes in a SquashFS filesystem.
On-disk data structure that holds a single xattr value.
Definition: xattr.h:78
Abstracts writing of extended attributes to a SquashFS filesystem.