summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3.swig
blob: 696974f0c6b89370f19abba0fc0c76658f936c3f (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
%module xdelta3
%import cstring.i
%import argcargv.i
%{
#include "xdelta3.h"

int xd3_main_cmdline (int ARGC, char **ARGV);

#undef SWIG_init
#undef SWIG_name

#define SWIG_init    initxdelta3
#define SWIG_name    "xdelta3"

%}

%cstring_input_binary(const char *input, unsigned int input_size);
%cstring_input_binary(const char *source, unsigned int source_size);

%define %max_output_withsize(TYPEMAP, SIZE, MAXSIZE)
%typemap(in) MAXSIZE (unsigned int alloc_size) {
  $1 = alloc_size = PyInt_AsLong(obj2);
}
%typemap(in,numinputs=0) (TYPEMAP, SIZE) {
}
%typemap(check) (TYPEMAP, SIZE) {
  // alloc_size input is #7th position in xd3_xxcode_memory()
  $1 = malloc(alloc_size7);
  $2 = &alloc_size7;
}
%typemap(argout,fragment="t_output_helper") (TYPEMAP, SIZE) {
  if (result == 0) {
    PyObject *o;
    // alloc_size7 now carries actual size
    o = PyString_FromStringAndSize($1,alloc_size7);
    $result = t_output_helper($result,o);
  } else {
    $result = t_output_helper($result,Py_None);
  }
  free($1);
}
%typemap(default) int flags {
  $1 = 0;
}
%enddef

%max_output_withsize(char *output_buf, unsigned int *output_size, unsigned int max_output);

int     xd3_encode_memory (const char   *input,
			   unsigned int  input_size,
			   const char   *source,
			   unsigned int  source_size,
			   char         *output_buf,
			   unsigned int *output_size,
			   unsigned int  max_output,
			   int           flags);

int     xd3_decode_memory (const char   *input,
			   unsigned int  input_size,
			   const char   *source,
			   unsigned int  source_size,
			   char         *output_buf,
			   unsigned int *output_size,
			   unsigned int  max_output,
			   int           flags);



int xd3_main_cmdline (int ARGC, char **ARGV);