--- /dev/null
+pytalloc_CObject_FromTallocPtr: PyObject *(void *)
+pytalloc_GetObjectType: PyTypeObject *(void)
+pytalloc_reference_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
+pytalloc_steal: PyObject *(PyTypeObject *, void *)
+pytalloc_steal_ex: PyObject *(PyTypeObject *, TALLOC_CTX *, void *)
/*
Unix SMB/CIFS implementation.
Python Talloc Module
- Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2010
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2010-2011
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
void inittalloc(void);
/* print a talloc tree report for a talloc python object */
-static PyObject *py_talloc_report_full(PyObject *self, PyObject *args)
+static PyObject *pytalloc_report_full(PyObject *self, PyObject *args)
{
PyObject *py_obj = Py_None;
PyTypeObject *type;
talloc_report_full(NULL, stdout);
} else {
type = (PyTypeObject*)PyObject_Type(py_obj);
- talloc_report_full(py_talloc_get_mem_ctx(py_obj), stdout);
+ talloc_report_full(pytalloc_get_mem_ctx(py_obj), stdout);
}
return Py_None;
}
/* enable null tracking */
-static PyObject *py_talloc_enable_null_tracking(PyObject *self)
+static PyObject *pytalloc_enable_null_tracking(PyObject *self)
{
talloc_enable_null_tracking();
return Py_None;
}
/* return the number of talloc blocks */
-static PyObject *py_talloc_total_blocks(PyObject *self, PyObject *args)
+static PyObject *pytalloc_total_blocks(PyObject *self, PyObject *args)
{
PyObject *py_obj = Py_None;
PyTypeObject *type;
type = (PyTypeObject*)PyObject_Type(py_obj);
- return PyLong_FromLong(talloc_total_blocks(py_talloc_get_mem_ctx(py_obj)));
+ return PyLong_FromLong(talloc_total_blocks(pytalloc_get_mem_ctx(py_obj)));
}
static PyMethodDef talloc_methods[] = {
- { "report_full", (PyCFunction)py_talloc_report_full, METH_VARARGS,
+ { "report_full", (PyCFunction)pytalloc_report_full, METH_VARARGS,
"show a talloc tree for an object"},
- { "enable_null_tracking", (PyCFunction)py_talloc_enable_null_tracking, METH_NOARGS,
+ { "enable_null_tracking", (PyCFunction)pytalloc_enable_null_tracking, METH_NOARGS,
"enable tracking of the NULL object"},
- { "total_blocks", (PyCFunction)py_talloc_total_blocks, METH_VARARGS,
+ { "total_blocks", (PyCFunction)pytalloc_total_blocks, METH_VARARGS,
"return talloc block count"},
{ NULL }
};
/**
* Default (but only slightly more useful than the default) implementation of Repr().
*/
-static PyObject *py_talloc_default_repr(PyObject *obj)
+static PyObject *pytalloc_default_repr(PyObject *obj)
{
- py_talloc_Object *talloc_obj = (py_talloc_Object *)obj;
+ pytalloc_Object *talloc_obj = (pytalloc_Object *)obj;
PyTypeObject *type = (PyTypeObject*)PyObject_Type(obj);
return PyString_FromFormat("<%s talloc object at 0x%p>",
/**
* Simple dealloc for talloc-wrapping PyObjects
*/
-static void py_talloc_dealloc(PyObject* self)
+static void pytalloc_dealloc(PyObject* self)
{
- py_talloc_Object *obj = (py_talloc_Object *)self;
+ pytalloc_Object *obj = (pytalloc_Object *)self;
assert(talloc_unlink(NULL, obj->talloc_ctx) != -1);
obj->talloc_ctx = NULL;
self->ob_type->tp_free(self);
/**
* Default (but only slightly more useful than the default) implementation of cmp.
*/
-static int py_talloc_default_cmp(PyObject *_obj1, PyObject *_obj2)
+static int pytalloc_default_cmp(PyObject *_obj1, PyObject *_obj2)
{
- py_talloc_Object *obj1 = (py_talloc_Object *)_obj1,
- *obj2 = (py_talloc_Object *)_obj2;
+ pytalloc_Object *obj1 = (pytalloc_Object *)_obj1,
+ *obj2 = (pytalloc_Object *)_obj2;
if (obj1->ob_type != obj2->ob_type)
return (obj1->ob_type - obj2->ob_type);
- return ((char *)py_talloc_get_ptr(obj1) - (char *)py_talloc_get_ptr(obj2));
+ return ((char *)pytalloc_get_ptr(obj1) - (char *)pytalloc_get_ptr(obj2));
}
static PyTypeObject TallocObject_Type = {
.tp_name = "talloc.Object",
.tp_doc = "Python wrapper for a talloc-maintained object.",
- .tp_basicsize = sizeof(py_talloc_Object),
- .tp_dealloc = (destructor)py_talloc_dealloc,
+ .tp_basicsize = sizeof(pytalloc_Object),
+ .tp_dealloc = (destructor)pytalloc_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
- .tp_repr = py_talloc_default_repr,
- .tp_compare = py_talloc_default_cmp,
+ .tp_repr = pytalloc_default_repr,
+ .tp_compare = pytalloc_default_cmp,
};
void inittalloc(void)
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _PY_TALLOC_H_
-#define _PY_TALLOC_H_
+#ifndef _PYTALLOC_H_
+#define _PYTALLOC_H_
#include <Python.h>
#include <talloc.h>
PyObject_HEAD
TALLOC_CTX *talloc_ctx;
void *ptr;
-} py_talloc_Object;
+} pytalloc_Object;
-PyTypeObject *PyTalloc_GetObjectType(void);
-int PyTalloc_Check(PyObject *);
+PyTypeObject *pytalloc_GetObjectType(void);
+int pytalloc_Check(PyObject *);
-/* Retrieve the pointer for a py_talloc_object. Like talloc_get_type()
- * but for py_talloc_Objects. */
+/* Retrieve the pointer for a pytalloc_object. Like talloc_get_type()
+ * but for pytalloc_Objects. */
/* FIXME: Call PyErr_SetString(PyExc_TypeError, "expected " __STR(type) ")
* when talloc_get_type() returns NULL. */
-#define py_talloc_get_type(py_obj, type) (talloc_get_type(py_talloc_get_ptr(py_obj), type))
+#define pytalloc_get_type(py_obj, type) (talloc_get_type(pytalloc_get_ptr(py_obj), type))
-#define py_talloc_get_ptr(py_obj) (((py_talloc_Object *)py_obj)->ptr)
-#define py_talloc_get_mem_ctx(py_obj) ((py_talloc_Object *)py_obj)->talloc_ctx
+#define pytalloc_get_ptr(py_obj) (((pytalloc_Object *)py_obj)->ptr)
+#define pytalloc_get_mem_ctx(py_obj) ((pytalloc_Object *)py_obj)->talloc_ctx
-PyObject *py_talloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
-PyObject *py_talloc_steal(PyTypeObject *py_type, void *ptr);
-PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
-#define py_talloc_reference(py_type, talloc_ptr) py_talloc_reference_ex(py_type, talloc_ptr, talloc_ptr)
+PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
+PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr);
+PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr);
+#define pytalloc_reference(py_type, talloc_ptr) pytalloc_reference_ex(py_type, talloc_ptr, talloc_ptr)
-#define py_talloc_new(type, typeobj) py_talloc_steal(typeobj, talloc_zero(NULL, type))
+#define pytalloc_new(type, typeobj) pytalloc_steal(typeobj, talloc_zero(NULL, type))
-PyObject *PyCObject_FromTallocPtr(void *);
+PyObject *pytalloc_CObject_FromTallocPtr(void *);
-PyObject *PyString_FromString_check_null(const char *ptr);
-
-#endif /* _PY_TALLOC_H_ */
+#endif /* _PYTALLOC_H_ */
#include "pytalloc.h"
#include <assert.h>
-_PUBLIC_ PyTypeObject *PyTalloc_GetObjectType(void)
+_PUBLIC_ PyTypeObject *pytalloc_GetObjectType(void)
{
static PyTypeObject *type = NULL;
PyObject *mod;
/**
* Import an existing talloc pointer into a Python object.
*/
-_PUBLIC_ PyObject *py_talloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
+_PUBLIC_ PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
void *ptr)
{
- py_talloc_Object *ret = (py_talloc_Object *)py_type->tp_alloc(py_type, 0);
+ pytalloc_Object *ret = (pytalloc_Object *)py_type->tp_alloc(py_type, 0);
ret->talloc_ctx = talloc_new(NULL);
if (ret->talloc_ctx == NULL) {
return NULL;
/**
* Import an existing talloc pointer into a Python object.
*/
-_PUBLIC_ PyObject *py_talloc_steal(PyTypeObject *py_type, void *ptr)
+_PUBLIC_ PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr)
{
- return py_talloc_steal_ex(py_type, ptr, ptr);
+ return pytalloc_steal_ex(py_type, ptr, ptr);
}
* original parent, and creating a reference to the object in the python
* object
*/
-_PUBLIC_ PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr)
+_PUBLIC_ PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr)
{
- py_talloc_Object *ret;
+ pytalloc_Object *ret;
if (ptr == NULL) {
Py_RETURN_NONE;
}
- ret = (py_talloc_Object *)py_type->tp_alloc(py_type, 0);
+ ret = (pytalloc_Object *)py_type->tp_alloc(py_type, 0);
ret->talloc_ctx = talloc_new(NULL);
if (ret->talloc_ctx == NULL) {
return NULL;
talloc_free(ptr);
}
-_PUBLIC_ PyObject *PyCObject_FromTallocPtr(void *ptr)
+_PUBLIC_ PyObject *pytalloc_CObject_FromTallocPtr(void *ptr)
{
if (ptr == NULL) {
Py_RETURN_NONE;
return PyCObject_FromVoidPtr(ptr, py_cobject_talloc_free);
}
-_PUBLIC_ int PyTalloc_Check(PyObject *obj)
+_PUBLIC_ int pytalloc_Check(PyObject *obj)
{
- PyTypeObject *tp = PyTalloc_GetObjectType();
+ PyTypeObject *tp = pytalloc_GetObjectType();
return PyObject_TypeCheck(obj, tp);
}
public_deps='talloc',
pyext=True,
vnum=VERSION,
+ hide_symbols=True,
+ abi_directory='ABI',
+ abi_match='pytalloc_*',
private_library=private_library,
public_headers='pytalloc.h'
)
return NULL;
}
- security_descriptor = py_talloc_get_type(py_sec_desc, struct security_descriptor);
+ security_descriptor = pytalloc_get_type(py_sec_desc, struct security_descriptor);
if (!security_descriptor) {
PyErr_Format(PyExc_TypeError,
"Expected dcerpc.security.descriptor for security_descriptor argument got %s",
- talloc_get_name(py_talloc_get_ptr(py_sec_desc)));
+ talloc_get_name(pytalloc_get_ptr(py_sec_desc)));
return NULL;
}
- security_token = py_talloc_get_type(py_security_token, struct security_token);
+ security_token = pytalloc_get_type(py_security_token, struct security_token);
if (!security_token) {
PyErr_Format(PyExc_TypeError,
"Expected dcerpc.security.token for token argument, got %s",
- talloc_get_name(py_talloc_get_ptr(py_security_token)));
+ talloc_get_name(pytalloc_get_ptr(py_security_token)));
return NULL;
}
$self->pidl("static PyObject *py_$name\_get_$e->{NAME}(PyObject *obj, void *closure)");
$self->pidl("{");
$self->indent;
- $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(obj);");
+ $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(obj);");
$self->pidl("PyObject *py_$e->{NAME};");
- $self->ConvertObjectToPython("py_talloc_get_mem_ctx(obj)", $env, $e, $varname, "py_$e->{NAME}", "return NULL;");
+ $self->ConvertObjectToPython("pytalloc_get_mem_ctx(obj)", $env, $e, $varname, "py_$e->{NAME}", "return NULL;");
$self->pidl("return py_$e->{NAME};");
$self->deindent;
$self->pidl("}");
$self->pidl("static int py_$name\_set_$e->{NAME}(PyObject *py_obj, PyObject *value, void *closure)");
$self->pidl("{");
$self->indent;
- $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
- my $mem_ctx = "py_talloc_get_mem_ctx(py_obj)";
+ $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);");
+ my $mem_ctx = "pytalloc_get_mem_ctx(py_obj)";
my $l = $e->{LEVELS}[0];
my $nl = GetNextLevel($e, $l);
if ($l->{TYPE} eq "POINTER" and
not ($nl->{TYPE} eq "ARRAY" and ($nl->{IS_FIXED} or is_charset_array($e, $nl))) and
not ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE}))) {
- $self->pidl("talloc_unlink(py_talloc_get_mem_ctx(py_obj), $varname);");
+ $self->pidl("talloc_unlink(pytalloc_get_mem_ctx(py_obj), $varname);");
}
$self->ConvertObjectFromPython($env, $mem_ctx, $e, "value", $varname, "return -1;");
$self->pidl("return 0;");
$self->pidl("static PyObject *py_$name\_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)");
$self->pidl("{");
$self->indent;
- $self->pidl("return py_talloc_new($cname, type);");
+ $self->pidl("return pytalloc_new($cname, type);");
$self->deindent;
$self->pidl("}");
$self->pidl("");
$self->pidl("static PyObject *py_$name\_ndr_pack(PyObject *py_obj)");
$self->pidl("{");
$self->indent;
- $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
+ $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);");
$self->pidl("DATA_BLOB blob;");
$self->pidl("enum ndr_err_code err;");
- $self->pidl("err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_$name);");
+ $self->pidl("err = ndr_push_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_$name);");
$self->pidl("if (err != NDR_ERR_SUCCESS) {");
$self->indent;
$self->pidl("PyErr_SetNdrError(err);");
$self->pidl("static PyObject *py_$name\_ndr_unpack(PyObject *py_obj, PyObject *args)");
$self->pidl("{");
$self->indent;
- $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
+ $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);");
$self->pidl("DATA_BLOB blob;");
$self->pidl("int blob_length = 0;");
$self->pidl("enum ndr_err_code err;");
$self->pidl("}");
$self->pidl("blob.length = blob_length;");
$self->pidl("");
- $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
+ $self->pidl("err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
$self->pidl("if (err != NDR_ERR_SUCCESS) {");
$self->indent;
$self->pidl("PyErr_SetNdrError(err);");
$self->pidl("static PyObject *py_$name\_ndr_print(PyObject *py_obj)");
$self->pidl("{");
$self->indent;
- $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
+ $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);");
$self->pidl("PyObject *ret;");
$self->pidl("char *retstr;");
$self->pidl("");
- $self->pidl("retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_$name, \"$name\", object);");
+ $self->pidl("retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_$name, \"$name\", object);");
$self->pidl("ret = PyString_FromString(retstr);");
$self->pidl("talloc_free(retstr);");
$self->pidl("");
}
$self->pidl(".tp_methods = $py_methods,");
$self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
- $self->pidl(".tp_basicsize = sizeof(py_talloc_Object),");
+ $self->pidl(".tp_basicsize = sizeof(pytalloc_Object),");
$self->pidl(".tp_new = py_$name\_new,");
$self->deindent;
$self->pidl("};");
return;
}
$self->pidl("PY_CHECK_TYPE($ctype_name, $cvar, $fail);");
- $self->pidl("if (talloc_reference($mem_ctx, py_talloc_get_mem_ctx($cvar)) == NULL) {");
+ $self->pidl("if (talloc_reference($mem_ctx, pytalloc_get_mem_ctx($cvar)) == NULL) {");
$self->indent;
$self->pidl("PyErr_NoMemory();");
$self->pidl("$fail");
$self->deindent;
$self->pidl("}");
- $self->assign($target, "(".mapTypeName($ctype)." *)py_talloc_get_ptr($cvar)");
+ $self->assign($target, "(".mapTypeName($ctype)." *)pytalloc_get_ptr($cvar)");
return;
}
}
# Not yet supported
- if ($ctypename eq "string_array") { return "PyCObject_FromTallocPtr($cvar)"; }
+ if ($ctypename eq "string_array") { return "pytalloc_CObject_FromTallocPtr($cvar)"; }
if ($ctypename eq "ipv4address") { return "PyString_FromStringOrNULL($cvar)"; }
if ($ctypename eq "ipv6address") { return "PyString_FromStringOrNULL($cvar)"; }
if ($ctypename eq "dnsp_name") { return "PyString_FromStringOrNULL($cvar)"; }
if ($ctypename eq "dnsp_string") { return "PyString_FromStringOrNULL($cvar)"; }
if ($ctypename eq "pointer") {
- return "PyCObject_FromTallocPtr($cvar)";
+ return "pytalloc_CObject_FromTallocPtr($cvar)";
}
die("Unknown scalar type $ctypename");
error($location, "Unable to determine origin of type `" . mapTypeName($ctype) . "'");
return "NULL"; # FIXME!
}
- return "py_talloc_reference_ex($ctype_name, $mem_ctx, $cvar)";
+ return "pytalloc_reference_ex($ctype_name, $mem_ctx, $cvar)";
}
fatal($location, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar");
static PyObject *py_creds_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
- py_talloc_Object *ret = (py_talloc_Object *)type->tp_alloc(type, 0);
+ pytalloc_Object *ret = (pytalloc_Object *)type->tp_alloc(type, 0);
if (ret == NULL) {
PyErr_NoMemory();
return NULL;
return (PyObject *)ret;
}
-static PyObject *py_creds_get_username(py_talloc_Object *self)
+static PyObject *py_creds_get_username(pytalloc_Object *self)
{
return PyString_FromStringOrNULL(cli_credentials_get_username(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_set_username(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_username(pytalloc_Object *self, PyObject *args)
{
char *newval;
enum credentials_obtained obt = CRED_SPECIFIED;
return PyBool_FromLong(cli_credentials_set_username(PyCredentials_AsCliCredentials(self), newval, obt));
}
-static PyObject *py_creds_get_password(py_talloc_Object *self)
+static PyObject *py_creds_get_password(pytalloc_Object *self)
{
return PyString_FromStringOrNULL(cli_credentials_get_password(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_set_password(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_password(pytalloc_Object *self, PyObject *args)
{
char *newval;
enum credentials_obtained obt = CRED_SPECIFIED;
return PyBool_FromLong(cli_credentials_set_password(PyCredentials_AsCliCredentials(self), newval, obt));
}
-static PyObject *py_creds_get_domain(py_talloc_Object *self)
+static PyObject *py_creds_get_domain(pytalloc_Object *self)
{
return PyString_FromStringOrNULL(cli_credentials_get_domain(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_set_domain(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_domain(pytalloc_Object *self, PyObject *args)
{
char *newval;
enum credentials_obtained obt = CRED_SPECIFIED;
return PyBool_FromLong(cli_credentials_set_domain(PyCredentials_AsCliCredentials(self), newval, obt));
}
-static PyObject *py_creds_get_realm(py_talloc_Object *self)
+static PyObject *py_creds_get_realm(pytalloc_Object *self)
{
return PyString_FromStringOrNULL(cli_credentials_get_realm(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_set_realm(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_realm(pytalloc_Object *self, PyObject *args)
{
char *newval;
enum credentials_obtained obt = CRED_SPECIFIED;
return PyBool_FromLong(cli_credentials_set_realm(PyCredentials_AsCliCredentials(self), newval, obt));
}
-static PyObject *py_creds_get_bind_dn(py_talloc_Object *self)
+static PyObject *py_creds_get_bind_dn(pytalloc_Object *self)
{
return PyString_FromStringOrNULL(cli_credentials_get_bind_dn(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_set_bind_dn(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_bind_dn(pytalloc_Object *self, PyObject *args)
{
char *newval;
if (!PyArg_ParseTuple(args, "s", &newval))
return PyBool_FromLong(cli_credentials_set_bind_dn(PyCredentials_AsCliCredentials(self), newval));
}
-static PyObject *py_creds_get_workstation(py_talloc_Object *self)
+static PyObject *py_creds_get_workstation(pytalloc_Object *self)
{
return PyString_FromStringOrNULL(cli_credentials_get_workstation(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_set_workstation(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_workstation(pytalloc_Object *self, PyObject *args)
{
char *newval;
enum credentials_obtained obt = CRED_SPECIFIED;
return PyBool_FromLong(cli_credentials_set_workstation(PyCredentials_AsCliCredentials(self), newval, obt));
}
-static PyObject *py_creds_is_anonymous(py_talloc_Object *self)
+static PyObject *py_creds_is_anonymous(pytalloc_Object *self)
{
return PyBool_FromLong(cli_credentials_is_anonymous(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_set_anonymous(py_talloc_Object *self)
+static PyObject *py_creds_set_anonymous(pytalloc_Object *self)
{
cli_credentials_set_anonymous(PyCredentials_AsCliCredentials(self));
Py_RETURN_NONE;
}
-static PyObject *py_creds_authentication_requested(py_talloc_Object *self)
+static PyObject *py_creds_authentication_requested(pytalloc_Object *self)
{
return PyBool_FromLong(cli_credentials_authentication_requested(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_wrong_password(py_talloc_Object *self)
+static PyObject *py_creds_wrong_password(pytalloc_Object *self)
{
return PyBool_FromLong(cli_credentials_wrong_password(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_set_cmdline_callbacks(py_talloc_Object *self)
+static PyObject *py_creds_set_cmdline_callbacks(pytalloc_Object *self)
{
return PyBool_FromLong(cli_credentials_set_cmdline_callbacks(PyCredentials_AsCliCredentials(self)));
}
-static PyObject *py_creds_parse_string(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_parse_string(pytalloc_Object *self, PyObject *args)
{
char *newval;
enum credentials_obtained obt = CRED_SPECIFIED;
Py_RETURN_NONE;
}
-static PyObject *py_creds_get_nt_hash(py_talloc_Object *self)
+static PyObject *py_creds_get_nt_hash(pytalloc_Object *self)
{
const struct samr_Password *ntpw = cli_credentials_get_nt_hash(PyCredentials_AsCliCredentials(self), self->ptr);
return PyString_FromStringAndSize(discard_const_p(char, ntpw->hash), 16);
}
-static PyObject *py_creds_set_kerberos_state(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_kerberos_state(pytalloc_Object *self, PyObject *args)
{
int state;
if (!PyArg_ParseTuple(args, "i", &state))
Py_RETURN_NONE;
}
-static PyObject *py_creds_set_krb_forwardable(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_krb_forwardable(pytalloc_Object *self, PyObject *args)
{
int state;
if (!PyArg_ParseTuple(args, "i", &state))
Py_RETURN_NONE;
}
-static PyObject *py_creds_guess(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_guess(pytalloc_Object *self, PyObject *args)
{
PyObject *py_lp_ctx = Py_None;
struct loadparm_context *lp_ctx;
Py_RETURN_NONE;
}
-static PyObject *py_creds_set_machine_account(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_machine_account(pytalloc_Object *self, PyObject *args)
{
PyObject *py_lp_ctx = Py_None;
struct loadparm_context *lp_ctx;
}
-static PyObject *py_creds_get_named_ccache(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_get_named_ccache(pytalloc_Object *self, PyObject *args)
{
PyObject *py_lp_ctx = Py_None;
char *ccache_name;
return NULL;
}
-static PyObject *py_creds_set_gensec_features(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_set_gensec_features(pytalloc_Object *self, PyObject *args)
{
unsigned int gensec_features;
Py_RETURN_NONE;
}
-static PyObject *py_creds_get_gensec_features(py_talloc_Object *self, PyObject *args)
+static PyObject *py_creds_get_gensec_features(pytalloc_Object *self, PyObject *args)
{
unsigned int gensec_features;
PyTypeObject PyCredentials = {
.tp_name = "credentials.Credentials",
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
.tp_new = py_creds_new,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_methods = py_creds_methods,
PyTypeObject PyCredentialCacheContainer = {
.tp_name = "credentials.CredentialCacheContainer",
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
.tp_flags = Py_TPFLAGS_DEFAULT,
};
void initcredentials(void)
{
PyObject *m;
- PyTypeObject *talloc_type = PyTalloc_GetObjectType();
+ PyTypeObject *talloc_type = pytalloc_GetObjectType();
if (talloc_type == NULL)
return;
struct ccache_container *ccc;
} PyCredentialCacheContainerObject;
#define PyCredentials_Check(py_obj) PyObject_TypeCheck(py_obj, &PyCredentials)
-#define PyCredentials_AsCliCredentials(py_obj) py_talloc_get_type(py_obj, struct cli_credentials)
+#define PyCredentials_AsCliCredentials(py_obj) pytalloc_get_type(py_obj, struct cli_credentials)
#define cli_credentials_from_py_object(py_obj) (py_obj == Py_None)?cli_credentials_init_anon(NULL):PyCredentials_AsCliCredentials(py_obj)
#endif /* _PYCREDENTIALS_H_ */
if (!PyArg_ParseTuple(args, "i", &type))
return NULL;
- security = py_talloc_get_type(self, struct gensec_security);
+ security = pytalloc_get_type(self, struct gensec_security);
name = gensec_get_name_by_authtype(security, type);
if (name == NULL)
static PyObject *py_gensec_start_client(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
NTSTATUS status;
- py_talloc_Object *self;
+ pytalloc_Object *self;
struct gensec_settings *settings;
const char *kwnames[] = { "settings", NULL };
PyObject *py_settings;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", discard_const_p(char *, kwnames), &py_settings))
return NULL;
- self = (py_talloc_Object*)type->tp_alloc(type, 0);
+ self = (pytalloc_Object*)type->tp_alloc(type, 0);
if (self == NULL) {
PyErr_NoMemory();
return NULL;
static PyObject *py_gensec_start_server(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
NTSTATUS status;
- py_talloc_Object *self;
+ pytalloc_Object *self;
struct gensec_settings *settings = NULL;
const char *kwnames[] = { "settings", "auth_context", NULL };
PyObject *py_settings = Py_None;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO", discard_const_p(char *, kwnames), &py_settings, &py_auth_context))
return NULL;
- self = (py_talloc_Object*)type->tp_alloc(type, 0);
+ self = (pytalloc_Object*)type->tp_alloc(type, 0);
if (self == NULL) {
PyErr_NoMemory();
return NULL;
}
if (py_auth_context != Py_None) {
- auth_context = py_talloc_get_type(py_auth_context, struct auth4_context);
+ auth_context = pytalloc_get_type(py_auth_context, struct auth4_context);
if (!auth_context) {
PyErr_Format(PyExc_TypeError,
"Expected auth.AuthContext for auth_context argument, got %s",
- talloc_get_name(py_talloc_get_ptr(py_auth_context)));
+ talloc_get_name(pytalloc_get_ptr(py_auth_context)));
return NULL;
}
}
{
PyObject *py_creds = Py_None;
struct cli_credentials *creds;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
NTSTATUS status;
if (!PyArg_ParseTuple(args, "O", &py_creds))
if (!creds) {
PyErr_Format(PyExc_TypeError,
"Expected samba.credentaials for credentials argument got %s",
- talloc_get_name(py_talloc_get_ptr(py_creds)));
+ talloc_get_name(pytalloc_get_ptr(py_creds)));
}
status = gensec_set_credentials(security, creds);
TALLOC_CTX *mem_ctx;
NTSTATUS status;
PyObject *py_session_info;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
struct auth_session_info *info;
if (security->ops == NULL) {
PyErr_SetString(PyExc_RuntimeError, "no mechanism selected");
static PyObject *py_gensec_start_mech_by_name(PyObject *self, PyObject *args)
{
char *name;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
NTSTATUS status;
if (!PyArg_ParseTuple(args, "s", &name))
static PyObject *py_gensec_start_mech_by_sasl_name(PyObject *self, PyObject *args)
{
char *sasl_name;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
NTSTATUS status;
if (!PyArg_ParseTuple(args, "s", &sasl_name))
static PyObject *py_gensec_start_mech_by_authtype(PyObject *self, PyObject *args)
{
int authtype, level;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
NTSTATUS status;
if (!PyArg_ParseTuple(args, "ii", &authtype, &level))
return NULL;
static PyObject *py_gensec_want_feature(PyObject *self, PyObject *args)
{
int feature;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
/* This is i (and declared as an int above) by design, as they are handled as an integer in python */
if (!PyArg_ParseTuple(args, "i", &feature))
return NULL;
static PyObject *py_gensec_have_feature(PyObject *self, PyObject *args)
{
int feature;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
/* This is i (and declared as an int above) by design, as they are handled as an integer in python */
if (!PyArg_ParseTuple(args, "i", &feature))
return NULL;
TALLOC_CTX *mem_ctx;
DATA_BLOB in, out;
PyObject *ret, *py_in;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
PyObject *finished_processing;
if (!PyArg_ParseTuple(args, "O", &py_in))
TALLOC_CTX *mem_ctx;
DATA_BLOB in, out;
PyObject *ret, *py_in;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
if (!PyArg_ParseTuple(args, "O", &py_in))
return NULL;
TALLOC_CTX *mem_ctx;
DATA_BLOB in, out;
PyObject *ret, *py_in;
- struct gensec_security *security = py_talloc_get_type(self, struct gensec_security);
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
if (!PyArg_ParseTuple(args, "O", &py_in))
return NULL;
.tp_name = "gensec.Security",
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_methods = py_gensec_security_methods,
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
};
void initgensec(void);
{
PyObject *m;
- Py_Security.tp_base = PyTalloc_GetObjectType();
+ Py_Security.tp_base = pytalloc_GetObjectType();
if (Py_Security.tp_base == NULL)
return;
static PyObject *PyAuthContext_FromContext(struct auth4_context *auth_context)
{
- return py_talloc_reference(&PyAuthContext, auth_context);
+ return pytalloc_reference(&PyAuthContext, auth_context);
}
static PyObject *py_auth_context_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
}
if (py_imessaging_ctx != Py_None) {
- imessaging_context = py_talloc_get_type(py_imessaging_ctx, struct imessaging_context);
+ imessaging_context = pytalloc_get_type(py_imessaging_ctx, struct imessaging_context);
}
if (py_methods == Py_None && py_ldb == Py_None) {
static PyTypeObject PyAuthContext = {
.tp_name = "AuthContext",
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_new = py_auth_context_new,
};
{
PyObject *m;
- PyAuthContext.tp_base = PyTalloc_GetObjectType();
+ PyAuthContext.tp_base = pytalloc_GetObjectType();
if (PyAuthContext.tp_base == NULL)
return;
#include <pytalloc.h>
#include "auth/session.h"
-#define PyAuthSession_AsSession(obj) py_talloc_get_type(obj, struct auth_session_info)
+#define PyAuthSession_AsSession(obj) pytalloc_get_type(obj, struct auth_session_info)
struct auth_session_info *PyObject_AsSession(PyObject *obj);
#endif /* _PYAUTH_H */
void initregistry(void);
-/*#define PyRegistryKey_AsRegistryKey(obj) py_talloc_get_type(obj, struct registry_key)*/
-#define PyRegistry_AsRegistryContext(obj) ((struct registry_context *)py_talloc_get_ptr(obj))
-#define PyHiveKey_AsHiveKey(obj) ((struct hive_key*)py_talloc_get_ptr(obj))
+/*#define PyRegistryKey_AsRegistryKey(obj) pytalloc_get_type(obj, struct registry_key)*/
+#define PyRegistry_AsRegistryContext(obj) ((struct registry_context *)pytalloc_get_ptr(obj))
+#define PyHiveKey_AsHiveKey(obj) ((struct hive_key*)pytalloc_get_ptr(obj))
static PyObject *py_get_predefined_key_by_name(PyObject *self, PyObject *args)
result = reg_get_predefined_key_by_name(ctx, name, &key);
PyErr_WERROR_IS_ERR_RAISE(result);
- return py_talloc_steal(&PyRegistryKey, key);
+ return pytalloc_steal(&PyRegistryKey, key);
}
static PyObject *py_key_del_abs(PyObject *self, PyObject *args)
result = reg_get_predefined_key(ctx, hkey, &key);
PyErr_WERROR_IS_ERR_RAISE(result);
- return py_talloc_steal(&PyRegistryKey, key);
+ return pytalloc_steal(&PyRegistryKey, key);
}
static PyObject *py_diff_apply(PyObject *self, PyObject *args)
struct registry_context *ctx;
result = reg_open_local(NULL, &ctx);
PyErr_WERROR_IS_ERR_RAISE(result);
- return py_talloc_steal(&PyRegistry, ctx);
+ return pytalloc_steal(&PyRegistry, ctx);
}
static PyMethodDef registry_methods[] = {
.tp_name = "Registry",
.tp_methods = registry_methods,
.tp_new = registry_new,
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
.tp_flags = Py_TPFLAGS_DEFAULT,
};
talloc_free(mem_ctx);
PyErr_WERROR_IS_ERR_RAISE(result);
- return py_talloc_steal(&PyHiveKey, hive_key);
+ return pytalloc_steal(&PyHiveKey, hive_key);
}
PyTypeObject PyHiveKey = {
.tp_name = "HiveKey",
.tp_methods = hive_key_methods,
.tp_new = hive_new,
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
.tp_flags = Py_TPFLAGS_DEFAULT,
};
PyTypeObject PyRegistryKey = {
.tp_name = "RegistryKey",
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
.tp_flags = Py_TPFLAGS_DEFAULT,
};
return NULL;
}
- return py_talloc_steal(&PyRegistry, reg_ctx);
+ return pytalloc_steal(&PyRegistry, reg_ctx);
}
static PyObject *py_open_directory(PyObject *self, PyObject *args)
result = reg_open_directory(NULL, location, &key);
PyErr_WERROR_IS_ERR_RAISE(result);
- return py_talloc_steal(&PyHiveKey, key);
+ return pytalloc_steal(&PyHiveKey, key);
}
static PyObject *py_create_directory(PyObject *self, PyObject *args)
result = reg_create_directory(NULL, location, &key);
PyErr_WERROR_IS_ERR_RAISE(result);
- return py_talloc_steal(&PyHiveKey, key);
+ return pytalloc_steal(&PyHiveKey, key);
}
static PyObject *py_open_ldb_file(PyObject *self, PyObject *args, PyObject *kwargs)
talloc_free(mem_ctx);
PyErr_WERROR_IS_ERR_RAISE(result);
- return py_talloc_steal(&PyHiveKey, key);
+ return pytalloc_steal(&PyHiveKey, key);
}
static PyObject *py_str_regtype(PyObject *self, PyObject *args)
void initregistry(void)
{
PyObject *m;
- PyTypeObject *talloc_type = PyTalloc_GetObjectType();
+ PyTypeObject *talloc_type = pytalloc_GetObjectType();
if (talloc_type == NULL)
return;
/*
* Read SMB file and return the contents of the file as python string
*/
-static PyObject * py_smb_loadfile(py_talloc_Object *self, PyObject *args)
+static PyObject * py_smb_loadfile(pytalloc_Object *self, PyObject *args)
{
struct smb_composite_loadfile io;
const char *filename;
/*
* Create a SMB file with given string as the contents
*/
-static PyObject * py_smb_savefile(py_talloc_Object *self, PyObject *args)
+static PyObject * py_smb_savefile(pytalloc_Object *self, PyObject *args)
{
struct smb_composite_savefile io;
const char *filename;
/*
* List the directory contents for specified directory (Ignore '.' and '..' dirs)
*/
-static PyObject *py_smb_list(py_talloc_Object *self, PyObject *args, PyObject *kwargs)
+static PyObject *py_smb_list(pytalloc_Object *self, PyObject *args, PyObject *kwargs)
{
struct smb_private_data *spdata;
PyObject *py_dirlist;
/*
* Create a directory
*/
-static PyObject *py_smb_mkdir(py_talloc_Object *self, PyObject *args)
+static PyObject *py_smb_mkdir(pytalloc_Object *self, PyObject *args)
{
NTSTATUS status;
const char *dirname;
/*
* Remove a directory
*/
-static PyObject *py_smb_rmdir(py_talloc_Object *self, PyObject *args)
+static PyObject *py_smb_rmdir(pytalloc_Object *self, PyObject *args)
{
NTSTATUS status;
const char *dirname;
/*
* Check existence of a path
*/
-static PyObject *py_smb_chkpath(py_talloc_Object *self, PyObject *args)
+static PyObject *py_smb_chkpath(pytalloc_Object *self, PyObject *args)
{
NTSTATUS status;
const char *path;
/*
* Read ACL on a given file/directory as a security descriptor object
*/
-static PyObject *py_smb_getacl(py_talloc_Object *self, PyObject *args, PyObject *kwargs)
+static PyObject *py_smb_getacl(pytalloc_Object *self, PyObject *args, PyObject *kwargs)
{
NTSTATUS status;
union smb_open io;
/*
* Set ACL on file/directory using given security descriptor object
*/
-static PyObject *py_smb_setacl(py_talloc_Object *self, PyObject *args, PyObject *kwargs)
+static PyObject *py_smb_setacl(pytalloc_Object *self, PyObject *args, PyObject *kwargs)
{
NTSTATUS status;
union smb_open io;
spdata = self->ptr;
- sd = py_talloc_get_type(py_sd, struct security_descriptor);
+ sd = pytalloc_get_type(py_sd, struct security_descriptor);
if (!sd) {
PyErr_Format(PyExc_TypeError,
"Expected dcerpc.security.descriptor as argument, got %s",
- talloc_get_name(py_talloc_get_ptr(py_sd)));
+ talloc_get_name(pytalloc_get_ptr(py_sd)));
return NULL;
}
const char *kwnames[] = { "hostname", "service", "creds", "lp", NULL };
const char *hostname = NULL;
const char *service = NULL;
- py_talloc_Object *smb;
+ pytalloc_Object *smb;
struct smb_private_data *spdata;
NTSTATUS status;
return NULL;
}
- smb = (py_talloc_Object *)type->tp_alloc(type, 0);
+ smb = (pytalloc_Object *)type->tp_alloc(type, 0);
if (smb == NULL) {
PyErr_NoMemory();
return NULL;
static PyTypeObject PySMB = {
.tp_name = "smb.SMB",
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
.tp_new = py_smb_new,
.tp_flags = Py_TPFLAGS_DEFAULT,
.tp_methods = py_smb_methods,
void initsmb(void)
{
PyObject *m;
- PyTypeObject *talloc_type = PyTalloc_GetObjectType();
+ PyTypeObject *talloc_type = pytalloc_GetObjectType();
if (talloc_type == NULL) {
return;
}
/*
Unix SMB/CIFS implementation.
Samba utility functions
+
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008-2010
Copyright (C) Kamen Mazdrashki <kamen.mazdrashki@postpath.com> 2009
if (dom_sid_Type == NULL)
return NULL;
- return py_talloc_reference((PyTypeObject *)dom_sid_Type, sid);
+ return pytalloc_reference((PyTypeObject *)dom_sid_Type, sid);
}
static PyObject *py_net_vampire(py_net_Object *self, PyObject *args, PyObject *kwargs)
s->chunk.forest = &s->forest;
s->chunk.dest_dsa = &s->dest_dsa;
- return PyCObject_FromTallocPtr(s);
+ return pytalloc_CObject_FromTallocPtr(s);
}
if (!py_check_dcerpc_type(py_ctr, "samba.dcerpc.drsuapi", "DsGetNCChangesCtr1")) {
return NULL;
}
- s->chunk.ctr1 = py_talloc_get_ptr(py_ctr);
+ s->chunk.ctr1 = pytalloc_get_ptr(py_ctr);
s->partition.nc = *s->chunk.ctr1->naming_context;
s->partition.more_data = s->chunk.ctr1->more_data;
s->partition.source_dsa_guid = s->chunk.ctr1->source_dsa_guid;
if (!py_check_dcerpc_type(py_ctr, "samba.dcerpc.drsuapi", "DsGetNCChangesCtr6")) {
return NULL;
}
- s->chunk.ctr6 = py_talloc_get_ptr(py_ctr);
+ s->chunk.ctr6 = pytalloc_get_ptr(py_ctr);
s->partition.nc = *s->chunk.ctr6->naming_context;
s->partition.more_data = s->chunk.ctr6->more_data;
s->partition.source_dsa_guid = s->chunk.ctr6->source_dsa_guid;
/*
Unix SMB/CIFS implementation.
- Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008
+
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2011
Copyright (C) Andrew Bartlett <abartlet@samba.org> 2011
This program is free software; you can redistribute it and/or modify
static PyObject *py_auth_session_get_credentials(PyObject *self, void *closure)
{
- struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info);
+ struct auth_session_info *session = pytalloc_get_type(self, struct auth_session_info);
PyObject *py_credentials;
/* This is evil, as the credentials are not IDL structures */
py_credentials = py_return_ndr_struct("samba.credentials", "Credentials", session->credentials, session->credentials);
static int py_auth_session_set_credentials(PyObject *self, PyObject *value, void *closure)
{
- struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info);
+ struct auth_session_info *session = pytalloc_get_type(self, struct auth_session_info);
session->credentials = talloc_reference(session, PyCredentials_AsCliCredentials(value));
return 0;
}
/*
Unix SMB/CIFS implementation.
Samba utility functions
+
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
This program is free software; you can redistribute it and/or modify
static int py_GUID_cmp(PyObject *py_self, PyObject *py_other)
{
int ret;
- struct GUID *self = py_talloc_get_ptr(py_self), *other;
- other = py_talloc_get_ptr(py_other);
+ struct GUID *self = pytalloc_get_ptr(py_self), *other;
+ other = pytalloc_get_ptr(py_other);
if (other == NULL)
return -1;
static PyObject *py_GUID_str(PyObject *py_self)
{
- struct GUID *self = py_talloc_get_ptr(py_self);
+ struct GUID *self = pytalloc_get_ptr(py_self);
char *str = GUID_string(NULL, self);
PyObject *ret = PyString_FromString(str);
talloc_free(str);
static PyObject *py_GUID_repr(PyObject *py_self)
{
- struct GUID *self = py_talloc_get_ptr(py_self);
+ struct GUID *self = pytalloc_get_ptr(py_self);
char *str = GUID_string(NULL, self);
PyObject *ret = PyString_FromFormat("GUID('%s')", str);
talloc_free(str);
{
PyObject *str = NULL;
NTSTATUS status;
- struct GUID *guid = py_talloc_get_ptr(self);
+ struct GUID *guid = pytalloc_get_ptr(self);
const char *kwnames[] = { "str", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", discard_const_p(char *, kwnames), &str))
{
char *str = NULL;
NTSTATUS status;
- struct policy_handle *handle = py_talloc_get_ptr(self);
+ struct policy_handle *handle = pytalloc_get_ptr(self);
const char *kwnames[] = { "uuid", "type", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|si", discard_const_p(char *, kwnames), &str, &handle->handle_type))
static PyObject *py_policy_handle_repr(PyObject *py_self)
{
- struct policy_handle *self = py_talloc_get_ptr(py_self);
+ struct policy_handle *self = pytalloc_get_ptr(py_self);
char *uuid_str = GUID_string(NULL, &self->uuid);
PyObject *ret = PyString_FromFormat("policy_handle(%d, '%s')", self->handle_type, uuid_str);
talloc_free(uuid_str);
static PyObject *py_policy_handle_str(PyObject *py_self)
{
- struct policy_handle *self = py_talloc_get_ptr(py_self);
+ struct policy_handle *self = pytalloc_get_ptr(py_self);
char *uuid_str = GUID_string(NULL, &self->uuid);
PyObject *ret = PyString_FromFormat("%d, %s", self->handle_type, uuid_str);
talloc_free(uuid_str);
/*
Unix SMB/CIFS implementation.
Samba utility functions
- Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008-2010
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static PyObject *py_dom_sid_split(PyObject *py_self, PyObject *args)
{
- struct dom_sid *self = py_talloc_get_ptr(py_self);
+ struct dom_sid *self = pytalloc_get_ptr(py_self);
struct dom_sid *domain_sid;
TALLOC_CTX *mem_ctx;
uint32_t rid;
return NULL;
}
- py_domain_sid = py_talloc_steal(&dom_sid_Type, domain_sid);
+ py_domain_sid = pytalloc_steal(&dom_sid_Type, domain_sid);
talloc_free(mem_ctx);
return Py_BuildValue("(OI)", py_domain_sid, rid);
}
static int py_dom_sid_cmp(PyObject *py_self, PyObject *py_other)
{
- struct dom_sid *self = py_talloc_get_ptr(py_self), *other;
- other = py_talloc_get_ptr(py_other);
+ struct dom_sid *self = pytalloc_get_ptr(py_self), *other;
+ other = pytalloc_get_ptr(py_other);
if (other == NULL)
return -1;
static PyObject *py_dom_sid_str(PyObject *py_self)
{
- struct dom_sid *self = py_talloc_get_ptr(py_self);
+ struct dom_sid *self = pytalloc_get_ptr(py_self);
char *str = dom_sid_string(NULL, self);
PyObject *ret = PyString_FromString(str);
talloc_free(str);
static PyObject *py_dom_sid_repr(PyObject *py_self)
{
- struct dom_sid *self = py_talloc_get_ptr(py_self);
+ struct dom_sid *self = pytalloc_get_ptr(py_self);
char *str = dom_sid_string(NULL, self);
PyObject *ret = PyString_FromFormat("dom_sid('%s')", str);
talloc_free(str);
static int py_dom_sid_init(PyObject *self, PyObject *args, PyObject *kwargs)
{
char *str = NULL;
- struct dom_sid *sid = py_talloc_get_ptr(self);
+ struct dom_sid *sid = pytalloc_get_ptr(self);
const char *kwnames[] = { "str", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", discard_const_p(char *, kwnames), &str))
static PyObject *py_descriptor_sacl_add(PyObject *self, PyObject *args)
{
- struct security_descriptor *desc = py_talloc_get_ptr(self);
+ struct security_descriptor *desc = pytalloc_get_ptr(self);
NTSTATUS status;
struct security_ace *ace;
PyObject *py_ace;
if (!PyArg_ParseTuple(args, "O", &py_ace))
return NULL;
- ace = py_talloc_get_ptr(py_ace);
+ ace = pytalloc_get_ptr(py_ace);
status = security_descriptor_sacl_add(desc, ace);
PyErr_NTSTATUS_IS_ERR_RAISE(status);
Py_RETURN_NONE;
static PyObject *py_descriptor_dacl_add(PyObject *self, PyObject *args)
{
- struct security_descriptor *desc = py_talloc_get_ptr(self);
+ struct security_descriptor *desc = pytalloc_get_ptr(self);
NTSTATUS status;
struct security_ace *ace;
PyObject *py_ace;
if (!PyArg_ParseTuple(args, "O", &py_ace))
return NULL;
- ace = py_talloc_get_ptr(py_ace);
+ ace = pytalloc_get_ptr(py_ace);
status = security_descriptor_dacl_add(desc, ace);
PyErr_NTSTATUS_IS_ERR_RAISE(status);
static PyObject *py_descriptor_dacl_del(PyObject *self, PyObject *args)
{
- struct security_descriptor *desc = py_talloc_get_ptr(self);
+ struct security_descriptor *desc = pytalloc_get_ptr(self);
NTSTATUS status;
struct dom_sid *sid;
PyObject *py_sid;
if (!PyArg_ParseTuple(args, "O", &py_sid))
return NULL;
- sid = py_talloc_get_ptr(py_sid);
+ sid = pytalloc_get_ptr(py_sid);
status = security_descriptor_dacl_del(desc, sid);
PyErr_NTSTATUS_IS_ERR_RAISE(status);
Py_RETURN_NONE;
static PyObject *py_descriptor_sacl_del(PyObject *self, PyObject *args)
{
- struct security_descriptor *desc = py_talloc_get_ptr(self);
+ struct security_descriptor *desc = pytalloc_get_ptr(self);
NTSTATUS status;
struct dom_sid *sid;
PyObject *py_sid;
if (!PyArg_ParseTuple(args, "O", &py_sid))
return NULL;
- sid = py_talloc_get_ptr(py_sid);
+ sid = pytalloc_get_ptr(py_sid);
status = security_descriptor_sacl_del(desc, sid);
PyErr_NTSTATUS_IS_ERR_RAISE(status);
Py_RETURN_NONE;
static PyObject *py_descriptor_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)
{
- return py_talloc_steal(self, security_descriptor_initialise(NULL));
+ return pytalloc_steal(self, security_descriptor_initialise(NULL));
}
static PyObject *py_descriptor_from_sddl(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "sO!", &sddl, &dom_sid_Type, &py_sid))
return NULL;
- sid = py_talloc_get_ptr(py_sid);
+ sid = pytalloc_get_ptr(py_sid);
secdesc = sddl_decode(NULL, sddl, sid);
if (secdesc == NULL) {
return NULL;
}
- return py_talloc_steal((PyTypeObject *)self, secdesc);
+ return pytalloc_steal((PyTypeObject *)self, secdesc);
}
static PyObject *py_descriptor_as_sddl(PyObject *self, PyObject *args)
{
struct dom_sid *sid;
PyObject *py_sid = Py_None;
- struct security_descriptor *desc = py_talloc_get_ptr(self);
+ struct security_descriptor *desc = pytalloc_get_ptr(self);
char *text;
PyObject *ret;
return NULL;
if (py_sid != Py_None)
- sid = py_talloc_get_ptr(py_sid);
+ sid = pytalloc_get_ptr(py_sid);
else
sid = NULL;
{
PyObject *py_sid;
struct dom_sid *sid;
- struct security_token *token = py_talloc_get_ptr(self);
+ struct security_token *token = pytalloc_get_ptr(self);
if (!PyArg_ParseTuple(args, "O", &py_sid))
return NULL;
- sid = py_talloc_get_ptr(py_sid);
+ sid = pytalloc_get_ptr(py_sid);
return PyBool_FromLong(security_token_is_sid(token, sid));
}
{
PyObject *py_sid;
struct dom_sid *sid;
- struct security_token *token = py_talloc_get_ptr(self);
+ struct security_token *token = pytalloc_get_ptr(self);
if (!PyArg_ParseTuple(args, "O", &py_sid))
return NULL;
- sid = py_talloc_get_ptr(py_sid);
+ sid = pytalloc_get_ptr(py_sid);
return PyBool_FromLong(security_token_has_sid(token, sid));
}
static PyObject *py_token_is_anonymous(PyObject *self)
{
- struct security_token *token = py_talloc_get_ptr(self);
+ struct security_token *token = pytalloc_get_ptr(self);
return PyBool_FromLong(security_token_is_anonymous(token));
}
static PyObject *py_token_is_system(PyObject *self)
{
- struct security_token *token = py_talloc_get_ptr(self);
+ struct security_token *token = pytalloc_get_ptr(self);
return PyBool_FromLong(security_token_is_system(token));
}
static PyObject *py_token_has_builtin_administrators(PyObject *self)
{
- struct security_token *token = py_talloc_get_ptr(self);
+ struct security_token *token = pytalloc_get_ptr(self);
return PyBool_FromLong(security_token_has_builtin_administrators(token));
}
static PyObject *py_token_has_nt_authenticated_users(PyObject *self)
{
- struct security_token *token = py_talloc_get_ptr(self);
+ struct security_token *token = pytalloc_get_ptr(self);
return PyBool_FromLong(security_token_has_nt_authenticated_users(token));
}
static PyObject *py_token_has_privilege(PyObject *self, PyObject *args)
{
int priv;
- struct security_token *token = py_talloc_get_ptr(self);
+ struct security_token *token = pytalloc_get_ptr(self);
if (!PyArg_ParseTuple(args, "i", &priv))
return NULL;
static PyObject *py_token_set_privilege(PyObject *self, PyObject *args)
{
int priv;
- struct security_token *token = py_talloc_get_ptr(self);
+ struct security_token *token = pytalloc_get_ptr(self);
if (!PyArg_ParseTuple(args, "i", &priv))
return NULL;
static PyObject *py_token_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)
{
- return py_talloc_steal(self, security_token_initialise(NULL));
+ return pytalloc_steal(self, security_token_initialise(NULL));
}
static PyMethodDef py_token_extra_methods[] = {
sid = dom_sid_parse_talloc(NULL, str);
talloc_free(str);
- ret = py_talloc_steal(&dom_sid_Type, sid);
+ ret = pytalloc_steal(&dom_sid_Type, sid);
return ret;
}
static PyObject *py_ntacl_print(PyObject *self, PyObject *args)
{
- struct xattr_NTACL *ntacl = py_talloc_get_ptr(self);
+ struct xattr_NTACL *ntacl = pytalloc_get_ptr(self);
struct ndr_print *pr;
TALLOC_CTX *mem_ctx;
return NULL;
}
- return py_talloc_reference_ex(py_type, r_ctx, r);
+ return pytalloc_reference_ex(py_type, r_ctx, r);
}
PyObject *PyString_FromStringOrNULL(const char *str)
if (dom_sid_Type == NULL)
return NULL;
- return py_talloc_reference((PyTypeObject *)dom_sid_Type, sid);
+ return pytalloc_reference((PyTypeObject *)dom_sid_Type, sid);
}
NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
typedef inquiry lenfunc;
#endif
-#define PyLoadparmContext_AsLoadparmContext(obj) py_talloc_get_type(obj, struct loadparm_context)
-#define PyLoadparmService_AsLoadparmService(obj) py_talloc_get_type(obj, struct loadparm_service)
+#define PyLoadparmContext_AsLoadparmContext(obj) pytalloc_get_type(obj, struct loadparm_context)
+#define PyLoadparmService_AsLoadparmService(obj) pytalloc_get_type(obj, struct loadparm_service)
extern PyTypeObject PyLoadparmContext;
extern PyTypeObject PyLoadparmService;
static PyObject *PyLoadparmService_FromService(struct loadparm_service *service)
{
- return py_talloc_reference(&PyLoadparmService, service);
+ return pytalloc_reference(&PyLoadparmService, service);
}
static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const char *service_name, const char *param_name)
}
-static PyObject *py_lp_ctx_load(py_talloc_Object *self, PyObject *args)
+static PyObject *py_lp_ctx_load(pytalloc_Object *self, PyObject *args)
{
char *filename;
bool ret;
Py_RETURN_NONE;
}
-static PyObject *py_lp_ctx_load_default(py_talloc_Object *self)
+static PyObject *py_lp_ctx_load_default(pytalloc_Object *self)
{
bool ret;
ret = lpcfg_load_default(PyLoadparmContext_AsLoadparmContext(self));
Py_RETURN_NONE;
}
-static PyObject *py_lp_ctx_get(py_talloc_Object *self, PyObject *args)
+static PyObject *py_lp_ctx_get(pytalloc_Object *self, PyObject *args)
{
char *param_name;
char *section_name = NULL;
return ret;
}
-static PyObject *py_lp_ctx_is_myname(py_talloc_Object *self, PyObject *args)
+static PyObject *py_lp_ctx_is_myname(pytalloc_Object *self, PyObject *args)
{
char *name;
if (!PyArg_ParseTuple(args, "s", &name))
return PyBool_FromLong(lpcfg_is_myname(PyLoadparmContext_AsLoadparmContext(self), name));
}
-static PyObject *py_lp_ctx_is_mydomain(py_talloc_Object *self, PyObject *args)
+static PyObject *py_lp_ctx_is_mydomain(pytalloc_Object *self, PyObject *args)
{
char *name;
if (!PyArg_ParseTuple(args, "s", &name))
return PyBool_FromLong(lpcfg_is_mydomain(PyLoadparmContext_AsLoadparmContext(self), name));
}
-static PyObject *py_lp_ctx_set(py_talloc_Object *self, PyObject *args)
+static PyObject *py_lp_ctx_set(pytalloc_Object *self, PyObject *args)
{
char *name, *value;
bool ret;
Py_RETURN_NONE;
}
-static PyObject *py_lp_ctx_private_path(py_talloc_Object *self, PyObject *args)
+static PyObject *py_lp_ctx_private_path(pytalloc_Object *self, PyObject *args)
{
char *name, *path;
PyObject *ret;
return ret;
}
-static PyObject *py_lp_ctx_services(py_talloc_Object *self)
+static PyObject *py_lp_ctx_services(pytalloc_Object *self)
{
struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self);
PyObject *ret;
{ NULL }
};
-static PyObject *py_lp_ctx_default_service(py_talloc_Object *self, void *closure)
+static PyObject *py_lp_ctx_default_service(pytalloc_Object *self, void *closure)
{
return PyLoadparmService_FromService(lpcfg_default_service(PyLoadparmContext_AsLoadparmContext(self)));
}
-static PyObject *py_lp_ctx_config_file(py_talloc_Object *self, void *closure)
+static PyObject *py_lp_ctx_config_file(pytalloc_Object *self, void *closure)
{
const char *configfile = lpcfg_configfile(PyLoadparmContext_AsLoadparmContext(self));
if (configfile == NULL)
static PyObject *py_lp_ctx_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
- py_talloc_Object *ret = (py_talloc_Object *)type->tp_alloc(type, 0);
+ pytalloc_Object *ret = (pytalloc_Object *)type->tp_alloc(type, 0);
if (ret == NULL) {
PyErr_NoMemory();
return NULL;
return (PyObject *)ret;
}
-static Py_ssize_t py_lp_ctx_len(py_talloc_Object *self)
+static Py_ssize_t py_lp_ctx_len(pytalloc_Object *self)
{
return lpcfg_numservices(PyLoadparmContext_AsLoadparmContext(self));
}
-static PyObject *py_lp_ctx_getitem(py_talloc_Object *self, PyObject *name)
+static PyObject *py_lp_ctx_getitem(pytalloc_Object *self, PyObject *name)
{
struct loadparm_service *service;
if (!PyString_Check(name)) {
PyTypeObject PyLoadparmContext = {
.tp_name = "param.LoadParm",
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
.tp_getset = py_lp_ctx_getset,
.tp_methods = py_lp_ctx_methods,
.tp_new = py_lp_ctx_new,
PyTypeObject PyLoadparmService = {
.tp_name = "param.LoadparmService",
- .tp_basicsize = sizeof(py_talloc_Object),
+ .tp_basicsize = sizeof(pytalloc_Object),
.tp_methods = py_lp_service_methods,
.tp_flags = Py_TPFLAGS_DEFAULT,
};
void initparam(void)
{
PyObject *m;
- PyTypeObject *talloc_type = PyTalloc_GetObjectType();
+ PyTypeObject *talloc_type = pytalloc_GetObjectType();
if (talloc_type == NULL)
return;
#include "param/loadparm.h"
#include "lib/talloc/pytalloc.h"
-#define PyLoadparmContext_AsLoadparmContext(obj) py_talloc_get_type(obj, struct loadparm_context)
+#define PyLoadparmContext_AsLoadparmContext(obj) pytalloc_get_type(obj, struct loadparm_context)
_PUBLIC_ struct loadparm_context *lpcfg_from_py_object(TALLOC_CTX *mem_ctx, PyObject *py_obj)
{