add debugging code
[cor.git] / tools / pcmcia / crc32hash.c
blob1a18da9cb6a17e6a9ee74346b9f30c10ba342a7c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* crc32hash.c - derived from linux/lib/crc32.c, GNU GPL v2 */
3 /* Usage example:
4 $ ./crc32hash "Dual Speed"
5 */
7 #include <string.h>
8 #include <stdio.h>
9 #include <ctype.h>
10 #include <stdlib.h>
12 static unsigned int crc32(unsigned char const *p, unsigned int len)
14 int i;
15 unsigned int crc = 0;
16 while (len--) {
17 crc ^= *p++;
18 for (i = 0; i < 8; i++)
19 crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
21 return crc;
24 int main(int argc, char **argv) {
25 unsigned int result;
26 if (argc != 2) {
27 printf("no string passed as argument\n");
28 return -1;
30 result = crc32((unsigned char const *)argv[1], strlen(argv[1]));
31 printf("0x%x\n", result);
32 return 0;