]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * $Source$ | |
3 | * $Header$ | |
4 | */ | |
5 | ||
6 | #ifndef lint | |
7 | static char *rcsid_checksum_c = "$Header$"; | |
8 | #endif lint | |
9 | ||
10 | #include <stdio.h> | |
11 | #include <sys/file.h> | |
12 | ||
13 | /* | |
14 | * checksum_fd(fd) | |
15 | * returns 24-bit checksum of bytes in file | |
16 | */ | |
17 | ||
18 | int | |
19 | checksum_file(path) | |
20 | char *path; | |
21 | { | |
22 | register int sum; | |
23 | register int ch; | |
24 | register FILE *f; | |
25 | ||
26 | sum = 0; | |
27 | f = fopen(path, "r"); | |
28 | while ((ch = getc(f)) != EOF) { | |
29 | sum = (sum + ch) & ((1<<24)-1); | |
30 | } | |
31 | fclose(f); | |
32 | return(sum); | |
33 | } |