Revision 24319,
726 bytes
checked in by broder, 15 years ago
(diff) |
New Moira snapshot from SVN.
|
Line | |
---|
1 | /* $Id: checksum.c 3956 2010-01-05 20:56:56Z zacheiss $ |
---|
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>. |
---|
6 | */ |
---|
7 | |
---|
8 | #include <mit-copyright.h> |
---|
9 | #include <moira.h> |
---|
10 | #include "update_server.h" |
---|
11 | |
---|
12 | #include <stdio.h> |
---|
13 | |
---|
14 | RCSID("$HeadURL: svn+ssh://svn.mit.edu/moira/trunk/moira/update/checksum.c $ $Id: checksum.c 3956 2010-01-05 20:56:56Z zacheiss $"); |
---|
15 | |
---|
16 | /* |
---|
17 | * checksum_fd(fd) |
---|
18 | * returns 24-bit checksum of bytes in file |
---|
19 | */ |
---|
20 | |
---|
21 | long checksum_file(char *path) |
---|
22 | { |
---|
23 | long sum; |
---|
24 | int ch; |
---|
25 | FILE *f; |
---|
26 | |
---|
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; |
---|
33 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.