[SCM] Samba Shared Repository - branch master updated

Rusty Russell rusty at samba.org
Mon Feb 20 23:44:02 MST 2012


The branch, master has been updated
       via  89586ed lib/tdb2: 2.0.0 ABI
       via  abc7472 lib/tdb2: Convert tdb2 to a standalone library
       via  f7b999f lib/tdb2: Fix wscript
       via  4e90726 lib/tdb2: Mark public function as such
       via  a63d731 lib/tdb2: Do not include config.h in (to-be) public library, use replace.
       via  e6901fa lib/tdb2: tools should use config.h, and replace where available.
       via  fb8cf56 lib/ccan: define HAVE_CCAN.
      from  0528cb5 s3: Fix bug 8567 -- segfault in dom_sid_compare

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 89586ed1643101b3b94bba1fdcdc821026a00e65
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Feb 21 15:29:52 2012 +1030

    lib/tdb2: 2.0.0 ABI
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
    
    Autobuild-User: Rusty Russell <rusty at rustcorp.com.au>
    Autobuild-Date: Tue Feb 21 07:43:55 CET 2012 on sn-devel-104

commit abc74723cebcab30987bb16e359645ba37eb6c95
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Feb 21 15:29:52 2012 +1030

    lib/tdb2: Convert tdb2 to a standalone library
    
    Adds a Makefile, configure script, and tdb2.pc.in.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit f7b999fac0b6d00c8e60012eba3de2fd59d8c854
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Feb 21 15:29:30 2012 +1030

    lib/tdb2: Fix wscript
    
    Particularly fix the upcoming standalone build.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit 4e9072660a96324f8d9421f35593057b730ca185
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Feb 21 15:29:22 2012 +1030

    lib/tdb2: Mark public function as such
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit a63d731ae05af78bdc33db58880387169429753e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Feb 21 15:29:17 2012 +1030

    lib/tdb2: Do not include config.h in (to-be) public library, use replace.
    
    Like tdb1, it's the caller's responsibility to set up various config
    options (eg. by #include "config.h") before including the public
    header.
    
    We use HAVE_CCAN for including the (private) CCAN headers, otherwise
    dummy macros are used.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit e6901fa35069e234044c94b87ac9df4064b31d1c
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Tue Feb 21 15:29:12 2012 +1030

    lib/tdb2: tools should use config.h, and replace where available.
    
    The tdb2 tools should #include "config.h" before tdb2.h (about to
    become a requirement) and use libreplace where available.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit fb8cf568caf43615f7a06a623209a0fade629a35
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Tue Feb 21 15:29:06 2012 +1030

    lib/ccan: define HAVE_CCAN.
    
    This allows public headers to use CCAN if available, and dummy macros
    if not (eg. tdb2).
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

-----------------------------------------------------------------------

Summary of changes:
 lib/ccan/wscript                       |    1 +
 lib/tdb2/ABI/tdb-2.0.0.sigs            |   40 +++++++++++++++
 lib/{tdb => tdb2}/Makefile             |    0
 lib/tdb2/check.c                       |    2 +-
 lib/{replace => tdb2}/configure        |    0
 lib/tdb2/hash.c                        |    8 ++--
 lib/tdb2/lock.c                        |    8 ++--
 lib/tdb2/open.c                        |   12 ++--
 lib/tdb2/private.h                     |    5 ++
 lib/tdb2/summary.c                     |    2 +-
 lib/tdb2/tdb.c                         |   30 ++++++------
 lib/tdb2/tdb1_hash.c                   |    2 +-
 lib/tdb2/tdb2.h                        |   19 +++++++-
 lib/{tdb/tdb.pc.in => tdb2/tdb2.pc.in} |    2 +-
 lib/tdb2/tools/tdb2backup.c            |    1 +
 lib/tdb2/tools/tdb2dump.c              |    7 +++
 lib/tdb2/tools/tdb2restore.c           |    6 ++
 lib/tdb2/tools/tdb2tool.c              |    8 +++
 lib/tdb2/tools/tdb2torture.c           |    7 ++-
 lib/tdb2/transaction.c                 |    8 ++--
 lib/tdb2/traverse.c                    |    8 ++--
 lib/tdb2/wscript                       |   82 ++++++++++++++++++++-----------
 22 files changed, 185 insertions(+), 73 deletions(-)
 create mode 100644 lib/tdb2/ABI/tdb-2.0.0.sigs
 copy lib/{tdb => tdb2}/Makefile (100%)
 copy lib/{replace => tdb2}/configure (100%)
 copy lib/{tdb/tdb.pc.in => tdb2/tdb2.pc.in} (89%)


