Skip to content

Commit b04437d

Browse files
committed
Client version updated; user agent adjusted; warning fixed
1 parent 789b013 commit b04437d

2 files changed

Lines changed: 55 additions & 7 deletions

File tree

include/netlicensing/version.h

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,60 @@
11
#ifndef __NETLICENSING_VERSION__
22
#define __NETLICENSING_VERSION__
33

4-
#define NETLICENSING_VERSION_MAJOR 0
5-
#define NETLICENSING_VERSION_MINOR 0
6-
#define NETLICENSING_VERSION_TINY 1
4+
#define NETLICENSING_VERSION_MAJOR 2
5+
#define NETLICENSING_VERSION_MINOR 5
6+
#define NETLICENSING_VERSION_TINY 0
77

8-
#define NETLICENSING_VERSION "0.0.1"
8+
#define NETLICENSING_VERSION "2.5.0"
99

1010
// the format of this version is: MMmmtt
1111
// M = Major version, m = minor version, t = tiny version
1212
#define LIBED2K_VERSION_NUM ((NETLICENSING_VERSION_MAJOR * 10000) + (NETLICENSING_VERSION_MINOR * 100) + NETLICENSING_VERSION_TINY)
1313

14+
#define xstr(a) str(a)
15+
#define str(a) #a
16+
17+
#if defined(__linux__)
18+
#define NL_PLAT "Linux"
19+
#elif defined(__APPLE__)
20+
#define NL_PLAT "macOS"
21+
#elif defined(_WIN32)
22+
#define NL_PLAT "Windows"
23+
#else
24+
#define NL_PLAT "Unknown"
25+
#endif
26+
27+
#if defined(_MSC_VER)
28+
#define NL_CPP "MSVC"
29+
#define NL_CPP_VER xstr(_MSC_VER)
30+
#define NL_ARCH_WIN
31+
#elif defined(__llvm__)
32+
#define NL_CPP "Clang"
33+
#define NL_CPP_VER xstr(__clang_major__.__clang_minor__.__clang_patchlevel__)
34+
#elif defined(__GNUC__)
35+
#define NL_CPP "GCC"
36+
#define NL_CPP_VER xstr(__GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__)
37+
#elif defined(__BORLANDC__)
38+
#define NL_CPP "BC"
39+
#define NL_CPP_VER xstr(__BORLANDC__)
40+
#define NL_ARCH_WIN
41+
#else
42+
#define NL_CPP "Unknown"
43+
#define NL_CPP_VER
44+
#endif
45+
46+
#if defined(NL_ARCH_WIN)
47+
#if defined(_WIN64)
48+
#define NL_ARCH "64"
49+
#else
50+
#define NL_ARCH "32"
51+
#endif
52+
#else
53+
#if defined(__x86_64__)
54+
#define NL_ARCH "64"
55+
#else
56+
#define NL_ARCH "32"
57+
#endif
58+
#endif
59+
1460
#endif //__NETLICENSING_VERSION__

src/context.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class Context::NetworkService {
265265
CURL* handle_;
266266
};
267267

268-
const char* Context::NetworkService::m_user_agent = "netlicensing_cpp/" NETLICENSING_VERSION;
268+
const char* Context::NetworkService::m_user_agent = "NetLicensing/C++ " NETLICENSING_VERSION "/" NL_CPP NL_ARCH "," NL_CPP_VER "," NL_PLAT " (https://netlicensing.io)";
269269
const char* Context::NetworkService::m_content_type = "application/x-www-form-urlencoded";
270270
const char* Context::NetworkService::m_accept_type = "application/json";
271271

@@ -333,11 +333,13 @@ std::string Context::del(const std::string& endpoint, const parameters_type& par
333333
return network_service_->del(base_url_ + "/" + endpoint, params, user(), pass(), http_code);
334334
}
335335

336+
const std::string empty = "";
337+
336338
const std::string& Context::user() const {
337339
switch (mode_) {
338340
case BASIC_AUTHENTICATION: return username_;
339341
case APIKEY_IDENTIFICATION: return apiKey;
340-
case ANONYMOUS_IDENTIFICATION: return NULL;
342+
case ANONYMOUS_IDENTIFICATION: return empty;
341343
}
342344

343345
throw MalformedArgumentsException("Unknown authentication mode");
@@ -347,7 +349,7 @@ const std::string& Context::pass() const {
347349
switch (mode_) {
348350
case BASIC_AUTHENTICATION: return password_;
349351
case APIKEY_IDENTIFICATION: return api_key_;
350-
case ANONYMOUS_IDENTIFICATION: return NULL;
352+
case ANONYMOUS_IDENTIFICATION: return empty;
351353
}
352354

353355
throw MalformedArgumentsException("Unknown authentication mode");

0 commit comments

Comments
 (0)