请高手把下面一段转换成Delphi语言,在线等待....
/*
* Calculate a new fcs given the current fcs and the new data.
*/
__u16 pppfcs16(fcs, cp, len)
register __u16 fcs;
register unsigned char *cp;
register int len;
{
while (len--)
fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff];
return (fcs);
}
/*
* generate CRC16
*/
__u16 gen_fcs16(unsigned char *cp, int len)
{
__u16 fcs;
/* add on output */
fcs = pppfcs16(PPP_INITFCS, cp, len);
fcs ^= 0xffff; /* complement */
return fcs;
/*
cp[len] = (fcs & 0x00ff); // least significant byte first
cp[len+1] = ((fcs >> 8) & 0x00ff);
*/
}
/*
* check received data block
*/
__u16 chk_fcs16(unsigned char *cp, int len)
{
__u16 fcs;
fcs = pppfcs16(PPP_INITFCS, cp, len);
return fcs;
/*
if (fcs == PPP_GOODFCS)
return SUCCESS;
*/
}