File: transformation.h

package info (click to toggle)
dump 0.4b52-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,076 kB
  • sloc: ansic: 15,394; sh: 5,006; cpp: 3,268; makefile: 183
file content (117 lines) | stat: -rw-r--r-- 2,734 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <config.h>
#include <bsdcompat.h>
#include <protocols/dumprestore.h>

#ifdef HAVE_LZO
#include <lzo/lzo1x.h>
#endif /* HAVE_LZO */

#ifndef _transformation_H
#define _transformation_H

/*
 * Compression/encryption hooks.
 *
 * Open questions:
 * 1. should it be a failure if compress/decompress is called and we DON'T have the code included?
 */

typedef struct transformation {
	int enc;
	union {
		int initval__;
#ifdef HAVE_LZO
		struct {
			lzo_align_t __LZO_MMODEL *LZO_WorkMem;
		} lzo;
#endif /* HAVE_LZO */
#ifdef HAVE_ZLIB
		struct {
			int complvl;
		} zlib;
#endif /* HAVE_ZLIB */
#ifdef HAVE_BZLIB
		struct {
			int complvl;
		} bzlib;
#endif /* HAVE_ZLIB */
	} state;

	/*
	 * The name of the compression/encryption algorithm, for
	 * display purposes.
	 */
	const char *name;

	/*
	 * Is this mandatory even if the size of the buffer increases?
	 * As a general rule compression is optional * and encryption is
	 * mandatory.
	 */
	int mandatory;

	/*
	 * Initialize the system.
	 * (mode: 1 = compress/encrypt, 0 = decompress/decrypt)
	 */
	int (*initialize) (struct transformation *xform, int mode);

	/*
	 * Shut down the system
	 */
	int (*shutdown) (struct transformation *xform);

	/*
	 * Do anything necessary after forking the process.
	 */
	int (*startNewTape) (struct transformation *xform,
		struct tapebuf *tpbin, unsigned long *destlen);

	/*
	 * The dump process is master-slave with the actual
	 * disk and dump tape access handled by the slave processes.
	 * This method performs any initialization required by
	 * the latter process. (E.g., some encryption libraries
	 * must be reinitialized.)
	 */
	int (*startDiskIOProcess) (struct transformation *xform);

	/*
	 * Clean up everything before the slave process ends.
	 */
	int (*endDiskIOProcess) (struct transformation *xform);

	/*
	 * Compress/encrypt buffer.
	 */
	int (*compress) (struct transformation *xform, struct tapebuf *, unsigned long *destlen,
			const char *src, int srclen);

	/*
	 * Decompress/decrypt buffer.
	 */
	int (*decompress) (struct transformation *xform, struct tapebuf *, unsigned long *destlen,
			const char *src, int srclen, char **reason);

} Transformation;

extern Transformation transformation_null;

#ifdef HAVE_LZO
#define HAVE_BLOCK_TRANSFORMATION 1
extern Transformation *transformation_lzo_factory(int enc);
#endif /* HAVE_ZLIB */

#ifdef HAVE_ZLIB
#define HAVE_BLOCK_TRANSFORMATION 1
extern Transformation *transformation_zlib_factory(int enc, int complvl);
#endif /* HAVE_ZLIB */

#ifdef HAVE_BZLIB
#define HAVE_BLOCK_TRANSFORMATION 1
extern Transformation *transformation_bzlib_factory(int enc, int complvl);
#endif /* HAVE_BZLIB */

void quit(const char *fmt, ...);

#endif /* _transformation_H */