aboutsummaryrefslogtreecommitdiff
path: root/lib/io/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/io/src')
-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
3 files changed, 59 insertions, 56 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);