Debian Codegraph @

common/transformation.h

raw symbols SCIP
1 #include "config.h" // IWYU pragma: keep
2
3 #ifdef HAVE_LZO
4 #include <lzo/lzo1x.h>
5 #endif /* HAVE_LZO */
6
7 #ifndef _transformation_H
8 #define _transformation_H
9
10 struct tapebuf;
11
12 /*
13 * Compression/encryption hooks.
14 *
15 * Open questions:
16 * 1. should it be a failure if compress/decompress is called and we DON'T have the code included?
17 */
18
19 typedef struct transformation {
20 int enc;
21 union {
22 int initval__;
23 #ifdef HAVE_LZO
24 struct {
25 lzo_align_t __LZO_MMODEL *LZO_WorkMem;
26 } lzo;
27 #endif /* HAVE_LZO */
28 #ifdef HAVE_ZLIB
29 struct {
30 int complvl;
31 } zlib;
32 #endif /* HAVE_ZLIB */
33 #ifdef HAVE_BZLIB
34 struct {
35 int complvl;
36 } bzlib;
37 #endif /* HAVE_ZLIB */
38 } state;
39
40 /*
41 * The name of the compression/encryption algorithm, for
42 * display purposes.
43 */
44 const char *name;
45
46 /*
47 * Is this mandatory even if the size of the buffer increases?
48 * As a general rule compression is optional * and encryption is
49 * mandatory.
50 */
51 int mandatory;
52
53 /*
54 * Initialize the system.
55 * (mode: 1 = compress/encrypt, 0 = decompress/decrypt)
56 */
57 int (*initialize) (struct transformation *xform, int mode);
58
59 /*
60 * Shut down the system
61 */
62 int (*shutdown) (struct transformation *xform);
63
64 /*
65 * Do anything necessary after forking the process.
66 */
67 int (*startNewTape) (struct transformation *xform,
68 struct tapebuf *tpbin, unsigned long *destlen);
69
70 /*
71 * The dump process is master-slave with the actual
72 * disk and dump tape access handled by the slave processes.
73 * This method performs any initialization required by
74 * the latter process. (E.g., some encryption libraries
75 * must be reinitialized.)
76 */
77 int (*startDiskIOProcess) (struct transformation *xform);
78
79 /*
80 * Clean up everything before the slave process ends.
81 */
82 int (*endDiskIOProcess) (struct transformation *xform);
83
84 /*
85 * Compress/encrypt buffer.
86 */
87 int (*compress) (struct transformation *xform, struct tapebuf *, unsigned long *destlen,
88 const char *src, int srclen);
89
90 /*
91 * Decompress/decrypt buffer.
92 */
93 int (*decompress) (struct transformation *xform, struct tapebuf *, unsigned long *destlen,
94 const char *src, int srclen, const char **reason);
95
96 } Transformation;
97
98 extern Transformation transformation_null;
99
100 #ifdef HAVE_LZO
101 #define HAVE_BLOCK_TRANSFORMATION 1
102 extern Transformation *transformation_lzo_factory(int enc);
103 #endif /* HAVE_ZLIB */
104
105 #ifdef HAVE_ZLIB
106 #define HAVE_BLOCK_TRANSFORMATION 1
107 extern Transformation *transformation_zlib_factory(int enc, int complvl);
108 #endif /* HAVE_ZLIB */
109
110 #ifdef HAVE_BZLIB
111 #define HAVE_BLOCK_TRANSFORMATION 1
112 extern Transformation *transformation_bzlib_factory(int enc, int complvl);
113 #endif /* HAVE_BZLIB */
114
115 #endif /* _transformation_H */