Merge pull request 'Fix for windows' (#1) from jinham/LiveParise:main into main
Reviewed-on: #1
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.30)
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
project(Live\ Parise C)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
@@ -29,10 +30,14 @@ endif ()
|
||||
|
||||
# For CURL
|
||||
set(BUILD_STATIC_LIBS ON)
|
||||
if(WIN32)
|
||||
set(CURL_USE_SCHANNEL ON)
|
||||
endif ()
|
||||
|
||||
# For cJSON
|
||||
set(BUILD_SHARED_AND_STATIC_LIBS ON)
|
||||
set(ENABLE_CUSTOM_COMPILER_FLAGS OFF)
|
||||
set(ENABLE_CJSON_TEST OFF)
|
||||
|
||||
FetchContent_Declare(
|
||||
cJSON
|
||||
@@ -50,4 +55,4 @@ FetchContent_MakeAvailable(cJSON curl)
|
||||
|
||||
add_executable(main main.c)
|
||||
target_include_directories(main PUBLIC ${cJSON_SOURCE_DIR})
|
||||
target_link_libraries(main cjson-static libcurl_static)
|
||||
target_link_libraries(main cjson-static libcurl_static pthread)
|
||||
10
main.c
10
main.c
@@ -18,7 +18,7 @@
|
||||
}
|
||||
|
||||
#ifdef Debug
|
||||
#define DPRINT(s, ...) \
|
||||
#define DPRINT(s, __VA_ARGS__) \
|
||||
{ \
|
||||
printf(s, ...); \
|
||||
}
|
||||
@@ -46,6 +46,9 @@ const char SS[] = "381237373432790016";
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int thread;
|
||||
#ifdef WIN32
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
#endif
|
||||
|
||||
if (argc < 2)
|
||||
thread = 4;
|
||||
@@ -100,6 +103,11 @@ CURLcode curl_get(const char *const url, struct memory *chunk)
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)chunk);
|
||||
|
||||
status = curl_easy_perform(curl);
|
||||
if (status != CURLE_OK)
|
||||
{
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(status));
|
||||
exit(status);
|
||||
}
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
curl_slist_free_all(headers);
|
||||
|
||||
Reference in New Issue
Block a user