X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Ftools%2Fmktdb2.c;fp=ccan%2Ftdb2%2Ftools%2Fmktdb2.c;h=79011b1d11a106e18809ea963674496f6b883900;hp=0000000000000000000000000000000000000000;hb=8388c33a83ad51c6fdc355d938f08419d2b24923;hpb=a8bb84de3dd8b14701c96e02da669abd8ac525ff diff --git a/ccan/tdb2/tools/mktdb2.c b/ccan/tdb2/tools/mktdb2.c new file mode 100644 index 00000000..79011b1d --- /dev/null +++ b/ccan/tdb2/tools/mktdb2.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + unsigned int i, num_recs; + struct tdb_context *tdb; + + if (argc != 3 || (num_recs = atoi(argv[2])) == 0) + errx(1, "Usage: mktdb "); + + tdb = tdb_open(argv[1], TDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600,NULL); + if (!tdb) + err(1, "Opening %s", argv[1]); + + for (i = 0; i < num_recs; i++) { + TDB_DATA d; + + d.dptr = (void *)&i; + d.dsize = sizeof(i); + if (tdb_store(tdb, d, d, TDB_INSERT) != 0) + err(1, "Failed to store record %i", i); + } + printf("Done\n"); + return 0; +}