]>
Commit | Line | Data |
---|---|---|
de56407f | 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 | |
b18a5f6d | 19 | checksum_file(path) |
20 | char *path; | |
de56407f | 21 | { |
de56407f | 22 | register int sum; |
23 | register int ch; | |
24 | register FILE *f; | |
25 | ||
de56407f | 26 | sum = 0; |
b18a5f6d | 27 | f = fopen(path, "r"); |
de56407f | 28 | while ((ch = getc(f)) != EOF) { |
29 | sum = (sum + ch) & ((1<<24)-1); | |
30 | } | |
31 | fclose(f); | |
32 | return(sum); | |
33 | } |