-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathlibdoma.i
93 lines (72 loc) · 1.77 KB
/
libdoma.i
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
%module libdoma
%{
#define SWIG_FILE_WITH_INIT
#include "libdoma.h"
%}
%include cpointer.i
%typemap(newfree) char * "free($1);";
%typemap(newfree) flux_entry * "release_flux($1);";
int check_whitelist(const char * domain);
int check_asn(const char * asn_list);
int check_home(const char * host, int verbose);
int update(char* download_path);
%newobject asn_version;
const char * asn_version(void);
%newobject whitelist_version;
const char * whitelist_version(void);
%newobject get_cc_from_domain;
char * get_cc_from_domain(const char * domain);
%delobject destroy_flux_entry;
struct server_headers
{
long http_code;
double clen;
char *rurl;
char *ctype;
};
struct httpbody
{
size_t size;
size_t len;
char *bodydata;
};
struct flux_entry
{
char * addr_str;
char cc[2];
};
%typemap(in, numinputs=0) (char **asn, char **asn_details)
{
char *asn="", *asn_details="";
$1 = &asn;
$2 = &asn_details;
}
%typemap(argout) (char **asn, char **asn_details)
{
PyObject *o = PyTuple_New(3);
PyTuple_SetItem(o, 0, $result);
PyTuple_SetItem(o, 1, PyString_FromString(*$1));
PyTuple_SetItem(o, 2, PyString_FromString(*$2));
$result = o;
}
int get_asn(const char * domain, char **asn, char **asn_details);
%typemap(in, numinputs=0) (struct flux_entry **results)
{
struct flux_entry *results;
$1 = &results;
}
%typemap(argout) (struct flux_entry **results)
{
PyObject *o = PyTuple_New(2);
PyObject *list = PyList_New(0);
PyTuple_SetItem(o, 0, $result);
int i;
for(i=0; (*$1)[i].addr_str ; i++)
{
PyObject *obj = SWIG_NewPointerObj(&((*$1)[i]), $descriptor(struct flux_entry*), 0 );
PyList_Append(list, obj);
}
PyTuple_SetItem(o, 1, list);
$result = o;
}
int get_flux(const char * domain, struct flux_entry ** results);