CSL 5.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

oscdump.c
Go to the documentation of this file.
1 /*
2 * oscdump - Receive and dump OpenSound Control messages.
3 *
4 * Copyright (C) 2008 Kentaro Fukuchi <fukuchi@megaui.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA.
20 *
21 */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <errno.h>
27 #include <signal.h>
28 #include <config.h>
29 #include <lo/lo.h>
30
31 void usage(void)
32 {
33 printf("oscdump version %s\n"
34 "Copyright (C) 2008 Kentaro Fukuchi\n\n"
35 "Usage: oscdump port\n"
36 "Receive OpenSound Control messages via UDP and dump to standard output.\n\n"
37 "Description\n"
38 "port : specifies the listening port number.\n\n",
39 VERSION);
40 }
41
42 void errorHandler(int num, const char *msg, const char *where)
43 {
44 printf("liblo server error %d in path %s: %s\n", num, where, msg);
45 }
46
47 int messageHandler(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data)
48 {
49 int i;
50
51 printf("%s %s", path, types);
52
53 for(i=0; i<argc; i++) {
54 printf(" ");
55 lo_arg_pp((lo_type)types[i], argv[i]);
56 }
57 printf("\n");
58
59 return 0;
60 }
61
62 int main(int argc, char **argv)
63 {
64 lo_server server;
65
66 if(argc < 2) {
67 usage();
68 exit(1);
69 }
70
71 server = lo_server_new(argv[1], errorHandler);
72 if(server == NULL) {
73 printf("Could not start a server with port %s\n", argv[1]);
74 exit(1);
75 }
76
77 lo_server_add_method(server, NULL, NULL, messageHandler, NULL);
78
79
80 for(;;) {
81 lo_server_recv(server);
82 }
83
84 return 0;
85 }