-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathutils.h
More file actions
36 lines (29 loc) · 1.05 KB
/
Copy pathutils.h
File metadata and controls
36 lines (29 loc) · 1.05 KB
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 <iwlib.h>
#define OPEN_IW(sock) { \
char _buf[1024]; \
if((sock = iw_sockets_open()) < 0) { \
snprintf(_buf, 1024, "Error opening iwlib socket [Errno %d] %s", errno, strerror(errno)); \
PyErr_SetString(PyExc_OSError, _buf); \
return NULL; \
} \
}
#define SAFE_SETITEMSTRING(dict, key, value) do { \
PyObject *__tmp; \
__tmp = value; \
if (__tmp) { \
PyDict_SetItemString(dict, key, __tmp); \
Py_DECREF(__tmp); \
} \
} while(0)
PyObject *wireless_info_to_PyDict(struct wireless_info *info);
PyObject *wireless_config_to_PyDict(struct wireless_config *info);
PyObject *wireless_scan_to_PyDict(struct wireless_scan *scan);
/* Python 2/3 compatibility helpers **********************************/
#if PY_MAJOR_VERSION >= 3
#define PY_FROMSTRING(X) PyBytes_FromString( (X) )
#define PY_FROMFORMAT(X, Y) PyBytes_FromFormat( (X), (Y) )
#else
#define PY_FROMSTRING(X) PyString_FromString( (X) )
#define PY_FROMFORMAT(X, Y) PyString_FromFormat( (X), (Y) )
#endif