Skip to content

Commit

Permalink
Merge pull request #198 from ladislav-zezula/Issue_196
Browse files Browse the repository at this point in the history
* Removed using of Wininet (Windows only)
* HTTP functions implemented via sockets (Platform independent)
  • Loading branch information
ladislav-zezula authored Feb 17, 2021
2 parents a690a40 + 8cfa741 commit 684f956
Show file tree
Hide file tree
Showing 36 changed files with 2,120 additions and 534 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/*.cmake
/Makefile
/CMakeScripts/
/build/

# Visual Studio related files
*.opensdf
Expand Down
81 changes: 43 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.2)
project(CascLib)

set(HEADER_FILES
Expand All @@ -13,8 +13,10 @@ set(HEADER_FILES
src/common/FileTree.h
src/common/ListFile.h
src/common/Map.h
src/common/Mime.h
src/common/Path.h
src/common/RootHandler.h
src/common/Sockets.h
src/jenkins/lookup.h
)

Expand All @@ -25,7 +27,9 @@ set(SRC_FILES
src/common/FileStream.cpp
src/common/FileTree.cpp
src/common/ListFile.cpp
src/common/Mime.cpp
src/common/RootHandler.cpp
src/common/Sockets.cpp
src/jenkins/lookup3.c
src/md5/md5.cpp
src/CascDecompress.cpp
Expand Down Expand Up @@ -73,10 +77,10 @@ if(WIN32)
set(SRC_ADDITIONAL_FILES ${ZLIB_FILES})
set(LINK_LIBS wininet)
if(CASC_UNICODE)
message(STATUS "Build UNICODE version")
message(STATUS "Build UNICODE version")
add_definitions(-DUNICODE -D_UNICODE)
else()
message(STATUS "Build ANSI version")
message(STATUS "Build ANSI version")
endif()
endif()

Expand All @@ -93,57 +97,58 @@ endif()

option(CASC_BUILD_SHARED_LIB "Compile dynamically linked library" ON)
if(CASC_BUILD_SHARED_LIB)
message(STATUS "Build dynamically linked library")
add_library(casc SHARED ${SRC_FILES} ${HEADER_FILES} ${SRC_ADDITIONAL_FILES})
target_link_libraries(casc ${LINK_LIBS})
install(TARGETS casc RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} FRAMEWORK DESTINATION /Library/Frameworks)
target_include_directories(casc
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)
# On Win32, build CascLib.dll
if(WIN32)
set_target_properties(casc PROPERTIES OUTPUT_NAME CascLib)
endif()
message(STATUS "Build dynamically linked library")
add_library(casc SHARED ${SRC_FILES} ${HEADER_FILES} ${SRC_ADDITIONAL_FILES})

if(APPLE)
set_target_properties(casc PROPERTIES FRAMEWORK true)
set_target_properties(casc PROPERTIES PUBLIC_HEADER "src/CascLib.h src/CascPort.h")
set_target_properties(casc PROPERTIES LINK_FLAGS "-framework Carbon")
endif()

if(APPLE)
set_target_properties(casc PROPERTIES FRAMEWORK true)
set_target_properties(casc PROPERTIES PUBLIC_HEADER "src/CascLib.h src/CascPort.h")
set_target_properties(casc PROPERTIES LINK_FLAGS "-framework Carbon")
endif()

if(UNIX)
set_target_properties(casc PROPERTIES VERSION 1.0.0)
set_target_properties(casc PROPERTIES SOVERSION 1)
endif()
if(UNIX)
set_target_properties(casc PROPERTIES VERSION 1.0.0)
set_target_properties(casc PROPERTIES SOVERSION 1)
endif()

target_link_libraries(casc ${LINK_LIBS})
install(TARGETS casc RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} FRAMEWORK DESTINATION /Library/Frameworks)
target_include_directories(casc
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)
# On Win32, build CascLib.dll
if(WIN32)
set_target_properties(casc PROPERTIES OUTPUT_NAME CascLib)
endif()

endif()

option(CASC_BUILD_TESTS "Build Test application" OFF)
if(CASC_BUILD_TESTS)
set(CASC_BUILD_STATIC_LIB ON CACHE BOOL "Force Static library building to link test app")
message(STATUS "Build Test application")
set(CASC_BUILD_STATIC_LIB ON CACHE BOOL "Force Static library building to link test app" FORCE)
message(STATUS "Build Test application")
add_executable(casc_test ${TEST_SRC_FILES})
set_target_properties(casc_test PROPERTIES LINK_FLAGS "-pthread")
target_link_libraries(casc_test casc_static)
install(TARGETS casc_test RUNTIME DESTINATION bin)
install(TARGETS casc_test RUNTIME DESTINATION bin)
endif()

option(CASC_BUILD_STATIC_LIB "Build static linked library" OFF)
if(CASC_BUILD_STATIC_LIB)
message(STATUS "Build static linked library")
message(STATUS "Build static linked library")
add_library(casc_static STATIC ${SRC_FILES} ${HEADER_FILES} ${SRC_ADDITIONAL_FILES})
target_link_libraries(casc_static ${LINK_LIBS})
set_target_properties(casc_static PROPERTIES OUTPUT_NAME casc)
target_include_directories(casc_static
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)
install(TARGETS casc_static RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} FRAMEWORK DESTINATION /Library/Frameworks)

if(APPLE)
target_include_directories(casc_static
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)
install(TARGETS casc_static RUNTIME DESTINATION bin LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} FRAMEWORK DESTINATION /Library/Frameworks)

if(APPLE)
set_target_properties(casc_static PROPERTIES FRAMEWORK false)
set_target_properties(casc_static PROPERTIES PUBLIC_HEADER "src/CascLib.h src/CascPort.h")
set_target_properties(casc_static PROPERTIES LINK_FLAGS "-framework Carbon")
Expand Down
16 changes: 16 additions & 0 deletions CascLib_vs08.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,22 @@
RelativePath=".\src\common\RootHandler.h"
>
</File>
<File
RelativePath=".\src\common\Mime.cpp"
>
</File>
<File
RelativePath=".\src\common\Mime.h"
>
</File>
<File
RelativePath=".\src\common\Sockets.cpp"
>
</File>
<File
RelativePath=".\src\common\Sockets.h"
>
</File>
</Filter>
<Filter
Name="jenkins"
Expand Down
16 changes: 16 additions & 0 deletions CascLib_vs08_dll.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,22 @@
RelativePath=".\src\common\RootHandler.h"
>
</File>
<File
RelativePath=".\src\common\Mime.cpp"
>
</File>
<File
RelativePath=".\src\common\Mime.h"
>
</File>
<File
RelativePath=".\src\common\Sockets.cpp"
>
</File>
<File
RelativePath=".\src\common\Sockets.h"
>
</File>
</Filter>
<Filter
Name="jenkins"
Expand Down
28 changes: 28 additions & 0 deletions CascLib_vs08_test.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4127; 4131; 4244"
/>
<Tool
Name="VCManagedResourceCompilerTool"
Expand Down Expand Up @@ -168,6 +169,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4127; 4131; 4244"
/>
<Tool
Name="VCManagedResourceCompilerTool"
Expand Down Expand Up @@ -268,6 +270,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4127; 4131; 4244"
/>
<Tool
Name="VCManagedResourceCompilerTool"
Expand Down Expand Up @@ -369,6 +372,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4127; 4131; 4244"
/>
<Tool
Name="VCManagedResourceCompilerTool"
Expand Down Expand Up @@ -619,6 +623,14 @@
<File
RelativePath=".\src\zlib\deflate.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
DisableSpecificWarnings="4131"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\zlib\inffast.c"
Expand Down Expand Up @@ -836,6 +848,22 @@
RelativePath=".\src\common\RootHandler.h"
>
</File>
<File
RelativePath=".\src\common\Mime.cpp"
>
</File>
<File
RelativePath=".\src\common\Mime.h"
>
</File>
<File
RelativePath=".\src\common\Sockets.cpp"
>
</File>
<File
RelativePath=".\src\common\Sockets.h"
>
</File>
</Filter>
</Filter>
<Filter
Expand Down
4 changes: 4 additions & 0 deletions CascLib_vs19.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@
<ClInclude Include="src\common\ListFile.h" />
<ClInclude Include="src\common\Map.h" />
<ClInclude Include="src\common\RootHandler.h" />
<ClInclude Include="src\common\Mime.h" />
<ClInclude Include="src\common\Sockets.h" />
<ClInclude Include="src\FileStream.h" />
<ClInclude Include="src\md5\md5.h" />
</ItemGroup>
Expand Down Expand Up @@ -606,6 +608,8 @@
<ClCompile Include="src\common\FileTree.cpp" />
<ClCompile Include="src\common\ListFile.cpp" />
<ClCompile Include="src\common\RootHandler.cpp" />
<ClCompile Include="src\common\Mime.cpp" />
<ClCompile Include="src\common\Sockets.cpp" />
<ClCompile Include="src\jenkins\lookup3.c" />
<ClCompile Include="src\md5\md5.cpp" />
<ClCompile Include="src\zlib\adler32.c" />
Expand Down
12 changes: 12 additions & 0 deletions CascLib_vs19.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
<ClInclude Include="src\md5\md5.h">
<Filter>Source Files\md5</Filter>
</ClInclude>
<ClInclude Include="src\common\Mime.h">
<Filter>Source Files\common</Filter>
</ClInclude>
<ClInclude Include="src\common\Sockets.h">
<Filter>Source Files\common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\CascFiles.cpp">
Expand Down Expand Up @@ -172,5 +178,11 @@
<ClCompile Include="src\zlib\trees.c">
<Filter>Source Files\zlib</Filter>
</ClCompile>
<ClCompile Include="src\common\Mime.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
<ClCompile Include="src\common\Sockets.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions CascLib_vs19_dll.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@
<ClCompile Include="src\common\FileTree.cpp" />
<ClCompile Include="src\common\ListFile.cpp" />
<ClCompile Include="src\common\RootHandler.cpp" />
<ClCompile Include="src\common\Mime.cpp" />
<ClCompile Include="src\common\Sockets.cpp" />
<ClCompile Include="src\DllMain.c" />
<ClCompile Include="src\jenkins\lookup3.c" />
<ClCompile Include="src\md5\md5.cpp" />
Expand All @@ -239,6 +241,8 @@
<ClInclude Include="src\common\ListFile.h" />
<ClInclude Include="src\common\Map.h" />
<ClInclude Include="src\common\RootHandler.h" />
<ClInclude Include="src\common\Mime.h" />
<ClInclude Include="src\common\Sockets.h" />
<ClInclude Include="src\FileStream.h" />
<ClInclude Include="src\md5\md5.h" />
<ClInclude Include="src\zlib\deflate.h" />
Expand Down
12 changes: 12 additions & 0 deletions CascLib_vs19_dll.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
<ClCompile Include="src\zlib\trees.c">
<Filter>Source Files\zlib</Filter>
</ClCompile>
<ClCompile Include="src\common\Mime.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
<ClCompile Include="src\common\Sockets.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\common\Common.h">
Expand Down Expand Up @@ -167,6 +173,12 @@
<ClInclude Include="src\zlib\deflate.h">
<Filter>Source Files\zlib</Filter>
</ClInclude>
<ClInclude Include="src\common\Mime.h">
<Filter>Source Files\common</Filter>
</ClInclude>
<ClInclude Include="src\common\Sockets.h">
<Filter>Source Files\common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="src\DllMain.rc">
Expand Down
4 changes: 4 additions & 0 deletions CascLib_vs19_test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@
<ClCompile Include="src\common\FileTree.cpp" />
<ClCompile Include="src\common\ListFile.cpp" />
<ClCompile Include="src\common\RootHandler.cpp" />
<ClCompile Include="src\common\Mime.cpp" />
<ClCompile Include="src\common\Sockets.cpp" />
<ClCompile Include="src\jenkins\lookup3.c">
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level1</WarningLevel>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Level1</WarningLevel>
Expand Down Expand Up @@ -368,6 +370,8 @@
<ClInclude Include="src\common\ListFile.h" />
<ClInclude Include="src\common\Map.h" />
<ClInclude Include="src\common\RootHandler.h" />
<ClInclude Include="src\common\Mime.h" />
<ClInclude Include="src\common\Sockets.h" />
<ClInclude Include="src\md5\md5.h" />
</ItemGroup>
<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions CascLib_vs19_test.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
<ClCompile Include="src\zlib\trees.c">
<Filter>Source Files\zlib</Filter>
</ClCompile>
<ClCompile Include="src\common\Mime.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
<ClCompile Include="src\common\Sockets.cpp">
<Filter>Source Files\common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\common\Common.h">
Expand Down Expand Up @@ -171,6 +177,12 @@
<ClInclude Include="src\CascStructs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\common\Mime.h">
<Filter>Source Files\common</Filter>
</ClInclude>
<ClInclude Include="src\common\Sockets.h">
<Filter>Source Files\common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="doc\History.txt">
Expand Down
6 changes: 0 additions & 6 deletions doc/history.txt

This file was deleted.

Loading

0 comments on commit 684f956

Please sign in to comment.