8 #include "transformation.h"
14 lzo_initialize(Transformation *xform, int enc)
22 lzo_shutdown(Transformation *xform)
31 lzo_startNewTape(Transformation *xform, struct tapebuf *tpbin,
32 unsigned long *destlen)
38 * Start slave process.
41 lzo_startDiskIOProcess(Transformation *xform)
50 lzo_endDiskIOProcess(Transformation *xform)
54 if (xform->state.lzo.LZO_WorkMem != NULL) {
55 free(xform->state.lzo.LZO_WorkMem);
68 lzo_compress(Transformation *xform, struct tapebuf *tpbin,
69 unsigned long *destlen, const char *src, int srclen, int compressed)
72 lzo_uint *worklen2 = (lzo_uint *) destlen;
75 compresult = lzo1x_1_compress(src, srclen, tpbin->buf, worklen2,
76 xform->state.lzo.LZO_WorkMem);
78 return compresult == LZO_E_OK ? 1 : 0;
85 * Decompress a buffer.
88 lzo_decompress(Transformation *xform, struct tapebuf *tpbin,
89 unsigned long *destlen, const char *src, int srclen, char **reason)
93 lzo_uint destlen2 = *destlen;
94 cresult = lzo1x_decompress(src, srclen, tpbin->buf, &destlen2, NULL);
101 case LZO_E_EOF_NOT_FOUND:
102 *reason = "data error";
108 return (cresult == LZO_E_OK) ? 1 : 0;
111 #endif /* HAVE_LZO */
118 *transformation_lzo_factory(int enc)
120 Transformation *t = (Transformation *) malloc(sizeof (Transformation));
123 t->state.lzo.LZO_WorkMem = malloc(LZO1X_1_MEM_COMPRESS);
124 if (!t->state.lzo.LZO_WorkMem)
125 quit("couldn't allocate a compress buffer.\n");
128 #endif /* HAVE_LZO */
132 t->initialize = &lzo_initialize;
133 t->shutdown = &lzo_shutdown;
134 t->startNewTape = &lzo_startNewTape;
135 t->startDiskIOProcess = &lzo_startDiskIOProcess;
136 t->endDiskIOProcess = &lzo_endDiskIOProcess;
137 t->compress = &lzo_compress;
138 t->decompress = &lzo_decompress;