yet more timing hacks
[pcsx_rearmed.git] / deps / libretro-common / samples / utils / crc32.c
1 /* gcc -O3 -o crc32 crc32.c -lz */
2
3 #include <stdio.h>
4 #include <errno.h>
5 #include <string.h>
6
7 #include <encodings/crc32.h>
8
9 int main(int argc, const char* argv[])
10 {
11    if (argc != 2 )
12    {
13       fprintf( stderr, "Usage: crc32 <filename>\n" );
14       return 1;
15    }
16
17    FILE *file = fopen(argv[1], "rb");
18
19    if (file)
20    {
21       uint32_t crc = encoding_crc32(0L, NULL, 0 );
22
23       for (;;)
24       {
25          uint8_t buffer[16384];
26
27          int numread = fread((void*)buffer, 1, sizeof(buffer), file);
28
29          if (numread > 0)
30             crc = encoding_crc32( crc, buffer, numread );
31          else
32             break;
33       }
34
35       fclose(file);
36
37       printf("%08x\n", crc);
38       return 0;
39    }
40
41    fprintf(stderr, "Error opening input file: %s\n", strerror(errno));
42    return 1;
43 }