authparity.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*/
#include "ntp_stdlib.h"
int
{
int parity_err;
int bitcount;
int half;
int byte;
int i;
/*
* Go through counting bits in each byte. Check to see if
* each parity bit was set correctly. If not, note the error
* and set it right.
*/
parity_err = 0;
mask = 0x80000000;
bitcount = 0;
for (i = 0; i < 7; i++) { /* 7 data bits / byte */
bitcount++;
mask >>= 1;
}
/*
* If bitcount is even, parity must be set. If
* bitcount is odd, parity must be clear.
*/
if ((bitcount & 0x1) == 0) {
parity_err++;
}
} else {
parity_err++;
}
}
mask >>= 1;
}
}
/*
* Return the result of the parity check.
*/
return (parity_err == 0);
}