aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/io/src/dir_tree_iterator.c43
-rw-r--r--lib/io/src/unix/dir_iterator.c38
-rw-r--r--lib/io/src/win32/dir_iterator.c34
-rw-r--r--lib/io/test/dir_iterator.c2
-rw-r--r--lib/io/test/dir_tree_iterator.c2
-rw-r--r--lib/io/test/dir_tree_iterator2.c2
-rw-r--r--lib/io/test/dir_tree_iterator3.c2
-rw-r--r--lib/tar/src/iterator.c19
-rw-r--r--lib/tar/test/tar_iterator.c2
-rw-r--r--lib/tar/test/tar_iterator2.c2
-rw-r--r--lib/tar/test/tar_iterator3.c2
11 files changed, 76 insertions, 72 deletions
diff --git a/lib/io/src/dir_tree_iterator.c b/lib/io/src/dir_tree_iterator.c
index 7af4b5e..6370743 100644
--- a/lib/io/src/dir_tree_iterator.c
+++ b/lib/io/src/dir_tree_iterator.c
@@ -14,12 +14,12 @@
typedef struct dir_stack_t {
struct dir_stack_t *next;
- dir_iterator_t *dir;
+ sqfs_dir_iterator_t *dir;
char name[];
} dir_stack_t;
typedef struct {
- dir_iterator_t base;
+ sqfs_dir_iterator_t base;
dir_tree_cfg_t cfg;
int state;
@@ -37,7 +37,8 @@ static void pop(dir_tree_iterator_t *it)
}
}
-static int push(dir_tree_iterator_t *it, const char *name, dir_iterator_t *dir)
+static int push(dir_tree_iterator_t *it, const char *name,
+ sqfs_dir_iterator_t *dir)
{
dir_stack_t *ent = alloc_flex(sizeof(*ent), 1, strlen(name) + 1);
@@ -149,10 +150,10 @@ static void destroy(sqfs_object_t *obj)
free(it);
}
-static int next(dir_iterator_t *base, sqfs_dir_entry_t **out)
+static int next(sqfs_dir_iterator_t *base, sqfs_dir_entry_t **out)
{
dir_tree_iterator_t *it = (dir_tree_iterator_t *)base;
- dir_iterator_t *sub;
+ sqfs_dir_iterator_t *sub;
sqfs_dir_entry_t *ent;
int ret;
retry:
@@ -241,7 +242,7 @@ fail:
return it->state;
}
-static int read_link(dir_iterator_t *base, char **out)
+static int read_link(sqfs_dir_iterator_t *base, char **out)
{
dir_tree_iterator_t *it = (dir_tree_iterator_t *)base;
@@ -253,7 +254,7 @@ static int read_link(dir_iterator_t *base, char **out)
return it->top->dir->read_link(it->top->dir, out);
}
-static int open_subdir(dir_iterator_t *base, dir_iterator_t **out)
+static int open_subdir(sqfs_dir_iterator_t *base, sqfs_dir_iterator_t **out)
{
dir_tree_iterator_t *it = (dir_tree_iterator_t *)base;
@@ -265,14 +266,14 @@ static int open_subdir(dir_iterator_t *base, dir_iterator_t **out)
return it->top->dir->open_subdir(it->top->dir, out);
}
-static void ignore_subdir(dir_iterator_t *base)
+static void ignore_subdir(sqfs_dir_iterator_t *base)
{
dir_tree_iterator_t *it = (dir_tree_iterator_t *)base;
pop(it);
}
-static int open_file_ro(dir_iterator_t *base, sqfs_istream_t **out)
+static int open_file_ro(sqfs_dir_iterator_t *base, sqfs_istream_t **out)
{
dir_tree_iterator_t *it = (dir_tree_iterator_t *)base;
@@ -284,7 +285,7 @@ static int open_file_ro(dir_iterator_t *base, sqfs_istream_t **out)
return it->top->dir->open_file_ro(it->top->dir, out);
}
-static int read_xattr(dir_iterator_t *base, sqfs_xattr_t **out)
+static int read_xattr(sqfs_dir_iterator_t *base, sqfs_xattr_t **out)
{
dir_tree_iterator_t *it = (dir_tree_iterator_t *)base;
@@ -296,11 +297,11 @@ static int read_xattr(dir_iterator_t *base, sqfs_xattr_t **out)
return it->top->dir->read_xattr(it->top->dir, out);
}
-dir_iterator_t *dir_tree_iterator_create(const char *path,
- const dir_tree_cfg_t *cfg)
+sqfs_dir_iterator_t *dir_tree_iterator_create(const char *path,
+ const dir_tree_cfg_t *cfg)
{
dir_tree_iterator_t *it = calloc(1, sizeof(*it));
- dir_iterator_t *dir;
+ sqfs_dir_iterator_t *dir;
int ret;
if (it == NULL) {
@@ -322,14 +323,14 @@ dir_iterator_t *dir_tree_iterator_create(const char *path,
}
sqfs_object_init(it, destroy, NULL);
- ((dir_iterator_t *)it)->next = next;
- ((dir_iterator_t *)it)->read_link = read_link;
- ((dir_iterator_t *)it)->open_subdir = open_subdir;
- ((dir_iterator_t *)it)->ignore_subdir = ignore_subdir;
- ((dir_iterator_t *)it)->open_file_ro = open_file_ro;
- ((dir_iterator_t *)it)->read_xattr = read_xattr;
-
- return (dir_iterator_t *)it;
+ ((sqfs_dir_iterator_t *)it)->next = next;
+ ((sqfs_dir_iterator_t *)it)->read_link = read_link;
+ ((sqfs_dir_iterator_t *)it)->open_subdir = open_subdir;
+ ((sqfs_dir_iterator_t *)it)->ignore_subdir = ignore_subdir;
+ ((sqfs_dir_iterator_t *)it)->open_file_ro = open_file_ro;
+ ((sqfs_dir_iterator_t *)it)->read_xattr = read_xattr;
+
+ return (sqfs_dir_iterator_t *)it;
fail:
free(it);
return NULL;
diff --git a/lib/io/src/unix/dir_iterator.c b/lib/io/src/unix/dir_iterator.c
index d2ae011..74ac953 100644
--- a/lib/io/src/unix/dir_iterator.c
+++ b/lib/io/src/unix/dir_iterator.c
@@ -17,7 +17,7 @@
#include <errno.h>
typedef struct {
- dir_iterator_t base;
+ sqfs_dir_iterator_t base;
struct dirent *ent;
struct stat sb;
@@ -34,7 +34,7 @@ static void dir_destroy(sqfs_object_t *obj)
free(it);
}
-static int dir_read_link(dir_iterator_t *base, char **out)
+static int dir_read_link(sqfs_dir_iterator_t *base, char **out)
{
unix_dir_iterator_t *it = (unix_dir_iterator_t *)base;
ssize_t ret;
@@ -74,7 +74,7 @@ static int dir_read_link(dir_iterator_t *base, char **out)
return 0;
}
-static int dir_next(dir_iterator_t *base, sqfs_dir_entry_t **out)
+static int dir_next(sqfs_dir_iterator_t *base, sqfs_dir_entry_t **out)
{
unix_dir_iterator_t *it = (unix_dir_iterator_t *)base;
@@ -122,12 +122,12 @@ static int dir_next(dir_iterator_t *base, sqfs_dir_entry_t **out)
return it->state;
}
-static void dir_ignore_subdir(dir_iterator_t *it)
+static void dir_ignore_subdir(sqfs_dir_iterator_t *it)
{
(void)it;
}
-static int dir_open_file_ro(dir_iterator_t *base, sqfs_istream_t **out)
+static int dir_open_file_ro(sqfs_dir_iterator_t *base, sqfs_istream_t **out)
{
unix_dir_iterator_t *it = (unix_dir_iterator_t *)base;
int fd, ret;
@@ -153,16 +153,16 @@ static int dir_open_file_ro(dir_iterator_t *base, sqfs_istream_t **out)
return ret;
}
-static int dir_read_xattr(dir_iterator_t *it, sqfs_xattr_t **out)
+static int dir_read_xattr(sqfs_dir_iterator_t *it, sqfs_xattr_t **out)
{
(void)it;
*out = NULL;
return 0;
}
-static int create_iterator(dir_iterator_t **out, DIR *dir);
+static int create_iterator(sqfs_dir_iterator_t **out, DIR *dir);
-static int dir_open_subdir(dir_iterator_t *base, dir_iterator_t **out)
+static int dir_open_subdir(sqfs_dir_iterator_t *base, sqfs_dir_iterator_t **out)
{
const unix_dir_iterator_t *it = (const unix_dir_iterator_t *)base;
DIR *dir;
@@ -194,7 +194,7 @@ static int dir_open_subdir(dir_iterator_t *base, dir_iterator_t **out)
return create_iterator(out, dir);
}
-static int create_iterator(dir_iterator_t **out, DIR *dir)
+static int create_iterator(sqfs_dir_iterator_t **out, DIR *dir)
{
unix_dir_iterator_t *it = calloc(1, sizeof(*it));
@@ -215,20 +215,20 @@ static int create_iterator(dir_iterator_t **out, DIR *dir)
sqfs_object_init(it, dir_destroy, NULL);
it->device = it->sb.st_dev;
- ((dir_iterator_t *)it)->next = dir_next;
- ((dir_iterator_t *)it)->read_link = dir_read_link;
- ((dir_iterator_t *)it)->open_subdir = dir_open_subdir;
- ((dir_iterator_t *)it)->ignore_subdir = dir_ignore_subdir;
- ((dir_iterator_t *)it)->open_file_ro = dir_open_file_ro;
- ((dir_iterator_t *)it)->read_xattr = dir_read_xattr;
-
- *out = (dir_iterator_t *)it;
+ ((sqfs_dir_iterator_t *)it)->next = dir_next;
+ ((sqfs_dir_iterator_t *)it)->read_link = dir_read_link;
+ ((sqfs_dir_iterator_t *)it)->open_subdir = dir_open_subdir;
+ ((sqfs_dir_iterator_t *)it)->ignore_subdir = dir_ignore_subdir;
+ ((sqfs_dir_iterator_t *)it)->open_file_ro = dir_open_file_ro;
+ ((sqfs_dir_iterator_t *)it)->read_xattr = dir_read_xattr;
+
+ *out = (sqfs_dir_iterator_t *)it;
return 0;
}
-dir_iterator_t *dir_iterator_create(const char *path)
+sqfs_dir_iterator_t *dir_iterator_create(const char *path)
{
- dir_iterator_t *out;
+ sqfs_dir_iterator_t *out;
DIR *dir;
dir = opendir(path);
diff --git a/lib/io/src/win32/dir_iterator.c b/lib/io/src/win32/dir_iterator.c
index f66e323..15cfbc5 100644
--- a/lib/io/src/win32/dir_iterator.c
+++ b/lib/io/src/win32/dir_iterator.c
@@ -18,7 +18,7 @@
#define W32_TICS_PER_SEC 10000000UL
typedef struct {
- dir_iterator_t base;
+ sqfs_dir_iterator_t base;
WIN32_FIND_DATAW ent;
HANDLE dirhnd;
@@ -44,14 +44,14 @@ static sqfs_s64 w32time_to_unix(const FILETIME *ft)
return w32ts - UNIX_EPOCH_ON_W32;
}
-static int dir_iterator_read_link(dir_iterator_t *it, char **out)
+static int dir_iterator_read_link(sqfs_dir_iterator_t *it, char **out)
{
(void)it;
*out = NULL;
return SQFS_ERROR_UNSUPPORTED;
}
-static int dir_iterator_next(dir_iterator_t *it, sqfs_dir_entry_t **out)
+static int dir_iterator_next(sqfs_dir_iterator_t *it, sqfs_dir_entry_t **out)
{
dir_iterator_win32_t *w32 = (dir_iterator_win32_t *)it;
sqfs_dir_entry_t *ent = NULL;
@@ -115,12 +115,13 @@ static void dir_iterator_destroy(sqfs_object_t *obj)
free(dir);
}
-static void dir_iterator_ignore_subdir(dir_iterator_t *it)
+static void dir_iterator_ignore_subdir(sqfs_dir_iterator_t *it)
{
(void)it;
}
-static int dir_iterator_open_file_ro(dir_iterator_t *it, sqfs_istream_t **out)
+static int dir_iterator_open_file_ro(sqfs_dir_iterator_t *it,
+ sqfs_istream_t **out)
{
dir_iterator_win32_t *dir = (dir_iterator_win32_t *)it;
size_t plen, slen;
@@ -184,7 +185,7 @@ static int dir_iterator_open_file_ro(dir_iterator_t *it, sqfs_istream_t **out)
return ret;
}
-static int dir_iterator_read_xattr(dir_iterator_t *it, sqfs_xattr_t **out)
+static int dir_iterator_read_xattr(sqfs_dir_iterator_t *it, sqfs_xattr_t **out)
{
(void)it;
*out = NULL;
@@ -193,7 +194,8 @@ static int dir_iterator_read_xattr(dir_iterator_t *it, sqfs_xattr_t **out)
static int dir_iterator_init(dir_iterator_win32_t *it);
-static int dir_iterator_open_subdir(dir_iterator_t *it, dir_iterator_t **out)
+static int dir_iterator_open_subdir(sqfs_dir_iterator_t *it,
+ sqfs_dir_iterator_t **out)
{
const dir_iterator_win32_t *dir = (const dir_iterator_win32_t *)it;
dir_iterator_win32_t *sub = NULL;
@@ -228,7 +230,7 @@ static int dir_iterator_open_subdir(dir_iterator_t *it, dir_iterator_t **out)
sub = NULL;
}
- *out = (dir_iterator_t *)sub;
+ *out = (sqfs_dir_iterator_t *)sub;
return ret;
}
@@ -236,12 +238,12 @@ static int dir_iterator_init(dir_iterator_win32_t *it)
{
sqfs_object_init(it, dir_iterator_destroy, NULL);
- ((dir_iterator_t *)it)->next = dir_iterator_next;
- ((dir_iterator_t *)it)->read_link = dir_iterator_read_link;
- ((dir_iterator_t *)it)->open_subdir = dir_iterator_open_subdir;
- ((dir_iterator_t *)it)->ignore_subdir = dir_iterator_ignore_subdir;
- ((dir_iterator_t *)it)->open_file_ro = dir_iterator_open_file_ro;
- ((dir_iterator_t *)it)->read_xattr = dir_iterator_read_xattr;
+ ((sqfs_dir_iterator_t *)it)->next = dir_iterator_next;
+ ((sqfs_dir_iterator_t *)it)->read_link = dir_iterator_read_link;
+ ((sqfs_dir_iterator_t *)it)->open_subdir = dir_iterator_open_subdir;
+ ((sqfs_dir_iterator_t *)it)->ignore_subdir = dir_iterator_ignore_subdir;
+ ((sqfs_dir_iterator_t *)it)->open_file_ro = dir_iterator_open_file_ro;
+ ((sqfs_dir_iterator_t *)it)->read_xattr = dir_iterator_read_xattr;
it->is_first = true;
it->state = 0;
@@ -252,7 +254,7 @@ static int dir_iterator_init(dir_iterator_win32_t *it)
return 0;
}
-dir_iterator_t *dir_iterator_create(const char *path)
+sqfs_dir_iterator_t *dir_iterator_create(const char *path)
{
dir_iterator_win32_t *it;
size_t len, newlen;
@@ -299,7 +301,7 @@ dir_iterator_t *dir_iterator_create(const char *path)
it = NULL;
}
- return (dir_iterator_t *)it;
+ return (sqfs_dir_iterator_t *)it;
fail_alloc:
fprintf(stderr, "%s: allocation failure.\n", path);
free(wpath);
diff --git a/lib/io/test/dir_iterator.c b/lib/io/test/dir_iterator.c
index 48a57ec..013e41e 100644
--- a/lib/io/test/dir_iterator.c
+++ b/lib/io/test/dir_iterator.c
@@ -31,7 +31,7 @@ static int compare_files(const void *a, const void *b)
int main(int argc, char **argv)
{
- dir_iterator_t *dir, *suba, *subb, *subc, *sub;
+ sqfs_dir_iterator_t *dir, *suba, *subb, *subc, *sub;
sqfs_dir_entry_t *dent, *ent[6];
sqfs_istream_t *files[3];
char buffer[128];
diff --git a/lib/io/test/dir_tree_iterator.c b/lib/io/test/dir_tree_iterator.c
index 14fad7e..8e11e2a 100644
--- a/lib/io/test/dir_tree_iterator.c
+++ b/lib/io/test/dir_tree_iterator.c
@@ -22,7 +22,7 @@ static int compare_entries(const void *a, const void *b)
int main(int argc, char **argv)
{
sqfs_dir_entry_t *ent[17];
- dir_iterator_t *dir;
+ sqfs_dir_iterator_t *dir;
dir_tree_cfg_t cfg;
size_t i;
int ret;
diff --git a/lib/io/test/dir_tree_iterator2.c b/lib/io/test/dir_tree_iterator2.c
index 961cd39..2833dc5 100644
--- a/lib/io/test/dir_tree_iterator2.c
+++ b/lib/io/test/dir_tree_iterator2.c
@@ -22,7 +22,7 @@ static int compare_entries(const void *a, const void *b)
int main(int argc, char **argv)
{
sqfs_dir_entry_t *ent[17];
- dir_iterator_t *dir;
+ sqfs_dir_iterator_t *dir;
dir_tree_cfg_t cfg;
size_t i;
int ret;
diff --git a/lib/io/test/dir_tree_iterator3.c b/lib/io/test/dir_tree_iterator3.c
index 5e414d7..b82934f 100644
--- a/lib/io/test/dir_tree_iterator3.c
+++ b/lib/io/test/dir_tree_iterator3.c
@@ -22,7 +22,7 @@ static int compare_entries(const void *a, const void *b)
int main(int argc, char **argv)
{
sqfs_dir_entry_t *ent[17];
- dir_iterator_t *dir;
+ sqfs_dir_iterator_t *dir;
dir_tree_cfg_t cfg;
size_t i;
int ret;
diff --git a/lib/tar/src/iterator.c b/lib/tar/src/iterator.c
index a2708a0..85466ba 100644
--- a/lib/tar/src/iterator.c
+++ b/lib/tar/src/iterator.c
@@ -19,7 +19,7 @@
#include <fnmatch.h>
typedef struct {
- dir_iterator_t base;
+ sqfs_dir_iterator_t base;
tar_header_decoded_t current;
sqfs_istream_t *stream;
char **excludedirs;
@@ -167,7 +167,7 @@ static void strm_destroy(sqfs_object_t *obj)
/*****************************************************************************/
-static int it_next(dir_iterator_t *it, sqfs_dir_entry_t **out)
+static int it_next(sqfs_dir_iterator_t *it, sqfs_dir_entry_t **out)
{
tar_iterator_t *tar = (tar_iterator_t *)it;
size_t idx;
@@ -243,7 +243,7 @@ fail:
return tar->state;
}
-static int it_read_link(dir_iterator_t *it, char **out)
+static int it_read_link(sqfs_dir_iterator_t *it, char **out)
{
tar_iterator_t *tar = (tar_iterator_t *)it;
@@ -258,20 +258,20 @@ static int it_read_link(dir_iterator_t *it, char **out)
return (*out == NULL) ? SQFS_ERROR_ALLOC : 0;
}
-static int it_open_subdir(dir_iterator_t *it, dir_iterator_t **out)
+static int it_open_subdir(sqfs_dir_iterator_t *it, sqfs_dir_iterator_t **out)
{
(void)it;
*out = NULL;
return SQFS_ERROR_UNSUPPORTED;
}
-static void it_ignore_subdir(dir_iterator_t *it)
+static void it_ignore_subdir(sqfs_dir_iterator_t *it)
{
(void)it;
/* TODO: skip list */
}
-static int it_open_file_ro(dir_iterator_t *it, sqfs_istream_t **out)
+static int it_open_file_ro(sqfs_dir_iterator_t *it, sqfs_istream_t **out)
{
tar_iterator_t *tar = (tar_iterator_t *)it;
tar_istream_t *strm;
@@ -302,7 +302,7 @@ static int it_open_file_ro(dir_iterator_t *it, sqfs_istream_t **out)
return 0;
}
-static int it_read_xattr(dir_iterator_t *it, sqfs_xattr_t **out)
+static int it_read_xattr(sqfs_dir_iterator_t *it, sqfs_xattr_t **out)
{
tar_iterator_t *tar = (tar_iterator_t *)it;
@@ -359,10 +359,11 @@ static int tar_probe(const sqfs_u8 *data, size_t size)
return 0;
}
-dir_iterator_t *tar_open_stream(sqfs_istream_t *strm, tar_iterator_opts *opts)
+sqfs_dir_iterator_t *tar_open_stream(sqfs_istream_t *strm,
+ tar_iterator_opts *opts)
{
tar_iterator_t *tar = calloc(1, sizeof(*tar));
- dir_iterator_t *it = (dir_iterator_t *)tar;
+ sqfs_dir_iterator_t *it = (sqfs_dir_iterator_t *)tar;
xfrm_stream_t *xfrm = NULL;
const sqfs_u8 *ptr;
size_t size;
diff --git a/lib/tar/test/tar_iterator.c b/lib/tar/test/tar_iterator.c
index cd24c94..b90d5ca 100644
--- a/lib/tar/test/tar_iterator.c
+++ b/lib/tar/test/tar_iterator.c
@@ -31,7 +31,7 @@ static const char *fname = STRVALUE(TESTFNAME);
int main(int argc, char **argv)
{
sqfs_istream_t *fp, *ti, *ti2;
- dir_iterator_t *it;
+ sqfs_dir_iterator_t *it;
sqfs_dir_entry_t *ent;
char buffer[100];
sqfs_s32 ret;
diff --git a/lib/tar/test/tar_iterator2.c b/lib/tar/test/tar_iterator2.c
index 7b22af3..630f579 100644
--- a/lib/tar/test/tar_iterator2.c
+++ b/lib/tar/test/tar_iterator2.c
@@ -45,7 +45,7 @@ int main(int argc, char **argv)
{
unsigned char buffer[941];
sqfs_istream_t *fp, *ti;
- dir_iterator_t *it;
+ sqfs_dir_iterator_t *it;
sqfs_dir_entry_t *ent;
uint64_t offset;
sqfs_s32 i, ret;
diff --git a/lib/tar/test/tar_iterator3.c b/lib/tar/test/tar_iterator3.c
index 7973441..05940a2 100644
--- a/lib/tar/test/tar_iterator3.c
+++ b/lib/tar/test/tar_iterator3.c
@@ -14,7 +14,7 @@
int main(int argc, char **argv)
{
sqfs_istream_t *fp, *ti;
- dir_iterator_t *it;
+ sqfs_dir_iterator_t *it;
char buffer[100];
sqfs_dir_entry_t *ent;
char *link;