37 printf(
"oscsend version %s\n"
38 "Copyright (C) 2008 Kentaro Fukuchi\n\n"
39 "Usage: oscsend hostname port address types values...\n"
40 "Send OpenSound Control message via UDP.\n\n"
42 "hostname: specifies the remote host's name.\n"
43 "port : specifies the port number to connect to the remote host.\n"
44 "address : the OSC address where the message to be sent.\n"
45 "types : specifies the types of the following values.\n",
47 printf(
" %c - 32bit integer\n",
LO_INT32);
48 printf(
" %c - 64bit integer\n",
LO_INT64);
49 printf(
" %c - 32bit floating point number\n",
LO_FLOAT);
50 printf(
" %c - 64bit (double) floating point number\n",
LO_DOUBLE);
53 printf(
" %c - char\n",
LO_CHAR);
54 printf(
" %c - 4 byte midi packet (8 digits hexadecimal)\n",
LO_MIDI);
55 printf(
" %c - TRUE (no value required)\n",
LO_TRUE);
56 printf(
" %c - FALSE (no value required)\n",
LO_FALSE);
57 printf(
" %c - NIL (no value required)\n",
LO_NIL);
58 printf(
" %c - INFINITUM (no value required)\n",
LO_INFINITUM);
59 printf(
"values : space separated values.\n\n"
61 "$ oscsend localhost 7777 /sample/address %c%c%c%c 1 3.14 hello\n",
76 const char *types, *arg;
85 values = strlen(types);
89 for(i=0; i<values; i++) {
92 fprintf(stderr,
"Value #%d is not given.\n", i + 1);
101 v = strtol(arg, &endp, 10);
103 fprintf(stderr,
"An invalid value was given: '%s'\n", arg);
106 if((v == LONG_MAX || v == LONG_MIN) && errno == ERANGE) {
107 fprintf(stderr,
"Value out of range: '%s'\n", arg);
110 if(v > INT_MAX || v < INT_MIN) {
111 fprintf(stderr,
"Value out of range: '%s'\n", arg);
123 v = strtoll(arg, &endp, 10);
125 fprintf(stderr,
"An invalid value was given: '%s'\n", arg);
128 if((v == LONG_MAX || v == LONG_MIN) && errno == ERANGE) {
129 fprintf(stderr,
"Value out of range: '%s'\n", arg);
142 v = strtof(arg, &endp);
144 v = (float)strtod(arg, &endp);
147 fprintf(stderr,
"An invalid value was given: '%s'\n", arg);
159 v = strtod(arg, &endp);
162 fprintf(stderr,
"An invalid value was given: '%s'\n", arg);
187 ret = sscanf(arg,
"%08x", &midi);
189 fprintf(stderr,
"An invalid hexadecimal value was given: '%s'\n", arg);
192 packet[0] = (midi>>24) & 0xff;
193 packet[1] = (midi>>16) & 0xff;
194 packet[2] = (midi>> 8) & 0xff;
195 packet[3] = midi & 0xff;
213 fprintf(stderr,
"Type '%c' is not supported or invalid.\n", types[i]);
225 int main(
int argc,
char **argv)
236 if(argv[1] == NULL) {
237 fprintf(stderr,
"No hostname is given.\n");
240 if(argv[2] == NULL) {
241 fprintf(stderr,
"No port number is given.\n");
247 fprintf(stderr,
"Failed to open %s:%s\n", argv[1], argv[2]);
251 if(argv[3] == NULL) {
252 fprintf(stderr,
"No path is given.\n");
257 if(message == NULL) {
258 fprintf(stderr,
"Failed to create OSC message.\n");