/*static char *SCCSID = "@(#)ccs.c	6.2 92/01/31";*/
#include <os2def.h>
#include "const.h"
#include "misc.h"
#include "chain.h"
#include "buf.h"
#include "dir.h"
#include "storage.h"
#include "volume.h"
#include "frame.h"
#include "tables.h"
#include "pr_MISC.h"


#define CCS_ROT 7

/*
 ***	CCS - Compute Checksum
 *
 *	CCS computes a simple 32-bit checksum of a byte string.
 *	The string isn't known to start on a quad byte boundary.
 *
 *	WARNING - CCS will produce a different checksum then CAS!
 *
 *	ENTRY	pbString = start address of string
 *		cb = byte count
 *
 *	EXIT	Returns checksum
 *
 *	HISTORY
 *	    15-Sep-1988 14:56 by Leif Pederson [leifp] resynch w/Gordon
 */

CHECKSUM
CCS (pbString, cb)
PBYTE pbString;
ULONG cb;
{
	ULONG ul;		/* loop counter */
	CHECKSUM cks = 0;	/* accumulator */

	for (ul = 0; ul < cb; ul++) {

		/* add in the byte, then rotate left by CCS_ROT */
		cks += (CHECKSUM) (*pbString++);
		cks = (cks << CCS_ROT) + (cks >> (32-CCS_ROT));
	}
	return (cks);
}
