| 1 | %module xdelta3 | 
 
 
 
 
 | 2 | %import cstring.i | 
 
 
 
 
 | 3 | %import argcargv.i | 
 
 
 
 
 | 4 | %{ | 
 
 
 
 
 | 5 | #include "xdelta3.h" | 
 
 
 
 
 | 6 |  | 
 
 
 
 
 | 7 | int xd3_main_cmdline (int ARGC, char **ARGV); | 
 
 
 
 
 | 8 |  | 
 
 
 
 
 | 9 | #undef SWIG_init | 
 
 
 
 
 | 10 | #undef SWIG_name | 
 
 
 
 
 | 11 |  | 
 
 
 
 
 | 12 | #define SWIG_init    initxdelta3 | 
 
 
 
 
 | 13 | #define SWIG_name    "xdelta3" | 
 
 
 
 
 | 14 |  | 
 
 
 
 
 | 15 | %} | 
 
 
 
 
 | 16 |  | 
 
 
 
 
 | 17 | %cstring_input_binary(const char *input, unsigned int input_size); | 
 
 
 
 
 | 18 | %cstring_input_binary(const char *source, unsigned int source_size); | 
 
 
 
 
 | 19 |  | 
 
 
 
 
 | 20 | %define %max_output_withsize(TYPEMAP, SIZE, MAXSIZE) | 
 
 
 
 
 | 21 | %typemap(in) MAXSIZE (unsigned int alloc_size) { | 
 
 
 
 
 | 22 | $1 = alloc_size = PyInt_AsLong(obj2); | 
 
 
 
 
 | 23 | } | 
 
 
 
 
 | 24 | %typemap(in,numinputs=0) (TYPEMAP, SIZE) { | 
 
 
 
 
 | 25 | } | 
 
 
 
 
 | 26 | %typemap(check) (TYPEMAP, SIZE) { | 
 
 
 
 
 | 27 | // alloc_size input is #7th position in xd3_xxcode_memory() | 
 
 
 
 
 | 28 | $1 = malloc(alloc_size7); | 
 
 
 
 
 | 29 | $2 = &alloc_size7; | 
 
 
 
 
 | 30 | } | 
 
 
 
 
 | 31 | %typemap(argout,fragment="t_output_helper") (TYPEMAP, SIZE) { | 
 
 
 
 
 | 32 | if (result == 0) { | 
 
 
 
 
 | 33 | PyObject *o; | 
 
 
 
 
 | 34 | // alloc_size7 now carries actual size | 
 
 
 
 
 | 35 | o = PyString_FromStringAndSize($1,alloc_size7); | 
 
 
 
 
 | 36 | $result = t_output_helper($result,o); | 
 
 
 
 
 | 37 | } else { | 
 
 
 
 
 | 38 | $result = t_output_helper($result,Py_None); | 
 
 
 
 
 | 39 | } | 
 
 
 
 
 | 40 | free($1); | 
 
 
 
 
 | 41 | } | 
 
 
 
 
 | 42 | %typemap(default) int flags { | 
 
 
 
 
 | 43 | $1 = 0; | 
 
 
 
 
 | 44 | } | 
 
 
 
 
 | 45 | %enddef | 
 
 
 
 
 | 46 |  | 
 
 
 
 
 | 47 | %max_output_withsize(char *output_buf, unsigned int *output_size, unsigned int max_output); | 
 
 
 
 
 | 48 |  | 
 
 
 
 
 | 49 | int     xd3_encode_memory (const char   *input, | 
 
 
 
 
 | 50 | unsigned int  input_size, | 
 
 
 
 
 | 51 | const char   *source, | 
 
 
 
 
 | 52 | unsigned int  source_size, | 
 
 
 
 
 | 53 | char         *output_buf, | 
 
 
 
 
 | 54 | unsigned int *output_size, | 
 
 
 
 
 | 55 | unsigned int  max_output, | 
 
 
 
 
 | 56 | int           flags); | 
 
 
 
 
 | 57 |  | 
 
 
 
 
 | 58 | int     xd3_decode_memory (const char   *input, | 
 
 
 
 
 | 59 | unsigned int  input_size, | 
 
 
 
 
 | 60 | const char   *source, | 
 
 
 
 
 | 61 | unsigned int  source_size, | 
 
 
 
 
 | 62 | char         *output_buf, | 
 
 
 
 
 | 63 | unsigned int *output_size, | 
 
 
 
 
 | 64 | unsigned int  max_output, | 
 
 
 
 
 | 65 | int           flags); | 
 
 
 
 
 | 66 |  | 
 
 
 
 
 | 67 | int     xd3_main_cmdline (int ARGC, char **ARGV); | 
 
 
 
 
 | 68 |  | 
 
 
 
 
 | 69 | /* Is this the right way? */ | 
 
 
 
 
 | 70 | enum { | 
 
 
 
 
 | 71 | /*XD3_JUST_HDR,*/ | 
 
 
 
 
 | 72 | /*XD3_SKIP_WINDOW,*/ | 
 
 
 
 
 | 73 | /*XD3_SKIP_EMIT,*/ | 
 
 
 
 
 | 74 | /*XD3_FLUSH,*/ | 
 
 
 
 
 | 75 | XD3_SEC_DJW, | 
 
 
 
 
 | 76 | XD3_SEC_FGK, | 
 
 
 
 
 | 77 | /*XD3_SEC_TYPE,*/ | 
 
 
 
 
 | 78 | XD3_SEC_NODATA, | 
 
 
 
 
 | 79 | XD3_SEC_NOINST, | 
 
 
 
 
 | 80 | XD3_SEC_NOADDR, | 
 
 
 
 
 | 81 | /*XD3_SEC_OTHER,*/ | 
 
 
 
 
 | 82 | XD3_ADLER32, | 
 
 
 
 
 | 83 | XD3_ADLER32_NOVER, | 
 
 
 
 
 | 84 | XD3_ALT_CODE_TABLE, | 
 
 
 
 
 | 85 | XD3_NOCOMPRESS, | 
 
 
 
 
 | 86 | XD3_BEGREEDY, | 
 
 
 
 
 | 87 | XD3_COMPLEVEL_SHIFT, | 
 
 
 
 
 | 88 | XD3_COMPLEVEL_MASK, | 
 
 
 
 
 | 89 | XD3_COMPLEVEL_1, | 
 
 
 
 
 | 90 | XD3_COMPLEVEL_3, | 
 
 
 
 
 | 91 | XD3_COMPLEVEL_6, | 
 
 
 
 
 | 92 | XD3_COMPLEVEL_9, | 
 
 
 
 
 | 93 | }; |