Slight re-org of C API naming convention

This commit is contained in:
Joseph Henry
2021-05-05 16:19:27 -07:00
parent 85b861da2f
commit 9151f4471c
25 changed files with 24963 additions and 1518 deletions

View File

@@ -29,7 +29,7 @@ int zts_py_setblocking(int fd, int block)
{
int new_flags, cur_flags, err = 0;
Py_BEGIN_ALLOW_THREADS cur_flags = zts_fcntl(fd, F_GETFL, 0);
Py_BEGIN_ALLOW_THREADS cur_flags = zts_bsd_fcntl(fd, F_GETFL, 0);
if (cur_flags < 0) {
err = ZTS_ERR_SOCKET;
@@ -44,7 +44,7 @@ int zts_py_setblocking(int fd, int block)
}
if (new_flags != cur_flags) {
err = zts_fcntl(fd, F_SETFL, new_flags);
err = zts_bsd_fcntl(fd, F_SETFL, new_flags);
}
done:
@@ -57,7 +57,7 @@ int zts_py_getblocking(int fd)
{
int flags;
Py_BEGIN_ALLOW_THREADS flags = zts_fcntl(fd, F_GETFL, 0);
Py_BEGIN_ALLOW_THREADS flags = zts_bsd_fcntl(fd, F_GETFL, 0);
Py_END_ALLOW_THREADS
if (flags < 0)
@@ -103,7 +103,7 @@ PyObject* zts_py_accept(int fd)
{
struct zts_sockaddr_in addrbuf = { 0 };
socklen_t addrlen = sizeof(addrbuf);
int err = zts_accept(fd, (struct zts_sockaddr*)&addrbuf, &addrlen);
int err = zts_bsd_accept(fd, (struct zts_sockaddr*)&addrbuf, &addrlen);
char ipstr[ZTS_INET_ADDRSTRLEN] = { 0 };
zts_inet_ntop(ZTS_AF_INET, &(addrbuf.sin_addr), ipstr, ZTS_INET_ADDRSTRLEN);
PyObject* t;
@@ -120,7 +120,7 @@ int zts_py_listen(int fd, int backlog)
if (backlog < 0) {
backlog = 128;
}
return zts_listen(fd, backlog);
return zts_bsd_listen(fd, backlog);
}
int zts_py_bind(int fd, int family, int type, PyObject* addr_obj)
@@ -131,7 +131,7 @@ int zts_py_bind(int fd, int family, int type, PyObject* addr_obj)
if (zts_py_tuple_to_sockaddr(family, addr_obj, (struct zts_sockaddr*)&addrbuf, &addrlen) != ZTS_ERR_OK) {
return ZTS_ERR_ARG;
}
Py_BEGIN_ALLOW_THREADS err = zts_bind(fd, (struct zts_sockaddr*)&addrbuf, addrlen);
Py_BEGIN_ALLOW_THREADS err = zts_bsd_bind(fd, (struct zts_sockaddr*)&addrbuf, addrlen);
Py_END_ALLOW_THREADS return err;
}
@@ -143,7 +143,7 @@ int zts_py_connect(int fd, int family, int type, PyObject* addr_obj)
if (zts_py_tuple_to_sockaddr(family, addr_obj, (struct zts_sockaddr*)&addrbuf, &addrlen) != ZTS_ERR_OK) {
return ZTS_ERR_ARG;
}
Py_BEGIN_ALLOW_THREADS err = zts_connect(fd, (struct zts_sockaddr*)&addrbuf, addrlen);
Py_BEGIN_ALLOW_THREADS err = zts_bsd_connect(fd, (struct zts_sockaddr*)&addrbuf, addrlen);
Py_END_ALLOW_THREADS return err;
}
@@ -157,7 +157,7 @@ PyObject* zts_py_recv(int fd, int len, int flags)
return NULL;
}
bytes_read = zts_recv(fd, PyBytes_AS_STRING(buf), len, flags);
bytes_read = zts_bsd_recv(fd, PyBytes_AS_STRING(buf), len, flags);
t = PyTuple_New(2);
PyTuple_SetItem(t, 0, PyLong_FromLong(bytes_read));
@@ -187,7 +187,7 @@ int zts_py_send(int fd, PyObject* buf, int flags)
return 0;
}
bytes_sent = zts_send(fd, output.buf, output.len, flags);
bytes_sent = zts_bsd_send(fd, output.buf, output.len, flags);
PyBuffer_Release(&output);
return bytes_sent;
@@ -196,7 +196,7 @@ int zts_py_send(int fd, PyObject* buf, int flags)
int zts_py_close(int fd)
{
int err;
Py_BEGIN_ALLOW_THREADS err = zts_close(fd);
Py_BEGIN_ALLOW_THREADS err = zts_bsd_close(fd);
Py_END_ALLOW_THREADS return err;
}

1217
src/bindings/python/libzt.py Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -46,7 +46,7 @@ class socket:
# Only create native socket if no fd was provided. We may have
# accepted a connection
if sock_fd is None:
self._fd = libzt.zts_socket(sock_family, sock_type, sock_proto)
self._fd = libzt.zts_bsd_socket(sock_family, sock_type, sock_proto)
def has_dualstack_ipv6(self):
"""Return whether libzt supports dual stack sockets: yes"""
@@ -427,4 +427,4 @@ class socket:
- ZTS_SHUT_WR - Shut down writing side of socket.
- ZTS_SHUT_RDWR - Both ends of the socket.
"""
libzt.zts_shutdown(self._fd, how)
libzt.zts_bsd_shutdown(self._fd, how)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
#ifndef SWIG_libzt_WRAP_H_
#define SWIG_libzt_WRAP_H_
#include <map>
#include <string>
class SwigDirector_PythonDirectorCallbackClass
: public PythonDirectorCallbackClass
, public Swig::Director {
public:
SwigDirector_PythonDirectorCallbackClass(PyObject* self);
virtual void on_zerotier_event(zts_event_msg_t* msg);
virtual ~SwigDirector_PythonDirectorCallbackClass();
/* Internal director utilities */
public:
bool swig_get_inner(const char* swig_protected_method_name) const
{
std::map<std::string, bool>::const_iterator iv = swig_inner.find(swig_protected_method_name);
return (iv != swig_inner.end() ? iv->second : false);
}
void swig_set_inner(const char* swig_protected_method_name, bool swig_val) const
{
swig_inner[swig_protected_method_name] = swig_val;
}
private:
mutable std::map<std::string, bool> swig_inner;
#if defined(SWIG_PYTHON_DIRECTOR_VTABLE)
/* VTable implementation */
PyObject* swig_get_method(size_t method_index, const char* method_name) const
{
PyObject* method = vtable[method_index];
if (! method) {
swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);
method = PyObject_GetAttr(swig_get_self(), name);
if (! method) {
std::string msg = "Method in class PythonDirectorCallbackClass doesn't exist, undefined ";
msg += method_name;
Swig::DirectorMethodException::raise(msg.c_str());
}
vtable[method_index] = method;
}
return method;
}
private:
mutable swig::SwigVar_PyObject vtable[1];
#endif
};
#endif