Annotation of libelwix/example/test_crc.c, revision 1.2
1.2 ! misho 1: #include <stdio.h>
! 2: #include <string.h>
! 3: #include <sys/types.h>
! 4: #include <elwix.h>
! 5:
! 6:
! 7: int
! 8: main(int argc, char **argv)
! 9: {
! 10: FILE *f;
! 11: char line[BUFSIZ] = { 0 };
! 12:
! 13: if(argc < 2)
! 14: return 1;
! 15:
! 16: f = fopen(argv[1], "r");
! 17: if (!f)
! 18: return 1;
! 19:
! 20: while (fgets(line, sizeof line - 1, f)) {
! 21: printf("crc16-ccitt %x init(0xFFFF) %x init(0x1d0f) %x\n", crc_16_ccitt(line, strlen(line)),
! 22: crcCalc(line, strlen(line), 161, 0, 0xFFFF, 0x0),
! 23: crcCalc(line, strlen(line), 161, 0, 0x1D0F, 0x0));
! 24: printf("crc16 %x vs ccitt %x crc16_xy %x crc_16_xmodem %x\n", crc_16(line, strlen(line)), crc16_ccitt(line, strlen(line)),
! 25: crc16_xy(line, strlen(line)), crc_16_xmodem(line, strlen(line)));
! 26: printf("crc32 %x vs %x, eth %x\n", crc_32(line, strlen(line)), crc32tbl(0, line, strlen(line)), crcEther(line, strlen(line)));
! 27: printf("crc8 %x vs %x\n", crc_8(line, strlen(line)), crc8tbl(0, line, strlen(line)));
! 28: }
! 29:
! 30: fclose(f);
! 31: return 0;
! 32: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>