Mercurial > hg > toybox
comparison toys/cksum.c @ 336:0c816f5abe22
Add -F option to cksum.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 04 Jan 2009 22:45:03 -0600 |
parents | d5d8f9a6e649 |
children | aaafa1ceaa91 |
comparison
equal
deleted
inserted
replaced
335:556c10abdff6 | 336:0c816f5abe22 |
---|---|
4 * | 4 * |
5 * Copyright 2008 Rob Landley <rob@landley.net> | 5 * Copyright 2008 Rob Landley <rob@landley.net> |
6 * | 6 * |
7 * See http://www.opengroup.org/onlinepubs/009695399/utilities/cksum.html | 7 * See http://www.opengroup.org/onlinepubs/009695399/utilities/cksum.html |
8 | 8 |
9 USE_CKSUM(NEWTOY(cksum, NULL, TOYFLAG_BIN)) | 9 USE_CKSUM(NEWTOY(cksum, "F", TOYFLAG_BIN)) |
10 | 10 |
11 config CKSUM | 11 config CKSUM |
12 bool "cksum" | 12 bool "cksum" |
13 default y | 13 default y |
14 help | 14 help |
15 usage: cksum [file...] | 15 usage: cksum [-F] [file...] |
16 | |
16 For each file, output crc32 checksum value, length and name of file. | 17 For each file, output crc32 checksum value, length and name of file. |
17 If no files listed, copy from stdin. Filename "-" is a synonym for stdin. | 18 If no files listed, copy from stdin. Filename "-" is a synonym for stdin. |
19 | |
20 -F Start with 0xffffffff instead of 0. | |
18 */ | 21 */ |
19 | 22 |
20 #include "toys.h" | 23 #include "toys.h" |
21 | 24 |
22 DEFINE_GLOBALS( | 25 DEFINE_GLOBALS( |
30 return (crc<<8)^TT.crc_table[(crc>>24)^c]; | 33 return (crc<<8)^TT.crc_table[(crc>>24)^c]; |
31 } | 34 } |
32 | 35 |
33 static void do_cksum(int fd, char *name) | 36 static void do_cksum(int fd, char *name) |
34 { | 37 { |
35 unsigned crc = 0; | 38 unsigned crc = toys.optflags ? 0xffffffff : 0; |
36 uint64_t llen = 0, llen2; | 39 uint64_t llen = 0, llen2; |
37 | 40 |
38 // CRC the data | 41 // CRC the data |
39 | 42 |
40 for (;;) { | 43 for (;;) { |