lfn
serial
ticket/834-toolchain-update
topic/msim-upgrade
topic/simplify-dev-export
Last change
on this file since a1467102 was a1467102, checked in by Oleg Romanenko <romanenko.oleg@…>, 14 years ago |
- Add utility to calculate CRC32 for a file(s): filecrc
- Add utility to fill file with specified number of random bytes: filegen
I've used they for testing FAT server. CRC32 algorithm is equal to
cksfv linux utility.
|
-
Property mode
set to
100644
|
File size:
844 bytes
|
Line | |
---|
1 |
|
---|
2 | /** @addtogroup filecheck
|
---|
3 | * @{
|
---|
4 | */
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * @file filecrc.c
|
---|
8 | * @brief Tool for calculating CRC32 checksum for a file(s)
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 | #include <stdio.h>
|
---|
15 | #include <stdlib.h>
|
---|
16 | #include <sys/types.h>
|
---|
17 | #include <fcntl.h>
|
---|
18 | #include "crc32.h"
|
---|
19 |
|
---|
20 | #define NAME "filecrc"
|
---|
21 | #define VERSION "0.0.2"
|
---|
22 |
|
---|
23 | static void print_help(void);
|
---|
24 |
|
---|
25 |
|
---|
26 | int main(int argc, char **argv) {
|
---|
27 |
|
---|
28 | if (argc < 2) {
|
---|
29 | print_help();
|
---|
30 | return 0;
|
---|
31 | }
|
---|
32 |
|
---|
33 | int i;
|
---|
34 | for (i = 1; argv[i] != NULL && i < argc; i++) {
|
---|
35 | uint32_t hash = 0;
|
---|
36 | int fd = open(argv[i], O_RDONLY);
|
---|
37 | if (fd < 0) {
|
---|
38 | printf("Unable to open %s\n", argv[i]);
|
---|
39 | continue;
|
---|
40 | }
|
---|
41 |
|
---|
42 | if (crc32(fd, &hash) == 0) {
|
---|
43 | printf("%s : %x\n", argv[i], hash);
|
---|
44 | }
|
---|
45 |
|
---|
46 | close(fd);
|
---|
47 | }
|
---|
48 |
|
---|
49 | return 0;
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | /* Displays help for filecrc */
|
---|
54 | static void print_help(void)
|
---|
55 | {
|
---|
56 | printf(
|
---|
57 | "Usage: %s <file1> [file2] [...]\n",
|
---|
58 | NAME);
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * @}
|
---|
64 | */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.