1 /* $Id: vndcompress.h,v 1.2 2008/02/18 03:34:04 dyoung Exp $ */
4 * Copyright (c) 2005 by Florian Stoehr
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Florian Stoehr
18 * 4. The name of Florian Stoehr may not be used to endorse or promote
19 * products derived from this software without specific prior written
22 * THIS SOFTWARE IS PROVIDED BY FLORIAN STOEHR ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
38 * All numbers are in network byte order!
40 * Offset Size Description
41 * 0 128 Preamble (actually Linux load instructions)
43 * 131 4 Number of blocks
44 * 135 8*x 64-bit compressed block start offsets (rel. to FILE (!))
45 * 135+8*x y Compressed blocks
47 #ifndef __CLCONFIG_H__
48 #define __CLCONFIG_H__
50 #include <machine/bswap.h>
55 void vndcompress(const char *, const char *, uint32_t);
56 uint64_t * readheader(int, struct cloop_header
*, off_t
*);
57 void vnduncompress(const char *, const char *);
59 /* Size of the shell command (Linux compatibility) */
60 #define CLOOP_SH_SIZE 128
62 /* Atomic BSD block is always 512 bytes */
65 /* The default blocksize (compressed chunk) is 64 KB */
66 #define DEF_BLOCKSIZE 128*ATOMBLOCK
69 * SWAPPER: Convert a 64-bit value between network and local byte order
70 * SWAPPER32: Convert a 32-bit value between network and local byte order
72 #if (_BYTE_ORDER == _BIG_ENDIAN)
73 #define SWAPPER(arg) (arg)
74 #define SWAPPER32(arg) (arg)
75 #define SWAPPER16(arg) (arg)
77 #define SWAPPER(arg) bswap64(arg)
78 #define SWAPPER32(arg) bswap32(arg)
79 #define SWAPPER16(arg) bswap16(arg)
83 char sh
[CLOOP_SH_SIZE
];