reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit c44d3dce68c0741eca7db3bf641070172cbc2459
parent 5c122ae5bbb54acbc2d421cc04eeface478fb956
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sat, 30 Jan 2016 15:21:29 -0500

download: tweak the user agent to include REAPER's version

Diffstat:
Msrc/download.cpp | 12+++++++++++-
Msrc/main.cpp | 1+
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/download.cpp b/src/download.cpp @@ -94,9 +94,19 @@ DWORD WINAPI Download::Worker(void *ptr) string contents; + char userAgent[64] = {}; +#ifndef _WIN32 + snprintf(userAgent, sizeof(userAgent), +#else + // _snwprintf doesn't append a null byte if len >= count + // see https://msdn.microsoft.com/en-us/library/2ts7cx93.aspx + _snprintf(userAgent, sizeof(userAgent) - 1, +#endif + "ReaPack/%s (REAPER v%s)", "1.0", GetAppVersion()); + CURL *curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, download->url().c_str()); - curl_easy_setopt(curl, CURLOPT_USERAGENT, "ReaPack/1.0 (REAPER)"); + curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, DOWNLOAD_TIMEOUT); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, DOWNLOAD_TIMEOUT); diff --git a/src/main.cpp b/src/main.cpp @@ -39,6 +39,7 @@ static bool loadAPI(void *(*getFunc)(const char *)) REQUIRED_API(AddExtensionsMainMenu), REQUIRED_API(file_exists), + REQUIRED_API(GetAppVersion), REQUIRED_API(GetMainHwnd), REQUIRED_API(GetResourcePath), REQUIRED_API(GetUserFileNameForRead), // v3.21