2012-11-19 16:11:56 +00:00
|
|
|
/*
|
|
|
|
* This file is a part of Pcompress, a chunked parallel multi-
|
|
|
|
* algorithm lossless compression and decompression program.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Moinak Ghosh. All rights reserved.
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* moinakg@belenix.org, http://moinakg.wordpress.com/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _C_ONFIG_H
|
|
|
|
#define _C_ONFIG_H
|
|
|
|
|
|
|
|
#include <limits.h>
|
2013-02-12 16:23:04 +00:00
|
|
|
#include <utils.h>
|
2013-02-17 15:35:40 +00:00
|
|
|
#include <crypto_utils.h>
|
2012-11-19 16:11:56 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-02-12 16:23:04 +00:00
|
|
|
#define DEFAULT_SIMILARITY_INTERVAL 5
|
2013-02-16 18:03:06 +00:00
|
|
|
#define DEFAULT_CHUNK_CKSUM CKSUM_SHA256
|
|
|
|
#define DEFAULT_SIMILARITY_CKSUM CKSUM_BLAKE256
|
2013-02-12 16:23:04 +00:00
|
|
|
#define DEFAULT_COMPRESS COMPRESS_LZ4
|
2013-02-17 15:35:40 +00:00
|
|
|
#define CONTAINER_ITEMS 2048
|
2012-11-19 16:11:56 +00:00
|
|
|
#define MIN_CK 1
|
|
|
|
#define MAX_CK 5
|
|
|
|
|
|
|
|
// 8GB
|
|
|
|
#define MIN_ARCHIVE_SZ (8589934592ULL)
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char rootdir[PATH_MAX+1];
|
|
|
|
uint32_t chunk_sz; // Numeric ID: 1 - 4k ... 5 - 64k
|
2012-11-29 16:58:50 +00:00
|
|
|
int64_t archive_sz; // Total size of archive in bytes.
|
|
|
|
int verify_chunks; // Whether to use memcmp() to compare chunks byte for byte.
|
2013-02-12 16:23:04 +00:00
|
|
|
int algo; // Which compression algo for segments.
|
|
|
|
compress_algo_t compress_level; // Default preset compression level per algo.
|
2013-02-16 18:03:06 +00:00
|
|
|
cksum_t chunk_cksum_type; // Which digest to use for hash based chunk comparison.
|
|
|
|
cksum_t similarity_cksum; // Which digest to use similarity based segment lookup.
|
2012-11-29 16:58:50 +00:00
|
|
|
int chunk_cksum_sz; // Size of cksum in bytes.
|
2013-02-16 18:03:06 +00:00
|
|
|
int similarity_cksum_sz; // Size of cksum in bytes.
|
2013-02-14 17:40:53 +00:00
|
|
|
int pct_interval; // Similarity based match intervals in %age.
|
2012-11-19 16:11:56 +00:00
|
|
|
// The items below are computed given the above
|
|
|
|
// components.
|
|
|
|
|
2012-11-29 16:58:50 +00:00
|
|
|
uint32_t chunk_sz_bytes; // Average chunk size
|
2013-02-14 17:40:53 +00:00
|
|
|
uint32_t segment_sz_bytes; // Segment size in bytes
|
|
|
|
uint32_t segment_sz; // Number of chunks in one segment
|
2012-11-19 16:11:56 +00:00
|
|
|
uint32_t container_sz; // Number of segments
|
|
|
|
int directory_fanout; // Number of subdirectories in a directory
|
|
|
|
int directory_levels; // Levels of nested directories
|
|
|
|
int num_containers; // Number of containers in a directory
|
2013-02-14 17:40:53 +00:00
|
|
|
void *dbdata;
|
2012-11-19 16:11:56 +00:00
|
|
|
} archive_config_t;
|
|
|
|
|
2013-02-16 18:03:06 +00:00
|
|
|
typedef struct _segment_entry {
|
2013-02-17 15:35:40 +00:00
|
|
|
uint64_t chunk_offset;
|
|
|
|
uint32_t chunk_length;
|
|
|
|
uchar_t *chunk_cksum;
|
2013-02-16 18:03:06 +00:00
|
|
|
} segment_entry_t;
|
|
|
|
|
2012-11-19 16:11:56 +00:00
|
|
|
int read_config(char *configfile, archive_config_t *cfg);
|
2012-11-29 16:58:50 +00:00
|
|
|
int write_config(char *configfile, archive_config_t *cfg);
|
2013-02-16 18:03:06 +00:00
|
|
|
int set_config_s(archive_config_t *cfg, compress_algo_t algo, cksum_t ck, cksum_t ck_sim,
|
2013-02-14 17:40:53 +00:00
|
|
|
uint32_t chunksize, size_t file_sz, int pct_interval);
|
2012-11-19 16:11:56 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|