static PyObject *py_get_class_object(PyObject *self, PyObject *args) { char *s_clsid, *s_iid; struct GUID clsid, iid; struct IUnknown *object; NTSTATUS status; WERROR error; if (!PyArg_ParseTuple(args, "ss", &s_clsid, &s_iid)) return NULL; status = GUID_from_string(s_clsid, &clsid); if (!NT_STATUS_IS_OK(status)) { PyErr_FromNTSTATUS(status); return NULL; } status = GUID_from_string(s_iid, &iid); if (!NT_STATUS_IS_OK(status)) { PyErr_FromNTSTATUS(status); return NULL; } error = com_get_class_object(py_com_ctx, &clsid, &iid, &object); if (!W_ERROR_IS_OK(error)) { PyErr_FromWERROR(error); return NULL; } /* FIXME: Magic, integrate with stubs generated by pidl. */ Py_RETURN_NONE; }
static PyObject *py_wrap_getxattr(PyObject *self, PyObject *args) { char *filename, *attribute, *tdbname; TALLOC_CTX *mem_ctx; DATA_BLOB blob; PyObject *ret; NTSTATUS status; struct tdb_wrap *eadb = NULL; if (!PyArg_ParseTuple(args, "sss", &tdbname, &filename, &attribute)) return NULL; mem_ctx = talloc_new(NULL); eadb = tdb_wrap_open(mem_ctx, tdbname, 50000, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); if (eadb == NULL) { PyErr_SetFromErrno(PyExc_IOError); talloc_free(mem_ctx); return NULL; } status = pull_xattr_blob_tdb_raw(eadb, mem_ctx, attribute, filename, -1, 100, &blob); if (!NT_STATUS_IS_OK(status) || blob.length < 0) { PyErr_FromNTSTATUS(status); talloc_free(mem_ctx); return NULL; } ret = PyString_FromStringAndSize((char *)blob.data, blob.length); talloc_free(mem_ctx); return ret; }
static PyObject *py_wrap_setxattr(PyObject *self, PyObject *args) { char *filename, *attribute, *tdbname; DATA_BLOB blob; int blobsize; NTSTATUS status; TALLOC_CTX *mem_ctx; struct tdb_wrap *eadb; if (!PyArg_ParseTuple(args, "ssss#", &tdbname, &filename, &attribute, &blob.data, &blobsize)) return NULL; blob.length = blobsize; mem_ctx = talloc_new(NULL); eadb = tdb_wrap_open(mem_ctx, tdbname, 50000, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); if (eadb == NULL) { PyErr_SetFromErrno(PyExc_IOError); talloc_free(mem_ctx); return NULL; } status = push_xattr_blob_tdb_raw(eadb, mem_ctx, attribute, filename, -1, &blob); if (!NT_STATUS_IS_OK(status)) { PyErr_FromNTSTATUS(status); talloc_free(mem_ctx); return NULL; } talloc_free(mem_ctx); Py_RETURN_NONE; }