From 772312762986a7ec36262069a28ad3d4dde30559 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 28 Nov 2025 00:38:24 -0500 Subject: Project has been renamed, use https://slackware.uk/~urchlay/repos/alftools --- src/alfsum.c | 54 ------------------------------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 src/alfsum.c (limited to 'src/alfsum.c') diff --git a/src/alfsum.c b/src/alfsum.c deleted file mode 100644 index 2456e60..0000000 --- a/src/alfsum.c +++ /dev/null @@ -1,54 +0,0 @@ -#include "unalf.h" - -/* 20251104 bkw: implement the simple checksum used by ALF. - Dumbest possible algo: all the bytes are added together and - the bottom 16 bits of the result is the checksum. */ - -void alfsum(const char *file, FILE *f) { - int c; - unsigned long sum = 0; - - while((c = fgetc(f)) != EOF) - sum += c; - - printf("%04x\t%s\n", (unsigned int)(sum & 0xffff), file); -} - -int main(int argc, char **argv) { - int errs = 0; - char *file; - FILE *f; - - set_self(argv[0]); - - if(argc < 2 || !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) { - printf("alfsum v" VERSION " by B. Watson. WTFPL.\n" - "Usage: %s filename [filename(s) ...]\n" - "\t(use - to read from standard input)\n", - self); - return (argc < 2) ? -1 : 0; - } - - if(!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) { - puts(VERSION); - exit(0); - } - - while((file = *++argv)) { - if(argv[0][0] == '-' && !argv[0][1]) { - if(isatty(0)) - fprintf(stderr, "%s: reading from stdin...\n", self); - f = stdin; - file = " (stdin)"; - } else if(!(f = fopen(file, "rb"))) { - fprintf(stderr, "%s: ", self); - perror(file); - errs++; - continue; - } - alfsum(file, f); - fclose(f); - } - - return errs > 254 ? 254 : errs; -} -- cgit v1.2.3