20 #include <sys/types.h>
24 #define snprintf _snprintf
34 #include <sys/socket.h>
48 if(a == NULL)
return NULL;
58 a->host = strdup(host);
60 a->host = strdup(
"localhost");
64 a->host = strdup(
"localhost");
68 a->port = strdup(port);
87 char *host, *port, *proto;
101 }
else if (protocol ==
LO_UNIX) {
108 fprintf(stderr,
PACKAGE_NAME ": protocol '%s' not supported by this "
110 if(proto) free(proto);
165 int needquote = strchr(a->host,
':') ? 1 : 0;
169 fmt =
"osc.%s://[%s]:%s/";
171 fmt =
"osc.%s://%s:%s/";
174 ret = snprintf(NULL, 0, fmt,
181 buf = malloc((ret + 2) *
sizeof(
char));
182 snprintf(buf, ret+1, fmt,
191 if (a->socket != -1) {
194 if (a->host) free(a->host);
195 if (a->port) free(a->port);
196 if (a->ai) freeaddrinfo(a->ai);
214 msg = strerror(a->errnum);
218 return "unknown error";
221 return "unknown error";
232 protocol = malloc(strlen(url));
234 if (sscanf(url,
"osc://%s", protocol)) {
235 fprintf(stderr,
PACKAGE_NAME " warning: no protocol specified in URL, "
238 }
else if (sscanf(url,
"osc.%[^:/[]", protocol)) {
239 ret = strdup(protocol);
255 if(!strncmp(url,
"osc:", 4)) {
256 fprintf(stderr,
PACKAGE_NAME " warning: no protocol specified in URL, "
259 }
else if(!strncmp(url,
"osc.udp:", 8)) {
261 }
else if(!strncmp(url,
"osc.tcp:", 8)) {
263 }
else if(!strncmp(url,
"osc.unix:", 9)) {
271 char *hostname = malloc(strlen(url));
273 if (sscanf(url,
"osc://%[^[:/]", hostname)) {
276 if (sscanf(url,
"osc.%*[^:/]://[%[^]/]]", hostname)) {
279 if (sscanf(url,
"osc.%*[^:/]://%[^[:/]", hostname)) {
291 char *port = malloc(strlen(url));
293 if (sscanf(url,
"osc://%*[^:]:%[0-9]", port)) {
296 if (sscanf(url,
"osc.%*[^:]://%*[^:]:%[0-9]", port)) {
299 if (sscanf(url,
"osc://[%*[^]]]:%[0-9]", port)) {
302 if (sscanf(url,
"osc.%*[^:]://[%*[^]]]:%[0-9]", port)) {
314 char *path = malloc(strlen(url));
316 if (sscanf(url,
"osc://%*[^:]:%*[0-9]%s", path)) {
319 if (sscanf(url,
"osc.%*[^:]://%*[^:]:%*[0-9]%s", path) == 1) {
322 if (sscanf(url,
"osc.unix://%*[^/]%s", path) == 1) {
325 if (sscanf(url,
"osc.%*[^:]://%s", path)) {
337 if (t->protocol ==
LO_UDP)