From a248164de5f89cef824f5a1f7d8618fbe81ae0c4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 2 Oct 2004 23:35:50 +0000 Subject: r2790: Add code to generate WERROR exceptions. Arrange inclusion of autogenerated interface files to divvy them up into pipes that return WERRORs and pipes that return NTSTATUS values. (This used to be commit 294d1ae35c09432a41e5a07a3aa1884bfb9a93be) --- source4/scripting/swig/dcerpc.i | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i index 5c3ce0ceec..9508dc805e 100644 --- a/source4/scripting/swig/dcerpc.i +++ b/source4/scripting/swig/dcerpc.i @@ -37,7 +37,7 @@ #undef strcpy -PyObject *ntstatus_exception; +PyObject *ntstatus_exception, *werror_exception; /* Set up return of a dcerpc.NTSTATUS exception */ @@ -49,6 +49,14 @@ void set_ntstatus_exception(int status) PyErr_SetObject(ntstatus_exception, obj); } +void set_werror_exception(int status) +{ + PyObject *obj = Py_BuildValue("(i,s)", status, + win_errstr(W_ERROR(status))); + + PyErr_SetObject(werror_exception, obj); +} + /* Conversion functions for scalar types */ uint8 uint8_from_python(PyObject *obj, char *name) @@ -801,6 +809,7 @@ PyObject *DATA_BLOB_to_python(DATA_BLOB obj) %pythoncode %{ NTSTATUS = _dcerpc.NTSTATUS + WERROR = _dcerpc.WERROR %} %init %{ @@ -808,7 +817,9 @@ PyObject *DATA_BLOB_to_python(DATA_BLOB obj) lp_load(dyn_CONFIGFILE, True, False, False); load_interfaces(); ntstatus_exception = PyErr_NewException("_dcerpc.NTSTATUS", NULL, NULL); + werror_exception = PyErr_NewException("_dcerpc.WERROR", NULL, NULL); PyDict_SetItemString(d, "NTSTATUS", ntstatus_exception); + PyDict_SetItemString(d, "WERROR", werror_exception); %} %typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) { @@ -855,7 +866,9 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, const char *username, const char *password); -/* Run this test after each wrapped function */ +%include "librpc/gen_ndr/misc.i" + +/* Wrapped functions returning NTSTATUS */ %exception { $action @@ -865,7 +878,17 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **OUT, } } -%include "librpc/gen_ndr/misc.i" %include "librpc/gen_ndr/lsa.i" %include "librpc/gen_ndr/samr.i" + +/* Wrapped functions returning WERROR */ + +%exception { + $action + if (!W_ERROR_IS_OK(arg3->out.result)) { + set_werror_exception(W_ERROR_V(arg3->out.result)); + return NULL; + } +} + %include "librpc/gen_ndr/winreg.i" -- cgit