]>
Commit | Line | Data |
---|---|---|
7ac48069 | 1 | /* $Id$ |
2 | * | |
3 | * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology. | |
4 | * For copying and distribution information, please see the file | |
5 | * <mit-copyright.h>. | |
de56407f | 6 | */ |
de56407f | 7 | |
546bc43b | 8 | #include <mit-copyright.h> |
7ac48069 | 9 | #include <moira.h> |
10 | #include "update_server.h" | |
11 | ||
de56407f | 12 | #include <stdio.h> |
7ac48069 | 13 | |
14 | RCSID("$Header$"); | |
de56407f | 15 | |
16 | /* | |
17 | * checksum_fd(fd) | |
18 | * returns 24-bit checksum of bytes in file | |
19 | */ | |
20 | ||
85330553 | 21 | long checksum_file(char *path) |
de56407f | 22 | { |
85330553 | 23 | long sum; |
44d12d58 | 24 | int ch; |
25 | FILE *f; | |
de56407f | 26 | |
5eaef520 | 27 | sum = 0; |
28 | f = fopen(path, "r"); | |
29 | while ((ch = getc(f)) != EOF) | |
30 | sum = (sum + ch) & ((1 << 24) - 1); | |
31 | fclose(f); | |
32 | return sum; | |
de56407f | 33 | } |