#include "config.h" // IWYU pragma: keep #ifdef HAVE_LZO #include #endif /* HAVE_LZO */ #ifndef _transformation_H #define _transformation_H struct tapebuf; /* * 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, const 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 */ #endif /* _transformation_H */