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

Revision 23178, 564 bytes checked in by broder, 16 years ago (diff)
Take a new snapshot from CVS for Moira, and add a debathena-moira-update-server package
Line 
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>.
6 */
7
8#include <mit-copyright.h>
9#include <moira.h>
10#include "update_server.h"
11
12#include <stdio.h>
13
14RCSID("$Header$");
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.