Commit 83a0bdc5 authored by Mathieu Parent's avatar Mathieu Parent

New upstream version 2.1.9

parent 488ae121
_pytalloc_check_type: int (PyObject *, const char *)
_pytalloc_get_mem_ctx: TALLOC_CTX *(PyObject *)
_pytalloc_get_ptr: void *(PyObject *)
_pytalloc_get_type: void *(PyObject *, const char *)
pytalloc_BaseObject_PyType_Ready: int (PyTypeObject *)
pytalloc_BaseObject_check: int (PyObject *)
pytalloc_BaseObject_size: size_t (void)
pytalloc_CObject_FromTallocPtr: PyObject *(void *)
pytalloc_Check: int (PyObject *)
pytalloc_GenericObject_reference_ex: PyObject *(TALLOC_CTX *, void *)
pytalloc_GenericObject_steal_ex: PyObject *(TALLOC_CTX *, void *)
pytalloc_GetBaseObjectType: PyTypeObject *(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 *)
_pytalloc_check_type: int (PyObject *, const char *)
_pytalloc_get_mem_ctx: TALLOC_CTX *(PyObject *)
_pytalloc_get_ptr: void *(PyObject *)
_pytalloc_get_type: void *(PyObject *, const char *)
pytalloc_BaseObject_PyType_Ready: int (PyTypeObject *)
pytalloc_BaseObject_check: int (PyObject *)
pytalloc_BaseObject_size: size_t (void)
pytalloc_Check: int (PyObject *)
pytalloc_GenericObject_reference_ex: PyObject *(TALLOC_CTX *, void *)
pytalloc_GenericObject_steal_ex: PyObject *(TALLOC_CTX *, void *)
pytalloc_GetBaseObjectType: PyTypeObject *(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 *)
_talloc: void *(const void *, size_t)
_talloc_array: void *(const void *, size_t, unsigned int, const char *)
_talloc_free: int (void *, const char *)
_talloc_get_type_abort: void *(const void *, const char *, const char *)
_talloc_memdup: void *(const void *, const void *, size_t, const char *)
_talloc_move: void *(const void *, const void *)
_talloc_pooled_object: void *(const void *, size_t, const char *, unsigned int, size_t)
_talloc_realloc: void *(const void *, void *, size_t, const char *)
_talloc_realloc_array: void *(const void *, void *, size_t, unsigned int, const char *)
_talloc_reference_loc: void *(const void *, const void *, const char *)
_talloc_set_destructor: void (const void *, int (*)(void *))
_talloc_steal_loc: void *(const void *, const void *, const char *)
_talloc_zero: void *(const void *, size_t, const char *)
_talloc_zero_array: void *(const void *, size_t, unsigned int, const char *)
talloc_asprintf: char *(const void *, const char *, ...)
talloc_asprintf_append: char *(char *, const char *, ...)
talloc_asprintf_append_buffer: char *(char *, const char *, ...)
talloc_autofree_context: void *(void)
talloc_check_name: void *(const void *, const char *)
talloc_disable_null_tracking: void (void)
talloc_enable_leak_report: void (void)
talloc_enable_leak_report_full: void (void)
talloc_enable_null_tracking: void (void)
talloc_enable_null_tracking_no_autofree: void (void)
talloc_find_parent_byname: void *(const void *, const char *)
talloc_free_children: void (void *)
talloc_get_name: const char *(const void *)
talloc_get_size: size_t (const void *)
talloc_increase_ref_count: int (const void *)
talloc_init: void *(const char *, ...)
talloc_is_parent: int (const void *, const void *)
talloc_named: void *(const void *, size_t, const char *, ...)
talloc_named_const: void *(const void *, size_t, const char *)
talloc_parent: void *(const void *)
talloc_parent_name: const char *(const void *)
talloc_pool: void *(const void *, size_t)
talloc_realloc_fn: void *(const void *, void *, size_t)
talloc_reference_count: size_t (const void *)
talloc_reparent: void *(const void *, const void *, const void *)
talloc_report: void (const void *, FILE *)
talloc_report_depth_cb: void (const void *, int, int, void (*)(const void *, int, int, int, void *), void *)
talloc_report_depth_file: void (const void *, int, int, FILE *)
talloc_report_full: void (const void *, FILE *)
talloc_set_abort_fn: void (void (*)(const char *))
talloc_set_log_fn: void (void (*)(const char *))
talloc_set_log_stderr: void (void)
talloc_set_memlimit: int (const void *, size_t)
talloc_set_name: const char *(const void *, const char *, ...)
talloc_set_name_const: void (const void *, const char *)
talloc_show_parents: void (const void *, FILE *)
talloc_strdup: char *(const void *, const char *)
talloc_strdup_append: char *(char *, const char *)
talloc_strdup_append_buffer: char *(char *, const char *)
talloc_strndup: char *(const void *, const char *, size_t)
talloc_strndup_append: char *(char *, const char *, size_t)
talloc_strndup_append_buffer: char *(char *, const char *, size_t)
talloc_test_get_magic: int (void)
talloc_total_blocks: size_t (const void *)
talloc_total_size: size_t (const void *)
talloc_unlink: int (const void *, void *)
talloc_vasprintf: char *(const void *, const char *, va_list)
talloc_vasprintf_append: char *(char *, const char *, va_list)
talloc_vasprintf_append_buffer: char *(char *, const char *, va_list)
talloc_version_major: int (void)
talloc_version_minor: int (void)
......@@ -2,37 +2,10 @@
# and for SAMBA_ macros for building libraries, binaries etc
import Options, Build, os
from optparse import SUPPRESS_HELP
from samba_utils import os_path_relpath, TO_LIST
from samba_utils import os_path_relpath, TO_LIST, samba_add_onoff_option
from samba_autoconf import library_flags
def SAMBA3_ADD_OPTION(opt, option, help=(), dest=None, default=True,
with_name="with", without_name="without"):
if default is None:
default_str = "auto"
elif default is True:
default_str = "yes"
elif default is False:
default_str = "no"
else:
default_str = str(default)
if help == ():
help = ("Build with %s support (default=%s)" % (option, default_str))
if dest is None:
dest = "with_%s" % option.replace('-', '_')
with_val = "--%s-%s" % (with_name, option)
without_val = "--%s-%s" % (without_name, option)
#FIXME: This is broken and will always default to "default" no matter if
# --with or --without is chosen.
opt.add_option(with_val, help=help, action="store_true", dest=dest,
default=default)
opt.add_option(without_val, help=SUPPRESS_HELP, action="store_false",
dest=dest)
Options.Handler.SAMBA3_ADD_OPTION = SAMBA3_ADD_OPTION
Options.Handler.SAMBA3_ADD_OPTION = samba_add_onoff_option
def SAMBA3_IS_STATIC_MODULE(bld, module):
'''Check whether module is in static list'''
......
......@@ -708,6 +708,7 @@ def SAMBA_CONFIG_H(conf, path=None):
testflags=True)
conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
conf.ADD_CFLAGS('-Werror=format-security -Wformat-security', testflags=True)
# This check is because for ldb_search(), a NULL format string
# is not an error, but some compilers complain about that.
if CHECK_CFLAGS(conf, ["-Werror=format", "-Wformat=2"], '''
......
......@@ -286,7 +286,9 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, version_script=False, msg=None):
os.makedirs(subdir)
Utils.writef(os.path.join(subdir, 'lib1.c'), 'int lib_func(void) { return 42; }\n')
Utils.writef(os.path.join(dir, 'main.c'), 'int main(void) {return !(lib_func() == 42);}\n')
Utils.writef(os.path.join(dir, 'main.c'),
'int lib_func(void);\n'
'int main(void) {return !(lib_func() == 42);}\n')
bld = Build.BuildContext()
bld.log = conf.log
......@@ -436,6 +438,7 @@ def CHECK_UNAME(conf):
ret = True
for v in "sysname machine release version".split():
if not conf.CHECK_CODE('''
int printf(const char *format, ...);
struct utsname n;
if (uname(&n) == -1) return -1;
printf("%%s", n.%s);
......
......@@ -49,7 +49,8 @@ def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5,0,0)):
conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir
perl_inc = read_perl_config_var('print "@INC"')
perl_inc.remove('.')
if '.' in perl_inc:
perl_inc.remove('.')
conf.start_msg("PERL_INC: ")
conf.end_msg("%s" % (perl_inc), 'GREEN')
conf.env.PERL_INC = perl_inc
......@@ -2,6 +2,7 @@
# and for SAMBA_ macros for building libraries, binaries etc
import os, sys, re, fnmatch, shlex
from optparse import SUPPRESS_HELP
import Build, Options, Utils, Task, Logs, Configure
from TaskGen import feature, before, after
from Configure import conf, ConfigurationContext
......@@ -669,3 +670,27 @@ def samba_before_apply_obj_vars(self):
if is_standard_libpath(v, i):
v['LIBPATH'].remove(i)
def samba_add_onoff_option(opt, option, help=(), dest=None, default=True,
with_name="with", without_name="without"):
if default is None:
default_str = "auto"
elif default is True:
default_str = "yes"
elif default is False:
default_str = "no"
else:
default_str = str(default)
if help == ():
help = ("Build with %s support (default=%s)" % (option, default_str))
if dest is None:
dest = "with_%s" % option.replace('-', '_')
with_val = "--%s-%s" % (with_name, option)
without_val = "--%s-%s" % (without_name, option)
opt.add_option(with_val, help=help, action="store_true", dest=dest,
default=default)
opt.add_option(without_val, help=SUPPRESS_HELP, action="store_false",
dest=dest)
Options.Handler.samba_add_onoff_option = samba_add_onoff_option
......@@ -490,12 +490,12 @@ struct foo bar = { .y = 'X', .x = 1 };
if not conf.CHECK_LARGEFILE():
raise Utils.WafError('Samba requires large file support support, but not available on this platform: sizeof(off_t) < 8')
if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
if conf.env.HAVE_STDDEF_H and conf.env.HAVE_STDLIB_H:
conf.DEFINE('STDC_HEADERS', 1)
conf.CHECK_HEADERS('sys/time.h time.h', together=True)
if 'HAVE_SYS_TIME_H' in conf.env and 'HAVE_TIME_H' in conf.env:
if conf.env.HAVE_SYS_TIME_H and conf.env.HAVE_TIME_H:
conf.DEFINE('TIME_WITH_SYS_TIME', 1)
# cope with different extensions for libraries
......
/*
/*
Unix SMB/CIFS implementation.
Samba utility functions
Copyright (C) Andrew Tridgell 1998
......@@ -94,17 +94,17 @@ int rep_getifaddrs(struct ifaddrs **ifap)
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
return -1;
}
ifc.ifc_len = sizeof(buff);
ifc.ifc_buf = buff;
if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
close(fd);
return -1;
}
}
ifr = ifc.ifc_req;
n = ifc.ifc_len / sizeof(struct ifreq);
/* Loop through interfaces, looking for given IP address */
......@@ -171,7 +171,7 @@ int rep_getifaddrs(struct ifaddrs **ifap)
close(fd);
return 0;
}
}
#define _FOUND_IFACE_ANY
#endif /* HAVE_IFACE_IFCONF */
......@@ -200,14 +200,14 @@ int rep_getifaddrs(struct ifaddrs **ifap)
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
return -1;
}
strioctl.ic_cmd = SIOCGIFCONF;
strioctl.ic_dp = buff;
strioctl.ic_len = sizeof(buff);
if (ioctl(fd, I_STR, &strioctl) < 0) {
close(fd);
return -1;
}
}
/* we can ignore the possible sizeof(int) here as the resulting
number of interface structures won't change */
......@@ -217,16 +217,16 @@ int rep_getifaddrs(struct ifaddrs **ifap)
at the start of the buffer if the offered size is a
multiple of the structure size plus an int */
if (n*sizeof(struct ifreq) + sizeof(int) == strioctl.ic_len) {
ifr = (struct ifreq *)(buff + sizeof(int));
ifr = (struct ifreq *)(buff + sizeof(int));
} else {
ifr = (struct ifreq *)buff;
ifr = (struct ifreq *)buff;
}
/* Loop through interfaces */
for (i = 0; i<n; i++) {
ifreq = ifr[i];
curif = calloc(1, sizeof(struct ifaddrs));
if (lastif == NULL) {
*ifap = curif;
......
......@@ -171,6 +171,10 @@
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#endif
#ifdef HAVE_SETPROCTITLE_H
#include <setproctitle.h>
#endif
......
......@@ -34,7 +34,7 @@
* probably requires libm on most operating systems. Don't yet
* support the exponent (e,E) and sigfig (g,G). Also, fmtint()
* was pretty badly broken, it just wasn't being exercised in ways
* which showed it, so that's been fixed. Also, formated the code
* which showed it, so that's been fixed. Also, formatted the code
* to mutt conventions, and removed dead code left over from the
* original. Also, there is now a builtin-test, just compile with:
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
......
......@@ -46,6 +46,10 @@
#define mkdir(dir, mode) mkdir(dir)
#endif
#if HAVE_LIBGEN_H
# include <libgen.h>
#endif
/* Test whether a file name is the "." or ".." directory entries.
* These really should be inline functions.
*/
......
......@@ -365,4 +365,8 @@ struct addrinfo {
#endif /* HAVE_LINUX_IPV6_V6ONLY_26 */
#endif /* HAVE_IPV6 */
#ifndef SCOPE_DELIMITER
#define SCOPE_DELIMITER '%'
#endif
#endif
......@@ -4,6 +4,9 @@
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
......@@ -15,7 +18,7 @@
#define MAP_FILE 0
#endif
main()
int main(void)
{
int *buf;
int i;
......
......@@ -3,6 +3,9 @@
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
......@@ -18,7 +21,7 @@
#define MAP_FAILED (int *)-1
#endif
main()
int main(void)
{
int *buf;
int fd;
......
......@@ -26,4 +26,4 @@ void foo(const char *format, ...)
printf("1");
exit(0);
}
main() { foo("hello"); }
int main(void) { foo("hello"); }
......@@ -189,7 +189,7 @@ def configure(conf):
''',
define='HAVE_IPV6',
lib='nsl socket',
headers='sys/socket.h netdb.h netinet/in.h')
headers='sys/socket.h netdb.h netinet/in.h net/if.h')
if conf.CONFIG_SET('HAVE_SYS_UCONTEXT_H') and conf.CONFIG_SET('HAVE_SIGNAL_H'):
conf.CHECK_CODE('''
......@@ -376,7 +376,7 @@ removeea setea
if conf.CHECK_FUNCS_IN('dgettext gettext', '', checklibc=True, headers='libintl.h'):
# save for dependency definitions
conf.env.intl_libs=''
# others (e.g. FreeBSD) have seperate libintl
# others (e.g. FreeBSD) have separate libintl
elif conf.CHECK_FUNCS_IN('dgettext gettext', 'intl', checklibc=False, headers='libintl.h'):
# save for dependency definitions
conf.env.intl_libs='intl'
......@@ -483,6 +483,9 @@ removeea setea
if conf.CONFIG_SET('HAVE_PORT_CREATE') and conf.CONFIG_SET('HAVE_PORT_H'):
conf.DEFINE('HAVE_SOLARIS_PORTS', 1)
if conf.CHECK_FUNCS('eventfd', headers='sys/eventfd.h'):
conf.DEFINE('HAVE_EVENTFD', 1)
conf.CHECK_HEADERS('poll.h')
conf.CHECK_FUNCS('poll')
......@@ -701,9 +704,10 @@ def build(bld):
deps='crypt dl nsl socket rt attr' + extra_libs)
bld.SAMBA_SUBSYSTEM('replace-test',
source='''test/testsuite.c test/strptime.c
test/os2_delete.c test/getifaddrs.c''',
deps='replace')
source='''test/testsuite.c test/strptime.c
test/os2_delete.c test/getifaddrs.c''',
deps='replace',
cflags="-Wno-format-length")
if bld.env.standalone_replace:
bld.SAMBA_BINARY('replace_testsuite',
......
......@@ -61,11 +61,21 @@ ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t si
#elif defined(HAVE_GETEA)
return getea(path, name, value, size);
#elif defined(HAVE_EXTATTR_GET_FILE)
char *s;
ssize_t retval;
int attrnamespace = (strncmp(name, "system", 6) == 0) ?
EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
int attrnamespace;
const char *attrname;
if (strncmp(name, "system.", 7) == 0) {
attrnamespace = EXTATTR_NAMESPACE_SYSTEM;
attrname = name + 7;
} else if (strncmp(name, "user.", 5) == 0) {
attrnamespace = EXTATTR_NAMESPACE_USER;
attrname = name + 5;
} else {
errno = EINVAL;
return -1;
}
/*
* The BSD implementation has a nasty habit of silently truncating
* the returned value to the size of the buffer, so we have to check
......@@ -125,11 +135,20 @@ ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size)
#elif defined(HAVE_FGETEA)
return fgetea(filedes, name, value, size);
#elif defined(HAVE_EXTATTR_GET_FD)
char *s;
ssize_t retval;
int attrnamespace = (strncmp(name, "system", 6) == 0) ?
EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
int attrnamespace;
const char *attrname;
if (strncmp(name, "system.", 7) == 0) {
attrnamespace = EXTATTR_NAMESPACE_SYSTEM;
attrname = name + 7;
} else if (strncmp(name, "user.", 5) == 0) {
attrnamespace = EXTATTR_NAMESPACE_USER;
attrname = name + 5;
} else {
errno = EINVAL;
return -1;
}
if((retval=extattr_get_fd(filedes, attrnamespace, attrname, NULL, 0)) >= 0) {
if (size == 0) {
......@@ -414,10 +433,19 @@ int rep_removexattr (const char *path, const char *name)
#elif defined(HAVE_REMOVEEA)
return removeea(path, name);
#elif defined(HAVE_EXTATTR_DELETE_FILE)
char *s;
int attrnamespace = (strncmp(name, "system", 6) == 0) ?
EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
int attrnamespace;
const char *attrname;
if (strncmp(name, "system.", 7) == 0) {
attrnamespace = EXTATTR_NAMESPACE_SYSTEM;
attrname = name + 7;
} else if (strncmp(name, "user.", 5) == 0) {
attrnamespace = EXTATTR_NAMESPACE_USER;
attrname = name + 5;
} else {
errno = EINVAL;
return -1;
}
return extattr_delete_file(path, attrnamespace, attrname);
#elif defined(HAVE_ATTR_REMOVE)
......@@ -455,10 +483,19 @@ int rep_fremovexattr (int filedes, const char *name)
#elif defined(HAVE_FREMOVEEA)
return fremoveea(filedes, name);
#elif defined(HAVE_EXTATTR_DELETE_FD)
char *s;
int attrnamespace = (strncmp(name, "system", 6) == 0) ?
EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
int attrnamespace;
const char *attrname;
if (strncmp(name, "system.", 7) == 0) {
attrnamespace = EXTATTR_NAMESPACE_SYSTEM;
attrname = name + 7;
} else if (strncmp(name, "user.", 5) == 0) {
attrnamespace = EXTATTR_NAMESPACE_USER;
attrname = name + 5;
} else {
errno = EINVAL;
return -1;
}
return extattr_delete_fd(filedes, attrnamespace, attrname);
#elif defined(HAVE_ATTR_REMOVEF)
......@@ -496,11 +533,21 @@ int rep_setxattr (const char *path, const char *name, const void *value, size_t
#elif defined(HAVE_SETEA)
return setea(path, name, value, size, flags);
#elif defined(HAVE_EXTATTR_SET_FILE)
char *s;
int retval = 0;
int attrnamespace = (strncmp(name, "system", 6) == 0) ?
EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
int attrnamespace;
const char *attrname;
if (strncmp(name, "system.", 7) == 0) {
attrnamespace = EXTATTR_NAMESPACE_SYSTEM;
attrname = name + 7;
} else if (strncmp(name, "user.", 5) == 0) {
attrnamespace = EXTATTR_NAMESPACE_USER;
attrname = name + 5;
} else {
errno = EINVAL;
return -1;
}
if (flags) {
/* Check attribute existence */
retval = extattr_get_file(path, attrnamespace, attrname, NULL, 0);
......@@ -563,11 +610,21 @@ int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size
#elif defined(HAVE_FSETEA)
return fsetea(filedes, name, value, size, flags);
#elif defined(HAVE_EXTATTR_SET_FD)
char *s;
int retval = 0;
int attrnamespace = (strncmp(name, "system", 6) == 0) ?
EXTATTR_NAMESPACE_SYSTEM : EXTATTR_NAMESPACE_USER;
const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
int attrnamespace;
const char *attrname;
if (strncmp(name, "system.", 7) == 0) {
attrnamespace = EXTATTR_NAMESPACE_SYSTEM;
attrname = name + 7;
} else if (strncmp(name, "user.", 5) == 0) {
attrnamespace = EXTATTR_NAMESPACE_USER;
attrname = name + 5;
} else {
errno = EINVAL;
return -1;
}
if (flags) {
/* Check attribute existence */
retval = extattr_get_fd(filedes, attrnamespace, attrname, NULL, 0);
......
......@@ -238,6 +238,14 @@ static PyTypeObject TallocBaseObject_Type = {
#endif
};
static PyTypeObject TallocGenericObject_Type = {
.tp_name = "talloc.GenericObject",
.tp_doc = "Python wrapper for a talloc-maintained object.",
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_base = &TallocBaseObject_Type,
.tp_basicsize = sizeof(pytalloc_BaseObject),
};
#define MODULE_DOC PyDoc_STR("Python wrapping of talloc-maintained objects.")
#if PY_MAJOR_VERSION >= 3
......@@ -261,6 +269,9 @@ static PyObject *module_init(void)
if (PyType_Ready(&TallocBaseObject_Type) < 0)
return NULL;
if (PyType_Ready(&TallocGenericObject_Type) < 0)
return NULL;
#if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&moduledef);
#else
......@@ -273,6 +284,8 @@ static PyObject *module_init(void)
PyModule_AddObject(m, "Object", (PyObject *)&TallocObject_Type);
Py_INCREF(&TallocBaseObject_Type);
PyModule_AddObject(m, "BaseObject", (PyObject *)&TallocBaseObject_Type);
Py_INCREF(&TallocGenericObject_Type);
PyModule_AddObject(m, "GenericObject", (PyObject *)&TallocGenericObject_Type);
return m;
}
......
......@@ -40,6 +40,10 @@ int pytalloc_Check(PyObject *);
int pytalloc_BaseObject_check(PyObject *);
int _pytalloc_check_type(PyObject *py_obj, const char *type_name);
#define pytalloc_check_type(py_obj, type) \
_pytalloc_check_type((PyObject *)(py_obj), #type)
/* Retrieve the pointer for a pytalloc_object. Like talloc_get_type()
* but for pytalloc_Objects. */
void *_pytalloc_get_type(PyObject *py_obj, const char *type_name);
......@@ -58,8 +62,30 @@ PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void
#define pytalloc_new(type, typeobj) pytalloc_steal(typeobj, talloc_zero(NULL, type))
#if PY_MAJOR_VERSION < 3
PyObject *pytalloc_CObject_FromTallocPtr(void *);
/*
* Don't use this anymore! Use pytalloc_GenericObject_steal()
* or pytalloc_GenericObject_reference().
*/
#ifndef _DEPRECATED_
#ifdef HAVE___ATTRIBUTE__
#define _DEPRECATED_ __attribute__ ((deprecated))
#else
#define _DEPRECATED_
#endif
#endif
PyObject *pytalloc_CObject_FromTallocPtr(void *) _DEPRECATED_;
#endif
/*
* Wrap a generic talloc pointer into a talloc.GenericObject,
* this is a subclass of talloc.BaseObject.
*/
PyObject *pytalloc_GenericObject_steal_ex(TALLOC_CTX *mem_ctx, void *ptr);
#define pytalloc_GenericObject_steal(talloc_ptr) \
pytalloc_GenericObject_steal_ex(talloc_ptr, talloc_ptr)
PyObject *pytalloc_GenericObject_reference_ex(TALLOC_CTX *mem_ctx, void *ptr);
#define pytalloc_GenericObject_reference(talloc_ptr) \
pytalloc_GenericObject_reference_ex(talloc_ptr, talloc_ptr)
size_t pytalloc_BaseObject_size(void);
......
......@@ -91,6 +91,15 @@ int pytalloc_BaseObject_Check(PyObject *)
Check whether a specific object is a talloc BaseObject. Returns non-zero if it is
a pytalloc_BaseObject and zero otherwise.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
int pytalloc_check_type(PyObject *py_obj, type)
Check if the object based on `pytalloc_*Object` py_obj. type should be a
C type, similar to a type passed to `talloc_get_type`.
This can be used as a check before using pytalloc_get_type()
or an alternative codepath. Returns non-zero if it is
an object of the expected type and zero otherwise.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
type *pytalloc_get_type(PyObject *py_obj, type)
......@@ -113,7 +122,9 @@ Retrieve the talloc context associated with a pytalloc_Object or pytalloc_BaseOb
PyObject *pytalloc_steal_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr)
Create a new Python wrapping object for a talloc pointer and context, with
py_type as associated Python sub type object.
py_type as associated Python sub type object. This typically used
when `mem_ctx` and `ptr` differ, e.g. a pointer to an array element.
`pytalloc_get_ptr()` can be used to get the pointer out of the object again.
This will *not* increment the reference counter for the talloc context,
so the caller should make sure such an increment has happened. When the Python
......@@ -123,7 +134,9 @@ object goes away, it will unreference the talloc context.
PyObject *pytalloc_steal(PyTypeObject *py_type, void *ptr)
Create a new Python wrapping object for a talloc pointer and context, with
py_type as associated Python sub type object.
py_type as associated Python sub type object. The pointer will also be used
as the talloc context. `pytalloc_get_type()` can be used to get
the pointer out of the object again.
This will *not* increment the reference counter for the talloc context,
so the caller should make sure such an increment has happened. When the Python
......@@ -133,7 +146,9 @@ object goes away, it will unreference the talloc context.
PyObject *pytalloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr)
Create a new Python wrapping object for a talloc pointer and context, with
py_type as associated Python sub type object.
py_type as associated Python sub type object. This typically used
when `mem_ctx` and `ptr` differ, e.g. a pointer to an array element.
`pytalloc_get_ptr()` can be used to get the pointer out of the object again.
This will increment the reference counter for the talloc context.
......@@ -142,7 +157,8 @@ PyObject *pytalloc_reference(PyTypeObject *py_type, void *talloc_ptr)
Create a new Python wrapping object for a talloc pointer, with
py_type as associated Python sub type object. The pointer will also be used
as the talloc context.
as the talloc context. `pytalloc_get_type()` can be used to get
the pointer out of the object again.
This will increment the reference counter for the talloc context.
......@@ -153,14 +169,59 @@ Create a new, empty pytalloc_Object with the specified Python type object. type
should be a C type, similar to talloc_new().
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
PyObject *pytalloc_CObject_FromTallocPtr(void *);
PyObject *pytalloc_GenericObject_steal_ex(void *ptr)
Create a new Python wrapping object for a generic talloc pointer,
as sub type of `pytalloc_BaseObject`. This typically used
when `mem_ctx` and `ptr` differ, e.g. a pointer to an array element.
`pytalloc_get_ptr()` can be used to get the pointer out of the object again.
This will *not* increment the reference counter for the talloc context,
so the caller should make sure such an increment has happened. When the Python
object goes away, it will unreference the talloc context.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
PyObject *pytalloc_GenericObject_steal(void *ptr)
Create a new Python wrapping object for a generic talloc pointer,
as sub type of `pytalloc_BaseObject`. The pointer will also be used
as the talloc context. `pytalloc_get_type()` can be used to get
the pointer out of the object again.
This will *not* increment the reference counter for the talloc context,
so the caller should make sure such an increment has happened. When the Python
object goes away, it will unreference the talloc context.