X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=libcurl.c;h=c6e2b472e96ecce8284780e8931d77dc410d0686;hp=baa7f958d9e50be783684d89d6f302582741ee0e;hb=dbba88193908a87435fae15ccf8c28d76f36def7;hpb=03306bdd4418fa1db27901218887856adb573fbc diff --git a/libcurl.c b/libcurl.c index baa7f958..c6e2b472 100644 --- a/libcurl.c +++ b/libcurl.c @@ -55,7 +55,7 @@ typedef enum CINIT(LOW_SPEED_LIMIT, LONG , 19), CINIT(LOW_SPEED_TIME, LONG, 20), CINIT(PROTOCOLS, LONG, 181), - CINIT(REDIR_PROTOCOLS, LONG, 182), + CINIT(REDIR_PROTOCOLS, LONG, 182) } CURLoption; #define CURLPROTO_HTTP (1<<0) @@ -108,7 +108,7 @@ typedef enum CURLINFO_PROXYAUTH_AVAIL = CURLINFO_LONG + 24, CURLINFO_OS_ERRNO = CURLINFO_LONG + 25, CURLINFO_NUM_CONNECTS = CURLINFO_LONG + 26, - CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27, + CURLINFO_SSL_ENGINES = CURLINFO_SLIST + 27 } CURLINFO; @@ -534,6 +534,37 @@ static void Curl_EndDownload(downloadinfo *di, CurlStatus status, CURLcode error Z_Free(di); } +/* +==================== +CleanURL + +Returns a "cleaned up" URL for display (to strip login data) +==================== +*/ +static const char *CleanURL(const char *url) +{ + static char urlbuf[1024]; + const char *p, *q, *r; + + // if URL is of form anything://foo-without-slash@rest, replace by anything://rest + p = strstr(url, "://"); + if(p) + { + q = strchr(p + 3, '@'); + if(q) + { + r = strchr(p + 3, '/'); + if(!r || q < r) + { + dpsnprintf(urlbuf, sizeof(urlbuf), "%.*s%s", (int)(p - url + 3), url, q + 1); + return urlbuf; + } + } + } + + return url; +} + /* ==================== CheckPendingDownloads @@ -556,7 +587,7 @@ static void CheckPendingDownloads(void) { if(!di->buffer) { - Con_Printf("Downloading %s -> %s", di->url, di->filename); + Con_Printf("Downloading %s -> %s", CleanURL(di->url), di->filename); di->stream = FS_OpenRealFile(di->filename, "ab", false); if(!di->stream) @@ -574,7 +605,7 @@ static void CheckPendingDownloads(void) } else { - Con_DPrintf("Downloading %s -> memory\n", di->url); + Con_DPrintf("Downloading %s -> memory\n", CleanURL(di->url)); di->startpos = 0; } @@ -746,7 +777,7 @@ static qboolean Curl_Begin(const char *URL, double maxspeed, const char *name, q // 141.2.16.3 - - [17/Mar/2006:22:32:43 +0100] "GET /maps/tznex07.pk3 HTTP/1.1" 200 1077455 "dp://141.2.16.7:26000/" "Nexuiz Linux 22:07:43 Mar 17 2006" if(!name) - name = URL; + name = CleanURL(URL); if(!buf) { @@ -763,7 +794,7 @@ static qboolean Curl_Begin(const char *URL, double maxspeed, const char *name, q downloadinfo *di = Curl_Find(fn); if(di) { - Con_Printf("Can't download %s, already getting it from %s!\n", fn, di->url); + Con_Printf("Can't download %s, already getting it from %s!\n", fn, CleanURL(di->url)); // however, if it was not for this map yet... if(forthismap && !di->forthismap) @@ -1073,7 +1104,7 @@ static void Curl_Info_f(void) for(di = downloads; di; di = di->next) { double speed, percent; - Con_Printf(" %s -> %s ", di->url, di->filename); + Con_Printf(" %s -> %s ", CleanURL(di->url), di->filename); percent = 100.0 * Curl_GetDownloadAmount(di); speed = Curl_GetDownloadSpeed(di); if(percent >= 0) @@ -1136,10 +1167,6 @@ void Curl_Curl_f(void) return; } - for(i = 0; i != Cmd_Argc(); ++i) - Con_DPrintf("%s ", Cmd_Argv(i)); - Con_DPrint("\n"); - if(Cmd_Argc() < 2) { Con_Print("usage:\ncurl --info, curl --cancel [filename], curl url\n"); @@ -1311,7 +1338,7 @@ Curl_downloadinfo_t *Curl_GetDownloadInfo(int *nDownloads, const char **addition for(di = downloads; di; di = di->next) { // do not show infobars for background downloads - if(!developer.integer) + if(developer.integer <= 0) if(di->buffer) continue; strlcpy(downinfo[i].filename, di->filename, sizeof(downinfo[i].filename));