aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2009-01-05 01:05:43 -0600
committerRob Landley <rob@landley.net>2009-01-05 01:05:43 -0600
commitb15b8fa99ae53396145ea540106b74d37797f774 (patch)
tree1b16efb7c111d9ef52378b5765cb585d5eb01c79 /lib/lib.c
parent2f638c397a916399049ac0adaf32a53f635d31bc (diff)
downloadtoybox-b15b8fa99ae53396145ea540106b74d37797f774.tar.gz
Add -N, -I, -L, and -P options to cksum.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/lib.c b/lib/lib.c
index f94d6fdf..89c8781b 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -721,15 +721,16 @@ void replace_tempfile(int fdin, int fdout, char **tempname)
// Create a 256 entry CRC32 lookup table.
-void crc_init(unsigned int *crc_table)
+void crc_init(unsigned int *crc_table, int little_endian)
{
unsigned int i;
// Init the CRC32 table (big endian)
for (i=0; i<256; i++) {
- unsigned int j, c = i<<24;
+ unsigned int j, c = little_endian ? i : i<<24;
for (j=8; j; j--)
- c=c&0x80000000 ? (c<<1)^0x04c11db7 : (c<<1);
+ if (little_endian) c = (c&1) ? (c>>1)^0xEDB88320 : c>>1;
+ else c=c&0x80000000 ? (c<<1)^0x04c11db7 : (c<<1);
crc_table[i] = c;
}
}