1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5*c9431fa1Sahl * Common Development and Distribution License (the "License"). 6*c9431fa1Sahl * You may not use this file except in compliance with the License. 7fa9e4066Sahrens * 8fa9e4066Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fa9e4066Sahrens * or http://www.opensolaris.org/os/licensing. 10fa9e4066Sahrens * See the License for the specific language governing permissions 11fa9e4066Sahrens * and limitations under the License. 12fa9e4066Sahrens * 13fa9e4066Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14fa9e4066Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fa9e4066Sahrens * If applicable, add the following below this CDDL HEADER, with the 16fa9e4066Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17fa9e4066Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18fa9e4066Sahrens * 19fa9e4066Sahrens * CDDL HEADER END 20fa9e4066Sahrens */ 21*c9431fa1Sahl 22fa9e4066Sahrens /* 23*c9431fa1Sahl * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24fa9e4066Sahrens * Use is subject to license terms. 25fa9e4066Sahrens */ 26fa9e4066Sahrens 27fa9e4066Sahrens #ifndef _SYS_ZIO_COMPRESS_H 28fa9e4066Sahrens #define _SYS_ZIO_COMPRESS_H 29fa9e4066Sahrens 30fa9e4066Sahrens #pragma ident "%Z%%M% %I% %E% SMI" 31fa9e4066Sahrens 32fa9e4066Sahrens #include <sys/zio.h> 33fa9e4066Sahrens 34fa9e4066Sahrens #ifdef __cplusplus 35fa9e4066Sahrens extern "C" { 36fa9e4066Sahrens #endif 37fa9e4066Sahrens 38fa9e4066Sahrens /* 39fa9e4066Sahrens * Common signature for all zio compress/decompress functions. 40fa9e4066Sahrens */ 41fa9e4066Sahrens typedef size_t zio_compress_func_t(void *src, void *dst, 42*c9431fa1Sahl size_t s_len, size_t d_len, int); 43fa9e4066Sahrens typedef int zio_decompress_func_t(void *src, void *dst, 44*c9431fa1Sahl size_t s_len, size_t d_len, int); 45fa9e4066Sahrens 46fa9e4066Sahrens /* 47fa9e4066Sahrens * Information about each compression function. 48fa9e4066Sahrens */ 49fa9e4066Sahrens typedef struct zio_compress_info { 50*c9431fa1Sahl zio_compress_func_t *ci_compress; /* compression function */ 51*c9431fa1Sahl zio_decompress_func_t *ci_decompress; /* decompression function */ 52*c9431fa1Sahl int ci_level; /* level parameter */ 53*c9431fa1Sahl char *ci_name; /* algorithm name */ 54fa9e4066Sahrens } zio_compress_info_t; 55fa9e4066Sahrens 56fa9e4066Sahrens extern zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS]; 57fa9e4066Sahrens 58fa9e4066Sahrens /* 59fa9e4066Sahrens * Compression routines. 60fa9e4066Sahrens */ 61*c9431fa1Sahl extern size_t lzjb_compress(void *src, void *dst, size_t s_len, size_t d_len, 62*c9431fa1Sahl int level); 63*c9431fa1Sahl extern int lzjb_decompress(void *src, void *dst, size_t s_len, size_t d_len, 64*c9431fa1Sahl int level); 65*c9431fa1Sahl extern size_t gzip_compress(void *src, void *dst, size_t s_len, size_t d_len, 66*c9431fa1Sahl int level); 67*c9431fa1Sahl extern int gzip_decompress(void *src, void *dst, size_t s_len, size_t d_len, 68*c9431fa1Sahl int level); 69fa9e4066Sahrens 70fa9e4066Sahrens /* 71fa9e4066Sahrens * Compress and decompress data if necessary. 72fa9e4066Sahrens */ 73fa9e4066Sahrens extern int zio_compress_data(int cpfunc, void *src, uint64_t srcsize, 74fa9e4066Sahrens void **destp, uint64_t *destsizep, uint64_t *destbufsizep); 75fa9e4066Sahrens extern int zio_decompress_data(int cpfunc, void *src, uint64_t srcsize, 76fa9e4066Sahrens void *dest, uint64_t destsize); 77fa9e4066Sahrens 78fa9e4066Sahrens #ifdef __cplusplus 79fa9e4066Sahrens } 80fa9e4066Sahrens #endif 81fa9e4066Sahrens 82fa9e4066Sahrens #endif /* _SYS_ZIO_COMPRESS_H */ 83