|
From: Nicholas J H. <nj...@ec...> - 2006-03-29 21:16:19
|
Hi, Thanks for the bug report. I have added your patch to CVS. I also added two new methods: lo_server_get_protocol() and =20 lo_address_get_protocol() nick. On 26 Mar 2006, at 13:43, Sz=E9kelyi Szabolcs wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > [please Cc: me, i'm not on liblo-devel] > > Hi! > > Tiny but ugly bug... > > lo_address_get_url() returns an osc.udp:// URL regardless of the > protocol for the address specified in its argument. > > A bug report was also submitted to SF.net BTS. > > I've attached a test case and the patch. The test case should print =20= > the > same URL twice, but the second time prints a UDP URL instead of TCP. > > Bye, > - -- > Sze'kelyi Szabolcs > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2.2 (GNU/Linux) > > iD8DBQFEJoxwGJRwVVqzMkMRAuZqAJ941rIl0IcAQKgaBw6VJkOUie2yeACcCCZi > 61jKMQgVLGY5iIp4NIXWD0A=3D > =3DRUre > -----END PGP SIGNATURE----- > --- liblo-0.23.orig/src/address.c 2006-03-26 13:23:02.000000000 = +0200 > +++ liblo-0.23/src/address.c 2006-03-26 14:01:31.000000000 +0200 > @@ -108,6 +108,21 @@ > return a->port; > } > > +static const char* lo_address_get_protocol_name(int proto) > +{ > + switch(proto) { > + case LO_UDP: > + return "udp"; > + case LO_TCP: > + return "tcp"; > +#ifndef WIN32 > + case LO_UNIX: > + return "unix"; > +#endif > + } > + return NULL; > +} > + > char *lo_address_get_url(lo_address a) > { > char *buf; > @@ -120,13 +135,15 @@ > } else { > fmt =3D "osc.%s://%s:%s/"; > } > - ret =3D snprintf(NULL, 0, fmt, "udp", a->host, a->port); > + ret =3D snprintf(NULL, 0, fmt, > + lo_address_get_protocol_name(a->proto), a->host, = a->port); > if (ret <=3D 0) { > /* this libc is not C99 compliant, guess a size */ > ret =3D 1023; > } > buf =3D malloc((ret + 2) * sizeof(char)); > - snprintf(buf, ret+1, fmt, "udp", a->host, a->port); > + snprintf(buf, ret+1, fmt, > + lo_address_get_protocol_name(a->proto), a->host, a->port); > > return buf; > } > #include <stdio.h> > #include <lo/lo.h> > > int main(int argc, char** argv) > { > lo_server s =3D lo_server_new_with_proto("1025", LO_TCP, NULL); > char* url1 =3D lo_server_get_url(s); > char* url2 =3D lo_address_get_url(lo_address_new_from_url(url1)); > > fprintf(stderr, "%s\n", url1); > fprintf(stderr, "%s\n", url2); > > return 0; > } > |