Skip to content

Commit

Permalink
reader: rename reader2 to reader.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed Aug 17, 2023
1 parent d5dc3ad commit 1393fb0
Show file tree
Hide file tree
Showing 12 changed files with 636 additions and 636 deletions.
2 changes: 1 addition & 1 deletion include/sqsh_file_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct SqshFileReader {
* @privatesection
*/
struct SqshFileIterator iterator;
struct SqshReader2 reader;
struct SqshReader reader;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion include/sqsh_mapper_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ struct SqshMapReader {
uint64_t address;
uint64_t upper_limit;
struct SqshMapIterator iterator;
struct SqshReader2 reader;
struct SqshReader reader;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion include/sqsh_metablock_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct SqshMetablockReader {
/**
* @privatesection
*/
struct SqshReader2 reader;
struct SqshReader reader;
struct SqshMetablockIterator iterator;
};

Expand Down
34 changes: 17 additions & 17 deletions include/sqsh_reader_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ extern "C" {
#endif

/***************************************
* reader/reader2.c
* reader/reader.c
*/

struct SqshReader2IteratorImpl {
struct SqshReaderIteratorImpl {
int (*next)(void *iterator, size_t desired_size);
const uint8_t *(*data)(const void *iterator);
size_t (*size)(const void *iterator);
Expand All @@ -55,7 +55,7 @@ struct SqshReader2IteratorImpl {
/**
* @brief An iterator over extended attributes.
*/
struct SqshReader2 {
struct SqshReader {
/**
* @privatesection
*/
Expand All @@ -68,7 +68,7 @@ struct SqshReader2 {
/**
* @brief interface to the iterator.
*/
const struct SqshReader2IteratorImpl *iterator_impl;
const struct SqshReaderIteratorImpl *iterator_impl;

/**
* @brief The offset of the iterator.
Expand Down Expand Up @@ -124,7 +124,7 @@ struct SqshReader2 {

/**
* @internal
* @memberof SqshReader2
* @memberof SqshReader
* @brief Initializes a reader.
*
* @param[out] reader Pointer to the metablock reader to be initialized.
Expand All @@ -133,13 +133,13 @@ struct SqshReader2 {
*
* @return 0 on success, less than zero on error.
*/
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__reader2_init(
struct SqshReader2 *reader,
const struct SqshReader2IteratorImpl *iterator_impl, void *iterator);
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__reader_init(
struct SqshReader *reader,
const struct SqshReaderIteratorImpl *iterator_impl, void *iterator);

/**
* @internal
* @memberof SqshReader2
* @memberof SqshReader
* @brief Advances the reader by the given offset and size.
*
* @param[in,out] reader Pointer to the metablock reader to be advanced.
Expand All @@ -148,12 +148,12 @@ SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__reader2_init(
*
* @return 0 on success, less than zero on error.
*/
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__reader2_advance(
struct SqshReader2 *reader, sqsh_index_t offset, size_t size);
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__reader_advance(
struct SqshReader *reader, sqsh_index_t offset, size_t size);

/**
* @internal
* @memberof SqshReader2
* @memberof SqshReader
* @brief Returns a pointer to the data at the current position of the metablock
* reader.
*
Expand All @@ -162,30 +162,30 @@ SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__reader2_advance(
* @return Pointer to the data at the current position of the metablock reader.
*/
SQSH_NO_EXPORT const uint8_t *
sqsh__reader2_data(const struct SqshReader2 *reader);
sqsh__reader_data(const struct SqshReader *reader);

/**
* @internal
* @memberof SqshReader2
* @memberof SqshReader
* @brief Returns the size of the data at the current position of the metablock
* reader.
*
* @param[in] reader Pointer to the metablock reader.
*
* @return Size of the data at the current position of the metablock reader.
*/
SQSH_NO_EXPORT size_t sqsh__reader2_size(const struct SqshReader2 *reader);
SQSH_NO_EXPORT size_t sqsh__reader_size(const struct SqshReader *reader);

/**
* @internal
* @memberof SqshReader2
* @memberof SqshReader
* @brief Cleans up and frees the resources used by the metablock reader.
*
* @param[in,out] reader Pointer to the metablock reader to be cleaned up.
*
* @return 0 on success, less than zero on error.
*/
SQSH_NO_EXPORT int sqsh__reader2_cleanup(struct SqshReader2 *reader);
SQSH_NO_EXPORT int sqsh__reader_cleanup(struct SqshReader *reader);

#ifdef __cplusplus
}
Expand Down
12 changes: 6 additions & 6 deletions lib/file/file_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ file_iterator_size(const void *iterator) {
return sqsh_file_iterator_size(iterator);
}

static const struct SqshReader2IteratorImpl file_reader_impl = {
static const struct SqshReaderIteratorImpl file_reader_impl = {
.next = file_iterator_next,
.data = file_iterator_data,
.size = file_iterator_size,
Expand All @@ -66,7 +66,7 @@ sqsh__file_reader_init(
if (rv < 0) {
goto out;
}
rv = sqsh__reader2_init(
rv = sqsh__reader_init(
&reader->reader, &file_reader_impl, &reader->iterator);
out:
return rv;
Expand Down Expand Up @@ -95,22 +95,22 @@ sqsh_file_reader_new(const struct SqshFile *file, int *err) {
int
sqsh_file_reader_advance(
struct SqshFileReader *reader, sqsh_index_t offset, size_t size) {
return sqsh__reader2_advance(&reader->reader, offset, size);
return sqsh__reader_advance(&reader->reader, offset, size);
}

const uint8_t *
sqsh_file_reader_data(const struct SqshFileReader *reader) {
return sqsh__reader2_data(&reader->reader);
return sqsh__reader_data(&reader->reader);
}

size_t
sqsh_file_reader_size(const struct SqshFileReader *reader) {
return sqsh__reader2_size(&reader->reader);
return sqsh__reader_size(&reader->reader);
}

int
sqsh__file_reader_cleanup(struct SqshFileReader *reader) {
sqsh__reader2_cleanup(&reader->reader);
sqsh__reader_cleanup(&reader->reader);
sqsh__file_iterator_cleanup(&reader->iterator);

return 0;
Expand Down
14 changes: 7 additions & 7 deletions lib/mapper/map_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ map_iterator_size(const void *iterator) {
return sqsh__map_iterator_size(iterator);
}

static const struct SqshReader2IteratorImpl map_reader_impl = {
static const struct SqshReaderIteratorImpl map_reader_impl = {
.next = map_iterator_next,
.data = map_iterator_data,
.size = map_iterator_size,
Expand All @@ -74,15 +74,15 @@ sqsh__map_reader_init(
if (rv < 0) {
goto out;
}
rv = sqsh__reader2_init(
rv = sqsh__reader_init(
&reader->reader, &map_reader_impl, &reader->iterator);
if (rv < 0) {
goto out;
}
reader->upper_limit = upper_limit;
reader->address = start_address;

rv = sqsh__reader2_advance(&reader->reader, offset, 0);
rv = sqsh__reader_advance(&reader->reader, offset, 0);
out:
if (rv < 0) {
sqsh__map_reader_cleanup(reader);
Expand All @@ -106,7 +106,7 @@ int
sqsh__map_reader_advance(
struct SqshMapReader *reader, sqsh_index_t offset, size_t size) {
reader->address += offset;
return sqsh__reader2_advance(&reader->reader, offset, size);
return sqsh__reader_advance(&reader->reader, offset, size);
}

int
Expand All @@ -117,17 +117,17 @@ sqsh__map_reader_all(struct SqshMapReader *reader) {

const uint8_t *
sqsh__map_reader_data(const struct SqshMapReader *reader) {
return sqsh__reader2_data(&reader->reader);
return sqsh__reader_data(&reader->reader);
}

size_t
sqsh__map_reader_size(const struct SqshMapReader *reader) {
return sqsh__reader2_size(&reader->reader);
return sqsh__reader_size(&reader->reader);
}

int
sqsh__map_reader_cleanup(struct SqshMapReader *reader) {
sqsh__reader2_cleanup(&reader->reader);
sqsh__reader_cleanup(&reader->reader);
sqsh__map_iterator_cleanup(&reader->iterator);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
libsqsh_sources = files(
'reader/reader2.c',
'reader/reader.c',
'archive/archive.c',
'archive/compression_options.c',
'archive/inode_map.c',
Expand Down
12 changes: 6 additions & 6 deletions lib/metablock/metablock_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ metablock_iterator_size(const void *iterator) {
return sqsh__metablock_iterator_size(iterator);
}

static const struct SqshReader2IteratorImpl metablock_reader_impl = {
static const struct SqshReaderIteratorImpl metablock_reader_impl = {
.next = metablock_iterator_next,
.data = metablock_iterator_data,
.size = metablock_iterator_size,
Expand All @@ -70,7 +70,7 @@ sqsh__metablock_reader_init(
if (rv < 0) {
goto out;
}
rv = sqsh__reader2_init(
rv = sqsh__reader_init(
&reader->reader, &metablock_reader_impl, &reader->iterator);
out:
return rv;
Expand All @@ -79,22 +79,22 @@ sqsh__metablock_reader_init(
int
sqsh__metablock_reader_advance(
struct SqshMetablockReader *reader, sqsh_index_t offset, size_t size) {
return sqsh__reader2_advance(&reader->reader, offset, size);
return sqsh__reader_advance(&reader->reader, offset, size);
}

const uint8_t *
sqsh__metablock_reader_data(const struct SqshMetablockReader *reader) {
return sqsh__reader2_data(&reader->reader);
return sqsh__reader_data(&reader->reader);
}

size_t
sqsh__metablock_reader_size(const struct SqshMetablockReader *reader) {
return sqsh__reader2_size(&reader->reader);
return sqsh__reader_size(&reader->reader);
}

int
sqsh__metablock_reader_cleanup(struct SqshMetablockReader *reader) {
sqsh__reader2_cleanup(&reader->reader);
sqsh__reader_cleanup(&reader->reader);
sqsh__metablock_iterator_cleanup(&reader->iterator);

return 0;
Expand Down
32 changes: 16 additions & 16 deletions lib/reader/reader2.c → lib/reader/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <assert.h>

static int
reader_iterator_next(struct SqshReader2 *reader, size_t desired_size) {
reader_iterator_next(struct SqshReader *reader, size_t desired_size) {
int rv = reader->iterator_impl->next(reader->iterator, desired_size);
if (rv == 0) {
rv = -SQSH_ERROR_OUT_OF_BOUNDS;
Expand All @@ -63,10 +63,10 @@ reader_iterator_next(struct SqshReader2 *reader, size_t desired_size) {
*/
static int
reader_iterator_skip(
struct SqshReader2 *reader, sqsh_index_t *offset, size_t desired_size) {
struct SqshReader *reader, sqsh_index_t *offset, size_t desired_size) {
int rv = 0;
void *iterator = reader->iterator;
const struct SqshReader2IteratorImpl *impl = reader->iterator_impl;
const struct SqshReaderIteratorImpl *impl = reader->iterator_impl;

size_t current_size = impl->size(iterator);

Expand All @@ -85,9 +85,9 @@ reader_iterator_skip(
}

int
sqsh__reader2_init(
struct SqshReader2 *reader,
const struct SqshReader2IteratorImpl *iterator_impl, void *iterator) {
sqsh__reader_init(
struct SqshReader *reader,
const struct SqshReaderIteratorImpl *iterator_impl, void *iterator) {
reader->data = NULL;
reader->size = 0;
reader->offset = 0;
Expand All @@ -108,10 +108,10 @@ sqsh__reader2_init(
* @return 0 on success, negative on error.
*/
static int
reader_fill_buffer(struct SqshReader2 *reader, size_t size) {
reader_fill_buffer(struct SqshReader *reader, size_t size) {
int rv = 0;
void *iterator = reader->iterator;
const struct SqshReader2IteratorImpl *impl = reader->iterator_impl;
const struct SqshReaderIteratorImpl *impl = reader->iterator_impl;
struct SqshBuffer *buffer = &reader->buffer;
sqsh_index_t offset = reader->offset;

Expand Down Expand Up @@ -149,7 +149,7 @@ reader_fill_buffer(struct SqshReader2 *reader, size_t size) {
}

static int
handle_buffered(struct SqshReader2 *reader, sqsh_index_t offset, size_t size) {
handle_buffered(struct SqshReader *reader, sqsh_index_t offset, size_t size) {
int rv = 0;
struct SqshBuffer new_buffer = {0};
sqsh_index_t iterator_offset = reader->iterator_offset;
Expand Down Expand Up @@ -179,10 +179,10 @@ handle_buffered(struct SqshReader2 *reader, sqsh_index_t offset, size_t size) {
}

static int
handle_mapped(struct SqshReader2 *reader, sqsh_index_t offset, size_t size) {
handle_mapped(struct SqshReader *reader, sqsh_index_t offset, size_t size) {
int rv = 0;
void *iterator = reader->iterator;
const struct SqshReader2IteratorImpl *impl = reader->iterator_impl;
const struct SqshReaderIteratorImpl *impl = reader->iterator_impl;

if (SQSH_ADD_OVERFLOW(offset, reader->offset, &offset)) {
rv = -SQSH_ERROR_INTEGER_OVERFLOW;
Expand Down Expand Up @@ -215,8 +215,8 @@ handle_mapped(struct SqshReader2 *reader, sqsh_index_t offset, size_t size) {
}

int
sqsh__reader2_advance(
struct SqshReader2 *reader, sqsh_index_t offset, size_t size) {
sqsh__reader_advance(
struct SqshReader *reader, sqsh_index_t offset, size_t size) {
if (offset >= reader->iterator_offset) {
offset -= reader->iterator_offset;
reader->iterator_offset = 0;
Expand All @@ -227,16 +227,16 @@ sqsh__reader2_advance(
}

const uint8_t *
sqsh__reader2_data(const struct SqshReader2 *reader) {
sqsh__reader_data(const struct SqshReader *reader) {
return reader->data;
}

size_t
sqsh__reader2_size(const struct SqshReader2 *reader) {
sqsh__reader_size(const struct SqshReader *reader) {
return reader->size;
}

int
sqsh__reader2_cleanup(struct SqshReader2 *reader) {
sqsh__reader_cleanup(struct SqshReader *reader) {
return sqsh__buffer_cleanup(&reader->buffer);
}
Loading

0 comments on commit 1393fb0

Please sign in to comment.