Esempio n. 1
0
void nr_ice_compute_codeword(char *buf, int len,char *codeword)
{
    int _status;
    UINT4 c;
    char *base_codeword;

    r_crc32(buf,len,&c);
    c %= 2048;

    base_codeword=dictionary[c];

    /* Copy the codeword but padded right with _ */
    memset(codeword,'_',4);
    codeword[4]=0;
    memcpy(codeword,base_codeword,strlen(base_codeword));

    _status=0;
    return;
}
Esempio n. 2
0
File: rcrc.c Progetto: ieei/rlib
#include <rlib/rlib.h>


static const rchar * r_crc_test_vec = "123456789";
static const rsize   r_crc_test_vec_size = 9;

RTEST (rcrc, crc32, RTEST_FAST)
{
  r_assert_cmphex (r_crc32 (r_crc_test_vec, 0), ==, 0);
  r_assert_cmphex (r_crc32 (r_crc_test_vec, r_crc_test_vec_size), ==, 0xcbf43926);
}
RTEST_END;

RTEST (rcrc, crc32c, RTEST_FAST)
{
  r_assert_cmphex (r_crc32c (r_crc_test_vec, 0), ==, 0);
  r_assert_cmphex (r_crc32c (r_crc_test_vec, r_crc_test_vec_size), ==, 0xe3069283);
}
RTEST_END;

RTEST (rcrc, crc32bzip, RTEST_FAST)
{
  r_assert_cmphex (r_crc32bzip2 (r_crc_test_vec, 0), ==, 0);
  r_assert_cmphex (r_crc32bzip2 (r_crc_test_vec, r_crc_test_vec_size), ==, 0xfc891918);
}
RTEST_END;