Skip to content

Commit

Permalink
libmksqsh: add id_table_builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed Apr 27, 2024
1 parent 73e1ffd commit 1926e07
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
18 changes: 18 additions & 0 deletions libmksqsh/include/mksqsh_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ int mksqsh__fragment_table_flush(struct MksqshFragmentTable *table);

int mksqsh__fragment_table_cleanup(struct MksqshFragmentTable *table);

/***************************************
* table/id_table_builder.c
*/

struct MksqshIdTable {
struct MksqshTable table;
};

int mksqsh__id_table_init(
struct MksqshIdTable *table, FILE *content_output, FILE *lookup_output);

int mksqsh__id_table_add(
struct MksqshIdTable *table, uint64_t start, uint32_t size);

int mksqsh__id_table_flush(struct MksqshIdTable *table);

int mksqsh__id_table_cleanup(struct MksqshIdTable *table);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions libmksqsh/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ libmksqsh_sources = files(
'archive/superblock_builder.c',
'metablock/metablock_builder.c',
'table/fragment_table_builder.c',
'table/id_table_builder.c',
'table/table_builder.c',
)
29 changes: 29 additions & 0 deletions libmksqsh/src/table/id_table_builder.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <cextras/endian.h>
#include <mksqsh_table.h>
#include <sqsh_data_set.h>

int
mksqsh__id_table_init(

Check warning on line 6 in libmksqsh/src/table/id_table_builder.c

View check run for this annotation

Codecov / codecov/patch

libmksqsh/src/table/id_table_builder.c#L6

Added line #L6 was not covered by tests
struct MksqshIdTable *table, FILE *content_output,
FILE *lookup_output) {
const size_t entry_size = sizeof(uint32_t);
return mksqsh__table_init(

Check warning on line 10 in libmksqsh/src/table/id_table_builder.c

View check run for this annotation

Codecov / codecov/patch

libmksqsh/src/table/id_table_builder.c#L9-L10

Added lines #L9 - L10 were not covered by tests
&table->table, entry_size, content_output, lookup_output);
}

int
mksqsh__id_table_write(struct MksqshIdTable *table, uint32_t id) {
uint32_t id_le = CX_CPU_2_LE32(id);

Check warning on line 16 in libmksqsh/src/table/id_table_builder.c

View check run for this annotation

Codecov / codecov/patch

libmksqsh/src/table/id_table_builder.c#L15-L16

Added lines #L15 - L16 were not covered by tests

return mksqsh__table_add(&table->table, &id_le, sizeof(id_le));

Check warning on line 18 in libmksqsh/src/table/id_table_builder.c

View check run for this annotation

Codecov / codecov/patch

libmksqsh/src/table/id_table_builder.c#L18

Added line #L18 was not covered by tests
}

int
mksqsh__id_table_flush(struct MksqshIdTable *table) {
return mksqsh__table_flush(&table->table);

Check warning on line 23 in libmksqsh/src/table/id_table_builder.c

View check run for this annotation

Codecov / codecov/patch

libmksqsh/src/table/id_table_builder.c#L22-L23

Added lines #L22 - L23 were not covered by tests
}

int
mksqsh__id_table_cleanup(struct MksqshIdTable *table) {
return mksqsh__table_cleanup(&table->table);

Check warning on line 28 in libmksqsh/src/table/id_table_builder.c

View check run for this annotation

Codecov / codecov/patch

libmksqsh/src/table/id_table_builder.c#L27-L28

Added lines #L27 - L28 were not covered by tests
}

0 comments on commit 1926e07

Please sign in to comment.