summaryrefslogtreecommitdiff
path: root/app/dolmetschctl.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-08 07:51:20 +0200
committerChristian Pointner <equinox@spreadspace.org>2015-10-08 07:51:20 +0200
commit029c3144e04523cdcbc7d296e7bf22287754ed43 (patch)
tree3b24527903bf87fa1ad4522b08f664a464fb1017 /app/dolmetschctl.c
parentadded inital app code (diff)
added sample code for liblo
Diffstat (limited to 'app/dolmetschctl.c')
-rw-r--r--app/dolmetschctl.c63
1 files changed, 61 insertions, 2 deletions
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;
}