Mercurial > hg > cdb
comparison testzero.c @ 0:2cb46628feec
from cdb-0.75 per http://cr.yp.to/cdb.html,
retrieved 2025-01-03,
contents appear to have been create on 2000-02-19
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Wed, 29 Jan 2025 10:50:34 +0000 |
| parents | |
| children | 3bfef1f22a97 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:2cb46628feec |
|---|---|
| 1 #include "uint32.h" | |
| 2 #include "scan.h" | |
| 3 #include "strerr.h" | |
| 4 #include "cdb_make.h" | |
| 5 | |
| 6 #define FATAL "testzero: fatal: " | |
| 7 | |
| 8 void die_write(void) | |
| 9 { | |
| 10 strerr_die2sys(111,FATAL,"unable to write: "); | |
| 11 } | |
| 12 | |
| 13 static char key[4]; | |
| 14 static char data[65536]; | |
| 15 struct cdb_make c; | |
| 16 | |
| 17 main(int argc,char **argv) | |
| 18 { | |
| 19 int fd; | |
| 20 unsigned long loop; | |
| 21 | |
| 22 if (!*argv) _exit(0); | |
| 23 if (!*++argv) _exit(0); | |
| 24 scan_ulong(*argv,&loop); | |
| 25 | |
| 26 if (cdb_make_start(&c,1) == -1) die_write(); | |
| 27 | |
| 28 while (loop) { | |
| 29 uint32_pack(key,--loop); | |
| 30 if (cdb_make_add(&c,key,4,data,sizeof data) == -1) die_write(); | |
| 31 } | |
| 32 | |
| 33 if (cdb_make_finish(&c) == -1) die_write(); | |
| 34 _exit(0); | |
| 35 } |
