source: trunk/third/moira/update/checksum.c @ 24250

Revision 24250, 729 bytes checked in by broder, 15 years ago (diff)
New Moira snapshot from subversion. Sorry for the large diff - looks like all of the keywords changed in the SVN import process.
Line 
1/* $Id: checksum.c,v 1.9 1998-02-15 17:49:26 danw Exp $
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
14RCSID("$Header: /afs/.athena.mit.edu/astaff/project/moiradev/repository/moira/update/checksum.c,v 1.9 1998-02-15 17:49:26 danw Exp $");
15
16/*
17 * checksum_fd(fd)
18 * returns 24-bit checksum of bytes in file
19 */
20
21long 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.