1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5c9431fa1Sahl * Common Development and Distribution License (the "License"). 6c9431fa1Sahl * 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 */ 21c9431fa1Sahl 22fa9e4066Sahrens /* 23*b24ab676SJeff Bonwick * Copyright 2009 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 #include <sys/zio.h> 31fa9e4066Sahrens 32fa9e4066Sahrens #ifdef __cplusplus 33fa9e4066Sahrens extern "C" { 34fa9e4066Sahrens #endif 35fa9e4066Sahrens 36fa9e4066Sahrens /* 37fa9e4066Sahrens * Common signature for all zio compress/decompress functions. 38fa9e4066Sahrens */ 39fa9e4066Sahrens typedef size_t zio_compress_func_t(void *src, void *dst, 40c9431fa1Sahl size_t s_len, size_t d_len, int); 41fa9e4066Sahrens typedef int zio_decompress_func_t(void *src, void *dst, 42c9431fa1Sahl size_t s_len, size_t d_len, int); 43fa9e4066Sahrens 44fa9e4066Sahrens /* 45fa9e4066Sahrens * Information about each compression function. 46fa9e4066Sahrens */ 47fa9e4066Sahrens typedef struct zio_compress_info { 48c9431fa1Sahl zio_compress_func_t *ci_compress; /* compression function */ 49c9431fa1Sahl zio_decompress_func_t *ci_decompress; /* decompression function */ 50c9431fa1Sahl int ci_level; /* level parameter */ 51c9431fa1Sahl char *ci_name; /* algorithm name */ 52fa9e4066Sahrens } zio_compress_info_t; 53fa9e4066Sahrens 54fa9e4066Sahrens extern zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS]; 55fa9e4066Sahrens 56fa9e4066Sahrens /* 57fa9e4066Sahrens * Compression routines. 58fa9e4066Sahrens */ 59c9431fa1Sahl extern size_t lzjb_compress(void *src, void *dst, size_t s_len, size_t d_len, 60c9431fa1Sahl int level); 61c9431fa1Sahl extern int lzjb_decompress(void *src, void *dst, size_t s_len, size_t d_len, 62c9431fa1Sahl int level); 63c9431fa1Sahl extern size_t gzip_compress(void *src, void *dst, size_t s_len, size_t d_len, 64c9431fa1Sahl int level); 65c9431fa1Sahl extern int gzip_decompress(void *src, void *dst, size_t s_len, size_t d_len, 66c9431fa1Sahl int level); 67*b24ab676SJeff Bonwick extern size_t zle_compress(void *src, void *dst, size_t s_len, size_t d_len, 68*b24ab676SJeff Bonwick int level); 69*b24ab676SJeff Bonwick extern int zle_decompress(void *src, void *dst, size_t s_len, size_t d_len, 70*b24ab676SJeff Bonwick int level); 71fa9e4066Sahrens 72fa9e4066Sahrens /* 73fa9e4066Sahrens * Compress and decompress data if necessary. 74fa9e4066Sahrens */ 75*b24ab676SJeff Bonwick extern size_t zio_compress_data(enum zio_compress c, void *src, void *dst, 76*b24ab676SJeff Bonwick size_t s_len); 77*b24ab676SJeff Bonwick extern int zio_decompress_data(enum zio_compress c, void *src, void *dst, 78*b24ab676SJeff Bonwick size_t s_len, size_t d_len); 79fa9e4066Sahrens 80fa9e4066Sahrens #ifdef __cplusplus 81fa9e4066Sahrens } 82fa9e4066Sahrens #endif 83fa9e4066Sahrens 84fa9e4066Sahrens #endif /* _SYS_ZIO_COMPRESS_H */ 85