This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "includes.h"
-#include "ldb/include/includes.h"
-
-#include "ldb/ldb_tdb/ldb_tdb.h"
+#include "ldb_tdb.h"
/*
the purpose of this code is to work around the braindead posix locking
return 0;
}
-#if (_SAMBA_BUILD_ >= 4)
static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...)
{
struct ldb_context *ldb = talloc_get_type(tdb_get_logging_private(tdb), struct ldb_context);
enum ldb_debug_level ldb_level;
char *message;
+
+ if (ldb == NULL)
+ return;
+
va_start(ap, fmt);
message = talloc_vasprintf(ldb, fmt, ap);
va_end(ap);
ldb_debug(ldb, ldb_level, "ltdb: tdb(%s): %s", name, message);
talloc_free(message);
}
-#else
-static void ltdb_log_fn(struct tdb_context *tdb, int level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
-static void ltdb_log_fn(struct tdb_context *tdb, int level, const char *fmt, ...)
-{
- /* until we merge the tdb debug changes into samba3, we don't know
- how serious the error is, and we can't go via the ldb loggin code */
- va_list ap;
- const char *name = tdb_name(tdb);
- char *message;
- va_start(ap, fmt);
- message = talloc_vasprintf(NULL, fmt, ap);
- va_end(ap);
- DEBUG(3, ("ltdb: tdb(%s): %s", name, message));
- talloc_free(message);
-}
-#endif
/*
wrapped connection to a tdb database. The caller should _not_ free
{
struct ltdb_wrap *w;
struct stat st;
-#if (_SAMBA_BUILD_ >= 4)
struct tdb_logging_context log_ctx;
- struct tdb_logging_context log_ctx_p = &log_ctx;
+
log_ctx.log_fn = ltdb_log_fn;
log_ctx.log_private = ldb;
-#else
- tdb_log_func log_ctx_p = ltdb_log_fn;
-#endif
if (stat(path, &st) == 0) {
for (w=tdb_list;w;w=w->next) {
if (st.st_dev == w->device && st.st_ino == w->inode) {
- talloc_reference(mem_ctx, w);
+ if (!talloc_reference(mem_ctx, w)) {
+ return NULL;
+ }
return w->tdb;
}
}
return NULL;
}
- w->tdb = tdb_open_ex(path, hash_size, tdb_flags, open_flags, mode, log_ctx_p, NULL);
+ w->tdb = tdb_open_ex(path, hash_size, tdb_flags, open_flags, mode, &log_ctx, NULL);
if (w->tdb == NULL) {
talloc_free(w);
return NULL;