diff options
author | Martin Pool <mbp@samba.org> | 2001-12-04 11:25:44 +0000 |
---|---|---|
committer | Martin Pool <mbp@samba.org> | 2001-12-04 11:25:44 +0000 |
commit | 28e676d9c341664d08baa77d6f48be061f7a5690 (patch) | |
tree | ad890c10c43398d47669f8659348118d7a16518a /source3/tdb | |
parent | 7d9e09f5279ee19a69a0f9e09fe3bb9eb51cc885 (diff) | |
download | samba-28e676d9c341664d08baa77d6f48be061f7a5690.tar.gz samba-28e676d9c341664d08baa77d6f48be061f7a5690.tar.bz2 samba-28e676d9c341664d08baa77d6f48be061f7a5690.zip |
Implement suggestion from tridge to leave the old tdb_open interface
as it was, and add tdb_open_ex() which takes a log callback. I guess
this makes more sense since it's a public interface.
(This used to be commit 391a65395e6cdc0300f81eb1072a3366cacd1203)
Diffstat (limited to 'source3/tdb')
-rw-r--r-- | source3/tdb/tdb.c | 11 | ||||
-rw-r--r-- | source3/tdb/tdb.h | 6 | ||||
-rw-r--r-- | source3/tdb/tdbtest.c | 6 | ||||
-rw-r--r-- | source3/tdb/tdbtool.c | 8 | ||||
-rw-r--r-- | source3/tdb/tdbtorture.c | 4 |
5 files changed, 22 insertions, 13 deletions
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index b18d869f4e..3d4a6051d2 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -1408,8 +1408,15 @@ static int tdb_read_header(TDB_CONTEXT *tdb) Return is NULL on error, in which case errno is also set. Don't try to call tdb_error or tdb_errname, just do strerror(errno). */ TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode, - tdb_log_func log_func) + int open_flags, mode_t mode) +{ + return tdb_open_ex(name, hash_size, tdb_flags, open_flags, mode, NULL); +} + + +TDB_CONTEXT *tdb_open_ex(char *name, int hash_size, int tdb_flags, + int open_flags, mode_t mode, + tdb_log_func log_func) { TDB_CONTEXT tdb[1], *ret, *i; struct stat st; diff --git a/source3/tdb/tdb.h b/source3/tdb/tdb.h index 991343a67c..039c925702 100644 --- a/source3/tdb/tdb.h +++ b/source3/tdb/tdb.h @@ -105,9 +105,11 @@ int tdb_reopen(TDB_CONTEXT *tdb); int tdb_reopen_all(void); void tdb_log_to_stderr(TDB_CONTEXT *tdb, int level, const char *format, ...); void tdb_logging_function(TDB_CONTEXT *tdb, tdb_log_func fn); +TDB_CONTEXT *tdb_open_ex(char *name, int hash_size, int tdb_flags, + int open_flags, mode_t mode, + tdb_log_func log_func); TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags, - int open_flags, mode_t mode, - tdb_log_func log_func); + int open_flags, mode_t mode); enum TDB_ERROR tdb_error(TDB_CONTEXT *tdb); const char *tdb_errorstr(TDB_CONTEXT *tdb); TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key); diff --git a/source3/tdb/tdbtest.c b/source3/tdb/tdbtest.c index ca4ca54142..7f3b1d48b7 100644 --- a/source3/tdb/tdbtest.c +++ b/source3/tdb/tdbtest.c @@ -225,9 +225,9 @@ int main(int argc, char *argv[]) unlink("test.gdbm"); - db = tdb_open("test.tdb", 0, TDB_CLEAR_IF_FIRST, - O_RDWR | O_CREAT | O_TRUNC, 0600, - tdb_log_to_stderr); + db = tdb_open_ex("test.tdb", 0, TDB_CLEAR_IF_FIRST, + O_RDWR | O_CREAT | O_TRUNC, 0600, + tdb_log_to_stderr); gdbm = gdbm_open("test.gdbm", 512, GDBM_WRITER|GDBM_NEWDB|GDBM_FAST, 0600, NULL); diff --git a/source3/tdb/tdbtool.c b/source3/tdb/tdbtool.c index ecde37a5ea..a559fb0558 100644 --- a/source3/tdb/tdbtool.c +++ b/source3/tdb/tdbtool.c @@ -174,9 +174,9 @@ static void create_tdb(void) return; } if (tdb) tdb_close(tdb); - tdb = tdb_open(tok, 0, TDB_CLEAR_IF_FIRST, - O_RDWR | O_CREAT | O_TRUNC, 0600, - tdb_log_to_stderr); + tdb = tdb_open_ex(tok, 0, TDB_CLEAR_IF_FIRST, + O_RDWR | O_CREAT | O_TRUNC, 0600, + tdb_log_to_stderr); if (!tdb) { printf("Could not create %s: %s\n", tok, strerror(errno)); } @@ -190,7 +190,7 @@ static void open_tdb(void) return; } if (tdb) tdb_close(tdb); - tdb = tdb_open(tok, 0, 0, O_RDWR, 0600, tdb_log_to_stderr); + tdb = tdb_open_ex(tok, 0, 0, O_RDWR, 0600, tdb_log_to_stderr); if (!tdb) { printf("Could not open %s: %s\n", tok, strerror(errno)); } diff --git a/source3/tdb/tdbtorture.c b/source3/tdb/tdbtorture.c index 4e12386d73..1cce60dc22 100644 --- a/source3/tdb/tdbtorture.c +++ b/source3/tdb/tdbtorture.c @@ -177,8 +177,8 @@ int main(int argc, char *argv[]) if ((pids[i+1]=fork()) == 0) break; } - db = tdb_open("torture.tdb", 2, TDB_CLEAR_IF_FIRST, - O_RDWR | O_CREAT, 0600, tdb_log_to_stderr); + db = tdb_open_ex("torture.tdb", 2, TDB_CLEAR_IF_FIRST, + O_RDWR | O_CREAT, 0600, tdb_log_to_stderr); if (!db) { fatal("db open failed"); } |