2012-12-03 18:15:41 +00:00
|
|
|
/*
|
|
|
|
* This file is a part of Pcompress, a chunked parallel multi-
|
|
|
|
* algorithm lossless compression and decompression program.
|
|
|
|
*
|
2013-03-07 14:56:48 +00:00
|
|
|
* Copyright (C) 2012-2013 Moinak Ghosh. All rights reserved.
|
2012-12-03 18:15:41 +00:00
|
|
|
* Use is subject to license terms.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
2013-03-07 14:56:48 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this program.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2012-12-03 18:15:41 +00:00
|
|
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
2014-07-24 16:50:30 +00:00
|
|
|
*
|
2012-12-03 18:15:41 +00:00
|
|
|
*/
|
|
|
|
|
2013-11-10 17:39:42 +00:00
|
|
|
#ifndef _PC_ARCHIVE_FILTER_H
|
|
|
|
#define _PC_ARCHIVE_FILTER_H
|
2012-12-03 18:15:41 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
2013-11-10 17:39:42 +00:00
|
|
|
#include <sys/stat.h>
|
2013-11-13 17:58:01 +00:00
|
|
|
#include <inttypes.h>
|
2013-11-10 17:39:42 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <archive.h>
|
|
|
|
#include <archive_entry.h>
|
2012-12-03 18:15:41 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-11-13 17:58:01 +00:00
|
|
|
#define FILTER_RETURN_SKIP (1)
|
|
|
|
#define FILTER_RETURN_ERROR (-1)
|
2014-09-17 15:04:38 +00:00
|
|
|
#define FILTER_RETURN_SOFT_ERROR (-2)
|
2014-09-11 14:59:53 +00:00
|
|
|
#define FILTER_XATTR_ENTRY "_._pc_filter_xattr"
|
2013-11-13 17:58:01 +00:00
|
|
|
|
2014-12-14 18:07:40 +00:00
|
|
|
#define FILTER_OUTPUT_MEM 1
|
|
|
|
#define FILTER_OUTPUT_FILE 2
|
|
|
|
|
2014-09-24 16:24:36 +00:00
|
|
|
#define HELPER_DEF_BUFSIZ (512 * 1024)
|
|
|
|
#define WVPK_FILE_SIZE_LIMIT (18 * 1024 * 1024)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The biggest scratch buffer reqd by filter routines.
|
|
|
|
* Currently this is the WavPack filter buffer.
|
|
|
|
*/
|
|
|
|
#define FILTER_SCRATCH_SIZE_MAX WVPK_FILE_SIZE_LIMIT
|
|
|
|
|
|
|
|
#ifndef _MPLV2_LICENSE_
|
|
|
|
# define PJG_FILE_SIZE_LIMIT (8 * 1024 * 1024)
|
|
|
|
# define PJG_APPVERSION1 (25)
|
|
|
|
# define PJG_APPVERSION2 (25)
|
|
|
|
#endif
|
|
|
|
|
2014-12-14 18:07:40 +00:00
|
|
|
#pragma pack(1)
|
|
|
|
typedef struct _filter_std_hdr {
|
|
|
|
uint64_t in_size;
|
|
|
|
} filter_std_hdr_t;
|
|
|
|
#pragma pack()
|
|
|
|
|
|
|
|
typedef struct _filter_output {
|
|
|
|
int output_type;
|
|
|
|
uint8_t *out;
|
|
|
|
size_t out_size;
|
|
|
|
int out_fd;
|
2014-12-21 08:43:58 +00:00
|
|
|
int hdr_valid;
|
2014-12-14 18:07:40 +00:00
|
|
|
filter_std_hdr_t hdr;
|
|
|
|
} filter_output_t;
|
|
|
|
|
2013-11-10 17:39:42 +00:00
|
|
|
struct filter_info {
|
2013-11-13 17:58:01 +00:00
|
|
|
struct archive *source_arc;
|
2013-11-10 17:39:42 +00:00
|
|
|
struct archive *target_arc;
|
|
|
|
struct archive_entry *entry;
|
|
|
|
int fd;
|
2013-11-13 17:58:01 +00:00
|
|
|
int compressing, block_size;
|
2013-12-30 17:54:37 +00:00
|
|
|
int *type_ptr;
|
2014-09-17 16:13:00 +00:00
|
|
|
int cmp_level;
|
2014-12-14 18:07:40 +00:00
|
|
|
filter_output_t *fout;
|
2014-09-24 16:24:36 +00:00
|
|
|
uchar_t scratch_buffer;
|
|
|
|
size_t scratch_buffer_size;
|
2013-11-10 17:39:42 +00:00
|
|
|
};
|
2012-12-03 18:15:41 +00:00
|
|
|
|
2013-11-14 16:24:46 +00:00
|
|
|
struct filter_flags {
|
|
|
|
int enable_packjpg;
|
2014-09-17 15:04:38 +00:00
|
|
|
int enable_wavpack;
|
2014-12-20 05:54:09 +00:00
|
|
|
int exe_preprocess;
|
2013-11-14 16:24:46 +00:00
|
|
|
};
|
|
|
|
|
2013-11-13 17:58:01 +00:00
|
|
|
typedef ssize_t (*filter_func_ptr)(struct filter_info *fi, void *filter_private);
|
|
|
|
|
|
|
|
struct type_data {
|
|
|
|
void *filter_private;
|
|
|
|
filter_func_ptr filter_func;
|
|
|
|
char *filter_name;
|
|
|
|
};
|
2013-11-10 17:39:42 +00:00
|
|
|
|
2013-11-14 16:24:46 +00:00
|
|
|
void add_filters_by_type(struct type_data *typetab, struct filter_flags *ff);
|
2014-09-11 14:59:53 +00:00
|
|
|
int type_tag_from_filter_name(struct type_data *typetab, const char *fname,
|
|
|
|
size_t len);
|
2012-12-03 18:15:41 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-07-24 16:50:30 +00:00
|
|
|
#endif
|