mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
wip
This commit is contained in:
@ -215,11 +215,19 @@ int verifyChecksumFromFile(char *mess, char *clientChecksum, char *fname, ssize_
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
const int readUnitSize = 128;
|
const int readUnitSize = 128;
|
||||||
char buf[readUnitSize];
|
char buf[readUnitSize + 1];
|
||||||
buf[0]=0xf;
|
bytes = fread(buf, 1, readUnitSize + 1, fp);
|
||||||
ssize_t bytes = 1;
|
// the first time, extra bytes are read
|
||||||
ssize_t totalBytesRead = bytes;
|
ssize_t totalBytesRead = bytes - 1;
|
||||||
|
char lastByte = buf[0];
|
||||||
|
// bytes = 128
|
||||||
while (bytes > 0) {
|
while (bytes > 0) {
|
||||||
|
buf[0] = lastbyte;
|
||||||
|
// shift by 4 bits to the left
|
||||||
|
for (int i = 0; i < bytes; ++i) {
|
||||||
|
buf[i] = ((buf[i] & 0xf) << 4) + ((buf[i + 1] >> 4) & 0xf);
|
||||||
|
}
|
||||||
|
lastbyte = buf[bytes];
|
||||||
if (!MD5_Update(&c, buf, bytes)) {
|
if (!MD5_Update(&c, buf, bytes)) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
strcpy(mess, "Unable to calculate checksum (MD5_Update)\n");
|
strcpy(mess, "Unable to calculate checksum (MD5_Update)\n");
|
||||||
@ -231,7 +239,7 @@ int verifyChecksumFromFile(char *mess, char *clientChecksum, char *fname, ssize_
|
|||||||
LOG(logINFOBLUE, ("\tReached %lu bytes. Not reading more\n", totalBytesRead));
|
LOG(logINFOBLUE, ("\tReached %lu bytes. Not reading more\n", totalBytesRead));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bytes = fread(buf, 1, readUnitSize, fp);
|
bytes = fread(buf + 1, 1, readUnitSize, fp);
|
||||||
totalBytesRead += bytes;
|
totalBytesRead += bytes;
|
||||||
}
|
}
|
||||||
// last null character (if size does not match)
|
// last null character (if size does not match)
|
||||||
|
Reference in New Issue
Block a user