Merge branch 'master' into PIStringListTests_11-20
This commit is contained in:
@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.0)
|
|||||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||||
project(pip)
|
project(pip)
|
||||||
set(pip_MAJOR 2)
|
set(pip_MAJOR 2)
|
||||||
set(pip_MINOR 15)
|
set(pip_MINOR 16)
|
||||||
set(pip_REVISION 1)
|
set(pip_REVISION 0)
|
||||||
set(pip_SUFFIX )
|
set(pip_SUFFIX )
|
||||||
set(pip_COMPANY SHS)
|
set(pip_COMPANY SHS)
|
||||||
set(pip_DOMAIN org.SHS)
|
set(pip_DOMAIN org.SHS)
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
#define PICRYPT_DISABLED_WARNING piCout << "[PICrypt]" << "Warning: PICrypt is disabled, to enable install sodium library and rebuild pip";
|
#define PICRYPT_DISABLED_WARNING piCout << "[PICrypt]" << "Warning: PICrypt is disabled, to enable install sodium library and rebuild pip";
|
||||||
|
|
||||||
const char hash_def_key[] = "_picrypt_";
|
const char hash_def_key[] = "_picrypt_\0\0\0\0\0\0\0";
|
||||||
|
const int hash_def_key_size = 9;
|
||||||
|
|
||||||
|
|
||||||
PICrypt::PICrypt() {
|
PICrypt::PICrypt() {
|
||||||
@@ -52,7 +53,7 @@ PIByteArray PICrypt::setKey(const PIString & secret) {
|
|||||||
#ifdef PIP_CRYPT
|
#ifdef PIP_CRYPT
|
||||||
hash.resize(crypto_generichash_BYTES);
|
hash.resize(crypto_generichash_BYTES);
|
||||||
PIByteArray s(secret.data(), secret.size());
|
PIByteArray s(secret.data(), secret.size());
|
||||||
crypto_generichash(hash.data(), hash.size(), s.data(), s.size(), (const uchar*)hash_def_key, sizeof(hash_def_key) - 1);
|
crypto_generichash(hash.data(), hash.size(), s.data(), s.size(), (const uchar*)hash_def_key, hash_def_key_size);
|
||||||
hash.resize(key_.size());
|
hash.resize(key_.size());
|
||||||
setKey(hash);
|
setKey(hash);
|
||||||
#endif
|
#endif
|
||||||
@@ -147,7 +148,7 @@ PIByteArray PICrypt::hash(const PIString & secret) {
|
|||||||
if (!init()) return hash;
|
if (!init()) return hash;
|
||||||
hash.resize(crypto_generichash_BYTES);
|
hash.resize(crypto_generichash_BYTES);
|
||||||
PIByteArray s(secret.data(), secret.size());
|
PIByteArray s(secret.data(), secret.size());
|
||||||
crypto_generichash(hash.data(), hash.size(), s.data(), s.size(), (const uchar*)hash_def_key, sizeof(hash_def_key) - 1);
|
crypto_generichash(hash.data(), hash.size(), s.data(), s.size(),(const uchar*)hash_def_key, hash_def_key_size);
|
||||||
#else
|
#else
|
||||||
PICRYPT_DISABLED_WARNING
|
PICRYPT_DISABLED_WARNING
|
||||||
#endif
|
#endif
|
||||||
@@ -160,7 +161,7 @@ PIByteArray PICrypt::hash(const PIByteArray & data) {
|
|||||||
#ifdef PIP_CRYPT
|
#ifdef PIP_CRYPT
|
||||||
if (!init()) return hash;
|
if (!init()) return hash;
|
||||||
hash.resize(crypto_generichash_BYTES);
|
hash.resize(crypto_generichash_BYTES);
|
||||||
crypto_generichash(hash.data(), hash.size(), data.data(), data.size(), (const uchar*)hash_def_key, sizeof(hash_def_key) - 1);
|
crypto_generichash(hash.data(), hash.size(), data.data(), data.size(), (const uchar*)hash_def_key, hash_def_key_size);
|
||||||
#else
|
#else
|
||||||
PICRYPT_DISABLED_WARNING
|
PICRYPT_DISABLED_WARNING
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ PIPluginInfoStorage * PIPluginInfoStorage::instance() {
|
|||||||
|
|
||||||
PIPluginLoader::PIPluginLoader(const PIString & name) {
|
PIPluginLoader::PIPluginLoader(const PIString & name) {
|
||||||
func_loader_version = nullptr;
|
func_loader_version = nullptr;
|
||||||
|
func_set_user_version = nullptr;
|
||||||
func_static_merge = nullptr;
|
func_static_merge = nullptr;
|
||||||
error = Unknown;
|
error = Unknown;
|
||||||
loaded = false;
|
loaded = false;
|
||||||
@@ -268,14 +269,17 @@ bool PIPluginLoader::load(const PIString & name) {
|
|||||||
if (messages) piCout << error_str;
|
if (messages) piCout << error_str;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (__PIP_PLUGIN_LOADER_VERSION__ != func_loader_version()) {
|
int loader_version = func_loader_version();
|
||||||
|
if (__PIP_PLUGIN_LOADER_VERSION__ != loader_version) {
|
||||||
unload();
|
unload();
|
||||||
error = InvalidLoaderVersion;
|
error = InvalidLoaderVersion;
|
||||||
error_str = "Load plugin \"" + lib.path() + "\" error: invalid loader version: application = " + PIString::fromNumber(func_loader_version())
|
error_str = "Load plugin \"" + lib.path() + "\" error: invalid loader version: application = " + PIString::fromNumber(__PIP_PLUGIN_LOADER_VERSION__)
|
||||||
+ ", plugin = " + PIString::fromNumber(__PIP_PLUGIN_LOADER_VERSION__);
|
+ ", plugin = " + PIString::fromNumber(loader_version);
|
||||||
if (messages) piCout << error_str;
|
if (messages) piCout << error_str;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
func_set_user_version = (FunctionSetUserVersion)lib.resolve(STR(__PIP_PLUGIN_SET_USER_VERSION_FUNC__));
|
||||||
|
if (func_set_user_version) func_set_user_version();
|
||||||
if (ai->userVersion().size_s() > 1) {
|
if (ai->userVersion().size_s() > 1) {
|
||||||
PIString pversion = pi->userVersion(), lversion = ai->userVersion();
|
PIString pversion = pi->userVersion(), lversion = ai->userVersion();
|
||||||
if (pversion != lversion) {
|
if (pversion != lversion) {
|
||||||
|
|||||||
@@ -67,15 +67,18 @@
|
|||||||
# define PIP_PLUGIN_EXPORT
|
# define PIP_PLUGIN_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __PIP_PLUGIN_LOADER_VERSION_FUNC__ pip_loader_version
|
#define __PIP_PLUGIN_LOADER_VERSION_FUNC__ pip_loader_version
|
||||||
#define __PIP_PLUGIN_STATIC_MERGE_FUNC__ pip_merge_static
|
#define __PIP_PLUGIN_SET_USER_VERSION_FUNC__ pip_set_user_version
|
||||||
#define __PIP_PLUGIN_LOADER_VERSION__ 2
|
#define __PIP_PLUGIN_STATIC_MERGE_FUNC__ pip_merge_static
|
||||||
|
#define __PIP_PLUGIN_LOADER_VERSION__ 3
|
||||||
|
|
||||||
#define PIP_PLUGIN_SET_USER_VERSION(v) \
|
#define PIP_PLUGIN_SET_USER_VERSION(v) \
|
||||||
STATIC_INITIALIZER_BEGIN \
|
extern "C" { \
|
||||||
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
|
PIP_PLUGIN_EXPORT void __PIP_PLUGIN_SET_USER_VERSION_FUNC__() { \
|
||||||
if (pi) pi->setUserVersion(v); \
|
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
|
||||||
STATIC_INITIALIZER_END
|
if (pi) pi->setUserVersion(v); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
#define PIP_PLUGIN_ADD_STATIC_SECTION(type, ptr) \
|
#define PIP_PLUGIN_ADD_STATIC_SECTION(type, ptr) \
|
||||||
STATIC_INITIALIZER_BEGIN \
|
STATIC_INITIALIZER_BEGIN \
|
||||||
@@ -142,6 +145,7 @@ private:
|
|||||||
class PIP_EXPORT PIPluginLoader {
|
class PIP_EXPORT PIPluginLoader {
|
||||||
public:
|
public:
|
||||||
typedef int(*FunctionLoaderVersion)();
|
typedef int(*FunctionLoaderVersion)();
|
||||||
|
typedef void(*FunctionSetUserVersion)();
|
||||||
typedef void(*FunctionStaticMerge)(int, void *, void *);
|
typedef void(*FunctionStaticMerge)(int, void *, void *);
|
||||||
|
|
||||||
//! Possible load plugin error
|
//! Possible load plugin error
|
||||||
@@ -202,6 +206,7 @@ private:
|
|||||||
|
|
||||||
PILibrary lib;
|
PILibrary lib;
|
||||||
FunctionLoaderVersion func_loader_version;
|
FunctionLoaderVersion func_loader_version;
|
||||||
|
FunctionSetUserVersion func_set_user_version;
|
||||||
FunctionStaticMerge func_static_merge;
|
FunctionStaticMerge func_static_merge;
|
||||||
PIString error_str;
|
PIString error_str;
|
||||||
Error error;
|
Error error;
|
||||||
|
|||||||
@@ -335,62 +335,122 @@ TEST(PIString_Tests, operator_less_cstring_false_equal){
|
|||||||
ASSERT_FALSE(str1 < str2);
|
ASSERT_FALSE(str1 < str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_more_pistring_true){
|
TEST(PIString_Tests, operator_grater_pistring_true){
|
||||||
PIString str1 = "testin";
|
PIString str1 = "testin";
|
||||||
PIString str2 = "testing";
|
PIString str2 = "testing";
|
||||||
ASSERT_TRUE(str2 > str1);
|
ASSERT_TRUE(str2 > str1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_more_pistring_false){
|
TEST(PIString_Tests, operator_grater_pistring_false){
|
||||||
PIString str1 = "testing";
|
PIString str1 = "testing";
|
||||||
PIString str2 = "testin";
|
PIString str2 = "testin";
|
||||||
ASSERT_FALSE(str2 > str1);
|
ASSERT_FALSE(str2 > str1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_more_pistring_false_equal){
|
TEST(PIString_Tests, operator_grater_pistring_false_equal){
|
||||||
PIString str1 = "testing";
|
PIString str1 = "testing";
|
||||||
PIString str2 = "testing";
|
PIString str2 = "testing";
|
||||||
ASSERT_FALSE(str1 > str2);
|
ASSERT_FALSE(str1 > str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_more_pichar_true){
|
TEST(PIString_Tests, operator_grater_pichar_true){
|
||||||
PIString str1 = "t";
|
PIString str1 = "t";
|
||||||
PIChar str2 = "a";
|
PIChar str2 = "a";
|
||||||
ASSERT_TRUE(str1 > str2);
|
ASSERT_TRUE(str1 > str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_more_pichar_false){
|
TEST(PIString_Tests, operator_grater_pichar_false){
|
||||||
PIString str1 = "a";
|
PIString str1 = "a";
|
||||||
PIChar str2 = "t";
|
PIChar str2 = "t";
|
||||||
ASSERT_FALSE(str1 > str2);
|
ASSERT_FALSE(str1 > str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_more_pichar_false_equal){
|
TEST(PIString_Tests, operator_grater_pichar_false_equal){
|
||||||
PIString str1 = "t";
|
PIString str1 = "t";
|
||||||
PIChar str2 = "t";
|
PIChar str2 = "t";
|
||||||
ASSERT_FALSE(str1 > str2);
|
ASSERT_FALSE(str1 > str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_more_cstring_true){
|
TEST(PIString_Tests, operator_grater_cstring_true){
|
||||||
PIString str1 = "t";
|
PIString str1 = "t";
|
||||||
char str2[] = "a";
|
char str2[] = "a";
|
||||||
ASSERT_TRUE(str1 > str2);
|
ASSERT_TRUE(str1 > str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_more_cstring_false){
|
TEST(PIString_Tests, operator_grater_cstring_false){
|
||||||
PIString str1 = "a";
|
PIString str1 = "a";
|
||||||
char str2[] = "t";
|
char str2[] = "t";
|
||||||
ASSERT_FALSE(str1 > str2);
|
ASSERT_FALSE(str1 > str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_more_cstring_false_equal){
|
TEST(PIString_Tests, operator_grater_cstring_false_equal){
|
||||||
PIString str1 = "t";
|
PIString str1 = "t";
|
||||||
char str2[] = "t";
|
char str2[] = "t";
|
||||||
ASSERT_FALSE(str1 > str2);
|
ASSERT_FALSE(str1 > str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PIString_Tests, operator_less_eq_pistring_true){
|
TEST(PIString_Tests, operator_less_eq_pistring_true_less){
|
||||||
PIString str1 = "testin";
|
PIString str1 = "testin";
|
||||||
PIString str2 = "testing";
|
PIString str2 = "testing";
|
||||||
ASSERT_TRUE(str1 <= str2);
|
ASSERT_TRUE(str1 <= str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_less_eq_pistring_false){
|
||||||
|
PIString str1 = "testing";
|
||||||
|
PIString str2 = "testin";
|
||||||
|
ASSERT_FALSE(str1 <= str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_less_eq_pistring_true_equal){
|
||||||
|
PIString str1 = "testing";
|
||||||
|
PIString str2 = "testing";
|
||||||
|
ASSERT_TRUE(str1 <= str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_less_eq_pichar_true){
|
||||||
|
PIString str1 = "a";
|
||||||
|
PIChar str2 = "t";
|
||||||
|
ASSERT_TRUE(str1 <= str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_less_eq_pichar_false){
|
||||||
|
PIString str1 = "t";
|
||||||
|
PIChar str2 = "a";
|
||||||
|
ASSERT_FALSE(str1 <= str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_less_eq_pichar_true_equal){
|
||||||
|
PIString str1 = "t";
|
||||||
|
PIChar str2 = "t";
|
||||||
|
ASSERT_TRUE(str1 <= str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_less_eq_cstring_true){
|
||||||
|
PIString str1 = "a";
|
||||||
|
char str2[] = "t";
|
||||||
|
ASSERT_TRUE(str1 <= str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_less_eq_cstring_false){
|
||||||
|
PIString str1 = "t";
|
||||||
|
char str2[] = "a";
|
||||||
|
ASSERT_FALSE(str1 <= str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_less_eq_cstring_true_equal){
|
||||||
|
PIString str1 = "t";
|
||||||
|
char str2[] = "t";
|
||||||
|
ASSERT_TRUE(str1 <= str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_grater_eq_pistring_true){
|
||||||
|
PIString str1 = "testin";
|
||||||
|
PIString str2 = "testing";
|
||||||
|
ASSERT_TRUE(str2 >= str1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(PIString_Tests, operator_grater_eq_pistring_false){
|
||||||
|
PIString str1 = "testing";
|
||||||
|
PIString str2 = "testin";
|
||||||
|
ASSERT_FALSE(str2 >= str1);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user