mac os版本
parent
75e4e2b0dc
commit
0d02ac5336
|
@ -2,6 +2,34 @@ cmake_minimum_required(VERSION 3.11)
|
|||
enable_language(CXX)
|
||||
project(General)
|
||||
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# O/S Detection
|
||||
|
||||
# these are defined in common.h too
|
||||
SET(LINUX False)
|
||||
SET(FREEBSD False)
|
||||
SET(MACOS False)
|
||||
|
||||
# Detect the operating system
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
SET(TARGET_OS_NAME "macos")
|
||||
SET(TARGET_OS 3)
|
||||
SET(MACOS True)
|
||||
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
SET(TARGET_OS_NAME "freebsd")
|
||||
SET(TARGET_OS 2)
|
||||
SET(FREEBSD True)
|
||||
ELSE()
|
||||
SET(TARGET_OS_NAME "linux")
|
||||
SET(TARGET_OS 1)
|
||||
SET(LINUX True)
|
||||
ENDIF()
|
||||
|
||||
# show the operating system on the console
|
||||
message(STATUS "operating system: ${TARGET_OS_NAME} (TARGET_OS=${TARGET_OS})")
|
||||
|
||||
message( "current compiler " ${CMAKE_CXX_COMPILER_ID})
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
# using Clang
|
||||
|
@ -18,11 +46,39 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
|||
# using Intel C++
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
# using Visual Studio C++
|
||||
aux_source_directory(src DIRSRCS)
|
||||
aux_source_directory(src/pattern PaternSrc)
|
||||
aux_source_directory(src/function FunctionSrc)
|
||||
aux_source_directory(src/algorithm AlgorithmSrc)
|
||||
aux_source_directory(src/encrypt EncryptSrc)
|
||||
|
||||
add_compile_options( /DEBUG /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS)
|
||||
|
||||
add_library(General OBJECT ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc} )
|
||||
|
||||
set_property(TARGET General PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
|
||||
|
||||
|
||||
elseif("AppleClang" STREQUAL ${CMAKE_CXX_COMPILER_ID})
|
||||
message("apple clang compiler")
|
||||
|
||||
aux_source_directory(src DIRSRCS)
|
||||
aux_source_directory(src/pattern PaternSrc)
|
||||
# aux_source_directory(src/function FunctionSrc)
|
||||
aux_source_directory(src/algorithm AlgorithmSrc)
|
||||
aux_source_directory(src/encrypt EncryptSrc)
|
||||
add_library(General OBJECT ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc} )
|
||||
|
||||
set_property(TARGET General PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
|
||||
endif()
|
||||
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj)
|
||||
message( "LIBRARY_OUTPUT_PATH " ${LIBRARY_OUTPUT_PATH})
|
||||
|
||||
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
INCLUDE_DIRECTORIES (./)
|
||||
INCLUDE_DIRECTORIES (inc)
|
||||
|
@ -30,16 +86,7 @@ INCLUDE_DIRECTORIES (encrypt)
|
|||
INCLUDE_DIRECTORIES (pattern)
|
||||
|
||||
include_directories(third/include)
|
||||
aux_source_directory(src DIRSRCS)
|
||||
aux_source_directory(src/pattern PaternSrc)
|
||||
aux_source_directory(src/function FunctionSrc)
|
||||
aux_source_directory(src/algorithm AlgorithmSrc)
|
||||
aux_source_directory(src/encrypt EncryptSrc)
|
||||
|
||||
message("source file is " ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc})
|
||||
|
||||
|
||||
add_library(General OBJECT ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc} )
|
||||
|
||||
set_property(TARGET General PROPERTY
|
||||
MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by admin on 2019/4/11.
|
||||
// Created by admin on 2019/4/11. 这
|
||||
//
|
||||
#include "debug.h"
|
||||
|
||||
|
@ -186,3 +186,5 @@ int dumpObj(void *dst,int rowNum,int num,bool ifAsii,char *out) {
|
|||
cout << out << "\r\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ public:
|
|||
{
|
||||
ECB = 0, CBC = 1, CFB = 2
|
||||
};
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Created by 29019 on 2020/1/5.
|
||||
//
|
||||
|
||||
#include "rsa.h"
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
@ -69,10 +68,6 @@ const static int PrimeTable[550]=
|
|||
};
|
||||
|
||||
|
||||
// 判断两个数是否为互素
|
||||
static int Mod(BigInt p1,BigInt p2){
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
目前的做法是基于费马素性检测
|
||||
假如a是整数,p是质数,且a,p互质(即两者只有一个公约数1),那么a的(p-1)次方除以p的余数恒等于1。
|
||||
|
|
|
@ -8,12 +8,8 @@
|
|||
#include <memory.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include "src/math/BigInt.hpp"
|
||||
|
||||
using namespace std;
|
||||
class rsa {
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //GENERAL_RSA_H
|
||||
|
|
|
@ -8,7 +8,7 @@ typedef struct
|
|||
|
||||
vector<RuningProcess> RangeProcess();
|
||||
|
||||
vector<string> StripList(const char *in, const char *d)
|
||||
vector<string> StripList(const char *in, const char *d)∫∫
|
||||
{
|
||||
vector<string> ret;
|
||||
map<uint16_t,bool> pos;
|
||||
|
@ -558,3 +558,4 @@ int DaemonizeMonitor::StopProcess(string path)
|
|||
#ifdef linux
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#define BIG_INT_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <tuple>
|
||||
|
||||
|
||||
|
||||
class BigInt {
|
||||
std::string value;
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
#if __cplusplus >= 201103L
|
||||
#pragma message("编译器支持c++11 ")
|
||||
#endif // __cplusplus >= 201103L
|
||||
#include "utils.h"
|
||||
#ifdef linux
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
int itoa(int n ,char * const s,int radix){
|
||||
if(nullptr == s){
|
||||
return -1;
|
||||
}
|
||||
if (radix == 10){
|
||||
sprintf(s,"%d",n);
|
||||
}
|
||||
if(radix == 8){
|
||||
sprintf(s,"%o",n);
|
||||
}
|
||||
if(radix == 16){
|
||||
sprintf(s,"%x",n);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
string itos(int x)
|
||||
{
|
||||
char buf[100] = {0};
|
||||
itoa(x, buf, 10);
|
||||
return string(buf);
|
||||
}
|
||||
|
||||
inline ENV_SYS CurrentEnvSys() {
|
||||
#ifdef linux
|
||||
return ENV_LINUX;
|
||||
#endif
|
||||
#ifdef _WINDOWS
|
||||
return ENV_WINDOWS;
|
||||
#endif
|
||||
#ifdef _UNIX
|
||||
return ENV_UNIX
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
return ENV_WINDOWS;
|
||||
#endif
|
||||
#if !defined(linux) && defined(_WINDOWS) && defined(_UNIX) && defined(_WIN32)
|
||||
return ENV_NONE;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline ENV_COMPILER CurrentEnvCompiler()
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
return GCC;
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
return CL;
|
||||
#endif
|
||||
#ifdef __clang__
|
||||
return CLANG;
|
||||
#endif
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
// 限制float有效位
|
||||
float LimitFloat(float in,int size) {
|
||||
uint64_t tmp = 1;
|
||||
for(int i = 0;i < size;i++){
|
||||
tmp = tmp*10;
|
||||
}
|
||||
uint64_t integer = uint64_t(in * tmp); // 提取整数部分
|
||||
|
||||
uint64_t decimal = integer %tmp; // 提取小数部分
|
||||
std::cout<< "float_limit " << in<< " "<< integer << " "<< decimal << " "<< tmp <<std::endl;
|
||||
|
||||
return float(integer)/tmp;
|
||||
}
|
||||
|
||||
|
||||
std::string FormatString(const char *format,...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[1024];
|
||||
va_start(args,format);
|
||||
vsprintf(buf,format,args);
|
||||
va_end(args);
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
|
||||
BYTE_ORDER_TYPE HostByteOrder(){
|
||||
short x = 0x1234;
|
||||
uint8_t y = *((uint8_t*)(&x));
|
||||
if(y == 0x34){
|
||||
return BYTE_ORDER_TYPE::LITTLE_ENDIAN_TYPE;
|
||||
}else{
|
||||
return BYTE_ORDER_TYPE::BIG_ENDIAN_TYPE;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue