@@ -34,6 +34,10 @@ static bool file_reader(cmp_ctx_t *ctx, void *data, size_t limit) {
3434 return read_bytes(data, limit, (FILE * )ctx->buf);
3535}
3636
37+ static bool file_skipper(cmp_ctx_t * ctx, size_t count) {
38+ return fseek((FILE * )ctx->buf, count, SEEK_CUR);
39+ }
40+
3741static size_t file_writer(cmp_ctx_t * ctx, const void * data, size_t count) {
3842 return fwrite(data, sizeof(uint8_t), count, (FILE * )ctx->buf);
3943}
@@ -56,7 +60,7 @@ int main(void) {
5660 if (fh == NULL)
5761 error_and_exit("Error opening data.dat");
5862
59- cmp_init(&cmp, fh, file_reader, file_writer);
63+ cmp_init(&cmp, fh, file_reader, file_skipper, file_writer);
6064
6165 if (!cmp_write_array(&cmp, 2))
6266 error_and_exit(cmp_strerror(&cmp));
@@ -92,13 +96,14 @@ int main(void) {
9296 if (!cmp_read_str(&cmp, message_pack, &str_size))
9397 error_and_exit(cmp_strerror(&cmp));
9498
95- printf("Array Length: %zu .\n", array_size);
99+ printf("Array Length: %u .\n", array_size);
96100 printf("[\"%s\", \"%s\"]\n", hello, message_pack);
97101
98102 fclose(fh);
99103
100104 return EXIT_SUCCESS;
101105}
106+
102107```
103108
104109## Advanced Usage
0 commit comments