Based on the comments of Chris Jester-Young and piCookie, I developed the following function. I hope you find it useful.
int fileCheckSum(const char *fileName)
{
FILE *fp;
long fileSize;
char *fileBuffer;
size_t result;
int sum = 0;
long index;
fp = fopen(fileName, "rb");
if (fp == NULL)
{
fputs ("File error",stderr);
exit (1);
}
fseek(fp, 0L, SEEK_END);
fileSize = ftell(fp);
fseek(fp, 0L, SEEK_SET);
fileBuffer = (char*) malloc (sizeof(char) * fileSize);
if (fileBuffer == NULL)
{
fputs ("Memory error",stderr);
exit (2);
}
result = fread(fileBuffer, 1, fileSize, fp);
if (result != fileSize)
{
fputs ("Reading error", stderr);
if (fileBuffer != NULL)
free(fileBuffer);
exit (3);
}
for (index = 0; index < fileSize; index++)
{
sum += fileBuffer[index] & 255;
}
fclose(fp);
if (fileBuffer != NULL)
free(fileBuffer);
return sum % 32767;
}