https://gist.github.com/cooldaemon/148113
Makefile
SOURCES = $(wildcard *.c) |
|
OBJECTS = $(SOURCES:%.c=%.o) |
|
-ltokyocabinet -lz -lbz2 -lpthread -lm -lc |
|
rm -f
$(TARGET)
$(OBJECTS)
void print_value(TCHDB *, const char *); |
|
void print_error(TCHDB *); |
|
int main(int argc, char *argv[]) { |
|
if (!tchdbopen(hdb, "test.tch", HDBOWRITER | HDBOCREAT)) { |
|
!tchdbput2(hdb, "foo", "hop") || |
|
!tchdbput2(hdb, "bar", "step") || |
|
!tchdbput2(hdb, "baz", "jump") |
|
while ((key = tchdbiternext2(hdb)) != NULL) { |
|
void cleanup(TCHDB *hdb) { |
|
void print_value(TCHDB *hdb, const char *key) { |
|
char *value = tchdbget2(hdb, key); |
|
printf("get value: %s\n", value); |
|
void print_error(TCHDB *hdb) { |
|
int ecode = tchdbecode(hdb); |
|
fprintf(stderr,
"open error: %s\n",
tchdberrmsg(ecode));