From 956f5dffa76908fe70dffaf9aeee11f057208895 Mon Sep 17 00:00:00 2001
From: open-license-manager <rillf@maildrop.cc>
Date: 周二, 22 7月 2014 05:20:33 +0800
Subject: [PATCH] fix compilation for gcc 4.8 & some unit test

---
 src/library/pc-identifiers.h    |    7 +++++++
 src/library/api/license++.h     |    4 +++-
 src/library/LicenseReader.cpp   |    6 +++---
 src/library/os/linux/os-linux.c |    4 ++--
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/library/LicenseReader.cpp b/src/library/LicenseReader.cpp
index 16662dd..bbddf04 100644
--- a/src/library/LicenseReader.cpp
+++ b/src/library/LicenseReader.cpp
@@ -18,6 +18,7 @@
 #include <fstream>
 #include <sstream>
 #include <stdlib.h>
+#include "pc-identifiers.h"
 #include "LicenseReader.h"
 #include "base/StringUtils.h"
 #include "base/public-key.h"
@@ -68,7 +69,7 @@
 		UserPcIdentifier str_code;
 		strncpy(str_code, client_signature.c_str(), sizeof(str_code));
 		EVENT_TYPE event = validate_user_pc_identifier(str_code);
-		if (event != OK) {
+		if (event != LICENSE_OK) {
 			er.addEvent(event, SEVERITY_ERROR);
 		}
 	}
@@ -149,8 +150,7 @@
 			string client_signature = trim_copy(
 					ini.GetValue(productNamePtr, "client_signature", ""));
 			client_signature.erase(
-					std::remove(client_signature.begin(),
-							client_signature.end(), "-"),
+					std::remove(client_signature.begin(), client_signature.end(), '-'),
 					client_signature.end());
 			int from_sw_version = ini.GetLongValue(productNamePtr,
 					"from_sw_version", FullLicenseInfo::UNUSED_SOFTWARE_VERSION);
diff --git a/src/library/api/license++.h b/src/library/api/license++.h
index b56a0e9..413c2d0 100644
--- a/src/library/api/license++.h
+++ b/src/library/api/license++.h
@@ -13,7 +13,9 @@
 
 #ifdef __unix__
 #define DllExport
-#define MAX_PATH 1024
+#ifndef MAX_PATH
+	#define MAX_PATH 1024
+#endif
 #else
 #include <windows.h>
 #define DllExport  __declspec( dllexport )
diff --git a/src/library/os/linux/os-linux.c b/src/library/os/linux/os-linux.c
index 1344199..cfb5bf4 100644
--- a/src/library/os/linux/os-linux.c
+++ b/src/library/os/linux/os-linux.c
@@ -175,8 +175,8 @@
 	hexuuid = (char *) malloc(sizeof(char) * strlen(uuid));
 	memset(buffer_out, 0, out_size);
 
-	for (i = 0, j = 0; j < len; i++) {
-		if (isxdigit(uuid[j])) {
+	for (i = 0, j = 0; i < len; i++) {
+		if (isxdigit(uuid[i])) {
 			hexuuid[j] = uuid[i];
 			j++;
 		} else {
diff --git a/src/library/pc-identifiers.h b/src/library/pc-identifiers.h
index 88d2442..1b25936 100644
--- a/src/library/pc-identifiers.h
+++ b/src/library/pc-identifiers.h
@@ -10,6 +10,10 @@
 #include "api/datatypes.h"
 #include "base/base.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef unsigned char PcIdentifier[6];
 typedef char UserPcIdentifier[21];
 
@@ -19,4 +23,7 @@
 
 EVENT_TYPE validate_user_pc_identifier(UserPcIdentifier str_code);
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* PC_IDENTIFIERS_H_ */

--
Gitblit v1.9.1