summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr/py_misc.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-04-21 11:53:00 +0200
committerAndrew Bartlett <abartlet@samba.org>2009-04-21 11:53:00 +0200
commit6f60a6e71aa9b734ec80865f598ff302d45f2bf3 (patch)
tree933d58ef20ab5f324a5390f67d26e811739e93e8 /source4/librpc/ndr/py_misc.c
parent1856b999c88e0e460fbf713b459d5d367db999f2 (diff)
downloadsamba-6f60a6e71aa9b734ec80865f598ff302d45f2bf3.tar.gz
samba-6f60a6e71aa9b734ec80865f598ff302d45f2bf3.tar.bz2
samba-6f60a6e71aa9b734ec80865f598ff302d45f2bf3.zip
python/dcerpc: Custom implementations of policy_handle.__init__ and policy_handle.__repr__
pair-programmed with Jelmer
Diffstat (limited to 'source4/librpc/ndr/py_misc.c')
-rw-r--r--source4/librpc/ndr/py_misc.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/source4/librpc/ndr/py_misc.c b/source4/librpc/ndr/py_misc.c
index 4e25566148..b56c355fc3 100644
--- a/source4/librpc/ndr/py_misc.c
+++ b/source4/librpc/ndr/py_misc.c
@@ -90,3 +90,41 @@ static void py_GUID_patch(PyTypeObject *type)
#define PY_GUID_PATCH py_GUID_patch
+static int py_policy_handle_init(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+ char *str = NULL;
+ NTSTATUS status;
+ struct policy_handle *handle = py_talloc_get_ptr(self);
+ const char *kwnames[] = { "uuid", "type", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|si", discard_const_p(char *, kwnames), &str, &handle->handle_type))
+ return -1;
+
+ if (str != NULL) {
+ status = GUID_from_string(str, &handle->uuid);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_SetNTSTATUS(status);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static PyObject *py_policy_handle_repr(PyObject *py_self)
+{
+ struct policy_handle *self = py_talloc_get_ptr(py_self);
+ char *uuid_str = GUID_string(NULL, &self->uuid);
+ PyObject *ret = PyString_FromFormat("policy_handle('%s', %d)", uuid_str, self->handle_type);
+ talloc_free(uuid_str);
+ return ret;
+}
+
+static void py_policy_handle_patch(PyTypeObject *type)
+{
+ type->tp_init = py_policy_handle_init;
+ type->tp_repr = py_policy_handle_repr;
+}
+
+#define PY_POLICY_HANDLE_PATCH py_policy_handle_patch
+