Add OpenSSL include dir

This commit is contained in:
badaix 2024-06-03 22:30:43 +02:00
parent c1bbfdf167
commit f50a03ba1e
5 changed files with 50 additions and 44 deletions

View file

@ -234,42 +234,44 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: print environment - name: print environment
run: env run: env
- name: dependencies - name: dependencies
run: brew install pkgconfig libsoxr flac libvorbis opus ccache expat run: |
- name: cache boost brew update
id: cache-boost brew install pkgconfig libsoxr flac libvorbis opus ccache expat
uses: actions/cache@v4 - name: cache boost
with: id: cache-boost
path: boost_${{ env.BOOST_VERSION }} uses: actions/cache@v4
key: boost-${{ env.BOOST_VERSION }} with:
enableCrossOsArchive: true path: boost_${{ env.BOOST_VERSION }}
- name: get boost key: boost-${{ env.BOOST_VERSION }}
if: steps.cache-boost.outputs.cache-hit != 'true' enableCrossOsArchive: true
run: | - name: get boost
wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION//_/.}/source/boost_${BOOST_VERSION}.tar.bz2 if: steps.cache-boost.outputs.cache-hit != 'true'
tar xjf boost_${BOOST_VERSION}.tar.bz2 run: |
- name: cache ccache wget https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION//_/.}/source/boost_${BOOST_VERSION}.tar.bz2
id: cache-ccache tar xjf boost_${BOOST_VERSION}.tar.bz2
uses: actions/cache@v4 - name: cache ccache
with: id: cache-ccache
path: /Users/runner/Library/Caches/ccache uses: actions/cache@v4
key: ${{ runner.os }}-${{ matrix.xcode }}-ccache-${{ github.sha }} with:
restore-keys: ${{ runner.os }}-${{ matrix.xcode }}-ccache- path: /Users/runner/Library/Caches/ccache
- name: configure key: ${{ runner.os }}-${{ matrix.xcode }}-ccache-${{ github.sha }}
run: | restore-keys: ${{ runner.os }}-${{ matrix.xcode }}-ccache-
cmake -S . -B build \ - name: configure
-DWERROR=ON -DBUILD_TESTS=ON \ run: |
-DBOOST_ROOT=boost_${BOOST_VERSION} \ cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \ -DWERROR=ON -DBUILD_TESTS=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DBOOST_ROOT=boost_${BOOST_VERSION} \
-DCMAKE_CXX_FLAGS="-I/usr/local/include -DCMAKE_CXX_FLAGS=-DJSON_HAS_CPP_14" -DCMAKE_BUILD_TYPE=Release \
env: -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer -DCMAKE_CXX_FLAGS="-I/usr/local/include -DCMAKE_CXX_FLAGS=-DJSON_HAS_CPP_14"
- name: build env:
run: cmake --build build --parallel 3 --verbose DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
- name: build
run: cmake --build build --parallel 3 --verbose
windows: windows:

View file

@ -4,6 +4,8 @@ if(NOT WIN32 AND NOT ANDROID)
list(APPEND SOURCES daemon.cpp) list(APPEND SOURCES daemon.cpp)
endif() endif()
include_directories(${SOXR_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
if(SOXR_FOUND) if(SOXR_FOUND)
include_directories(${SOXR_INCLUDE_DIRS}) include_directories(${SOXR_INCLUDE_DIRS})
endif(SOXR_FOUND) endif(SOXR_FOUND)
@ -15,3 +17,5 @@ if(ANDROID)
elseif(SOXR_FOUND) elseif(SOXR_FOUND)
target_link_libraries(common ${SOXR_LIBRARIES}) target_link_libraries(common ${SOXR_LIBRARIES})
endif() endif()
target_link_libraries(common OpenSSL::Crypto OpenSSL::SSL)

View file

@ -39,7 +39,7 @@ static inline bool is_base64(unsigned char c)
return ((isalnum(c) != 0) || (c == '+') || (c == '/')); return ((isalnum(c) != 0) || (c == '+') || (c == '/'));
} }
std::string base64_encode(const unsigned char* bytes_to_encode, unsigned int in_len) std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len)
{ {
std::string ret; std::string ret;
int i = 0; int i = 0;
@ -90,7 +90,7 @@ std::string base64_encode(const std::string& text)
std::string base64_decode(const std::string& encoded_string) std::string base64_decode(const std::string& encoded_string)
{ {
int in_len = encoded_string.size(); size_t in_len = encoded_string.size();
int i = 0; int i = 0;
int in_ = 0; int in_ = 0;
unsigned char char_array_4[4], char_array_3[3]; unsigned char char_array_4[4], char_array_3[3];
@ -103,7 +103,7 @@ std::string base64_decode(const std::string& encoded_string)
if (i == 4) if (i == 4)
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
char_array_4[i] = base64_chars.find(char_array_4[i]); char_array_4[i] = static_cast<unsigned char>(base64_chars.find(char_array_4[i]));
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
@ -122,7 +122,7 @@ std::string base64_decode(const std::string& encoded_string)
char_array_4[j] = 0; char_array_4[j] = 0;
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
char_array_4[j] = base64_chars.find(char_array_4[j]); char_array_4[j] = static_cast<unsigned char>(base64_chars.find(char_array_4[j]));
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
@ -136,7 +136,7 @@ std::string base64_decode(const std::string& encoded_string)
} }
std::string base64url_encode(const unsigned char* bytes_to_encode, unsigned int in_len) std::string base64url_encode(const unsigned char* bytes_to_encode, size_t in_len)
{ {
std::string res = base64_encode(bytes_to_encode, in_len); std::string res = base64_encode(bytes_to_encode, in_len);
std::replace(res.begin(), res.end(), '+', '-'); std::replace(res.begin(), res.end(), '+', '-');

View file

@ -20,10 +20,10 @@
#include <string> #include <string>
std::string base64_encode(const unsigned char* bytes_to_encode, unsigned int in_len); std::string base64_encode(const unsigned char* bytes_to_encode, size_t in_len);
std::string base64_encode(const std::string& text); std::string base64_encode(const std::string& text);
std::string base64_decode(const std::string& encoded_string); std::string base64_decode(const std::string& encoded_string);
std::string base64url_encode(const unsigned char* bytes_to_encode, unsigned int in_len); std::string base64url_encode(const unsigned char* bytes_to_encode, size_t in_len);
std::string base64url_encode(const std::string& text); std::string base64url_encode(const std::string& text);
std::string base64url_decode(const std::string& encoded_string); std::string base64url_decode(const std::string& encoded_string);

View file

@ -2,7 +2,7 @@
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_library(Catch INTERFACE) add_library(Catch INTERFACE)
target_include_directories( target_include_directories(
Catch INTERFACE ${CATCH_INCLUDE_DIR} ${CMAKE_SOURCE_DIR} ${Boost_INCLUDE_DIR}) Catch INTERFACE ${CATCH_INCLUDE_DIR} ${CMAKE_SOURCE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
set(TEST_LIBRARIES Catch) set(TEST_LIBRARIES Catch)
if(ANDROID) if(ANDROID)