An example that shows how to use rpc_object_pack and rpc_object_unpack APIs.
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
int
main(int argc, const char *argv[])
{
const char *keys[] = {"key"};
(void)argc;
(void)argv;
const char *str;
int64_t num;
int64_t dict_num;
int cnt;
bool sure;
(void)cookie;
&str, &num, &sure, &nonexistent_obj, &dict_num);
if (nonexistent_obj != NULL)
printf("Nonexistent obj shouldn't be initialized");
printf("unpack cnt: %i\n", cnt);
printf("str = %s, num = %" PRId64 ", dict_num = %" PRId64
", sure = %s\n", str, num, dict_num,
sure ? "true" : "false");
return rpc_object_pack(
"{inline:'inline_string',s,i,uint:u,b,n,array:['inline',i,5:i,<int64>i,{s}]}",
"hello", "world",
"int", -12345L,
0x80808080L,
"true_or_false", true,
"nothing",
1L, 2L, 3L, "!", "?");
});
if (server == NULL) {
fprintf(stderr, "cannot create server: %s", strerror(errno));
return (1);
}
if (client == NULL) {
fprintf(stderr, "cannot connect: %s", strerror(errno));
return (1);
}
"world", 123, true,
return (0);
}