diff options
-rwxr-xr-x | app/configure | 1 | ||||
-rw-r--r-- | app/dolmetschctl.c | 63 |
2 files changed, 62 insertions, 2 deletions
diff --git a/app/configure b/app/configure index 9648f0f..597ba07 100755 --- a/app/configure +++ b/app/configure @@ -88,6 +88,7 @@ rm -f config.h rm -f include.mk case $TARGET in Linux) + LDFLAGS=$LD_FLAGS' -llo -lpthread' ;; *) echo "platform not supported" diff --git a/app/dolmetschctl.c b/app/dolmetschctl.c index 3591628..1d695a5 100644 --- a/app/dolmetschctl.c +++ b/app/dolmetschctl.c @@ -20,9 +20,15 @@ * along with dolmetschctl. If not, see <http://www.gnu.org/licenses/>. */ +#include "config.h" + #include <stdio.h> +#include <stdlib.h> +#include <unistd.h> -#include "config.h" +#include "lo/lo.h" + +volatile int done = 0; void print_version() { @@ -36,9 +42,62 @@ void print_version() #endif } +void print_error(int num, const char *msg, const char *path) +{ + printf("liblo server error %d in path %s: %s\n", num, path, msg); + fflush(stdout); +} + + +int generic_handler(const char *path, const char *types, lo_arg ** argv, + int argc, void *data, void *user_data) +{ + int i; + + printf("path: <%s>\n", path); + for(i = 0; i < argc; i++) { + printf("arg %d '%c' ", i, types[i]); + lo_arg_pp((lo_type)types[i], argv[i]); + printf("\n"); + } + printf("\n"); + fflush(stdout); + + return 1; +} + +int foo_handler(const char *path, const char *types, lo_arg ** argv, + int argc, void *data, void *user_data) +{ + printf("%s <- f:%f, i:%d\n", path, argv[0]->f, argv[1]->i); + fflush(stdout); + + return 0; +} + +int quit_handler(const char *path, const char *types, lo_arg ** argv, + int argc, void *data, void *user_data) +{ + done = 1; + printf("quiting\n"); + fflush(stdout); + + return 0; +} int main(int argc, char* argv[]) { - print_version(); + lo_server_thread st = lo_server_thread_new("7770", print_error); + lo_server_thread_add_method(st, NULL, NULL, generic_handler, NULL); + lo_server_thread_add_method(st, "/foo/bar", "fi", foo_handler, NULL); + lo_server_thread_add_method(st, "/quit", "", quit_handler, NULL); + lo_server_thread_start(st); + + while (!done) { + usleep(1000); + } + + lo_server_thread_free(st); + return 0; } |