Skip to content
  • This project
    • Loading...
  • Sign in

Barry / rf-depot

Go to a project
Toggle navigation
Toggle navigation pinning
  • Projects
  • Groups
  • Snippets
  • Help
  • Project
  • Activity
  • Repository
  • Graphs
  • Network
  • Create a new issue
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Network
  • Compare
  • Branches
  • Tags
Switch branch/tag
  • rf-depot
  • sw
  • bbplayer
  • lib
  • libbbc
  • Tests
  • cksum.c
  • root's avatar
    initial commit · bc83a1ad
    bc83a1ad
    root committed 2020-05-02 05:58:04 +0000
cksum.c 346 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <stdio.h>

int main(int args, char **argv)
{
	FILE *f;
	unsigned short sum=0, data;
	char line[128];

	if (argv[1] == NULL) return -1;
	f = fopen(argv[1], "rb");
	if (!f) return -2;

	while (fgets(line,64,f)) {
		if (feof(f)) break;
		data = (unsigned short) strtoul(line, NULL, 16);
		sum += data;
	}
	printf("%04x", sum);
	return 0;
}