Changeset truncated at 500 lines:

diff --git a/lib/ccan/wscript b/lib/ccan/wscript
index 9daf091..59fe93a 100644
--- a/lib/ccan/wscript
+++ b/lib/ccan/wscript
@@ -3,6 +3,7 @@
 import Logs, sys
 
 def configure(conf):
+    conf.DEFINE('HAVE_CCAN', 1)
     # FIXME: if they don't have -Werror, these will all fail.  But they
     # probably will anyway...
     conf.CHECK_CODE('int __attribute__((cold)) func(int x) { return x; }',
diff --git a/lib/tdb2/ABI/tdb-2.0.0.sigs b/lib/tdb2/ABI/tdb-2.0.0.sigs
new file mode 100644
index 0000000..0e54b90
--- /dev/null
+++ b/lib/tdb2/ABI/tdb-2.0.0.sigs
@@ -0,0 +1,40 @@
+tdb1_incompatible_hash: uint64_t (const void *, size_t, uint64_t, void *)
+tdb_add_flag: void (struct tdb_context *, unsigned int)
+tdb_append: enum TDB_ERROR (struct tdb_context *, struct tdb_data, struct tdb_data)
+tdb_chainlock: enum TDB_ERROR (struct tdb_context *, TDB_DATA)
+tdb_chainlock_read: enum TDB_ERROR (struct tdb_context *, TDB_DATA)
+tdb_chainunlock: void (struct tdb_context *, TDB_DATA)
+tdb_chainunlock_read: void (struct tdb_context *, TDB_DATA)
+tdb_check_: enum TDB_ERROR (struct tdb_context *, enum TDB_ERROR (*)(TDB_DATA, TDB_DATA, void *), void *)
+tdb_close: int (struct tdb_context *)
+tdb_delete: enum TDB_ERROR (struct tdb_context *, struct tdb_data)
+tdb_error: enum TDB_ERROR (struct tdb_context *)
+tdb_errorstr: const char *(enum TDB_ERROR)
+tdb_exists: bool (struct tdb_context *, TDB_DATA)
+tdb_fd: int (const struct tdb_context *)
+tdb_fetch: enum TDB_ERROR (struct tdb_context *, struct tdb_data, struct tdb_data *)
+tdb_firstkey: enum TDB_ERROR (struct tdb_context *, struct tdb_data *)
+tdb_foreach_: void (int (*)(struct tdb_context *, void *), void *)
+tdb_get_attribute: enum TDB_ERROR (struct tdb_context *, union tdb_attribute *)
+tdb_get_flags: unsigned int (struct tdb_context *)
+tdb_get_seqnum: int64_t (struct tdb_context *)
+tdb_lockall: enum TDB_ERROR (struct tdb_context *)
+tdb_lockall_read: enum TDB_ERROR (struct tdb_context *)
+tdb_name: const char *(const struct tdb_context *)
+tdb_nextkey: enum TDB_ERROR (struct tdb_context *, struct tdb_data *)
+tdb_open: struct tdb_context *(const char *, int, int, mode_t, union tdb_attribute *)
+tdb_parse_record_: enum TDB_ERROR (struct tdb_context *, TDB_DATA, enum TDB_ERROR (*)(TDB_DATA, TDB_DATA, void *), void *)
+tdb_remove_flag: void (struct tdb_context *, unsigned int)
+tdb_repack: enum TDB_ERROR (struct tdb_context *)
+tdb_set_attribute: enum TDB_ERROR (struct tdb_context *, const union tdb_attribute *)
+tdb_store: enum TDB_ERROR (struct tdb_context *, struct tdb_data, struct tdb_data, int)
+tdb_summary: enum TDB_ERROR (struct tdb_context *, enum tdb_summary_flags, char **)
+tdb_transaction_cancel: void (struct tdb_context *)
+tdb_transaction_commit: enum TDB_ERROR (struct tdb_context *)
+tdb_transaction_prepare_commit: enum TDB_ERROR (struct tdb_context *)
+tdb_transaction_start: enum TDB_ERROR (struct tdb_context *)
+tdb_traverse_: int64_t (struct tdb_context *, int (*)(struct tdb_context *, TDB_DATA, TDB_DATA, void *), void *)
+tdb_unlockall: void (struct tdb_context *)
+tdb_unlockall_read: void (struct tdb_context *)
+tdb_unset_attribute: void (struct tdb_context *, enum tdb_attribute_type)
+tdb_wipe_all: enum TDB_ERROR (struct tdb_context *)
diff --git a/lib/tdb/Makefile b/lib/tdb2/Makefile
similarity index 100%
copy from lib/tdb/Makefile
copy to lib/tdb2/Makefile
diff --git a/lib/tdb2/check.c b/lib/tdb2/check.c
index ecd6c13..6ad1ebd 100644
--- a/lib/tdb2/check.c
+++ b/lib/tdb2/check.c
@@ -794,7 +794,7 @@ static enum TDB_ERROR check_linear(struct tdb_context *tdb,
 	return TDB_SUCCESS;
 }
 
-enum TDB_ERROR tdb_check_(struct tdb_context *tdb,
+_PUBLIC_ enum TDB_ERROR tdb_check_(struct tdb_context *tdb,
 			  enum TDB_ERROR (*check)(TDB_DATA, TDB_DATA, void *),
 			  void *data)
 {
diff --git a/lib/replace/configure b/lib/tdb2/configure
similarity index 100%
copy from lib/replace/configure
copy to lib/tdb2/configure
diff --git a/lib/tdb2/hash.c b/lib/tdb2/hash.c
index 619d56f..0d4d780 100644
--- a/lib/tdb2/hash.c
+++ b/lib/tdb2/hash.c
@@ -851,7 +851,7 @@ static enum TDB_ERROR chainlock(struct tdb_context *tdb, const TDB_DATA *key,
 
 /* lock/unlock one hash chain. This is meant to be used to reduce
    contention - it cannot guarantee how many records will be locked */
-enum TDB_ERROR tdb_chainlock(struct tdb_context *tdb, TDB_DATA key)
+_PUBLIC_ enum TDB_ERROR tdb_chainlock(struct tdb_context *tdb, TDB_DATA key)
 {
 	if (tdb->flags & TDB_VERSION1) {
 		if (tdb1_chainlock(tdb, key) == -1)
@@ -862,7 +862,7 @@ enum TDB_ERROR tdb_chainlock(struct tdb_context *tdb, TDB_DATA key)
 					   "tdb_chainlock");
 }
 
-void tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key)
+_PUBLIC_ void tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key)
 {
 	uint64_t h = tdb_hash(tdb, key.dptr, key.dsize);
 	tdb_off_t lockstart, locksize;
@@ -882,7 +882,7 @@ void tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key)
 	tdb_unlock_hashes(tdb, lockstart, locksize, F_WRLCK);
 }
 
-enum TDB_ERROR tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key)
+_PUBLIC_ enum TDB_ERROR tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key)
 {
 	if (tdb->flags & TDB_VERSION1) {
 		if (tdb1_chainlock_read(tdb, key) == -1)
@@ -893,7 +893,7 @@ enum TDB_ERROR tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key)
 					   "tdb_chainlock_read");
 }
 
