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