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