diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-05-14 12:09:21 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:53:45 -0500 |
commit | a2273116fbb5890680c11fecba1bfd0026b7dd9b (patch) | |
tree | 6eae6f6e6b6996dce1dcfce2826fc126f34384aa /source4/lib/tdb_helper.c | |
parent | a07f42b4ffee81e62ea7f586241c97fd5e55a819 (diff) | |
download | samba-a2273116fbb5890680c11fecba1bfd0026b7dd9b.tar.gz samba-a2273116fbb5890680c11fecba1bfd0026b7dd9b.tar.bz2 samba-a2273116fbb5890680c11fecba1bfd0026b7dd9b.zip |
r728: - let libldb_tdb depend on new subsystem LIBTDB
- remove tdb logging helper functions out of LIBTDB subsystem
- build libtdb shared lib with 'make library_libtdb'
the libs are not usable for now,
tridge: please remove the dependecy of CatchSignal() and smb_panic()
from libtdb
maybe use function pointers in the TDB_CONTEXT
then run make library_libtdb
and then make build/tests/trivial.o
and then gcc -o trivial -L./bin -ltdb
and then gcc -o trivial -L./bin -lldb
metze
(This used to be commit 520b9762161d9b5d5223b42910494af80fd5c1e3)
Diffstat (limited to 'source4/lib/tdb_helper.c')
-rw-r--r-- | source4/lib/tdb_helper.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/source4/lib/tdb_helper.c b/source4/lib/tdb_helper.c new file mode 100644 index 0000000000..121243bd0f --- /dev/null +++ b/source4/lib/tdb_helper.c @@ -0,0 +1,67 @@ +/* + Unix SMB/CIFS implementation. + tdb utility functions + Copyright (C) Andrew Tridgell 1992-1998 + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include <fnmatch.h> + +/* these are little tdb utility functions that are meant to make + dealing with a tdb database a little less cumbersome in Samba */ + + +/**************************************************************************** + Log tdb messages via DEBUG(). +****************************************************************************/ + +static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...) +{ + va_list ap; + char *ptr = NULL; + + va_start(ap, format); + vasprintf(&ptr, format, ap); + va_end(ap); + + if (!ptr || !*ptr) + return; + + DEBUG(level, ("tdb(%s): %s", tdb->name ? tdb->name : "unnamed", ptr)); + SAFE_FREE(ptr); +} + +/**************************************************************************** + Like tdb_open() but also setup a logging function that redirects to + the samba DEBUG() system. +****************************************************************************/ + +TDB_CONTEXT *tdb_open_log(const char *name, int hash_size, int tdb_flags, + int open_flags, mode_t mode) +{ + TDB_CONTEXT *tdb; + + if (!lp_use_mmap()) + tdb_flags |= TDB_NOMMAP; + + tdb = tdb_open_ex(name, hash_size, tdb_flags, + open_flags, mode, tdb_log); + if (!tdb) + return NULL; + + return tdb; +} |