Chris@320: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@320: Chris@320: #include Chris@320: #include Chris@320: #include Chris@320: #include Chris@320: #include Chris@320: Chris@320: void Chris@320: usage(char *program_name) Chris@320: { Chris@320: char *base_name = strrchr(program_name, '/'); Chris@320: Chris@320: if (base_name && *(base_name + 1) != 0) { Chris@320: base_name += 1; Chris@320: } else { Chris@320: base_name = program_name; Chris@320: } Chris@320: Chris@320: fprintf(stderr, "\nusage: %s []\n\n", program_name); Chris@320: fprintf(stderr, "example OSC URLs:\n\n" Chris@320: " osc.udp://localhost:19383/path/test 1.0 4.2\n" Chris@320: " osc.udp://my.host.org:10886/3/13/load file\n\n"); Chris@320: fprintf(stderr, "numeric arguments will be treated as OSC 'f' floating point types.\n\n"); Chris@320: exit(1); Chris@320: } Chris@320: Chris@320: int main(int argc, char *argv[]) Chris@320: { Chris@320: lo_address a; Chris@320: char *url, *host, *port, *path; Chris@320: lo_message message; Chris@320: unsigned int i; Chris@320: Chris@320: if (argc < 2) { Chris@320: usage(argv[0]); Chris@320: /* does not return */ Chris@320: } Chris@320: url = argv[1]; Chris@320: Chris@320: host = lo_url_get_hostname(url); Chris@320: port = lo_url_get_port(url); Chris@320: path = lo_url_get_path(url); Chris@320: a = lo_address_new(host, port); Chris@320: Chris@320: message = lo_message_new(); Chris@320: Chris@320: for (i = 0; i + 2 < argc; ++i) { Chris@320: Chris@320: int index = i + 2; Chris@320: char *param; Chris@320: Chris@320: param = argv[index]; Chris@320: if (!isdigit(param[0])) { Chris@320: lo_message_add_string(message, argv[index]); Chris@320: } else { Chris@320: lo_message_add_float(message, atof(argv[index])); Chris@320: } Chris@320: } Chris@320: Chris@320: lo_send_message(a, path, message); Chris@320: Chris@320: if (lo_address_errno(a)) { Chris@320: printf("liblo error: %s\n", lo_address_errstr(a)); Chris@320: } Chris@320: Chris@320: free(host); Chris@320: free(port); Chris@320: free(path); Chris@320: Chris@320: return 0; Chris@320: } Chris@320: