On Sat, Feb 19, 2011 at 02:53:27PM +0100, Clément Bœsch wrote:
@@ -164,14 +164,21 @@ check4proxies( URL_t *url ) { #endif
mp_msg(MSGT_NETWORK,MSGL_V,"Using HTTP proxy: %s\n", proxy_url->url ); - len = make_http_proxy_url(proxy_url, url->url, NULL, 0) + 1; - new_url = malloc(len); + + if (proxy_url->username) + mp_asprintf(&new_url, "http_proxy://%s:%s@%s:%d/%s", + proxy_url->username, + proxy_url->password ? proxy_url->password : "", + proxy_url->hostname, proxy_url->port, url->url); + else + mp_asprintf(&new_url, "http_proxy://%s:%d/%s", + proxy_url->hostname, proxy_url->port, url->url); + if( new_url==NULL ) { mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed); url_free(proxy_url); return url_out; } - make_http_proxy_url(proxy_url, url->url, new_url, len); tmp_url = url_new( new_url );
Please keep the separate functions, it makes the code easier to read.
- snprintf(meta, sizeof(meta), "%.4s", (char *) &sh_video->format); + mp_asprintf(&meta, "%.4s", (char *) &sh_video->format); else - snprintf(meta, sizeof(meta), "0x%08X", sh_video->format); - return strdup(meta); + mp_asprintf(&meta, "0x%08X", sh_video->format); + return meta;
That would be a good bit nicer if the function just returned the pointer... Is there are reasonable chance we will ever want/need the int return value?