comparison osc/sv-osc-send.c @ 69:76cc2c424268

* Update the main sv.prf for compatibility with Qt 4.2 qmake instead of that from 4.1. Add a README.Qt41 describing how to build with 4.1 if preferred. * Add OSC support for control from external scripts etc (work in progress).
author Chris Cannam
date Fri, 10 Nov 2006 13:27:57 +0000
parents
children
comparison
equal deleted inserted replaced
68:050d764df239 69:76cc2c424268
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include <ctype.h>
7 #include <lo/lo.h>
8
9 void
10 usage(char *program_name)
11 {
12 char *base_name = strrchr(program_name, '/');
13
14 if (base_name && *(base_name + 1) != 0) {
15 base_name += 1;
16 } else {
17 base_name = program_name;
18 }
19
20 fprintf(stderr, "\nusage: %s <OSC URL> [<values>]\n\n", program_name);
21 fprintf(stderr, "example OSC URLs:\n\n"
22 " osc.udp://localhost:19383/path/test 1.0 4.2\n"
23 " osc.udp://my.host.org:10886/3/13/load file\n\n");
24 fprintf(stderr, "numeric arguments will be treated as OSC 'f' floating point types.\n\n");
25 exit(1);
26 }
27
28 int main(int argc, char *argv[])
29 {
30 lo_address a;
31 char *url, *host, *port, *path;
32 lo_message message;
33 unsigned int i;
34
35 if (argc < 2) {
36 usage(argv[0]);
37 /* does not return */
38 }
39 url = argv[1];
40
41 host = lo_url_get_hostname(url);
42 port = lo_url_get_port(url);
43 path = lo_url_get_path(url);
44 a = lo_address_new(host, port);
45
46 message = lo_message_new();
47
48 for (i = 0; i + 2 < argc; ++i) {
49
50 int index = i + 2;
51 char *param;
52
53 param = argv[index];
54 if (!isdigit(param[0])) {
55 lo_message_add_string(message, argv[index]);
56 } else {
57 lo_message_add_float(message, atof(argv[index]));
58 }
59 }
60
61 lo_send_message(a, path, message);
62
63 if (lo_address_errno(a)) {
64 printf("liblo error: %s\n", lo_address_errstr(a));
65 }
66
67 free(host);
68 free(port);
69 free(path);
70
71 return 0;
72 }
73