X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=junkcode%2Frusty%40rustcorp.com.au-ntdb%2Ftools%2Fmkntdb.c;fp=junkcode%2Frusty%40rustcorp.com.au-ntdb%2Ftools%2Fmkntdb.c;h=e728987a533fd75ab50b8c2f0788ff2f290533c9;hb=1aab74723e837a0fd8091e264a325bb2cdcdd0fa;hp=0000000000000000000000000000000000000000;hpb=979071e8587d4819a7f78613b68d29e222e5db63;p=ccan diff --git a/junkcode/rusty@rustcorp.com.au-ntdb/tools/mkntdb.c b/junkcode/rusty@rustcorp.com.au-ntdb/tools/mkntdb.c new file mode 100644 index 00000000..e728987a --- /dev/null +++ b/junkcode/rusty@rustcorp.com.au-ntdb/tools/mkntdb.c @@ -0,0 +1,29 @@ +#include "ntdb.h" +#include +#include +#include +#include + +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 "); + + 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; +}