aboutsummaryrefslogtreecommitdiff
path: root/include/sqfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-05 19:08:10 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-05 19:08:10 +0200
commitf8a92529ec04b560b5b9e647b976892412f78134 (patch)
tree5308d7f500df46ef64423708ed40a37675f4020c /include/sqfs
parent320ae4f8e752f6652c7b5c8201d7267cd4de17c1 (diff)
Fix API visibility for libsquashfs.so
This commit adds a "predef.h" header to libsquashfs that exposes two macros, SQFS_API and SQFS_INTERNAL that are used to explicilty set the visibiliy of stuff that ends up in libsquashfs to default or hidden. For compatibillity with Windows which may at some point eventually be considered, the SQFS_API define is set to dllexport IF the cpp symbol SQFS_BUILDING_DLL is defined and set to import otherwise. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs')
-rw-r--r--include/sqfs/block_processor.h14
-rw-r--r--include/sqfs/compress.h13
-rw-r--r--include/sqfs/dir.h32
-rw-r--r--include/sqfs/id_table.h22
-rw-r--r--include/sqfs/inode.h6
-rw-r--r--include/sqfs/meta_reader.h22
-rw-r--r--include/sqfs/meta_writer.h24
-rw-r--r--include/sqfs/predef.h36
-rw-r--r--include/sqfs/super.h11
-rw-r--r--include/sqfs/table.h15
-rw-r--r--include/sqfs/xattr.h24
11 files changed, 141 insertions, 78 deletions
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h
index bde0a2e..97bfd34 100644
--- a/include/sqfs/block_processor.h
+++ b/include/sqfs/block_processor.h
@@ -8,6 +8,7 @@
#define SFQS_BLOCK_PROCESSOR_H
#include "config.h"
+#include "sqfs/predef.h"
#include "sqfs/compress.h"
enum {
@@ -67,13 +68,14 @@ typedef int (*sqfs_block_cb)(void *user, sqfs_block_t *blk);
extern "C" {
#endif
+SQFS_API
sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
sqfs_compressor_t *cmp,
unsigned int num_workers,
void *user,
sqfs_block_cb callback);
-void sqfs_block_processor_destroy(sqfs_block_processor_t *proc);
+SQFS_API void sqfs_block_processor_destroy(sqfs_block_processor_t *proc);
/*
Add a block to be processed. Returns non-zero on error and prints a message
@@ -85,22 +87,22 @@ void sqfs_block_processor_destroy(sqfs_block_processor_t *proc);
Even on failure, the workers may still be running and
sqfs_block_processor_finish must be called before cleaning up.
*/
-int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc,
- sqfs_block_t *block);
+SQFS_API int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc,
+ sqfs_block_t *block);
/*
Wait for the compressor workers to finish. Returns zero on success, non-zero
if an internal error occoured or one of the block callbacks returned a
non-zero value.
*/
-int sqfs_block_processor_finish(sqfs_block_processor_t *proc);
+SQFS_API int sqfs_block_processor_finish(sqfs_block_processor_t *proc);
/*
Convenience function to process a data block. Returns 0 on success,
prints to stderr on failure.
*/
-int sqfs_block_process(sqfs_block_t *block, sqfs_compressor_t *cmp,
- uint8_t *scratch, size_t scratch_size);
+SQFS_API int sqfs_block_process(sqfs_block_t *block, sqfs_compressor_t *cmp,
+ uint8_t *scratch, size_t scratch_size);
#ifdef __cplusplus
}
diff --git a/include/sqfs/compress.h b/include/sqfs/compress.h
index c826c84..27c603d 100644
--- a/include/sqfs/compress.h
+++ b/include/sqfs/compress.h
@@ -14,6 +14,7 @@
#include <stddef.h>
#include <stdint.h>
+#include "sqfs/predef.h"
#include "sqfs/super.h"
typedef struct sqfs_compressor_t sqfs_compressor_t;
@@ -132,16 +133,18 @@ typedef enum {
extern "C" {
#endif
-int sqfs_compressor_config_init(sqfs_compressor_config_t *cfg,
- E_SQFS_COMPRESSOR id,
- size_t block_size, uint16_t flags);
+SQFS_API int sqfs_compressor_config_init(sqfs_compressor_config_t *cfg,
+ E_SQFS_COMPRESSOR id,
+ size_t block_size, uint16_t flags);
-bool sqfs_compressor_exists(E_SQFS_COMPRESSOR id);
+SQFS_API bool sqfs_compressor_exists(E_SQFS_COMPRESSOR id);
+SQFS_API
sqfs_compressor_t *sqfs_compressor_create(const sqfs_compressor_config_t *cfg);
-const char *sqfs_compressor_name_from_id(E_SQFS_COMPRESSOR id);
+SQFS_API const char *sqfs_compressor_name_from_id(E_SQFS_COMPRESSOR id);
+SQFS_API
int sqfs_compressor_id_from_name(const char *name, E_SQFS_COMPRESSOR *out);
#ifdef __cplusplus
diff --git a/include/sqfs/dir.h b/include/sqfs/dir.h
index c57831c..3a65102 100644
--- a/include/sqfs/dir.h
+++ b/include/sqfs/dir.h
@@ -9,6 +9,7 @@
#include "config.h"
+#include "sqfs/predef.h"
#include "sqfs/meta_reader.h"
#include "sqfs/meta_writer.h"
@@ -44,33 +45,34 @@ extern "C" {
#endif
/* Returns 0 on success. Internally prints to stderr on failure */
-int sqfs_meta_reader_read_dir_header(sqfs_meta_reader_t *m,
- sqfs_dir_header_t *hdr);
+SQFS_API int sqfs_meta_reader_read_dir_header(sqfs_meta_reader_t *m,
+ sqfs_dir_header_t *hdr);
/* Entry can be freed with a single free() call.
The function internally prints to stderr on failure */
-sqfs_dir_entry_t *sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m);
+SQFS_API sqfs_dir_entry_t *sqfs_meta_reader_read_dir_ent(sqfs_meta_reader_t *m);
-sqfs_dir_writer_t *sqfs_dir_writer_create(sqfs_meta_writer_t *dm);
+SQFS_API sqfs_dir_writer_t *sqfs_dir_writer_create(sqfs_meta_writer_t *dm);
-void sqfs_dir_writer_destroy(sqfs_dir_writer_t *writer);
+SQFS_API void sqfs_dir_writer_destroy(sqfs_dir_writer_t *writer);
-int sqfs_dir_writer_begin(sqfs_dir_writer_t *writer);
+SQFS_API int sqfs_dir_writer_begin(sqfs_dir_writer_t *writer);
-int sqfs_dir_writer_add_entry(sqfs_dir_writer_t *writer, const char *name,
- uint32_t inode_num, uint64_t inode_ref,
- mode_t mode);
+SQFS_API int sqfs_dir_writer_add_entry(sqfs_dir_writer_t *writer,
+ const char *name,
+ uint32_t inode_num, uint64_t inode_ref,
+ mode_t mode);
-int sqfs_dir_writer_end(sqfs_dir_writer_t *writer);
+SQFS_API int sqfs_dir_writer_end(sqfs_dir_writer_t *writer);
-size_t sqfs_dir_writer_get_size(sqfs_dir_writer_t *writer);
+SQFS_API size_t sqfs_dir_writer_get_size(sqfs_dir_writer_t *writer);
-uint64_t sqfs_dir_writer_get_dir_reference(sqfs_dir_writer_t *writer);
+SQFS_API uint64_t sqfs_dir_writer_get_dir_reference(sqfs_dir_writer_t *writer);
-size_t sqfs_dir_writer_get_index_size(sqfs_dir_writer_t *writer);
+SQFS_API size_t sqfs_dir_writer_get_index_size(sqfs_dir_writer_t *writer);
-int sqfs_dir_writer_write_index(sqfs_dir_writer_t *writer,
- sqfs_meta_writer_t *im);
+SQFS_API int sqfs_dir_writer_write_index(sqfs_dir_writer_t *writer,
+ sqfs_meta_writer_t *im);
#ifdef __cplusplus
}
diff --git a/include/sqfs/id_table.h b/include/sqfs/id_table.h
index 0e652ec..f8b3b5c 100644
--- a/include/sqfs/id_table.h
+++ b/include/sqfs/id_table.h
@@ -12,7 +12,8 @@
#include <stdint.h>
#include <stddef.h>
-#include "compress.h"
+#include "sqfs/predef.h"
+#include "sqfs/compress.h"
typedef struct sqfs_id_table_t sqfs_id_table_t;
@@ -21,26 +22,27 @@ extern "C" {
#endif
/* Prints error message to stderr on failure. */
-sqfs_id_table_t *sqfs_id_table_create(void);
+SQFS_API sqfs_id_table_t *sqfs_id_table_create(void);
-void sqfs_id_table_destroy(sqfs_id_table_t *tbl);
+SQFS_API void sqfs_id_table_destroy(sqfs_id_table_t *tbl);
/* Resolve a 32 bit to a 16 bit table index.
Returns 0 on success. Internally prints errors to stderr. */
-int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, uint32_t id, uint16_t *out);
+SQFS_API int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, uint32_t id,
+ uint16_t *out);
/* Write an ID table to a SquashFS image.
Returns 0 on success. Internally prints error message to stderr. */
-int sqfs_id_table_write(sqfs_id_table_t *tbl, int outfd, sqfs_super_t *super,
- sqfs_compressor_t *cmp);
+SQFS_API int sqfs_id_table_write(sqfs_id_table_t *tbl, int outfd,
+ sqfs_super_t *super, sqfs_compressor_t *cmp);
/* Read an ID table from a SquashFS image.
Returns 0 on success. Internally prints error messages to stderr. */
-int sqfs_id_table_read(sqfs_id_table_t *tbl, int fd, sqfs_super_t *super,
- sqfs_compressor_t *cmp);
+SQFS_API int sqfs_id_table_read(sqfs_id_table_t *tbl, int fd,
+ sqfs_super_t *super, sqfs_compressor_t *cmp);
-int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, uint16_t index,
- uint32_t *out);
+SQFS_API int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl,
+ uint16_t index, uint32_t *out);
#ifdef __cplusplus
}
diff --git a/include/sqfs/inode.h b/include/sqfs/inode.h
index d693aec..37a088c 100644
--- a/include/sqfs/inode.h
+++ b/include/sqfs/inode.h
@@ -9,6 +9,7 @@
#include "config.h"
+#include "sqfs/predef.h"
#include "sqfs/meta_reader.h"
#include "sqfs/meta_writer.h"
@@ -138,13 +139,14 @@ extern "C" {
/* Inode can be freed with a single free() call.
The function internally prints error message to stderr on failure. */
+SQFS_API
sqfs_inode_generic_t *sqfs_meta_reader_read_inode(sqfs_meta_reader_t *ir,
sqfs_super_t *super,
uint64_t block_start,
size_t offset);
-int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *iw,
- sqfs_inode_generic_t *n);
+SQFS_API int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *iw,
+ sqfs_inode_generic_t *n);
#ifdef __cplusplus
}
diff --git a/include/sqfs/meta_reader.h b/include/sqfs/meta_reader.h
index 6f0d184..1e5e027 100644
--- a/include/sqfs/meta_reader.h
+++ b/include/sqfs/meta_reader.h
@@ -9,6 +9,7 @@
#include "config.h"
+#include "sqfs/predef.h"
#include "sqfs/compress.h"
#include "sqfs/data.h"
@@ -24,21 +25,24 @@ extern "C" {
Start offset and limit can be specified to do bounds checking against
a subregion of the filesystem image.
*/
-sqfs_meta_reader_t *sqfs_meta_reader_create(int fd, sqfs_compressor_t *cmp,
- uint64_t start, uint64_t limit);
+SQFS_API sqfs_meta_reader_t *sqfs_meta_reader_create(int fd,
+ sqfs_compressor_t *cmp,
+ uint64_t start,
+ uint64_t limit);
-void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m);
+SQFS_API void sqfs_meta_reader_destroy(sqfs_meta_reader_t *m);
/* Returns 0 on success. Internally prints to stderr on failure */
-int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
- size_t offset);
+SQFS_API int sqfs_meta_reader_seek(sqfs_meta_reader_t *m, uint64_t block_start,
+ size_t offset);
-void sqfs_meta_reader_get_position(sqfs_meta_reader_t *m,
- uint64_t *block_start,
- size_t *offset);
+SQFS_API void sqfs_meta_reader_get_position(sqfs_meta_reader_t *m,
+ uint64_t *block_start,
+ size_t *offset);
/* Returns 0 on success. Internally prints to stderr on failure */
-int sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data, size_t size);
+SQFS_API int sqfs_meta_reader_read(sqfs_meta_reader_t *m, void *data,
+ size_t size);
#ifdef __cplusplus
}
diff --git a/include/sqfs/meta_writer.h b/include/sqfs/meta_writer.h
index bb14993..3611984 100644
--- a/include/sqfs/meta_writer.h
+++ b/include/sqfs/meta_writer.h
@@ -9,6 +9,7 @@
#include "config.h"
+#include "sqfs/predef.h"
#include "sqfs/compress.h"
#include "sqfs/id_table.h"
#include "sqfs/data.h"
@@ -24,31 +25,32 @@ extern "C" {
If keep_in_mem is true, the blocks are collected in memory and must
be explicitly flushed to disk using meta_write_write_to_file.
*/
-sqfs_meta_writer_t *sqfs_meta_writer_create(int fd, sqfs_compressor_t *cmp,
- bool keep_in_mem);
+SQFS_API sqfs_meta_writer_t *sqfs_meta_writer_create(int fd,
+ sqfs_compressor_t *cmp,
+ bool keep_in_mem);
-void sqfs_meta_writer_destroy(sqfs_meta_writer_t *m);
+SQFS_API void sqfs_meta_writer_destroy(sqfs_meta_writer_t *m);
/* Compress and flush the currently unfinished block to disk. Returns 0 on
success, internally prints error message to stderr on failure */
-int sqfs_meta_writer_flush(sqfs_meta_writer_t *m);
+SQFS_API int sqfs_meta_writer_flush(sqfs_meta_writer_t *m);
/* Returns 0 on success. Prints error message to stderr on failure. */
-int sqfs_meta_writer_append(sqfs_meta_writer_t *m, const void *data,
- size_t size);
+SQFS_API int sqfs_meta_writer_append(sqfs_meta_writer_t *m, const void *data,
+ size_t size);
/* Query the current block start position and offset within the block */
-void sqfs_meta_writer_get_position(const sqfs_meta_writer_t *m,
- uint64_t *block_start,
- uint32_t *offset);
+SQFS_API void sqfs_meta_writer_get_position(const sqfs_meta_writer_t *m,
+ uint64_t *block_start,
+ uint32_t *offset);
/* Reset all internal state, including the current block start position. */
-void sqfs_meta_writer_reset(sqfs_meta_writer_t *m);
+SQFS_API void sqfs_meta_writer_reset(sqfs_meta_writer_t *m);
/* If created with keep_in_mem true, write the collected blocks to disk.
Does not flush the current block. Writes error messages to stderr and
returns non-zero on failure. */
-int sqfs_meta_write_write_to_file(sqfs_meta_writer_t *m);
+SQFS_API int sqfs_meta_write_write_to_file(sqfs_meta_writer_t *m);
#ifdef __cplusplus
}
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h
new file mode 100644
index 0000000..210f306
--- /dev/null
+++ b/include/sqfs/predef.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * predef.h
+ *
+ * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
+ */
+#ifndef SQFS_PREDEF_H
+#define SQFS_PREDEF_H
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+ #ifdef SQFS_BUILDING_DLL
+ #if defined(__GNUC__) || defined(__clang__)
+ #define SQFS_API __attribute__ ((dllexport))
+ #else
+ #define SQFS_API __declspec(dllexport)
+ #endif
+ #else
+ #if defined(__GNUC__) || defined(__clang__)
+ #define SQFS_API __attribute__ ((dllimport))
+ #else
+ #define SQFS_API __declspec(dllimport)
+ #endif
+ #endif
+
+ #define SQFS_INTERNAL
+#else
+ #if defined(__GNUC__) || defined(__clang__)
+ #define SQFS_API __attribute__ ((visibility ("default")))
+ #define SQFS_INTERNAL __attribute__ ((visibility ("hidden")))
+ #else
+ #define SQFS_API
+ #define SQFS_INTERNAL
+ #endif
+#endif
+
+#endif /* SQFS_PREDEF_H */
diff --git a/include/sqfs/super.h b/include/sqfs/super.h
index 0df1691..6593555 100644
--- a/include/sqfs/super.h
+++ b/include/sqfs/super.h
@@ -9,6 +9,8 @@
#include "config.h"
+#include "sqfs/predef.h"
+
#include <stdint.h>
#include <stddef.h>
@@ -71,14 +73,15 @@ extern "C" {
#endif
/* Returns 0 on success. Prints error messages to stderr on failure. */
-int sqfs_super_init(sqfs_super_t *super, size_t block_size, uint32_t mtime,
- E_SQFS_COMPRESSOR compressor);
+SQFS_API int sqfs_super_init(sqfs_super_t *super, size_t block_size,
+ uint32_t mtime,
+ E_SQFS_COMPRESSOR compressor);
/* Returns 0 on success. Prints error messages to stderr on failure. */
-int sqfs_super_write(sqfs_super_t *super, int fd);
+SQFS_API int sqfs_super_write(sqfs_super_t *super, int fd);
/* Returns 0 on success. Prints error messages to stderr on failure. */
-int sqfs_super_read(sqfs_super_t *super, int fd);
+SQFS_API int sqfs_super_read(sqfs_super_t *super, int fd);
#ifdef __cplusplus
}
diff --git a/include/sqfs/table.h b/include/sqfs/table.h
index b5eeb54..0bd3112 100644
--- a/include/sqfs/table.h
+++ b/include/sqfs/table.h
@@ -7,6 +7,7 @@
#ifndef SQFS_TABLE_H
#define SQFS_TABLE_H
+#include "sqfs/predef.h"
#include "sqfs/compress.h"
#include "sqfs/super.h"
@@ -28,12 +29,14 @@ extern "C" {
Returns 0 on success. Internally prints error messages to stderr.
*/
-int sqfs_write_table(int outfd, sqfs_super_t *super, sqfs_compressor_t *cmp,
- const void *data, size_t table_size, uint64_t *start);
-
-void *sqfs_read_table(int fd, sqfs_compressor_t *cmp, size_t table_size,
- uint64_t location, uint64_t lower_limit,
- uint64_t upper_limit);
+SQFS_API int sqfs_write_table(int outfd, sqfs_super_t *super,
+ sqfs_compressor_t *cmp,
+ const void *data, size_t table_size,
+ uint64_t *start);
+
+SQFS_API void *sqfs_read_table(int fd, sqfs_compressor_t *cmp,
+ size_t table_size, uint64_t location,
+ uint64_t lower_limit, uint64_t upper_limit);
#ifdef __cplusplus
}
diff --git a/include/sqfs/xattr.h b/include/sqfs/xattr.h
index 5350534..d1b3bdd 100644
--- a/include/sqfs/xattr.h
+++ b/include/sqfs/xattr.h
@@ -9,6 +9,7 @@
#include "config.h"
+#include "sqfs/predef.h"
#include "sqfs/compress.h"
#include <stdbool.h>
@@ -54,28 +55,31 @@ extern "C" {
#endif
/* Get a prefix string from the ID or NULL if unknown */
-const char *sqfs_get_xattr_prefix(E_SQFS_XATTR_TYPE id);
+SQFS_API const char *sqfs_get_xattr_prefix(E_SQFS_XATTR_TYPE id);
/* Get id from xattr key prefix or -1 if not supported */
-int sqfs_get_xattr_prefix_id(const char *key);
+SQFS_API int sqfs_get_xattr_prefix_id(const char *key);
/* Check if a given xattr key can be encoded in squashfs at all. */
-bool sqfs_has_xattr(const char *key);
+SQFS_API bool sqfs_has_xattr(const char *key);
-void sqfs_xattr_reader_destroy(sqfs_xattr_reader_t *xr);
+SQFS_API void sqfs_xattr_reader_destroy(sqfs_xattr_reader_t *xr);
-sqfs_xattr_reader_t *sqfs_xattr_reader_create(int sqfsfd, sqfs_super_t *super,
- sqfs_compressor_t *cmp);
+SQFS_API sqfs_xattr_reader_t *sqfs_xattr_reader_create(int sqfsfd,
+ sqfs_super_t *super,
+ sqfs_compressor_t *cmp);
-int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, uint32_t idx,
- sqfs_xattr_id_t *desc);
+SQFS_API int sqfs_xattr_reader_get_desc(sqfs_xattr_reader_t *xr, uint32_t idx,
+ sqfs_xattr_id_t *desc);
-int sqfs_xattr_reader_seek_kv(sqfs_xattr_reader_t *xr,
- const sqfs_xattr_id_t *desc);
+SQFS_API int sqfs_xattr_reader_seek_kv(sqfs_xattr_reader_t *xr,
+ const sqfs_xattr_id_t *desc);
+SQFS_API
sqfs_xattr_value_t *sqfs_xattr_reader_read_value(sqfs_xattr_reader_t *xr,
const sqfs_xattr_entry_t *key);
+SQFS_API
sqfs_xattr_entry_t *sqfs_xattr_reader_read_key(sqfs_xattr_reader_t *xr);
#ifdef __cplusplus