Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libloc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
libloc
Commits
24ca7992
Commit
24ca7992
authored
Oct 13, 2019
by
Michael Tremer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python: Expose flags
Signed-off-by:
Michael Tremer
<
michael.tremer@ipfire.org
>
parent
4ef1761f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
src/python/locationmodule.c
src/python/locationmodule.c
+10
-0
src/python/network.c
src/python/network.c
+45
-0
No files found.
src/python/locationmodule.c
View file @
24ca7992
...
...
@@ -115,5 +115,15 @@ PyMODINIT_FUNC PyInit_location(void) {
// Version
PyDict_SetItemString
(
d
,
"__version__"
,
PyUnicode_FromString
(
VERSION
));
// Add flags
if
(
PyModule_AddIntConstant
(
m
,
"FLAG_ANONYMOUS_PROXY"
,
LOC_NETWORK_FLAG_ANONYMOUS_PROXY
))
return
NULL
;
if
(
PyModule_AddIntConstant
(
m
,
"FLAG_SATELLITE_PROVIDER"
,
LOC_NETWORK_FLAG_SATELLITE_PROVIDER
))
return
NULL
;
if
(
PyModule_AddIntConstant
(
m
,
"FLAG_ANYCAST"
,
LOC_NETWORK_FLAG_ANYCAST
))
return
NULL
;
return
m
;
}
src/python/network.c
View file @
24ca7992
...
...
@@ -126,6 +126,50 @@ static int Network_set_asn(NetworkObject* self, PyObject* value) {
return
0
;
}
static
PyObject
*
Network_has_flag
(
NetworkObject
*
self
,
PyObject
*
args
)
{
enum
loc_network_flags
flag
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
flag
))
return
NULL
;
if
(
loc_network_has_flag
(
self
->
network
,
flag
))
Py_RETURN_TRUE
;
Py_RETURN_FALSE
;
}
static
PyObject
*
Network_set_flag
(
NetworkObject
*
self
,
PyObject
*
args
)
{
enum
loc_network_flags
flag
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
flag
))
return
NULL
;
int
r
=
loc_network_set_flag
(
self
->
network
,
flag
);
if
(
r
)
{
// What exception to throw here?
return
NULL
;
}
Py_RETURN_NONE
;
}
static
struct
PyMethodDef
Network_methods
[]
=
{
{
"has_flag"
,
(
PyCFunction
)
Network_has_flag
,
METH_VARARGS
,
NULL
,
},
{
"set_flag"
,
(
PyCFunction
)
Network_set_flag
,
METH_VARARGS
,
NULL
,
},
{
NULL
},
};
static
struct
PyGetSetDef
Network_getsetters
[]
=
{
{
"asn"
,
...
...
@@ -153,6 +197,7 @@ PyTypeObject NetworkType = {
.
tp_dealloc
=
(
destructor
)
Network_dealloc
,
.
tp_init
=
(
initproc
)
Network_init
,
.
tp_doc
=
"Network object"
,
.
tp_methods
=
Network_methods
,
.
tp_getset
=
Network_getsetters
,
.
tp_repr
=
(
reprfunc
)
Network_repr
,
.
tp_str
=
(
reprfunc
)
Network_str
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment