(svn r11695) -Codechange: Converted the md5 algorithm to OOP

-Codechange: Adapt the md5 algorithm to the OpenTTD source
This commit is contained in:
skidd13
2007-12-25 13:59:21 +00:00
parent b3f6c0734b
commit 7963963d98
7 changed files with 240 additions and 312 deletions

View File

@@ -32,8 +32,8 @@ GRFConfig *_grfconfig_static;
static bool CalcGRFMD5Sum(GRFConfig *config)
{
FILE *f;
md5_state_t md5state;
md5_byte_t buffer[1024];
Md5 checksum;
uint8 buffer[1024];
size_t len, size;
/* open the file */
@@ -41,12 +41,11 @@ static bool CalcGRFMD5Sum(GRFConfig *config)
if (f == NULL) return false;
/* calculate md5sum */
md5_init(&md5state);
while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) {
size -= len;
md5_append(&md5state, buffer, len);
checksum.Append(buffer, len);
}
md5_finish(&md5state, config->md5sum);
checksum.Finish(config->md5sum);
FioFCloseFile(f);