Mercurial > hg > plosc
diff c/plosc.c @ 2:6c1ba6bf9f96
Added osc_split_address/3 to analyse address into host and port.
author | samer |
---|---|
date | Tue, 31 Jan 2012 15:53:45 +0000 |
parents | bbd2b1abfb32 |
children | 44e4b80bdf97 |
line wrap: on
line diff
--- a/c/plosc.c Tue Jan 31 10:34:46 2012 +0000 +++ b/c/plosc.c Tue Jan 31 15:53:45 2012 +0000 @@ -55,6 +55,7 @@ install_t install(); foreign_t mk_address( term_t host, term_t port, term_t addr); +foreign_t split_address( term_t addr, term_t host, term_t port); foreign_t is_address( term_t addr); foreign_t send_osc_now( term_t addr, term_t msg, term_t args); foreign_t send_osc_at( term_t addr, term_t msg, term_t args, term_t time); @@ -120,13 +121,14 @@ } install_t install() { - PL_register_foreign("osc_now", 2, (void *)now, 0); - PL_register_foreign("time_to_ts", 3, (void *)time_to_ts, 0); - PL_register_foreign("time_from_ts", 3, (void *)time_from_ts, 0); - PL_register_foreign("osc_mk_address", 3, (void *)mk_address, 0); - PL_register_foreign("osc_is_address", 1, (void *)is_address, 0); - PL_register_foreign("osc_send_now", 3, (void *)send_osc_now, 0); - PL_register_foreign("osc_send_at", 4, (void *)send_osc_at, 0); + PL_register_foreign("osc_now", 2, (void *)now, 0); + PL_register_foreign("time_to_ts", 3, (void *)time_to_ts, 0); + PL_register_foreign("time_from_ts", 3, (void *)time_from_ts, 0); + PL_register_foreign("osc_mk_address", 3, (void *)mk_address, 0); + PL_register_foreign("osc_split_address",3, (void *)split_address, 0); + PL_register_foreign("osc_is_address", 1, (void *)is_address, 0); + PL_register_foreign("osc_send_now", 3, (void *)send_osc_now, 0); + PL_register_foreign("osc_send_at", 4, (void *)send_osc_at, 0); PL_register_foreign("osc_send_from_at", 5, (void *)send_osc_from_at, 0); PL_register_foreign("osc_mk_server", 2, (void *)mk_server, 0); PL_register_foreign("osc_start_server", 1, (void *)start_server, 0); @@ -401,6 +403,17 @@ } } +foreign_t split_address(term_t addr, term_t host, term_t port) { + lo_address a; + const char *h, *p; + + return get_addr(addr,&a) + && (h=lo_address_get_hostname(a))!=NULL + && (p=lo_address_get_port(a))!=NULL + && PL_unify_atom_chars(host,h) + && PL_unify_integer(port,atoi(p)); +} + foreign_t now(term_t sec, term_t frac) { lo_timetag ts; int64_t s, f;