void str_bitmove( unsigned char * _buf, int _len, char _mflag, int _mnum )
{
int i,j;
unsigned char p_bit=0, c_bit;
if( _buf == NULL || _len == 0 || _mnum <= 0 ||
( _mflag!='R' && _mflag!='r' && _mflag!='L' && _mflag!='l' ) )
return;
if( _len*8 < _mnum )
_mnum = _len*8;
if( _mflag == 'R' || _mflag == 'r' ) {
for( i=0; i<_mnum; i++ ) {
for( j=0; j<_len; j++ ) {
c_bit = _buf[j] & 0x01;
_buf[j] >>= 1;
if( j > 0 && p_bit == 0x01 )
_buf[j] |= 0x80;
p_bit = c_bit;
}
}
}
else {
for( i=0; i<_mnum; i++ ) {
for( j=_len-1; j>=0; j-- ) {
c_bit = _buf[j] & 0x80;
_buf[j] <<= 1;
if( j < _len-1 && p_bit == 0x80 )
_buf[j] |= 0x01;
p_bit = c_bit;
}
}
}
return;
}
阅读(1520) | 评论(0) | 转发(0) |