上传日期:2004-05-31 20:47:31
上 传 者bozhanhua
说明:  一个小型数据库的实现源码
(The realization of a small database source)

tdb-1.0.6 (0, 2003-05-28)
tdb-1.0.6\ (16921, 2001-12-11)
tdb-1.0.6\ (10, 2001-12-11)
tdb-1.0.6\AUTHORS (380, 2001-05-08)
tdb-1.0.6\COPYING (17992, 2000-03-11)
tdb-1.0.6\ChangeLog (926, 2001-12-11)
tdb-1.0.6\INSTALL (7831, 2000-03-11)
tdb-1.0.6\ (798, 2001-12-11)
tdb-1.0.6\NEWS (752, 2001-05-08)
tdb-1.0.6\TODO (176, 2001-05-08)
tdb-1.0.6\acconfig.h (207, 2001-12-11)
tdb-1.0.6\aclocal.m4 (18173, 2001-12-11)
tdb-1.0.6\config.guess (31228, 2000-04-01)
tdb-1.0.6\ (600, 2001-12-11)
tdb-1.0.6\config.sub (24535, 2000-04-01)
tdb-1.0.6\configure (78045, 2001-12-11)
tdb-1.0.6\ (1877, 2001-12-11)
tdb-1.0.6\install-sh (5598, 2000-03-11)
tdb-1.0.6\ltconfig (94197, 2000-04-01)
tdb-1.0.6\ (109411, 2000-04-01)
tdb-1.0.6\missing (6283, 2000-03-11)
tdb-1.0.6\mkinstalldirs (722, 2000-03-11)
tdb-1.0.6\tdb.c (45947, 2001-12-11)
tdb-1.0.6\spinlock.c (7951, 2001-12-11)
tdb-1.0.6\spinlock.h (1366, 2001-12-05)
tdb-1.0.6\tdbtool.c (11655, 2001-12-11)
tdb-1.0.6\tdbdump.c (1951, 2001-12-11)
tdb-1.0.6\tdbspeed.c (3463, 2001-05-08)
tdb-1.0.6\tdbiterate.c (1157, 2001-05-08)
tdb-1.0.6\tdbtest.c (4626, 2001-12-11)
tdb-1.0.6\tdbtorture.c (3794, 2001-12-11)
tdb-1.0.6\tdb.h (4675, 2001-12-11)
tdb-1.0.6\tdb_close.3 (489, 2001-05-08)
tdb-1.0.6\tdb_delete.3 (760, 2001-05-08)
tdb-1.0.6\tdb_error.3 (720, 2001-05-08)
tdb-1.0.6\tdb_exists.3 (790, 2001-05-08)
tdb-1.0.6\tdb_fetch.3 (975, 2001-05-08)
tdb-1.0.6\tdb_firstkey.3 (1968, 2001-05-08)
tdb-1.0.6\tdb_open.3 (1565, 2001-05-08)
... ...

tdb - a trivial database system December 1999 ================================== This is a simple database API. It was inspired by the realisation that in Samba we have several ad-hoc bits of code that essentially implement small databases for sharing structures between parts of Samba. As I was about to add another I realised that a generic database module was called for to replace all the ad-hoc bits. I based the interface on gdbm. I couldn't use gdbm as we need to be able to have multiple writers to the databases at one time. Compilation ----------- add HAVE_MMAP=1 to use mmap instead of read/write add TDB_DEBUG=1 for verbose debug info add NOLOCK=1 to disable locking code Testing ------- Compile tdbtest.c and link with gdbm for testing. tdbtest will perform identical operations via tdb and gdbm then make sure the result is the same Also included is tdbtool, which allows simple database manipulation on the commandline. tdbtest and tdbtool are not built as part of Samba, but are included for completeness. File formats ------------ append tdb.magic to your /etc/magic so that file will recognise tdb files. Interface --------- The interface is very similar to gdbm except for the following: - different open interface. The tdb_open call is more similar to a traditional open() - no tdbm_reorganise() function - no tdbm_sync() function. No operations are cached in the library anyway - added a tdb_traverse() function for traversing the whole database A general rule for using tdb is that the caller frees any returned TDB_DATA structures. Just call free(p.dptr) to free a TDB_DATA return value called p. This is the same as gdbm. here is a full list of tdb functions with brief descriptions. ---------------------------------------------------------------------- TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags, int open_flags, mode_t mode) open the database, creating it if necessary The open_flags and mode are passed straight to the open call on the database file. A flags value of O_WRONLY is invalid The hash size is advisory, use zero for a default value. return is NULL on error possible tdb_flags are: TDB_CLEAR_IF_FIRST - clear database if we are the only one with it open TDB_INTERNAL - don't use a file, instaed store the data in memory. The filename is ignored in this case. TDB_NOLOCK - don't do any locking TDB_NOMMAP - don't use mmap TDB_CONVERT - Create a database in the reverse of native endian: normally when the database is created (or cleared with TDB_CLEAR_IF_FIRST), it is created in native endian order. This flag is set (or unset) automat ically for existing databases. ---------------------------------------------------------------------- enum TDB_ERROR tdb_error(TDB_CONTEXT *tdb); tdb_error returns the current error state of the tdb database. ---------------------------------------------------------------------- const char *tdb_errorstr(TDB_CONTEXT *tdb); tdb_errorstr returns a printable string that describes the error state of the database. ---------------------------------------------------------------------- int tdb_close(TDB_CONTEXT *tdb); close a database ---------------------------------------------------------------------- int tdb_update(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf); update an entry in place - this only works if the new data size is <= the old data size and the key exists. on failure return -1 ---------------------------------------------------------------------- TDB_DATA tdb_fetch(TDB_CONTEXT *tdb, TDB_DATA key); fetch an entry in the database given a key if the return value has a null dptr then a error occurred caller must free the resulting data ---- ... ...