]> andersk Git - moira.git/blame_incremental - update/checksum.c
#define MR_INGRES_ERR and MR_INGRES_SOFTFAIL for backward compatibility
[moira.git] / update / checksum.c
... / ...
CommitLineData
1/*
2 * $Source$
3 * $Header$
4 */
5/* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
6/* For copying and distribution information, please see the file */
7/* <mit-copyright.h>. */
8
9#ifndef lint
10static char *rcsid_checksum_c = "$Header$";
11#endif lint
12
13#include <mit-copyright.h>
14#include <stdio.h>
15#include <sys/types.h>
16#include <sys/file.h>
17
18/*
19 * checksum_fd(fd)
20 * returns 24-bit checksum of bytes in file
21 */
22
23int
24checksum_file(path)
25char *path;
26{
27 register int sum;
28 register int ch;
29 register FILE *f;
30
31 sum = 0;
32 f = fopen(path, "r");
33 while ((ch = getc(f)) != EOF) {
34 sum = (sum + ch) & ((1<<24)-1);
35 }
36 fclose(f);
37 return(sum);
38}
This page took 0.720929 seconds and 5 git commands to generate.