Mercurial > hg > piper-vamp-js
diff quick-test.cpp @ 2:4d6e60a7c80e
Some JSON fixes and a quick test program
author | Chris Cannam |
---|---|
date | Tue, 23 Aug 2016 12:04:49 +0100 |
parents | |
children | 3a5a6535d50d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/quick-test.cpp Tue Aug 23 12:04:49 2016 +0100 @@ -0,0 +1,38 @@ + +#include <iostream> +#include <dlfcn.h> + +using namespace std; + +int main(int argc, char **argv) +{ + string example = "./example.so"; + + void *lib = dlopen(example.c_str(), RTLD_LAZY | RTLD_LOCAL); + if (!lib) { + cerr << "failed to open " + example + ": " << dlerror() << endl; + return 1; + } + + typedef const char *(*RequestFn)(const char *); + RequestFn reqFn = (RequestFn)dlsym(lib, "vampipeRequestJson"); + if (!reqFn) { + cerr << "failed to find request function in " + + example + ": " << dlerror() << endl; + return 1; + } + + typedef void (*FreeFn)(const char *); + FreeFn freeFn = (FreeFn)dlsym(lib, "vampipeFreeJson"); + if (!freeFn) { + cerr << "failed to find free function in " + + example + ": " << dlerror() << endl; + return 1; + } + + string listRequest = "{\"type\": \"list\"}"; + const char *listResponse = reqFn(listRequest.c_str()); + cout << listResponse << endl; + freeFn(listResponse); +} +