#include "../tdkpin_resources.h" #include #include static void hash_u16(uint64_t *hash, uint16_t value) { for (unsigned byte = 0; byte < 2; byte++) { *hash ^= (uint8_t)(value >> (byte * 8)); *hash *= UINT64_C(1099511628211); } } static void hash_u32(uint64_t *hash, uint32_t value) { for (unsigned byte = 0; byte < 4; byte++) { *hash ^= (uint8_t)(value >> (byte * 8)); *hash *= UINT64_C(1099511628211); } } int main(void) { size_t direct = 0; size_t system_resolved = 0; size_t linked_unused = 0; uint64_t manifest_fields_hash = UINT64_C(14695981039346656037); for (size_t index = 0; index < TDKPIN_RESOURCE_COUNT; index++) { const TdkpinResourceDescriptor *entry = &tdkpin_resource_catalog[index]; assert(entry->meaningful_size > 0); assert(entry->meaningful_size <= entry->allocated_size); assert(entry->role != NULL && entry->role[0] != '\0'); for (size_t earlier = 0; earlier < index; earlier++) { assert(entry->type != tdkpin_resource_catalog[earlier].type || entry->id != tdkpin_resource_catalog[earlier].id); } if (entry->disposition == TDKPIN_RESOURCE_DIRECT) { direct++; } else if (entry->disposition == TDKPIN_RESOURCE_SYSTEM_RESOLVED) { system_resolved++; } else { assert(entry->disposition == TDKPIN_RESOURCE_LINKED_UNUSED); linked_unused++; } hash_u16(&manifest_fields_hash, (uint16_t)entry->type); hash_u16(&manifest_fields_hash, entry->id); hash_u32(&manifest_fields_hash, entry->file_offset); hash_u32(&manifest_fields_hash, entry->allocated_size); hash_u32(&manifest_fields_hash, entry->meaningful_size); hash_u16(&manifest_fields_hash, entry->flags); hash_u16(&manifest_fields_hash, entry->width); hash_u16(&manifest_fields_hash, entry->height); hash_u32(&manifest_fields_hash, entry->sample_rate); } assert(direct == 57); assert(system_resolved == 2); assert(linked_unused == 4); assert(manifest_fields_hash == UINT64_C(0x29d77e86100b5e75)); assert(tdkpin_resource_catalog[0].type == TDKPIN_RESOURCE_DAT); assert(tdkpin_resource_catalog[0].id == 400); assert(tdkpin_resource_catalog[62].type == TDKPIN_RESOURCE_DIALOG); assert(tdkpin_resource_catalog[62].id == 32517); assert(strcmp(tdkpin_resource_catalog[54].role, "image selected by GROUP_ICON 996") == 0); return 0; }