From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup] Add OS version to user-agent string
Date: Mon, 23 Oct 2017 10:34:00 -0000 [thread overview]
Message-ID: <20171023103417.214992-1-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20171019123520.85040-1-jon.turney@dronecode.org.uk>
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
nio-ie5.cc | 12 ++++++++----
win32.h | 2 ++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/nio-ie5.cc b/nio-ie5.cc
index c8f65a9..a649233 100644
--- a/nio-ie5.cc
+++ b/nio-ie5.cc
@@ -29,6 +29,7 @@
#include "LogSingleton.h"
#include "setup_version.h"
#include "getopt++/StringOption.h"
+#include <sstream>
static StringOption UserAgent ("", '\0', "user-agent", "User agent string for HTTP requests");
@@ -43,19 +44,22 @@ determine_default_useragent(void)
if (!default_useragent.empty())
return default_useragent;
- std::string token = "Unknown";
+ std::stringstream os;
+ os << "Windows NT " << OSMajorVersion() << "." << OSMinorVersion() << "." << OSBuildNumber();
+
+ std::string bitness = "Unknown";
#ifdef __x86_64__
- token = "Win64";
+ bitness = "Win64";
#else
typedef BOOL (WINAPI *PFNISWOW64PROCESS)(HANDLE, PBOOL);
PFNISWOW64PROCESS pfnIsWow64Process = (PFNISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
if (pfnIsWow64Process) {
BOOL bIsWow64 = FALSE;
if (pfnIsWow64Process(GetCurrentProcess(), &bIsWow64))
- token = bIsWow64 ? "WoW64" : "Win32";
+ bitness = bIsWow64 ? "WoW64" : "Win32";
}
#endif
- default_useragent = std::string("Cygwin-Setup/") + setup_version + " (" + token + ")";
+ default_useragent = std::string("Cygwin-Setup/") + setup_version + " (" + os.str() + ";" + bitness + ")";
return default_useragent;
}
diff --git a/win32.h b/win32.h
index fd4c80c..c866790 100644
--- a/win32.h
+++ b/win32.h
@@ -166,6 +166,7 @@ class VersionInfo
VersionInfo ();
DWORD major () const { return v.dwMajorVersion; }
DWORD minor () const { return v.dwMinorVersion; }
+ DWORD buildNumber () const { return v.dwBuildNumber; }
private:
OSVERSIONINFO v;
};
@@ -174,6 +175,7 @@ VersionInfo& GetVer ();
#define OSMajorVersion() (GetVer ().major ())
#define OSMinorVersion() (GetVer ().minor ())
+#define OSBuildNumber() (GetVer ().buildNumber ())
static inline void
GetDlgItemRect (HWND h, int item, LPRECT r)
--
2.14.2
prev parent reply other threads:[~2017-10-23 10:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 12:35 [PATCH setup] Add bitness " Jon Turney
2017-10-23 10:34 ` Jon Turney [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171023103417.214992-1-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=cygwin-apps@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).