From: Ian Darwin Date: Wed, 23 Jan 1991 13:21:44 +0000 (+0000) Subject: Initial revision X-Git-Tag: FILE3_27~302 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e2a77317e19790a5977b4f3cb07030948d5bd1c;p=file Initial revision --- diff --git a/src/compress.c b/src/compress.c new file mode 100644 index 00000000..38670146 --- /dev/null +++ b/src/compress.c @@ -0,0 +1,34 @@ +/* + * compress routines: + * is_compress() returns 0 if uncompressed, number of bits if compressed. + * uncompress(old, n, new) - uncompress old into new, return sizeof new + */ + +/* Check for compression, return nbits. Algorithm, in magic(4) format: + * 0 string \037\235 compressed data + * >2 byte&0x80 >0 block compressed + * >2 byte&0x1f x %d bits + */ +int +is_compress(p, b) +char *p; +int *b; +{ + + if (*p != '\037' || *(p+1) != '\235') + return 0; /* not compress()ed */ + + *b = *(p+2) & 0x80; + return *(p+2) & 0x1f; +} + +int +uncompress(old, n, new) +unsigned char *old, **new; +int n; +{ + *new = old; /* TODO write this */ + **new = 0; /* prevent infinite loop, skeleton version only */ + return n; +} +