-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zopfli.c
36 lines (32 loc) · 919 Bytes
/
Zopfli.c
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
#include <Python.h>
#include "zopfli/util.h"
#include "zopfli/zopfli.h"
static PyObject *zopfli_compress_file(PyObject *self, PyObject *args) {
const char *infilename;
const char *outfilename;
if (!PyArg_ParseTuple(args, "ss", &infilename, &outfilename)) {
return NULL;
}
Options options;
InitOptions(&options);
OutputType output_type = OUTPUT_GZIP;
options.numiterations = 5;
CompressFile(&options, output_type, infilename, outfilename);
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef method_list[] = {
{"compress_file", zopfli_compress_file, METH_VARARGS, "Compress a file"},
{NULL, NULL, 0, NULL}
};
PyMODINIT_FUNC initZopfli(void) {
PyObject *m;
m = Py_InitModule("Zopfli", method_list);
if (m == NULL)
return;
}
int main(int argc, char *argv[]) {
Py_SetProgramName(argv[0]);
Py_Initialize();
initZopfli();
}