summaryrefslogtreecommitdiff
path: root/source4/lib/messaging/pymessaging.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-10-29 15:33:59 +1100
committerAndrew Bartlett <abartlet@samba.org>2012-10-31 08:13:56 +1100
commit76b7348299870279acec5b7c9f02f4e4b2461703 (patch)
tree8f527f1c5dc26b49487b4b8862cd87478b3d52c5 /source4/lib/messaging/pymessaging.c
parent3b4ef03097293f758d8f11cbe434063ed1dc6b91 (diff)
downloadsamba-76b7348299870279acec5b7c9f02f4e4b2461703.tar.gz
samba-76b7348299870279acec5b7c9f02f4e4b2461703.tar.bz2
samba-76b7348299870279acec5b7c9f02f4e4b2461703.zip
pymessaging: Use the server_id IDL structure rather than a tuple
This will make it easier to pass this structure in and out. The tuple is still accepted as input. Andrew Bartlett
Diffstat (limited to 'source4/lib/messaging/pymessaging.c')
-rw-r--r--source4/lib/messaging/pymessaging.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c
index e8ef4a800b..fb74f3e1db 100644
--- a/source4/lib/messaging/pymessaging.c
+++ b/source4/lib/messaging/pymessaging.c
@@ -26,12 +26,14 @@
#include "librpc/rpc/pyrpc_util.h"
#include "librpc/ndr/libndr.h"
#include "lib/messaging/messaging.h"
+#include "lib/messaging/irpc.h"
#include "lib/events/events.h"
#include "cluster/cluster.h"
#include "param/param.h"
#include "param/pyparam.h"
#include "librpc/rpc/dcerpc.h"
#include "librpc/gen_ndr/server_id.h"
+#include <pytalloc.h>
void initmessaging(void);
@@ -40,10 +42,14 @@ extern PyTypeObject imessaging_Type;
static bool server_id_from_py(PyObject *object, struct server_id *server_id)
{
if (!PyTuple_Check(object)) {
- PyErr_SetString(PyExc_ValueError, "Expected tuple");
- return false;
- }
+ if (!py_check_dcerpc_type(object, "server_id", "server_id")) {
+ PyErr_SetString(PyExc_ValueError, "Expected tuple or server_id");
+ return false;
+ }
+ *server_id = *pytalloc_get_type(object, struct server_id);
+ return true;
+ }
if (PyTuple_Size(object) == 3) {
return PyArg_ParseTuple(object, "iii", &server_id->pid, &server_id->task_id, &server_id->vnn);
} else {
@@ -228,10 +234,19 @@ static PyMethodDef py_imessaging_methods[] = {
static PyObject *py_imessaging_server_id(PyObject *obj, void *closure)
{
imessaging_Object *iface = (imessaging_Object *)obj;
+ PyObject *py_server_id;
struct server_id server_id = imessaging_get_server_id(iface->msg_ctx);
+ struct server_id *p_server_id = talloc(NULL, struct server_id);
+ if (!p_server_id) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ *p_server_id = server_id;
+
+ py_server_id = py_return_ndr_struct("samba.dcerpc.server_id", "server_id", p_server_id, p_server_id);
+ talloc_unlink(NULL, p_server_id);
- return Py_BuildValue("(iii)", server_id.pid, server_id.task_id,
- server_id.vnn);
+ return py_server_id;
}
static PyGetSetDef py_imessaging_getset[] = {