diff --git a/include/mastodont_fetch.h b/include/mastodont_fetch.h index f303d83..5055b80 100644 --- a/include/mastodont_fetch.h +++ b/include/mastodont_fetch.h @@ -47,7 +47,7 @@ void mstdnt_fetch_data_cleanup(struct mstdnt_fetch_data* res); * @param args Mastodont General args passed * @param url URL of request * @param results Results from response - * @return Number of connections in progress + * @return Number of connections in progress, or -1 on error */ int mstdnt_fetch_curl_async(mastodont_t* mstdnt, CURL* curl, @@ -66,8 +66,8 @@ int mstdnt_fetch_curl_async(mastodont_t* mstdnt, * @param mstdnt Mastodont struct * @param opt Option, MSTDNT_AWAIT_ALL means it will keep going until * there are no more transfers. MSTDNT_AWAIT_ONCE will run -int mstdnt_await(mstdnt_t* mstdnt, enum mstdnt_fetch_await opt) -{ -} + * @return 1 on error + */ +int mstdnt_await(mastodont_t* mstdnt, enum mstdnt_fetch_await opt); #endif /* MASTODONT_FETCH_H */ diff --git a/include/mastodont_json_helper.h b/include/mastodont_json_helper.h index ea5d880..f9eb099 100644 --- a/include/mastodont_json_helper.h +++ b/include/mastodont_json_helper.h @@ -32,7 +32,7 @@ struct _mstdnt_val_ref }; int _mstdnt_json_init(cJSON** root, - struct mstdnt_fetch_results* results, + struct mstdnt_fetch_data* results, struct mstdnt_storage* storage); int _mstdnt_key_val_ref(cJSON* v, struct _mstdnt_val_ref* refs, diff --git a/include/mastodont_static.h b/include/mastodont_static.h index 712b978..5715e44 100644 --- a/include/mastodont_static.h +++ b/include/mastodont_static.h @@ -19,11 +19,11 @@ #include "mastodont_fetch.h" int mstdnt_instance_panel(mastodont_t* api, - struct mstdnt_args* args, - struct mstdnt_fetch_results* html); + struct mstdnt_args* args, + struct mstdnt_fetch_data* html); int mstdnt_terms_of_service(mastodont_t* api, - struct mstdnt_args* args, - struct mstdnt_fetch_results* html); + struct mstdnt_args* args, + struct mstdnt_fetch_data* html); #endif /* MSTDNT_STATIC_H */ diff --git a/src/fetch.c b/src/fetch.c index 7a418a2..20f4bbc 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -131,14 +131,14 @@ int mstdnt_await(mastodont_t* mstdnt, enum mstdnt_fetch_await opt) // Check if our socket is done while ((msg = curl_multi_info_read(mstdnt->curl, &msgs_left))) { - if (msg->msg == CURLMSG_DONE && msg->easy_handle == curl) + if (msg->msg == CURLMSG_DONE) { // Get easy info - curl_easy_getinfo(msg->curl, CURLINFO_PRIVATE, &data); - mstdnt_fetch_data_cleanup(&data); + curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &data); + mstdnt_fetch_data_cleanup(data); - curl_multi_remove_handle(mstdnt->curl, curl); - curl_easy_cleanup(curl); + curl_multi_remove_handle(mstdnt->curl, msg->easy_handle); + curl_easy_cleanup(msg->easy_handle); } } while (opt == MSTDNT_AWAIT_ALL && msgs_left); diff --git a/src/json_helper.c b/src/json_helper.c index e5352c5..45da051 100644 --- a/src/json_helper.c +++ b/src/json_helper.c @@ -24,7 +24,7 @@ #define TIMESTAMP_LEN 16 int _mstdnt_json_init(cJSON** root, - struct mstdnt_fetch_results* results, + struct mstdnt_fetch_data* results, struct mstdnt_storage* storage) { *root = cJSON_ParseWithLengthOpts(results->response, results->size, NULL, 0); diff --git a/src/list.c b/src/list.c index 0d156af..3d833e2 100644 --- a/src/list.c +++ b/src/list.c @@ -162,7 +162,7 @@ void* cb_args, mstdnt_list_json_callback }; - return mstdnt_request(data, m_args,&req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_update_list(mastodont_t* data, diff --git a/src/request.c b/src/request.c index 9260370..6f804ed 100644 --- a/src/request.c +++ b/src/request.c @@ -83,7 +83,7 @@ static mstdnt_sync_request(mastodont_t* data, int res = 0, curlerror = 0; cJSON* root; - struct mstdnt_fetch_results results = { 0 }; + struct mstdnt_fetch_data results = { 0 }; curlerror = mstdnt_fetch_curl(data, curl, m_args, diff --git a/src/static.c b/src/static.c index f2ba9fb..cffbbb4 100644 --- a/src/static.c +++ b/src/static.c @@ -20,7 +20,7 @@ int mstdnt_instance_panel(mastodont_t* api, struct mstdnt_args* m_args, mstdnt_request_cb_t cb_request, void* cb_args, - struct mstdnt_fetch_results* html) + struct mstdnt_fetch_data* html) { CURL* curl = curl_easy_init(); int status = mstdnt_fetch_curl(api, @@ -38,7 +38,7 @@ int mstdnt_terms_of_service(mastodont_t* api, struct mstdnt_args* m_args, mstdnt_request_cb_t cb_request, void* cb_args, - struct mstdnt_fetch_results* html) + struct mstdnt_fetch_data* html) { CURL* curl = curl_easy_init(); int status = mstdnt_fetch_curl(api,