mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Improvements to modpython.
1. Be able to write binary data to any sockets, not only to ones created from python. 2. Add support for CSmartPtr<CWebSession>
This commit is contained in:
@@ -68,6 +68,7 @@ using std::allocator;
|
||||
%template(SCString) std::set<CString>;
|
||||
typedef std::set<CString> SCString;
|
||||
%template(PyMCString) std::map<CString, CString>;
|
||||
%template(PyMStringVString) std::map<CString, VCString>;
|
||||
class MCString : public std::map<CString, CString> {};
|
||||
%template(PyModulesVector) std::vector<CModule*>;
|
||||
%template(VListeners) std::vector<CListener*>;
|
||||
@@ -108,6 +109,7 @@ class MCString : public std::map<CString, CString> {};
|
||||
%include "../include/znc/defines.h"
|
||||
%include "../include/znc/Utils.h"
|
||||
%template(PAuthBase) CSmartPtr<CAuthBase>;
|
||||
%template(WebSession) CSmartPtr<CWebSession>;
|
||||
%include "../include/znc/Config.h"
|
||||
%include "../include/znc/Csocket.h"
|
||||
%template(ZNCSocketManager) TSocketManager<CZNCSock>;
|
||||
@@ -163,6 +165,25 @@ class CPyRetBool {
|
||||
}
|
||||
}
|
||||
|
||||
%extend Csock {
|
||||
PyObject* WriteBytes(PyObject* data) {
|
||||
if (!PyBytes_Check(data)) {
|
||||
PyErr_SetString(PyExc_TypeError, "socket.WriteBytes needs bytes as argument");
|
||||
return NULL;
|
||||
}
|
||||
char* buffer;
|
||||
Py_ssize_t length;
|
||||
if (-1 == PyBytes_AsStringAndSize(data, &buffer, &length)) {
|
||||
return NULL;
|
||||
}
|
||||
if ($self->Write(buffer, length)) {
|
||||
Py_RETURN_TRUE;
|
||||
} else {
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%extend CModule {
|
||||
CString __str__() {
|
||||
return $self->GetModName();
|
||||
|
||||
Reference in New Issue
Block a user