summaryrefslogtreecommitdiffstats
path: root/testzero.c
blob: ba078659089fad3012c4538c978fe8c614b66297 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "uint32.h"
#include "scan.h"
#include "strerr.h"
#include "cdb_make.h"

#define FATAL "testzero: fatal: "

void die_write(void)
{
  strerr_die2sys(111,FATAL,"unable to write: ");
}

static char key[4];
static char data[65536];
struct cdb_make c;

main(int argc,char **argv)
{
  int fd;
  unsigned long loop;

  if (!*argv) _exit(0);
  if (!*++argv) _exit(0);
  scan_ulong(*argv,&loop);

  if (cdb_make_start(&c,1) == -1) die_write();

  while (loop) {
    uint32_pack(key,--loop);
    if (cdb_make_add(&c,key,4,data,sizeof data) == -1) die_write();
  }

  if (cdb_make_finish(&c) == -1) die_write();
  _exit(0);
}