diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-18 22:30:26 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-19 05:38:06 +0200 |
commit | 16cc345d4f84367e70e133200f7aa335c2aae8c6 (patch) | |
tree | 955a33c25c19f3127e24ba6b0e108da6b1f7f804 /lib/ntdb/tools/mkntdb.c | |
parent | 76758b9767fad45ff144bbfef3ab84bca5d4650e (diff) | |
download | samba-16cc345d4f84367e70e133200f7aa335c2aae8c6.tar.gz samba-16cc345d4f84367e70e133200f7aa335c2aae8c6.tar.bz2 samba-16cc345d4f84367e70e133200f7aa335c2aae8c6.zip |
TDB2: Goodbye TDB2, Hello NTDB.
This renames everything from tdb2 to ntdb: importantly, we no longer
use the tdb_ namespace, so you can link against both ntdb and tdb if
you want to.
This also enables building of standalone ntdb by the autobuild script.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ntdb/tools/mkntdb.c')
-rw-r--r-- | lib/ntdb/tools/mkntdb.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/ntdb/tools/mkntdb.c b/lib/ntdb/tools/mkntdb.c new file mode 100644 index 0000000000..e728987a53 --- /dev/null +++ b/lib/ntdb/tools/mkntdb.c @@ -0,0 +1,29 @@ +#include "ntdb.h" +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <ccan/err/err.h> + +int main(int argc, char *argv[]) +{ + unsigned int i, num_recs; + struct ntdb_context *ntdb; + + if (argc != 3 || (num_recs = atoi(argv[2])) == 0) + errx(1, "Usage: mktdb <tdbfile> <numrecords>"); + + ntdb = ntdb_open(argv[1], NTDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600,NULL); + if (!ntdb) + err(1, "Opening %s", argv[1]); + + for (i = 0; i < num_recs; i++) { + NTDB_DATA d; + + d.dptr = (void *)&i; + d.dsize = sizeof(i); + if (ntdb_store(ntdb, d, d, NTDB_INSERT) != 0) + err(1, "Failed to store record %i", i); + } + printf("Done\n"); + return 0; +} |