-void tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key)
+_PUBLIC_ void tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key)
 {
 	uint64_t h = tdb_hash(tdb, key.dptr, key.dsize);
 	tdb_off_t lockstart, locksize;
diff --git a/lib/tdb2/lock.c b/lib/tdb2/lock.c
index a71c95f..df0ec0c 100644
--- a/lib/tdb2/lock.c
+++ b/lib/tdb2/lock.c
@@ -851,22 +851,22 @@ void tdb_unlock_free_bucket(struct tdb_context *tdb, tdb_off_t b_off)
 	tdb_nest_unlock(tdb, free_lock_off(b_off), F_WRLCK);
 }
 
-enum TDB_ERROR tdb_lockall(struct tdb_context *tdb)
+_PUBLIC_ enum TDB_ERROR tdb_lockall(struct tdb_context *tdb)
 {
 	return tdb_allrecord_lock(tdb, F_WRLCK, TDB_LOCK_WAIT, false);
 }
 
-void tdb_unlockall(struct tdb_context *tdb)
+_PUBLIC_ void tdb_unlockall(struct tdb_context *tdb)
 {
 	tdb_allrecord_unlock(tdb, F_WRLCK);
 }
 
-enum TDB_ERROR tdb_lockall_read(struct tdb_context *tdb)
+_PUBLIC_ enum TDB_ERROR tdb_lockall_read(struct tdb_context *tdb)
 {
 	return tdb_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, false);
 }
 
