2023-06-12 20:36:16 +03:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
for (int i = 1; i < argc; i++)
|
|
|
|
{
|
|
|
|
FILE* fp = fopen(argv[i], "r");
|
|
|
|
if (fp == nullptr)
|
|
|
|
{
|
2023-06-19 10:31:23 +03:00
|
|
|
perror("fopen");
|
2023-06-12 20:36:16 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t sum = 0;
|
|
|
|
|
|
|
|
uint8_t buffer[1024];
|
|
|
|
while (size_t ret = fread(buffer, 1, sizeof(buffer), fp))
|
2023-12-10 19:20:14 +02:00
|
|
|
for (size_t j = 0; j < ret; j++)
|
2023-06-12 20:36:16 +03:00
|
|
|
sum += buffer[j];
|
|
|
|
|
|
|
|
if (ferror(fp))
|
|
|
|
perror("fread");
|
|
|
|
else
|
|
|
|
printf("%s: %02x\n", argv[i], sum);
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|