int
igchecksum (z, c)
register const char *z;
register int c;
{
register unsigned int ichk1, ichk2;
ichk1 = 0xffff;
ichk2 = 0;
do
{
register unsigned int b;
/* Rotate ichk1 left. */
if ((ichk1 & 0x8000) == 0)
ichk1 <<= 1;
else
{
ichk1 <<= 1;
++ichk1;
}
/* Add the next character to ichk1. */
b = *z++ & 0xff;
ichk1 += b;
/* Add ichk1 xor the character position in
the buffer counting from the back to ichk2. */
ichk2 += ichk1 ^ c;
/* If the character was zero, or adding it to
ichk1 caused an overflow, xor ichk2 to ichk1. */
if (b == 0 || (ichk1 & 0xffff) < b)
ichk1 ^= ichk2;
}
while (--c > 0);
return ichk1 & 0xffff;
}
/* End of File */