-void tdb_unlockall_read(struct tdb_context *tdb)
+_PUBLIC_ void tdb_unlockall_read(struct tdb_context *tdb)
 {
 	tdb_allrecord_unlock(tdb, F_RDLCK);
 }
diff --git a/lib/tdb2/open.c b/lib/tdb2/open.c
index 2730f21..b93fa83 100644
--- a/lib/tdb2/open.c
+++ b/lib/tdb2/open.c
@@ -210,7 +210,7 @@ static enum TDB_ERROR tdb_new_file(struct tdb_context *tdb)
 	return TDB_SUCCESS;
 }
 
-enum TDB_ERROR tdb_set_attribute(struct tdb_context *tdb,
+_PUBLIC_ enum TDB_ERROR tdb_set_attribute(struct tdb_context *tdb,
 				 const union tdb_attribute *attr)
 {
 	switch (attr->base.attr) {
@@ -256,7 +256,7 @@ enum TDB_ERROR tdb_set_attribute(struct tdb_context *tdb,
 	return TDB_SUCCESS;
 }
 
-enum TDB_ERROR tdb_get_attribute(struct tdb_context *tdb,
+_PUBLIC_ enum TDB_ERROR tdb_get_attribute(struct tdb_context *tdb,
 				 union tdb_attribute *attr)
 {
 	switch (attr->base.attr) {
@@ -320,7 +320,7 @@ enum TDB_ERROR tdb_get_attribute(struct tdb_context *tdb,
 	return TDB_SUCCESS;
 }
 
-void tdb_unset_attribute(struct tdb_context *tdb,
+_PUBLIC_ void tdb_unset_attribute(struct tdb_context *tdb,
 			 enum tdb_attribute_type type)
 {
 	switch (type) {
@@ -424,7 +424,7 @@ static enum TDB_ERROR capabilities_ok(struct tdb_context *tdb,
 	return ecode;
 }
 
-struct tdb_context *tdb_open(const char *name, int tdb_flags,
+_PUBLIC_ struct tdb_context *tdb_open(const char *name, int tdb_flags,
 			     int open_flags, mode_t mode,
 			     union tdb_attribute *attr)
 {
@@ -825,7 +825,7 @@ fail_errno:
 	return NULL;
 }
 
-int tdb_close(struct tdb_context *tdb)
+_PUBLIC_ int tdb_close(struct tdb_context *tdb)
 {
 	int ret = 0;
 	struct tdb_context **i;
@@ -873,7 +873,7 @@ int tdb_close(struct tdb_context *tdb)
 	return ret;
 }
 
-void tdb_foreach_(int (*fn)(struct tdb_context *, void *), void *p)
+_PUBLIC_ void tdb_foreach_(int (*fn)(struct tdb_context *, void *), void *p)
 {
 	struct tdb_context *i;
 
diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h
index 91d3ca0..31790bc 100644
--- a/lib/tdb2/private.h
+++ b/lib/tdb2/private.h
@@ -18,7 +18,12 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
+#ifndef HAVE_CCAN
+#error You need ccan to build tdb2!
+#endif
 #include "tdb2.h"
+#include <ccan/compiler/compiler.h>
 #include <ccan/likely/likely.h>
 #include <ccan/endian/endian.h>
 
diff --git a/lib/tdb2/summary.c b/lib/tdb2/summary.c
index f3a3a08..8ddd26e 100644
--- a/lib/tdb2/summary.c
+++ b/lib/tdb2/summary.c
@@ -211,7 +211,7 @@ static void add_capabilities(struct tdb_context *tdb, size_t num, char *summary)
 	}
 }
 
-enum TDB_ERROR tdb_summary(struct tdb_context *tdb,
+_PUBLIC_ enum TDB_ERROR tdb_summary(struct tdb_context *tdb,
 			   enum tdb_summary_flags flags,
 			   char **summary)
 {
diff --git a/lib/tdb2/tdb.c b/lib/tdb2/tdb.c
index 5e965ac..c9224bd 100644
--- a/lib/tdb2/tdb.c
+++ b/lib/tdb2/tdb.c
@@ -107,7 +107,7 @@ static enum TDB_ERROR update_data(struct tdb_context *tdb,
 	return ecode;
 }
 
-enum TDB_ERROR tdb_store(struct tdb_context *tdb,
+_PUBLIC_ enum TDB_ERROR tdb_store(struct tdb_context *tdb,
 			 struct tdb_data key, struct tdb_data dbuf, int flag)
 {
 	struct hash_info h;
@@ -174,7 +174,7 @@ out:
 	return tdb->last_error = ecode;
 }
 
-enum TDB_ERROR tdb_append(struct tdb_context *tdb,
+_PUBLIC_ enum TDB_ERROR tdb_append(struct tdb_context *tdb,
 			  struct tdb_data key, struct tdb_data dbuf)
 {
 	struct hash_info h;
@@ -248,7 +248,7 @@ out:
 	return tdb->last_error = ecode;
 }
 
-enum TDB_ERROR tdb_fetch(struct tdb_context *tdb, struct tdb_data key,
+_PUBLIC_ enum TDB_ERROR tdb_fetch(struct tdb_context *tdb, struct tdb_data key,
 			 struct tdb_data *data)
 {
 	tdb_off_t off;
@@ -280,7 +280,7 @@ enum TDB_ERROR tdb_fetch(struct tdb_context *tdb, struct tdb_data key,
 	return tdb->last_error = ecode;
 }
 
-bool tdb_exists(struct tdb_context *tdb, TDB_DATA key)
+_PUBLIC_ bool tdb_exists(struct tdb_context *tdb, TDB_DATA key)
 {
 	tdb_off_t off;
 	struct tdb_used_record rec;
@@ -301,7 +301,7 @@ bool tdb_exists(struct tdb_context *tdb, TDB_DATA key)
 	return off ? true : false;
 }
 
-enum TDB_ERROR tdb_delete(struct tdb_context *tdb, struct tdb_data key)
+_PUBLIC_ enum TDB_ERROR tdb_delete(struct tdb_context *tdb, struct tdb_data key)
 {
 	tdb_off_t off;
 	struct tdb_used_record rec;
@@ -346,7 +346,7 @@ unlock:
 	return tdb->last_error = ecode;
 }
 
-unsigned int tdb_get_flags(struct tdb_context *tdb)
+_PUBLIC_ unsigned int tdb_get_flags(struct tdb_context *tdb)
 {
 	return tdb->flags;
 }
@@ -372,7 +372,7 @@ static bool readonly_changable(struct tdb_context *tdb, const char *caller)
 	return true;
 }
 
-void tdb_add_flag(struct tdb_context *tdb, unsigned flag)
+_PUBLIC_ void tdb_add_flag(struct tdb_context *tdb, unsigned flag)
 {
 	if (tdb->flags & TDB_INTERNAL) {
 		tdb->last_error = tdb_logerr(tdb, TDB_ERR_EINVAL,
@@ -409,7 +409,7 @@ void tdb_add_flag(struct tdb_context *tdb, unsigned flag)
 	}
 }
 
-void tdb_remove_flag(struct tdb_context *tdb, unsigned flag)
+_PUBLIC_ void tdb_remove_flag(struct tdb_context *tdb, unsigned flag)
 {
 	if (tdb->flags & TDB_INTERNAL) {
 		tdb->last_error = tdb_logerr(tdb, TDB_ERR_EINVAL,
@@ -454,7 +454,7 @@ void tdb_remove_flag(struct tdb_context *tdb, unsigned flag)
 	}
 }
 
-const char *tdb_errorstr(enum TDB_ERROR ecode)
+_PUBLIC_ const char *tdb_errorstr(enum TDB_ERROR ecode)
 {
 	/* Gcc warns if you miss a case in the switch, so use that. */
 	switch (TDB_ERR_TO_OFF(ecode)) {
@@ -471,7 +471,7 @@ const char *tdb_errorstr(enum TDB_ERROR ecode)
 	return "Invalid error code";
 }
 
-enum TDB_ERROR tdb_error(struct tdb_context *tdb)
+_PUBLIC_ enum TDB_ERROR tdb_error(struct tdb_context *tdb)
 {
 	return tdb->last_error;
 }
@@ -506,7 +506,7 @@ enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
 	return ecode;
 }
 
-enum TDB_ERROR tdb_parse_record_(struct tdb_context *tdb,
+_PUBLIC_ enum TDB_ERROR tdb_parse_record_(struct tdb_context *tdb,
 				 TDB_DATA key,
 				 enum TDB_ERROR (*parse)(TDB_DATA k,
 							 TDB_DATA d,
@@ -548,12 +548,12 @@ enum TDB_ERROR tdb_parse_record_(struct tdb_context *tdb,
 	return tdb->last_error = ecode;
 }
 
-const char *tdb_name(const struct tdb_context *tdb)
+_PUBLIC_ const char *tdb_name(const struct tdb_context *tdb)
 {
 	return tdb->name;
 }
 
-int64_t tdb_get_seqnum(struct tdb_context *tdb)
+_PUBLIC_ int64_t tdb_get_seqnum(struct tdb_context *tdb)
 {
 	tdb_off_t off;
 
@@ -577,7 +577,7 @@ int64_t tdb_get_seqnum(struct tdb_context *tdb)
 }
 
 
-int tdb_fd(const struct tdb_context *tdb)
+_PUBLIC_ int tdb_fd(const struct tdb_context *tdb)
 {
 	return tdb->file->fd;
 }
@@ -600,7 +600,7 @@ static int repack_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
 	return 0;
 }
 
-enum TDB_ERROR tdb_repack(struct tdb_context *tdb)
+_PUBLIC_ enum TDB_ERROR tdb_repack(struct tdb_context *tdb)
 {
 	struct tdb_context *tmp_db;
 	struct traverse_state state;
diff --git a/lib/tdb2/tdb1_hash.c b/lib/tdb2/tdb1_hash.c
index 2d5e496..1d4e4ae 100644
--- a/lib/tdb2/tdb1_hash.c
+++ b/lib/tdb2/tdb1_hash.c
@@ -340,7 +340,7 @@ static uint32_t hashlittle( const void *key, size_t length )
   return c;
 }
 
-uint64_t tdb1_incompatible_hash(const void *key, size_t len, uint64_t seed,
+_PUBLIC_ uint64_t tdb1_incompatible_hash(const void *key, size_t len, uint64_t seed,
 				 void *unused)
 {
 	return hashlittle(key, len);
diff --git a/lib/tdb2/tdb2.h b/lib/tdb2/tdb2.h
index 44e7897..4782117 100644
--- a/lib/tdb2/tdb2.h
+++ b/lib/tdb2/tdb2.h
@@ -29,9 +29,8 @@
 extern "C" {
 #endif
 
-#include "config.h"
 #ifdef HAVE_LIBREPLACE
-#include "replace.h"
+#include <replace.h>
 #else
 #if HAVE_FILE_OFFSET_BITS
 #define _FILE_OFFSET_BITS 64
@@ -49,9 +48,25 @@ extern "C" {
 /* For memcmp */
 #include <string.h>
 #endif
+
+#if HAVE_CCAN
 #include <ccan/compiler/compiler.h>
 #include <ccan/typesafe_cb/typesafe_cb.h>
 #include <ccan/cast/cast.h>
+#else
+#ifndef typesafe_cb_preargs
+/* Failing to have CCAN just mean less typesafe protection, etc. */
+#define typesafe_cb_preargs(rtype, atype, fn, arg, ...)	\
+	((rtype (*)(__VA_ARGS__, atype))(fn))
+#endif
+#ifndef cast_const
+#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T)
+#define cast_const(type, expr) ((type)((intptr_t)(expr)))
+#else
+#define cast_const(type, expr) ((type *)(expr))
+#endif
+#endif
+#endif /* !HAVE_CCAN */
 
 union tdb_attribute;
 struct tdb_context;
diff --git a/lib/tdb/tdb.pc.in b/lib/tdb2/tdb2.pc.in
similarity index 89%
copy from lib/tdb/tdb.pc.in
copy to lib/tdb2/tdb2.pc.in
index b78419e..75e69d7 100644
--- a/lib/tdb/tdb.pc.in
+++ b/lib/tdb2/tdb2.pc.in
@@ -7,5 +7,5 @@ Name: tdb
 Description: A trivial database
 Version: @PACKAGE_VERSION@
 Libs: @LIB_RPATH@ -L${libdir} -ltdb
-Cflags: -I${includedir} 
+Cflags: -I${includedir}
 URL: http://tdb.samba.org/
diff --git a/lib/tdb2/tools/tdb2backup.c b/lib/tdb2/tools/tdb2backup.c
index 531bf29..729ae72 100644
--- a/lib/tdb2/tools/tdb2backup.c
+++ b/lib/tdb2/tools/tdb2backup.c
@@ -40,6 +40,7 @@
 
  */
 
+#include "config.h"
 #include "tdb2.h"
 #include "system/filesys.h"
 
diff --git a/lib/tdb2/tools/tdb2dump.c b/lib/tdb2/tools/tdb2dump.c
index abe1d9b..40230a2 100644
--- a/lib/tdb2/tools/tdb2dump.c
+++ b/lib/tdb2/tools/tdb2dump.c
@@ -16,7 +16,13 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
+#include "config.h"
 #include "tdb2.h"
+#ifdef HAVE_LIBREPLACE
+#include <replace.h>
+#include <system/filesys.h>
+#include <system/locale.h>
+#else
 #include <ctype.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -24,6 +30,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <unistd.h>
+#endif
 
 static void print_data(TDB_DATA d)
 {
diff --git a/lib/tdb2/tools/tdb2restore.c b/lib/tdb2/tools/tdb2restore.c
index 658215a..608b46d 100644
--- a/lib/tdb2/tools/tdb2restore.c
+++ b/lib/tdb2/tools/tdb2restore.c
@@ -17,13 +17,19 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
 #include "tdb2.h"
 #include <assert.h>
+#ifdef HAVE_LIBREPLACE
+#include <replace.h>
+#include <system/filesys.h>
+#else
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>


-- 
Samba Shared Repository


More information about the samba-cvs mailing list