summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-05-25 04:23:03 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-05-25 04:23:03 +0200
commit928ecbaebbde00515d08fd530db7c99169c905ef (patch)
tree257a93daab6d607ccfdfdab9b93b7e6788a9a11b /source4/pidl/lib/Parse
parenta2446e5f8550582c0d4353bb85874dea17cf1d98 (diff)
downloadsamba-928ecbaebbde00515d08fd530db7c99169c905ef.tar.gz
samba-928ecbaebbde00515d08fd530db7c99169c905ef.tar.bz2
samba-928ecbaebbde00515d08fd530db7c99169c905ef.zip
Add support for secondary contexts from Python.
(This used to be commit 16d1ad050546ae6500153438db8d3c857e6f3ad5)
Diffstat (limited to 'source4/pidl/lib/Parse')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm26
1 files changed, 23 insertions, 3 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 2795d987f7..dbbdb6bca1 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -650,20 +650,20 @@ sub Interface($$$)
$self->pidl("const char *binding_string;");
$self->pidl("struct cli_credentials *credentials;");
$self->pidl("struct loadparm_context *lp_ctx = NULL;");
- $self->pidl("PyObject *py_lp_ctx = Py_None, *py_credentials = Py_None;");
+ $self->pidl("PyObject *py_lp_ctx = Py_None, *py_credentials = Py_None, *py_basis = Py_None;");
$self->pidl("TALLOC_CTX *mem_ctx = NULL;");
$self->pidl("struct event_context *event_ctx;");
$self->pidl("NTSTATUS status;");
$self->pidl("");
$self->pidl("const char *kwnames[] = {");
$self->indent;
- $self->pidl("\"binding\", \"lp_ctx\", \"credentials\", NULL");
+ $self->pidl("\"binding\", \"lp_ctx\", \"credentials\", \"basis_connection\", NULL");
$self->deindent;
$self->pidl("};");
$self->pidl("extern struct loadparm_context *lp_from_py_object(PyObject *py_obj);");
$self->pidl("extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);");
$self->pidl("");
- $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s|OO:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials)) {");
+ $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s|OOO:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials, &py_basis)) {");
$self->indent;
$self->pidl("return NULL;");
$self->deindent;
@@ -691,8 +691,28 @@ sub Interface($$$)
$self->pidl("event_ctx = event_context_init(mem_ctx);");
$self->pidl("");
+ $self->pidl("if (py_basis != Py_None) {");
+ $self->indent;
+ $self->pidl("struct dcerpc_pipe *base_pipe;");
+ $self->pidl("");
+ $self->pidl("if (!PyObject_TypeCheck(py_basis, &dcerpc_InterfaceType)) {");
+ $self->indent;
+ $self->pidl("PyErr_SetString(PyExc_ValueError, \"basis_connection must be a DCE/RPC connection\");");
+ $self->pidl("talloc_free(mem_ctx);");
+ $self->pidl("return NULL;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+ $self->pidl("base_pipe = ((dcerpc_InterfaceObject *)py_basis)->pipe;");
+ $self->pidl("");
+ $self->pidl("status = dcerpc_secondary_context(base_pipe, &ret->pipe, &ndr_table_$interface->{NAME});");
+ $self->deindent;
+ $self->pidl("} else {");
+ $self->indent;
$self->pidl("status = dcerpc_pipe_connect(NULL, &ret->pipe, binding_string, ");
$self->pidl(" &ndr_table_$interface->{NAME}, credentials, event_ctx, lp_ctx);");
+ $self->deindent;
+ $self->pidl("}");
$self->handle_ntstatus("status", "NULL", "mem_ctx");
$self->pidl("ret->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;");