change curl_get failed behavior

This commit is contained in:
2024-09-09 09:32:26 +08:00
parent 922fcea866
commit be6fc14981

12
main.c
View File

@@ -104,10 +104,7 @@ CURLcode curl_get(const char *const url, struct memory *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);
@@ -146,7 +143,9 @@ char *get_enc()
const cJSON *enc = NULL;
REGEN_ENC_URL_F(url, current_timestamp());
curl_get(url, &data);
if (curl_get(url, &data) != CURLE_OK)
return NULL;
DPRINT("%s\n", data.response);
@@ -171,13 +170,16 @@ void parise(void *arg)
{
char url[200];
struct memory json_c = {0};
const char *enc = get_enc();
const char *enc = NULL;
const cJSON *result = NULL;
const cJSON *msg = NULL;
const cJSON *data = NULL;
const cJSON *errorMsg = NULL;
cJSON *json = NULL;
if ((enc = get_enc()) == NULL)
continue;
REGEN_URL_F(url, enc, current_timestamp());
curl_get(url, &json_c);