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

View file

@ -4,6 +4,8 @@ if(NOT WIN32 AND NOT ANDROID)
list(APPEND SOURCES daemon.cpp)
endif()
include_directories(${SOXR_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR})
if(SOXR_FOUND)
include_directories(${SOXR_INCLUDE_DIRS})
endif(SOXR_FOUND)
@ -15,3 +17,5 @@ if(ANDROID)
elseif(SOXR_FOUND)
target_link_libraries(common ${SOXR_LIBRARIES})
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 == '/'));
}
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;
int i = 0;
@ -90,7 +90,7 @@ std::string base64_encode(const std::string& text)
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 in_ = 0;
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)
{
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[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;
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[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::replace(res.begin(), res.end(), '+', '-');

View file

@ -20,10 +20,10 @@
#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_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_decode(const std::string& encoded_string);

View file

@ -2,7 +2,7 @@
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_library(Catch INTERFACE)
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)
if(ANDROID)