#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TDB_VERSION "0.0.1"
#define APPNAME _ANSI_MAGENTA "teodb_ex" _ANSI_NONE
#define TEODB_PEER ke->teo_cfg.app_argv[1]
#define TEODB_EX_KEY "teo_db_ex"
#define TEST_KEY "test"
#define TEST_VALUE "{ \"name\": \"1\" }"
#define ke cqd->ke
#define NUM_RECORDS_TO_SHOW "25"
void *ar_data = (*cqd->tdd)->key_data + (*cqd->tdd)->key_length;
uint32_t ar_data_num = *(uint32_t*)ar_data;
size_t ptr = sizeof(ar_data_num);
printf("7) Got Callback Queue callback with id: %o, type: %d => %s\n"
"Key: \"%s\"\n",
id, type, type ? "success" : "timeout",
(*cqd->tdd)->key_data);
printf("Number of records in list: %o\n", ar_data_num);
int i = 0; for(i = 0; i < ar_data_num; i++) {
size_t len = strlen((char*)ar_data + ptr) + 1;
printf("%d %s\n", i+1, (char*)ar_data + ptr);
ptr += len;
break;
}
}
puts("");
printf("Test finished ...\n");
#undef NUM_RECORDS_TO_SHOW
#undef ke
}
void get_cb(uint32_t
id,
int type,
void *data) {
#define ke cqd->ke
printf("5) Got Callback Queue callback with id: %o, type: %d => %s\n"
"Key: \"%s\", Value: \"%s\"\n",
id, type, type ? "success" : "timeout",
(*cqd->tdd)->key_data, (*cqd->tdd)->key_data + (*cqd->tdd)->key_length);
printf("6) Send LIST request to the TeoDB using cQueue\n");
printf(
"6.1) Register callback id %o\n", cq->
id);
size_t tdd_len;
#define KEY "teo_db_ex."
#undef ke
}
size_t data_len, void *user_data) {
switch(event) {
{
printf("The TeoDB peer: \"%s\" was connected\n",
printf("1) Add test key to the TeoDB, key: \"%s\", value: \"%s\"\n",
key, value);
size_t tdd_len;
size_t key_len = strlen(key) + 1;
printf("2) Send GET request to the TeoDB, key: \"%s\"\n",
key);
}
}
break;
{
{
printf("3) Got test key value from the TeoDB, "
"key: \"%s\", value: \"%s\"\n",
key, value);
printf("4) Send GET request to the TeoDB using cQueue, "
"key: \"%s\"\n",
key);
cqd->tdd = &tdd;
printf(
"4.1) Register callback id %d\n", cq->
id);
size_t tdd_len;
}
else {
}
}
break;
{
}
}
break;
}
}
break;
default: break;
}
}
int main(
int argc,
char** argv) {
"based on teonet ver. " VERSION "\n");
const char *app_argv[] = { "", "teodb_peer" };
return (EXIT_SUCCESS);
}