diff --git a/filesel/adbmeta-test.c b/filesel/adbmeta-test.c index 82045ac6..2762e670 100644 --- a/filesel/adbmeta-test.c +++ b/filesel/adbmeta-test.c @@ -734,7 +734,7 @@ const struct adbMetaEntry_t test_many_insert[7] = { for (i=0; i < 7; i++) { unsigned char *data = (unsigned char *)"b"; - size_t datasize = 1; + uint32_t datasize = 1; adbMetaGet (test_many_insert[i].filename, test_many_insert[i].filesize, test_many_insert[i].SIG, @@ -758,7 +758,7 @@ const struct adbMetaEntry_t test_many_insert[7] = { { unsigned char *data = (unsigned char *)"a"; - size_t datasize = 1; + uint32_t datasize = 1; adbMetaGet (test_many_insert[0].filename, 14, test_many_insert[0].SIG, diff --git a/filesel/adbmeta.c b/filesel/adbmeta.c index 1668680b..a4f245ad 100644 --- a/filesel/adbmeta.c +++ b/filesel/adbmeta.c @@ -236,10 +236,10 @@ static int adbMetaInit_ParseFd (osfile *f) ((uint_fast64_t)data[offset+6] << 8) | ((uint_fast64_t)data[offset+7]); offset += 8; - datasize = ((uint_fast64_t)data[offset+0] << 24) | - ((uint_fast64_t)data[offset+1] << 16) | - ((uint_fast64_t)data[offset+2] << 8) | - ((uint_fast64_t)data[offset+3]); + datasize = ((uint_fast32_t)data[offset+0] << 24) | + ((uint_fast32_t)data[offset+1] << 16) | + ((uint_fast32_t)data[offset+2] << 8) | + ((uint_fast32_t)data[offset+3]); offset += 4; if (offset + datasize > fill) @@ -400,7 +400,7 @@ void adbMetaClose (void) } } -static uint32_t adbMetaBinarySearchFilesize (const size_t filesize) +static uint32_t adbMetaBinarySearchFilesize (const uint32_t filesize) { uint_fast32_t searchbase = 0, searchlen = adbMetaCount; @@ -459,14 +459,14 @@ static uint32_t adbMetaBinarySearchFilesize (const size_t filesize) return searchbase; } -int adbMetaAdd (const char *filename, const size_t filesize, const char *SIG, const unsigned char *data, const size_t datasize) +int adbMetaAdd (const char *filename, const uint64_t filesize, const char *SIG, const unsigned char *data, const uint32_t datasize) { uint_fast32_t searchindex = adbMetaBinarySearchFilesize (filesize); int_fast32_t search; struct adbMetaEntry_t *temp; #ifdef ADBMETA_DEBUG - fprintf (stderr, "adbMetaAdd (\"%s\", %"PRId64", \"%s\", %p, %ld)\n", filename, filesize, SIG, data, datasize); + fprintf (stderr, "adbMetaAdd (\"%s\", %"PRIu64", \"%s\", 0x%p, %"PRIu32")\n", filename, filesize, SIG, data, datasize); #endif if (searchindex == adbMetaCount) @@ -545,13 +545,13 @@ int adbMetaAdd (const char *filename, const size_t filesize, const char *SIG, co return 0; } -int adbMetaRemove (const char *filename, const size_t filesize, const char *SIG) +int adbMetaRemove (const char *filename, const uint64_t filesize, const char *SIG) { uint_fast32_t searchindex = adbMetaBinarySearchFilesize (filesize); int_fast32_t search; #ifdef ADBMETA_DEBUG - fprintf (stderr, "adbMetaRemove (\"%s\", %ld, \"%s\")\n", filename, filesize, SIG); + fprintf (stderr, "adbMetaRemove (\"%s\", %"PRIu64", \"%s\")\n", filename, filesize, SIG); #endif if (searchindex == adbMetaCount) @@ -591,13 +591,13 @@ int adbMetaRemove (const char *filename, const size_t filesize, const char *SIG) return 1; /* not found */ } -int adbMetaGet (const char *filename, const size_t filesize, const char *SIG, unsigned char **data, size_t *datasize) +int adbMetaGet (const char *filename, const uint64_t filesize, const char *SIG, unsigned char **data, uint32_t *datasize) { uint_fast32_t searchindex = adbMetaBinarySearchFilesize (filesize); int_fast32_t search; #ifdef ADBMETA_DEBUG - fprintf (stderr, "adbMetaGet (\"%s\", %"PRId64", \"%s\") ", filename, filesize, SIG); + fprintf (stderr, "adbMetaGet (\"%s\", %"PRIu64", \"%s\") ", filename, filesize, SIG); #endif *data = 0; @@ -649,7 +649,7 @@ int adbMetaGet (const char *filename, const size_t filesize, const char *SIG, un *datasize = adbMetaEntries[search]->datasize; #ifdef ADBMETA_DEBUG - fprintf (stderr, " => %p %ld\n", *data, *datasize); + fprintf (stderr, " => %p %"PRIu32"\n", *data, *datasize); #endif return 0; } diff --git a/filesel/adbmeta.h b/filesel/adbmeta.h index 487058ff..c92f1d34 100644 --- a/filesel/adbmeta.h +++ b/filesel/adbmeta.h @@ -8,10 +8,10 @@ int adbMetaInit (const struct configAPI_t *configAPI); void adbMetaCommit (void); void adbMetaClose (void); // ZIP, GZ, BZ2, etc - who owns this meta-data -int adbMetaAdd (const char *filename, const size_t filesize, const char *SIG, const unsigned char *data, const size_t datasize); // Replaces too -int adbMetaRemove (const char *filename, const size_t filesize, const char *SIG); +int adbMetaAdd (const char *filename, const uint64_t filesize, const char *SIG, const unsigned char *data, const uint32_t datasize); // Replaces too +int adbMetaRemove (const char *filename, const uint64_t filesize, const char *SIG); // when done, use free() -int adbMetaGet (const char *filename, const size_t filesize, const char *SIG, unsigned char **data, size_t *datasize); +int adbMetaGet (const char *filename, const uint64_t filesize, const char *SIG, unsigned char **data, uint32_t *datasize); #endif diff --git a/filesel/filesystem-bzip2-test.c b/filesel/filesystem-bzip2-test.c index b56677f1..37639ebb 100644 --- a/filesel/filesystem-bzip2-test.c +++ b/filesel/filesystem-bzip2-test.c @@ -96,12 +96,12 @@ void register_dirdecompressor (const struct ocpdirdecompressor_t *ofd) { } -int adbMetaAdd (const char *filename, const size_t filesize, const char *SIG, const unsigned char *data, const size_t datasize) +int adbMetaAdd (const char *filename, const uint64_t filesize, const char *SIG, const unsigned char *data, const uint32_t datasize) { return 0; } -int adbMetaGet (const char *filename, const size_t filesize, const char *SIG, unsigned char **data, size_t *datasize) +int adbMetaGet (const char *filename, const uint64_t filesize, const char *SIG, unsigned char **data, uint32_t *datasize) { return -1; } diff --git a/filesel/filesystem-bzip2.c b/filesel/filesystem-bzip2.c index 5c548f7b..8deeec8a 100644 --- a/filesel/filesystem-bzip2.c +++ b/filesel/filesystem-bzip2.c @@ -96,6 +96,8 @@ static int bzip2_ocpfilehandle_compressInit (struct bzip2_ocpfilehandle_t *s) { int retval; + DEBUG_PRINT ("bzip2_ocpfilehandle_compressInit (s->need_deinit=%d)\n", s->need_deinit); + if (s->need_deinit) { BZ2_bzDecompressEnd (&s->strm); @@ -155,6 +157,8 @@ static void bzip2_ocpfilehandle_unref (struct ocpfilehandle_t *_s) return; } + DEBUG_PRINT("bzip2_ocpfilehandle_unref, last instance, s->need_deinit=%d\n", s->need_deinit); + if (s->need_deinit) { BZ2_bzDecompressEnd (&s->strm); @@ -183,6 +187,8 @@ static int bzip2_ocpfilehandle_seek_set (struct ocpfilehandle_t *_s, int64_t pos if (pos < 0) return -1; + DEBUG_PRINT ("bzip2_ocpfilehandle_seek_set pos=%"PRId64" oldpos=%"PRId64" realpos=%"PRId64" s->owner->filesize_pending=%d \n", pos, s->pos, s->realpos, s->owner->filesize_pending); + if (s->owner->filesize_pending) { if (pos > s->pos) @@ -207,6 +213,8 @@ static uint64_t bzip2_ocpfilehandle_getpos (struct ocpfilehandle_t *_s) { struct bzip2_ocpfilehandle_t *s = (struct bzip2_ocpfilehandle_t *)_s; + DEBUG_PRINT ("bzip2_ocpfilehandle_getpos pos=%"PRId64"\n", s->pos); + return s->pos; } @@ -214,6 +222,8 @@ static int bzip2_ocpfilehandle_eof (struct ocpfilehandle_t *_s) { struct bzip2_ocpfilehandle_t *s = (struct bzip2_ocpfilehandle_t *)_s; + DEBUG_PRINT ("bzip2_ocpfilehandle_eof\n"); + if (!s->owner->filesize_pending) { if (_s->filesize (_s) == FILESIZE_ERROR) /* force the size to be calculated */ @@ -229,6 +239,8 @@ static int bzip2_ocpfilehandle_error (struct ocpfilehandle_t *_s) { struct bzip2_ocpfilehandle_t *s = (struct bzip2_ocpfilehandle_t *)_s; + DEBUG_PRINT ("bzip2_ocpfilehandle_error\n"); + return s->error; } @@ -238,6 +250,8 @@ static int bzip2_ocpfilehandle_read (struct ocpfilehandle_t *_s, void *dst, int int retval = 0; int recall = 0; + DEBUG_PRINT ("bzip2_ocpfilehandle_read len=%d pos=%"PRId64" realpos=%"PRId64"\n", len, s->pos, s->realpos); + /* do we need to reverse? */ if ((s->pos < s->realpos) || (!s->need_deinit)) { @@ -411,7 +425,7 @@ static int bzip2_ocpfilehandle_read (struct ocpfilehandle_t *_s, void *dst, int dirdbGetName_internalstr (s->compressedfilehandle->dirdb_ref, &filename); - DEBUG_PRINT ("[BZIP2 filehandle_read EOF] adbMetaAdd(%s, %"PRId64", BZIP2, [%02x %02x %02x %02x %02x %02x %02x %02x] (%"PRIu64" + %d => %"PRIu64")\n", filename, compressedfile_size, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], s->realpos, s->outputbuffer_fill, filesize); + DEBUG_PRINT ("[BZIP2 filehandle_read EOF] adbMetaAdd(%s, %"PRIu64", BZIP2, [%02x %02x %02x %02x %02x %02x %02x %02x] (%"PRIu64" + %d => %"PRIu64")\n", filename, compressedfile_size, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], s->realpos, s->outputbuffer_fill, filesize); adbMetaAdd (filename, compressedfile_size, "BZIP2", buffer, 8); } @@ -520,7 +534,7 @@ static uint64_t bzip2_ocpfile_filesize (struct ocpfile_t *_s) compressedfile_size = s->compressedfile->filesize (s->compressedfile); uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; if ((compressedfile_size < 12) || (compressedfile_size == FILESIZE_ERROR) || (compressedfile_size == FILESIZE_STREAM)) { @@ -544,9 +558,11 @@ static uint64_t bzip2_ocpfile_filesize (struct ocpfile_t *_s) ((uint64_t)(metadata[0])); free (metadata); - DEBUG_PRINT ("[BZIP2 ocpfile_filesize]: got metadatasize=0x%08lx %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], s->uncompressed_filesize); + DEBUG_PRINT ("[BZIP2 ocpfile_filesize]: got metadatasize=0x%08"PRIu32" %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], s->uncompressed_filesize); return s->uncompressed_filesize; + } else { + DEBUG_PRINT ("[BZIP2 ocpfile_filesize]: got metadatasize=0x%08"PRIu32", unexpected size\n", metadatasize); } free (metadata); /* wrong size???... */ metadata = 0; @@ -808,7 +824,7 @@ static struct ocpdir_t *bzip2_check_steal (struct ocpfile_t *s, const uint32_t d if (s->filesize_ready (s)) { unsigned char *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; const char *filename = 0; dirdbGetName_internalstr (retval->child.compressedfile->dirdb_ref, &filename); @@ -827,8 +843,9 @@ static struct ocpdir_t *bzip2_check_steal (struct ocpfile_t *s, const uint32_t d ((uint64_t)(metadata[1]) << 8) | ((uint64_t)(metadata[0])); - DEBUG_PRINT ("[BZIP2 bzip2_check_steal]: got metadatasize=0x%08lx %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], retval->child.uncompressed_filesize); - + DEBUG_PRINT ("[BZIP2 bzip2_check_steal]: got metadatasize=0x%08"PRIu32" %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], retval->child.uncompressed_filesize); + } else { + DEBUG_PRINT ("[BZIP2 bzip2_check_steal]: got metadatasize=0x%08"PRIu32", an unexpected size\n", metadatasize); } free (metadata); metadata = 0; diff --git a/filesel/filesystem-gzip-test.c b/filesel/filesystem-gzip-test.c index 4b007334..309e6872 100644 --- a/filesel/filesystem-gzip-test.c +++ b/filesel/filesystem-gzip-test.c @@ -95,12 +95,12 @@ void register_dirdecompressor (const struct ocpdirdecompressor_t *ofd) { } -int adbMetaAdd (const char *filename, const size_t filesize, const char *SIG, const unsigned char *data, const size_t datasize) +int adbMetaAdd (const char *filename, const uint64_t filesize, const char *SIG, const unsigned char *data, const uint32_t datasize) { return 0; } -int adbMetaGet (const char *filename, const size_t filesize, const char *SIG, unsigned char **data, size_t *datasize) +int adbMetaGet (const char *filename, const uint64_t filesize, const char *SIG, unsigned char **data, uint32_t *datasize) { return -1; } diff --git a/filesel/filesystem-gzip.c b/filesel/filesystem-gzip.c index 2499877e..144cf795 100644 --- a/filesel/filesystem-gzip.c +++ b/filesel/filesystem-gzip.c @@ -411,7 +411,7 @@ static int gzip_ocpfilehandle_read (struct ocpfilehandle_t *_s, void *dst, int l dirdbGetName_internalstr (s->compressedfilehandle->dirdb_ref, &filename); - DEBUG_PRINT ("[GZIP filehandle_read EOF] adbMetaAdd(%s, %"PRId64", GZIP, [%02x %02x %02x %02x %02x %02x %02x %02x] (%"PRIu64" + %d => %"PRIu64")\n", filename, compressedfile_size, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], s->realpos, s->outputbuffer_fill, filesize); + DEBUG_PRINT ("[GZIP filehandle_read EOF] adbMetaAdd(%s, %"PRIu64", GZIP, [%02x %02x %02x %02x %02x %02x %02x %02x] (%"PRIu64" + %d => %"PRIu64")\n", filename, compressedfile_size, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], s->realpos, s->outputbuffer_fill, filesize); adbMetaAdd (filename, compressedfile_size, "GZIP", buffer, 8); } @@ -521,7 +521,7 @@ static uint64_t gzip_ocpfile_filesize (struct ocpfile_t *_s) compressedfile_size = s->compressedfile->filesize (s->compressedfile); uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; if ((compressedfile_size < 12) || (compressedfile_size == FILESIZE_ERROR) || (compressedfile_size == FILESIZE_STREAM)) { @@ -545,9 +545,11 @@ static uint64_t gzip_ocpfile_filesize (struct ocpfile_t *_s) ((uint64_t)(metadata[0])); free (metadata); - DEBUG_PRINT ("[GZIP ocpfile_filesize]: got metadatasize=0x%08lx %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], s->uncompressed_filesize); + DEBUG_PRINT ("[GZIP ocpfile_filesize]: got metadatasize=0x%08"PRIu32" %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], s->uncompressed_filesize); return s->uncompressed_filesize; + } else { + DEBUG_PRINT ("[GZIP ocpfile_filesize]: got metadatasize=0x%08"PRIu32", unexpected size\n", metadatasize); } free (metadata); /* wrong size???... */ metadata = 0; @@ -865,7 +867,7 @@ static struct ocpdir_t *gzip_check_steal (struct ocpfile_t *s, const uint32_t di if (s->filesize_ready (s)) { unsigned char *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; const char *filename = 0; dirdbGetName_internalstr (retval->child.compressedfile->dirdb_ref, &filename); @@ -884,8 +886,9 @@ static struct ocpdir_t *gzip_check_steal (struct ocpfile_t *s, const uint32_t di ((uint64_t)(metadata[1]) << 8) | ((uint64_t)(metadata[0])); - DEBUG_PRINT ("[GZIP gzip_check_steal]: got metadatasize=0x%08lx %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], retval->child.uncompressed_filesize); - + DEBUG_PRINT ("[GZIP gzip_check_steal]: got metadatasize=0x%08"PRIu32" %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], retval->child.uncompressed_filesize); + } else { + DEBUG_PRINT ("[GZIP gzip_check_steal]: got metadatasize=0x%08"PRIu32", unexpected size\n", metadatasize); } free (metadata); metadata = 0; diff --git a/filesel/filesystem-pak.c b/filesel/filesystem-pak.c index 1e6de68f..1214f252 100644 --- a/filesel/filesystem-pak.c +++ b/filesel/filesystem-pak.c @@ -162,7 +162,7 @@ static uint32_t pak_instance_add (struct pak_instance_t *self, const uint32_t fileoffset); /* in the blob, we will switch / into \0 temporary as we parse them */ -static void pak_instance_decode_blob (struct pak_instance_t *self, uint8_t *blob, size_t blobsize) +static void pak_instance_decode_blob (struct pak_instance_t *self, uint8_t *blob, uint32_t blobsize) { uint8_t *eos; @@ -218,7 +218,7 @@ static void pak_instance_decode_blob (struct pak_instance_t *self, uint8_t *blob #endif } -static void pak_instance_encode_blob (struct pak_instance_t *self, uint8_t **blob, size_t *blobfill) +static void pak_instance_encode_blob (struct pak_instance_t *self, uint8_t **blob, uint32_t *blobfill) { uint32_t counter; uint32_t blobsize = 0; @@ -607,7 +607,7 @@ struct ocpdir_t *pak_check (const struct ocpdirdecompressor_t *self, struct ocpf { const char *filename = 0; uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; dirdbGetName_internalstr (iter->archive_file->dirdb_ref, &filename); if (!adbMetaGet (filename, iter->archive_file->filesize (iter->archive_file), "PAK", &metadata, &metadatasize)) @@ -632,7 +632,7 @@ struct ocpdir_t *pak_check (const struct ocpdirdecompressor_t *self, struct ocpf if (iter->file_fill) { uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; const char *filename = 0; pak_instance_encode_blob (iter, &metadata, &metadatasize); @@ -1177,10 +1177,10 @@ static void pak_translate_complete (struct pak_instance_t *self) static void pak_translate (struct pak_instance_t *self, char *src, char **buffer, int *buffersize) { char *temp; - size_t srclen; + uint32_t srclen; char *dst = *buffer; - size_t dstlen = *buffersize; + uint32_t dstlen = *buffersize; DEBUG_PRINT ("pak_translate %s =>", src); @@ -1278,7 +1278,7 @@ static void pak_set_byuser_string (struct ocpdir_t *_self, const char *byuser) /* update adbMeta */ { uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; const char *filename = 0; pak_instance_encode_blob (self->owner, &metadata, &metadatasize); diff --git a/filesel/filesystem-rpg.c b/filesel/filesystem-rpg.c index 557f213f..6bf913fa 100644 --- a/filesel/filesystem-rpg.c +++ b/filesel/filesystem-rpg.c @@ -132,7 +132,7 @@ static uint32_t rpg_instance_add_file (struct rpg_instance_t *self, const uint64_t fileoffset); /* in the blob, we will switch / into \0 temporary as we parse them */ -static void rpg_instance_decode_blob (struct rpg_instance_t *self, uint8_t *blob, size_t blobsize) +static void rpg_instance_decode_blob (struct rpg_instance_t *self, uint8_t *blob, uint32_t blobsize) { uint8_t *eos; @@ -178,7 +178,7 @@ static void rpg_instance_decode_blob (struct rpg_instance_t *self, uint8_t *blob } } -static void rpg_instance_encode_blob (struct rpg_instance_t *self, uint8_t **blob, size_t *blobfill) +static void rpg_instance_encode_blob (struct rpg_instance_t *self, uint8_t **blob, uint32_t *blobfill) { uint32_t counter; uint32_t blobsize = 0; @@ -380,7 +380,7 @@ struct ocpdir_t *rpg_check (const struct ocpdirdecompressor_t *self, struct ocpf { const char *filename = 0; uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; dirdbGetName_internalstr (iter->archive_file->dirdb_ref, &filename); if (!adbMetaGet (filename, iter->archive_file->filesize (iter->archive_file), "RPG", &metadata, &metadatasize)) @@ -611,7 +611,7 @@ static int rpg_dir_readdir_iterate (ocpdirhandle_pt _self) { const char *filename; uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; finished: self->dir->owner->ready = 1; rpg_instance_encode_blob (self->dir->owner, &metadata, &metadatasize); diff --git a/filesel/filesystem-tar-test.c b/filesel/filesystem-tar-test.c index 88e5ab1c..dab61616 100644 --- a/filesel/filesystem-tar-test.c +++ b/filesel/filesystem-tar-test.c @@ -2134,10 +2134,10 @@ void register_dirdecompressor(const struct ocpdirdecompressor_t *odd) } static char *adbmeta_filename; -static size_t adbmeta_filesize; +static uint64_t adbmeta_filesize; static char *adbmeta_SIG; static unsigned char *adbmeta_data; -static size_t adbmeta_datasize; +static uint32_t adbmeta_datasize; void adbMetaClear(void) { @@ -2151,7 +2151,7 @@ void adbMetaClear(void) adbmeta_datasize = 0; } -int adbMetaAdd (const char *filename, const size_t filesize, const char *SIG, const unsigned char *data, const size_t datasize) +int adbMetaAdd (const char *filename, const uint64_t filesize, const char *SIG, const unsigned char *data, const uint32_t datasize) { adbMetaClear (); adbmeta_filename = strdup (filename); @@ -2164,7 +2164,7 @@ int adbMetaAdd (const char *filename, const size_t filesize, const char *SIG, co return 0; } -int adbMetaGet (const char *filename, const size_t filesize, const char *SIG, unsigned char **data, size_t *datasize) +int adbMetaGet (const char *filename, const uint64_t filesize, const char *SIG, unsigned char **data, uint32_t *datasize) { if (!adbmeta_filename) { diff --git a/filesel/filesystem-tar.c b/filesel/filesystem-tar.c index b0f2378f..dcc80a5e 100644 --- a/filesel/filesystem-tar.c +++ b/filesel/filesystem-tar.c @@ -162,7 +162,7 @@ static uint32_t tar_instance_add (struct tar_instance_t *self, const uint64_t fileoffset); /* in the blob, we will switch / into \0 temporary as we parse them */ -static void tar_instance_decode_blob (struct tar_instance_t *self, uint8_t *blob, size_t blobsize) +static void tar_instance_decode_blob (struct tar_instance_t *self, uint8_t *blob, uint32_t blobsize) { uint8_t *eos; @@ -221,7 +221,7 @@ static void tar_instance_decode_blob (struct tar_instance_t *self, uint8_t *blob tar_translate_complete (self); } -static void tar_instance_encode_blob (struct tar_instance_t *self, uint8_t **blob, size_t *blobfill) +static void tar_instance_encode_blob (struct tar_instance_t *self, uint8_t **blob, uint32_t *blobfill) { uint32_t counter; uint32_t blobsize = 0; @@ -595,7 +595,7 @@ struct ocpdir_t *tar_check (const struct ocpdirdecompressor_t *self, struct ocpf { const char *filename = 0; uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; dirdbGetName_internalstr (iter->archive_file->dirdb_ref, &filename); if (!adbMetaGet (filename, iter->archive_file->filesize (iter->archive_file), "TAR", &metadata, &metadatasize)) @@ -886,7 +886,7 @@ static int tar_dir_readdir_iterate (ocpdirhandle_pt _self) { const char *filename; uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; self->dir->owner->ready = 1; // tar_translate_complete (iter); /* in theory, two instances might scan at the same time, so we only clean-up then in the destructor @@ -1120,7 +1120,7 @@ static struct ocpfilehandle_t *tar_file_open (struct ocpfile_t *_self) retval->file = self; - DEBUG_PRINT ("We just created a TAR handle, REF the source\n"); + DEBUG_PRINT ("We just created a TAR handle, REF the source: \"%s\"\n", self->orig_full_filepath); tar_instance_ref (self->owner); tar_io_ref (self->owner); @@ -1362,7 +1362,7 @@ static void tar_set_byuser_string (struct ocpdir_t *_self, const char *byuser) /* update adbMeta */ { uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; const char *filename = 0; tar_instance_encode_blob (self->owner, &metadata, &metadatasize); diff --git a/filesel/filesystem-z.c b/filesel/filesystem-z.c index 9447e63b..53e86e76 100644 --- a/filesel/filesystem-z.c +++ b/filesel/filesystem-z.c @@ -344,7 +344,7 @@ static int Z_ocpfilehandle_read (struct ocpfilehandle_t *_s, void *dst, int len) dirdbGetName_internalstr (s->compressedfilehandle->dirdb_ref, &filename); - DEBUG_PRINT ("[Z filehandle_read EOF] adbMetaAdd(%s, %"PRId64", Z, [%02x %02x %02x %02x %02x %02x %02x %02x] %"PRIu64"\n", filename, compressedfile_size, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], filesize); + DEBUG_PRINT ("[Z filehandle_read EOF] adbMetaAdd(%s, %"PRIu64", Z, [%02x %02x %02x %02x %02x %02x %02x %02x] %"PRIu64"\n", filename, compressedfile_size, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], filesize); adbMetaAdd (filename, compressedfile_size, "Z", buffer, 8); } } @@ -451,7 +451,7 @@ static uint64_t Z_ocpfile_filesize (struct ocpfile_t *_s) compressedfile_size = s->compressedfile->filesize (s->compressedfile); uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; if ((compressedfile_size < 12) || (compressedfile_size == FILESIZE_ERROR) || (compressedfile_size == FILESIZE_STREAM)) { @@ -475,9 +475,11 @@ static uint64_t Z_ocpfile_filesize (struct ocpfile_t *_s) ((uint64_t)(metadata[0])); free (metadata); - DEBUG_PRINT ("[Z ocpfile_filesize]: got metadatasize=0x%08lx %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], s->uncompressed_filesize); + DEBUG_PRINT ("[Z ocpfile_filesize]: got metadatasize=0x%08"PRIu32" %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], s->uncompressed_filesize); return s->uncompressed_filesize; + } else { + DEBUG_PRINT ("[Z ocpfile_filesize]: got metadatasize=0x%08"PRIu32", unexpected size\n", metadatasize); } free (metadata); /* wrong size???... */ metadata = 0; @@ -746,7 +748,7 @@ static struct ocpdir_t *Z_check_steal (struct ocpfile_t *s, const uint32_t dirdb if (s->filesize_ready (s)) { unsigned char *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; const char *filename = 0; dirdbGetName_internalstr (retval->child.compressedfile->dirdb_ref, &filename); @@ -765,8 +767,9 @@ static struct ocpdir_t *Z_check_steal (struct ocpfile_t *s, const uint32_t dirdb ((uint64_t)(metadata[1]) << 8) | ((uint64_t)(metadata[0])); - DEBUG_PRINT ("[Z Z_check_steal]: got metadatasize=0x%08lx %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], retval->child.uncompressed_filesize); - + DEBUG_PRINT ("[Z Z_check_steal]: got metadatasize=0x%08"PRIu32" %02x %02x %02x %02x %02x %02x %02x %02x => %"PRIu64"\n", metadatasize, metadata[0], metadata[1], metadata[2], metadata[3], metadata[4], metadata[5], metadata[6], metadata[7], retval->child.uncompressed_filesize); + } else { + DEBUG_PRINT ("[Z ocpfile_filesize]: got metadatasize=0x%08"PRIu32", unexpected size\n", metadatasize); } free (metadata); metadata = 0; diff --git a/filesel/filesystem-zip.c b/filesel/filesystem-zip.c index 525e0d3d..057a35bc 100644 --- a/filesel/filesystem-zip.c +++ b/filesel/filesystem-zip.c @@ -207,7 +207,7 @@ static uint32_t zip_instance_add (struct zip_instance_t *self, const uint32_t DiskNumber, const uint64_t OffsetLocalHeader); -static void zip_instance_decode_blob (struct zip_instance_t *self, uint8_t *blob, size_t blobsize) +static void zip_instance_decode_blob (struct zip_instance_t *self, uint8_t *blob, uint32_t blobsize) { uint8_t *eos; @@ -294,7 +294,7 @@ static void zip_instance_decode_blob (struct zip_instance_t *self, uint8_t *blob zip_translate_complete (self); } -static void zip_instance_encode_blob (struct zip_instance_t *self, uint8_t **blob, size_t *blobfill) +static void zip_instance_encode_blob (struct zip_instance_t *self, uint8_t **blob, uint32_t *blobfill) { uint32_t counter; uint32_t blobsize = 0; @@ -1022,7 +1022,7 @@ static int zip_scan (struct zip_instance_t *self) { uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; const char *filename = 0; zip_instance_encode_blob (self, &metadata, &metadatasize); @@ -1111,7 +1111,7 @@ static struct ocpdir_t *zip_check (const struct ocpdirdecompressor_t *self, stru { const char *filename = 0; uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; dirdbGetName_internalstr (iter->archive_file->dirdb_ref, &filename); if (!adbMetaGet (filename, iter->archive_file->filesize (iter->archive_file), "ZIP", &metadata, &metadatasize)) @@ -2441,7 +2441,7 @@ static void zip_set_byuser_string (struct ocpdir_t *_self, const char *byuser) /* update adbMeta */ { uint8_t *metadata = 0; - size_t metadatasize = 0; + uint32_t metadatasize = 0; const char *filename = 0; zip_instance_encode_blob (self->owner, &metadata, &metadatasize); diff --git a/medialib/medialib.c b/medialib/medialib.c index 5e662eb7..8bee67cf 100644 --- a/medialib/medialib.c +++ b/medialib/medialib.c @@ -94,7 +94,7 @@ static int ocpdir_search_readdir_iterate (ocpdirhandle_pt); static struct ocpdir_t *ocpdir_search_readdir_dir (struct ocpdir_t *self, uint32_t dirdb_ref); static struct ocpfile_t *ocpdir_search_readdir_file (struct ocpdir_t *self, uint32_t dirdb_ref); -static void medialib_decode_blob (uint8_t *blob, size_t blobsize) +static void medialib_decode_blob (uint8_t *blob, uint32_t blobsize) { uint8_t *eos; @@ -126,7 +126,7 @@ static void medialib_decode_blob (uint8_t *blob, size_t blobsize) } } -static void medialib_encode_blob (uint8_t **blob, size_t *blobsize) +static void medialib_encode_blob (uint8_t **blob, uint32_t *blobsize) { int i; char *ptr; @@ -159,7 +159,7 @@ static void medialib_encode_blob (uint8_t **blob, size_t *blobsize) static void mlFlushBlob (void) { uint8_t *data = 0; - size_t datasize = 0; + uint32_t datasize = 0; medialib_encode_blob (&data, &datasize); if (datasize) { @@ -186,7 +186,7 @@ static int mlint (const struct configAPI_t *configAPI) { struct ocpdir_t *r; unsigned char *data = 0; - size_t datasize = 0; + uint32_t datasize = 0; medialib_root = ocpdir_mem_alloc (0, "medialib:"); if (!medialib_root)