Files
opendht/tools/dhtcnode.c
T
Adrien Beraud 083a28f5d8 c wrapper: add wrapper foundations
Wrapper can be enabled/disabled with
-DOPENDHT_C=On/Off when configuring the cmake
project.

This commit add foundations for a C wrapper
by building an opendht-c shared library that
wraps dhtrunner (for now only creation/destruction).

It also adds a test executable, dhtcnode, using the
C wrapper library.
2019-10-16 10:57:10 -04:00

31 lines
652 B
C

#include "c/opendht_c.h"
#include <stdio.h>
bool dht_get_callback(const dht_value* value, void* user_data)
{
dht_runner* runner = (dht_runner*)user_data;
printf("Get callback.");
}
bool dht_done_callback(bool ok, void* user_data)
{
dht_runner* runner = (dht_runner*)user_data;
printf("Done callback. %s", ok ? "Success !" : "Failure :-(");
}
int main()
{
dht_runner* runner = dht_runner_new();
dht_infohash h;
dht_infohash_random(&h);
printf("random hash: %s\n", dht_infohash_print(&h));
dht_runner_get(runner, &h, dht_get_callback, dht_done_callback, runner);
dht_runner_delete(runner);
return 0;
}