From 22be3676809310ce76eb83a61f4f0728a5ec3902 Mon Sep 17 00:00:00 2001 From: hamjin Date: Sun, 8 Sep 2024 23:17:53 +0800 Subject: [PATCH 1/4] main: check status in curl_get Signed-off-by: hamjin --- main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.c b/main.c index 63457fc..220872b 100644 --- a/main.c +++ b/main.c @@ -100,6 +100,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); -- 2.49.0 From 3b13327664712f01f7b8ec81c1633067492d99e3 Mon Sep 17 00:00:00 2001 From: hamjin Date: Sun, 8 Sep 2024 23:18:35 +0800 Subject: [PATCH 2/4] downgrade cmake requirement for clion Signed-off-by: hamjin --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5ed147..6ea9fc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.30) +cmake_minimum_required(VERSION 3.23) project(Live\ Parise C) set(CMAKE_C_STANDARD 11) -- 2.49.0 From 187cd014f76dbf34c83d6d425b7712c1483667d1 Mon Sep 17 00:00:00 2001 From: hamjin Date: Sun, 8 Sep 2024 23:21:41 +0800 Subject: [PATCH 3/4] fix build for windows for clion and msys-mingw (clang and gcc) Signed-off-by: hamjin --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ea9fc9..d0567f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ 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) \ No newline at end of file +target_link_libraries(main cjson-static libcurl_static pthread) \ No newline at end of file -- 2.49.0 From 710174d6dec3dcfe6e67d41931e11d8e1d6e8eb6 Mon Sep 17 00:00:00 2001 From: hamjin Date: Sun, 8 Sep 2024 23:22:39 +0800 Subject: [PATCH 4/4] fix console output Signed-off-by: hamjin --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 220872b..e131494 100644 --- a/main.c +++ b/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; -- 2.49.0