summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-04-29 04:05:38 +0000
committerAndrew Tridgell <tridge@samba.org>2000-04-29 04:05:38 +0000
commitc0e1c6505329972835ccbf6886f8aab8eb33e634 (patch)
tree89636bd285a92793124f8945f79346ca9761c5e1 /source3
parent74ac259e071db2a5bec716c6508e4ce232b9b1e2 (diff)
downloadsamba-c0e1c6505329972835ccbf6886f8aab8eb33e634.tar.gz
samba-c0e1c6505329972835ccbf6886f8aab8eb33e634.tar.bz2
samba-c0e1c6505329972835ccbf6886f8aab8eb33e634.zip
put tdb utility functions in a separate file
(This used to be commit 77009422a075300e5c07a3e75806a7dac47e2113)
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in5
-rw-r--r--source3/tdb/tdb.c44
-rw-r--r--source3/tdb/tdbutil.c67
3 files changed, 71 insertions, 45 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index ceb1899cba..018927b793 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -97,6 +97,8 @@ QUOTAOBJS=@QUOTAOBJS@
# object file lists
######################################################################
+TDB_OBJ = tdb/tdb.o tdb/tdbutil.o
+
LIB_OBJ = lib/charcnv.o lib/charset.o lib/debug.o lib/fault.o \
lib/getsmbpass.o lib/interface.o lib/kanji.o lib/md4.o \
lib/interfaces.o lib/pidfile.o lib/replace.o \
@@ -106,7 +108,8 @@ LIB_OBJ = lib/charcnv.o lib/charset.o lib/debug.o lib/fault.o \
lib/util_array.o lib/util_str.o lib/util_sid.o \
lib/util_unistr.o lib/util_file.o \
lib/util.o lib/util_sock.o lib/util_sec.o smbd/ssl.o lib/fnmatch.o \
- tdb/tdb.o lib/talloc.o lib/hash.o lib/substitute.o lib/fsusage.o
+ lib/talloc.o lib/hash.o lib/substitute.o lib/fsusage.o \
+ $(TDB_OBJ)
UBIQX_OBJ = ubiqx/ubi_BinTree.o ubiqx/ubi_Cache.o ubiqx/ubi_SplayTree.o \
ubiqx/ubi_dLinkList.o ubiqx/ubi_sLinkList.o ubiqx/debugparse.o
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index e884bb34b9..c8860e2191 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -1309,47 +1309,3 @@ int tdb_unlockchain(TDB_CONTEXT *tdb, TDB_DATA key)
}
-/* these two utility functions provide convent routines for storing
- simple string/value pairs in a tdb. They also serve as examples
- */
-
-/* fetch a value by a arbitrary blob key, return -1 if not found */
-
-int tdb_get_int_byblob(TDB_CONTEXT *tdb, char *keyval, size_t len)
-{
- TDB_DATA key, data;
- int ret;
-
- key.dptr = keyval;
- key.dsize = len;
- data = tdb_fetch(tdb, key);
- if (!data.dptr || data.dsize != sizeof(int)) return -1;
-
- memcpy(&ret, data.dptr, sizeof(int));
- free(data.dptr);
- return ret;
-}
-/* fetch a value by string key, return -1 if not found */
-int tdb_get_int(TDB_CONTEXT *tdb, char *keystr)
-{
- return tdb_get_int_byblob(tdb, keystr, strlen(keystr));
-}
-
-/* store a value by an arbitary blob key, return 0 on success, -1 on failure */
-int tdb_store_int_byblob(TDB_CONTEXT *tdb, char *keystr, size_t len, int v)
-{
- TDB_DATA key, data;
-
- key.dptr = keystr;
- key.dsize = len;
- data.dptr = (void *)&v;
- data.dsize = sizeof(int);
-
- return tdb_store(tdb, key, data, TDB_REPLACE);
-}
-
-/* store a value by string key, return 0 on success, -1 on failure */
-int tdb_store_int(TDB_CONTEXT *tdb, char *keystr, int v)
-{
- return tdb_store_int_byblob(tdb, keystr, strlen(keystr), v);
-}
diff --git a/source3/tdb/tdbutil.c b/source3/tdb/tdbutil.c
new file mode 100644
index 0000000000..7511020873
--- /dev/null
+++ b/source3/tdb/tdbutil.c
@@ -0,0 +1,67 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 3.0
+ 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"
+
+/* these are little tdb utility functions that are meant to make
+ dealing with a tdb database a little less cumbersome in Samba */
+
+
+/* fetch a value by a arbitrary blob key, return -1 if not found */
+int tdb_get_int_byblob(TDB_CONTEXT *tdb, char *keyval, size_t len)
+{
+ TDB_DATA key, data;
+ int ret;
+
+ key.dptr = keyval;
+ key.dsize = len;
+ data = tdb_fetch(tdb, key);
+ if (!data.dptr || data.dsize != sizeof(int)) return -1;
+
+ memcpy(&ret, data.dptr, sizeof(int));
+ free(data.dptr);
+ return ret;
+}
+
+/* fetch a value by string key, return -1 if not found */
+int tdb_get_int(TDB_CONTEXT *tdb, char *keystr)
+{
+ return tdb_get_int_byblob(tdb, keystr, strlen(keystr));
+}
+
+/* store a value by an arbitary blob key, return 0 on success, -1 on failure */
+int tdb_store_int_byblob(TDB_CONTEXT *tdb, char *keystr, size_t len, int v)
+{
+ TDB_DATA key, data;
+
+ key.dptr = keystr;
+ key.dsize = len;
+ data.dptr = (void *)&v;
+ data.dsize = sizeof(int);
+
+ return tdb_store(tdb, key, data, TDB_REPLACE);
+}
+
+/* store a value by string key, return 0 on success, -1 on failure */
+int tdb_store_int(TDB_CONTEXT *tdb, char *keystr, int v)
+{
+ return tdb_store_int_byblob(tdb, keystr, strlen(keystr), v);
+}