This source file includes following definitions.
- crc32
- main
1
2
3
4
5
6
7 #include <string.h>
8 #include <stdio.h>
9 #include <ctype.h>
10 #include <stdlib.h>
11
12 static unsigned int crc32(unsigned char const *p, unsigned int len)
13 {
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);
20 }
21 return crc;
22 }
23
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;
29 }
30 result = crc32((unsigned char const *)argv[1], strlen(argv[1]));
31 printf("0x%x\n", result);
32 return 0;
33 }