(Database) Add MD5 and SHA1 entries

This commit is contained in:
twinaphex 2015-02-02 04:03:46 +01:00
parent 24d36c8d03
commit 298fdbea8a
3 changed files with 58 additions and 0 deletions

View File

@ -178,6 +178,44 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q
strlcpy(db_info->crc32, crc32, sizeof(db_info->crc32));
}
}
if (!strcmp(key->string.buff, "sha1"))
{
unsigned i;
db_info->sha1 = (char*)calloc(val->binary.len, sizeof(unsigned char));
if (db_info->sha1)
{
char sha1[PATH_MAX_LENGTH];
for (i = 0; i < val->binary.len; i++)
{
char sha1_cat[PATH_MAX_LENGTH];
snprintf(sha1_cat, sizeof(sha1_cat), "%02X", (unsigned char)val->binary.buff[i]);
strlcat(sha1, sha1_cat, sizeof(sha1));
}
strlcpy(db_info->sha1, sha1, sizeof(db_info->sha1));
}
}
if (!strcmp(key->string.buff, "md5"))
{
unsigned i;
db_info->md5 = (char*)calloc(val->binary.len, sizeof(unsigned char));
if (db_info->md5)
{
char md5[PATH_MAX_LENGTH];
for (i = 0; i < val->binary.len; i++)
{
char md5_cat[PATH_MAX_LENGTH];
snprintf(md5_cat, sizeof(md5_cat), "%02X", (unsigned char)val->binary.buff[i]);
strlcat(md5, md5_cat, sizeof(md5));
}
strlcpy(db_info->md5, md5, sizeof(db_info->md5));
}
}
}
i++;
}
@ -237,6 +275,10 @@ void database_info_list_free(database_info_list_t *database_info_list)
free(info->bbfc_rating);
if (info->crc32)
free(info->crc32);
if (info->sha1)
free(info->sha1);
if (info->md5)
free(info->md5);
}
free(database_info_list->list);

View File

@ -41,6 +41,8 @@ typedef struct
char *cero_rating;
char *enhancement_hw;
char *crc32;
char *sha1;
char *md5;
unsigned edge_magazine_rating;
unsigned edge_magazine_issue;
unsigned max_users;

View File

@ -992,6 +992,20 @@ static int deferred_push_rdb_entry_detail(void *data, void *userdata,
path, list) == -1)
return -1;
}
if (db_info_entry->sha1)
{
if (create_string_list_rdb_entry_string("SHA1 Checksum",
"rdb_entry_sha1", db_info_entry->sha1,
path, list) == -1)
return -1;
}
if (db_info_entry->md5)
{
if (create_string_list_rdb_entry_string("MD5 Checksum",
"rdb_entry_md5", db_info_entry->md5,
path, list) == -1)
return -1;
}
}
if (db_info->count < 1)