Commit 81defbc3 authored by Rusty Russell's avatar Rusty Russell

tdb2: tools/

As per-tdb's tools.
parent 43d881a2
LDLIBS:=../../tdb2.o ../../hash.o ../../tally.o
CFLAGS:=-I../../.. -Wall -g #-g -O3 #-g -pg
LDFLAGS:=-L../../..
default: tdbtorture tdbtool mktdb
clean:
rm -f tdbtorture tdbtool mktdb
#include <ccan/tdb2/tdb2.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <err.h>
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 <tdbfile> <numrecords>");
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;
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment