zio_compress.h revision f7170741490edba9d1d9c697c177c887172bc741
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * CDDL HEADER START
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * The contents of this file are subject to the terms of the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Common Development and Distribution License (the "License").
4b22b9337f359bfd063322244f5336cc7c6ffcfars * You may not use this file except in compliance with the License.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4b22b9337f359bfd063322244f5336cc7c6ffcfars * or http://www.opensolaris.org/os/licensing.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * See the License for the specific language governing permissions
4b22b9337f359bfd063322244f5336cc7c6ffcfars * and limitations under the License.
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * When distributing Covered Code, include this CDDL HEADER in each
4b22b9337f359bfd063322244f5336cc7c6ffcfars * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4b22b9337f359bfd063322244f5336cc7c6ffcfars * If applicable, add the following below this CDDL HEADER, with the
4b22b9337f359bfd063322244f5336cc7c6ffcfars * fields enclosed by brackets "[]" replaced with your own identifying
4b22b9337f359bfd063322244f5336cc7c6ffcfars * information: Portions Copyright [yyyy] [name of copyright owner]
4b22b9337f359bfd063322244f5336cc7c6ffcfars *
4b22b9337f359bfd063322244f5336cc7c6ffcfars * CDDL HEADER END
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome * Use is subject to license terms.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome */
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifndef _SYS_ZIO_COMPRESS_H
4b22b9337f359bfd063322244f5336cc7c6ffcfars#define _SYS_ZIO_COMPRESS_H
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#include <sys/zio.h>
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars#ifdef __cplusplus
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern "C" {
4b22b9337f359bfd063322244f5336cc7c6ffcfars#endif
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Common signature for all zio compress functions. */
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef size_t zio_compress_func_t(void *src, void *dst,
4b22b9337f359bfd063322244f5336cc7c6ffcfars size_t s_len, size_t d_len, int);
4b22b9337f359bfd063322244f5336cc7c6ffcfars/* Common signature for all zio decompress functions. */
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef int zio_decompress_func_t(void *src, void *dst,
4b22b9337f359bfd063322244f5336cc7c6ffcfars size_t s_len, size_t d_len, int);
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Information about each compression function.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfarstypedef struct zio_compress_info {
4b22b9337f359bfd063322244f5336cc7c6ffcfars zio_compress_func_t *ci_compress; /* compression function */
4b22b9337f359bfd063322244f5336cc7c6ffcfars zio_decompress_func_t *ci_decompress; /* decompression function */
4b22b9337f359bfd063322244f5336cc7c6ffcfars int ci_level; /* level parameter */
4b22b9337f359bfd063322244f5336cc7c6ffcfars char *ci_name; /* algorithm name */
4b22b9337f359bfd063322244f5336cc7c6ffcfars} zio_compress_info_t;
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS];
4b22b9337f359bfd063322244f5336cc7c6ffcfars
4b22b9337f359bfd063322244f5336cc7c6ffcfars/*
4b22b9337f359bfd063322244f5336cc7c6ffcfars * Compression routines.
4b22b9337f359bfd063322244f5336cc7c6ffcfars */
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern size_t lzjb_compress(void *src, void *dst, size_t s_len, size_t d_len,
4b22b9337f359bfd063322244f5336cc7c6ffcfars int level);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern int lzjb_decompress(void *src, void *dst, size_t s_len, size_t d_len,
4b22b9337f359bfd063322244f5336cc7c6ffcfars int level);
4b22b9337f359bfd063322244f5336cc7c6ffcfarsextern size_t gzip_compress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
extern int gzip_decompress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
extern size_t zle_compress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
extern int zle_decompress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
extern size_t lz4_compress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
extern int lz4_decompress(void *src, void *dst, size_t s_len, size_t d_len,
int level);
/*
* Compress and decompress data if necessary.
*/
extern size_t zio_compress_data(enum zio_compress c, void *src, void *dst,
size_t s_len);
extern int zio_decompress_data(enum zio_compress c, void *src, void *dst,
size_t s_len, size_t d_len);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_ZIO_COMPRESS_H */