Bug 9807 - wbinfo: fix segfault in wbinfo_pam_logon
[Samba/gebeck_regimport.git] / lib / ntdb / tools / mkntdb.c
blobe728987a533fd75ab50b8c2f0788ff2f290533c9
1 #include "ntdb.h"
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <fcntl.h>
5 #include <ccan/err/err.h>
7 int main(int argc, char *argv[])
9 unsigned int i, num_recs;
10 struct ntdb_context *ntdb;
12 if (argc != 3 || (num_recs = atoi(argv[2])) == 0)
13 errx(1, "Usage: mktdb <tdbfile> <numrecords>");
15 ntdb = ntdb_open(argv[1], NTDB_DEFAULT, O_CREAT|O_TRUNC|O_RDWR, 0600,NULL);
16 if (!ntdb)
17 err(1, "Opening %s", argv[1]);
19 for (i = 0; i < num_recs; i++) {
20 NTDB_DATA d;
22 d.dptr = (void *)&i;
23 d.dsize = sizeof(i);
24 if (ntdb_store(ntdb, d, d, NTDB_INSERT) != 0)
25 err(1, "Failed to store record %i", i);
27 printf("Done\n");
28 return 0;