From 6e07fc0b96051daf4cc6625b75421bb17f20b008 Mon Sep 17 00:00:00 2001 From: nekobit Date: Wed, 26 Oct 2022 17:00:36 +0000 Subject: [PATCH] Fetch and cleanup FossilOrigin-Name: 218a4d992019baaf31e448e9b205565c02b5dbcd54259facf43351eed9895ff5 --- include/mastodont_account.h | 90 +++++++++++++++++++------------------ include/mastodont_fetch.h | 13 ++++++ src/account.c | 20 ++++----- src/application.c | 4 +- src/chats.c | 14 +++--- src/fetch.c | 59 ++++++++++++------------ src/list.c | 8 ++-- src/notification.c | 12 ++--- src/relationship.c | 4 +- src/scrobbles.c | 6 +-- src/search.c | 2 +- src/status.c | 32 ++++++------- src/timeline.c | 20 ++++----- 13 files changed, 149 insertions(+), 135 deletions(-) diff --git a/include/mastodont_account.h b/include/mastodont_account.h index 4a95699..938e5d7 100644 --- a/include/mastodont_account.h +++ b/include/mastodont_account.h @@ -78,6 +78,8 @@ struct mstdnt_account_args int mstdnt_account_action(mastodont_t* data, struct mstdnt_args* args, + mstdnt_request_cb_t cb_request, + void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_relationship* rel, @@ -87,9 +89,9 @@ int mstdnt_accounts_json(struct mstdnt_account* accounts[], size_t* size, cJSON* js); -#define MSTDNT_ACCOUNT_ACTION_DECL(type) int mstdnt_##type##_account(mastodont_t* data, struct mstdnt_args* args, char* id, struct mstdnt_storage* storage, struct mstdnt_relationship* relationship) -#define MSTDNT_ACCOUNT_ACTION_FUNC_URL(action) { \ - return mstdnt_account_action(data, args, id, storage, relationship, "api/v1/accounts/%s/" action); \ +#define MSTDNT_ACCOUNT_ACTION_DECL(type) int mstdnt_##type##_account(mastodont_t* data, struct mstdnt_args* args, mstdnt_request_cb_t cb_request, void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_relationship* relationship) +#define MSTDNT_ACCOUNT_ACTION_FUNC_URL(action) { \ + return mstdnt_account_action(data, args, cb_request, cb_args, id, storage, relationship, "api/v1/accounts/%s/" action); \ } MSTDNT_ACCOUNT_ACTION_DECL(follow); @@ -102,58 +104,58 @@ MSTDNT_ACCOUNT_ACTION_DECL(subscribe); MSTDNT_ACCOUNT_ACTION_DECL(unsubscribe); int mstdnt_verify_credentials(mastodont_t* data, - struct mstdnt_args* m_args, -mstdnt_request_cb_t cb_request, -void* cb_args, - struct mstdnt_account* acct, - struct mstdnt_storage* storage); + struct mstdnt_args* m_args, + mstdnt_request_cb_t cb_request, + void* cb_args, + struct mstdnt_account* acct, + struct mstdnt_storage* storage); int mstdnt_get_account(mastodont_t* data, - struct mstdnt_args* m_args, -mstdnt_request_cb_t cb_request, -void* cb_args, - int lookup_type, - char* id, - struct mstdnt_account* acct, - struct mstdnt_storage* storage); + struct mstdnt_args* m_args, + mstdnt_request_cb_t cb_request, + void* cb_args, + int lookup_type, + char* id, + struct mstdnt_account* acct, + struct mstdnt_storage* storage); int mstdnt_get_blocks(mastodont_t* data, + struct mstdnt_args* m_args, + mstdnt_request_cb_t cb_request, + void* cb_args, + struct mstdnt_account_args* args, + struct mstdnt_storage* storage, + struct mstdnt_account* accts[], + size_t* accts_len); + +int mstdnt_get_mutes(mastodont_t* data, + struct mstdnt_args* m_args, + mstdnt_request_cb_t cb_request, + void* cb_args, + struct mstdnt_account_args* args, + struct mstdnt_storage* storage, + struct mstdnt_account* accts[], + size_t* accts_len); + +int mstdnt_get_followers(mastodont_t* data, struct mstdnt_args* m_args, -mstdnt_request_cb_t cb_request, -void* cb_args, + mstdnt_request_cb_t cb_request, + void* cb_args, + char* id, struct mstdnt_account_args* args, struct mstdnt_storage* storage, struct mstdnt_account* accts[], size_t* accts_len); -int mstdnt_get_mutes(mastodont_t* data, - struct mstdnt_args* m_args, -mstdnt_request_cb_t cb_request, -void* cb_args, - struct mstdnt_account_args* args, - struct mstdnt_storage* storage, - struct mstdnt_account* accts[], - size_t* accts_len); - -int mstdnt_get_followers(mastodont_t* data, - struct mstdnt_args* m_args, -mstdnt_request_cb_t cb_request, -void* cb_args, - char* id, - struct mstdnt_account_args* args, - struct mstdnt_storage* storage, - struct mstdnt_account* accts[], - size_t* accts_len); - int mstdnt_get_following(mastodont_t* data, - struct mstdnt_args* m_args, -mstdnt_request_cb_t cb_request, -void* cb_args, - char* id, - struct mstdnt_account_args* args, - struct mstdnt_storage* storage, - struct mstdnt_account* accts[], - size_t* accts_len); + struct mstdnt_args* m_args, + mstdnt_request_cb_t cb_request, + void* cb_args, + char* id, + struct mstdnt_account_args* args, + struct mstdnt_storage* storage, + struct mstdnt_account* accts[], + size_t* accts_len); int mstdnt_account_json(struct mstdnt_account* acct, cJSON* js); int mstdnt_account_json_callback(cJSON* json, void* _args); diff --git a/include/mastodont_fetch.h b/include/mastodont_fetch.h index a7da90e..f303d83 100644 --- a/include/mastodont_fetch.h +++ b/include/mastodont_fetch.h @@ -47,6 +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 */ int mstdnt_fetch_curl_async(mastodont_t* mstdnt, CURL* curl, @@ -57,4 +58,16 @@ int mstdnt_fetch_curl_async(mastodont_t* mstdnt, CURLoption request_t, char* request_t_custom); +/** + * @brief Blocks until a transfer is complete. + * + * You can also check curl's socket + * + * @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) +{ +} + #endif /* MASTODONT_FETCH_H */ diff --git a/src/account.c b/src/account.c index fabb643..f14810f 100644 --- a/src/account.c +++ b/src/account.c @@ -57,8 +57,8 @@ int mstdnt_accounts_json_callback(cJSON* json, void* _args) static int mstdnt_get_accounts_query(char* url, mastodont_t* data, struct mstdnt_args* m_args, -mstdnt_request_cb_t cb_request, -void* cb_args, + mstdnt_request_cb_t cb_request, + void* cb_args, struct mstdnt_account_args* args, struct mstdnt_storage* storage, struct mstdnt_account* accts[], @@ -89,7 +89,7 @@ void* cb_args, mstdnt_accounts_json_callback, }; - return mstdnt_request(data, m_args, &req_args, ); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_get_followers(mastodont_t* data, @@ -104,7 +104,7 @@ void* cb_args, { char url[MSTDNT_URLSIZE]; snprintf(url, MSTDNT_URLSIZE, "api/v1/accounts/%s/followers", id); - return mstdnt_get_accounts_query(url, data, m_args, args, storage, accts, accts_len); + return mstdnt_get_accounts_query(url, data, m_args, cb_request, cb_args, args, storage, accts, accts_len); } int mstdnt_get_following(mastodont_t* data, @@ -119,7 +119,7 @@ void* cb_args, { char url[MSTDNT_URLSIZE]; snprintf(url, MSTDNT_URLSIZE, "api/v1/accounts/%s/following", id); - return mstdnt_get_accounts_query(url, data, m_args, args, storage, accts, accts_len); + return mstdnt_get_accounts_query(url, data, m_args, cb_request, cb_args, args, storage, accts, accts_len); } int mstdnt_get_blocks(mastodont_t* data, struct mstdnt_args* m_args, @@ -130,7 +130,7 @@ void* cb_args, struct mstdnt_account* accts[], size_t* accts_len) { - return mstdnt_get_accounts_query("api/v1/blocks", data, m_args, args, storage, accts, accts_len); + return mstdnt_get_accounts_query("api/v1/blocks", data, m_args, cb_request, cb_args, args, storage, accts, accts_len); } int mstdnt_get_mutes(mastodont_t* data, struct mstdnt_args* m_args, @@ -141,7 +141,7 @@ void* cb_args, struct mstdnt_account* accts[], size_t* accts_len) { - return mstdnt_get_accounts_query("api/v1/mutes", data, m_args, args, storage, accts, accts_len); + return mstdnt_get_accounts_query("api/v1/mutes", data, m_args, cb_request, cb_args, args, storage, accts, accts_len); } int mstdnt_get_account(mastodont_t* data, @@ -170,7 +170,7 @@ void* cb_args, mstdnt_account_json_callback, /* callback */ }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_verify_credentials(mastodont_t* data, @@ -191,7 +191,7 @@ void* cb_args, mstdnt_account_json_callback, /* callback */ }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_account_json(struct mstdnt_account* acct, cJSON* js) @@ -260,7 +260,7 @@ void* cb_args, mstdnt_relationship_json_callback }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } /* These are all the same */ diff --git a/src/application.c b/src/application.c index b323e2e..8c5ada4 100644 --- a/src/application.c +++ b/src/application.c @@ -113,7 +113,7 @@ void* cb_args, mstdnt_app_json_callback }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_obtain_oauth_token(mastodont_t* data, @@ -148,6 +148,6 @@ void* cb_args, mstdnt_token_json_callback }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } diff --git a/src/chats.c b/src/chats.c index 62de44b..0db1edf 100644 --- a/src/chats.c +++ b/src/chats.c @@ -114,7 +114,7 @@ void* cb_args, struct mstdnt_chat* chats[], size_t* size) { - struct _mstdnt_chats_cb_args cb_args = { chats, size }; + struct _mstdnt_chats_cb_args req_cb_args = { chats, size }; struct _mstdnt_query_param params[] = { { _MSTDNT_QUERY_BOOL, "with_muted", { .b = args->with_muted } }, { _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } }, @@ -133,11 +133,11 @@ void* cb_args, .params_post_len = 0, .request_type = CURLOPT_HTTPGET, .request_type_custom = NULL, - .args = &cb_args, + .args = &req_cb_args, .callback = mstdnt_chats_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_get_chat_messages(mastodont_t* data, @@ -152,7 +152,7 @@ void* cb_args, { char url[MSTDNT_URLSIZE]; snprintf(url, MSTDNT_URLSIZE, "api/v1/pleroma/chats/%s/messages", chat_id); - struct _mstdnt_messages_cb_args cb_args = { messages, size }; + struct _mstdnt_messages_cb_args req_cb_args = { messages, size }; struct _mstdnt_query_param params[] = { { _MSTDNT_QUERY_BOOL, "with_muted", { .b = args->with_muted } }, @@ -172,11 +172,11 @@ void* cb_args, .params_post_len = 0, .request_type = CURLOPT_HTTPGET, .request_type_custom = NULL, - .args = &cb_args, + .args = &req_cb_args, .callback = mstdnt_messages_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_get_chat(mastodont_t* data, @@ -203,7 +203,7 @@ void* cb_args, .callback = mstdnt_chat_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } void mstdnt_cleanup_chat(struct mstdnt_chat* chat) diff --git a/src/fetch.c b/src/fetch.c index 342cc72..7a418a2 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -57,7 +57,7 @@ int mstdnt_fetch_curl_async(mastodont_t* mstdnt, { #define is_custom request_t_custom && request_t == CURLOPT_CUSTOMREQUEST struct mstdnt_fetch_data* results = NULL; - CURLMcode res = 3; + CURLMcode res = 0; char token[TOKEN_STR_SIZE] = { 0 }; struct curl_slist* list = NULL; @@ -77,8 +77,13 @@ int mstdnt_fetch_curl_async(mastodont_t* mstdnt, // Setup data to pass into results results = calloc(1, sizeof(struct mstdnt_fetch_data)); - results.callback = cb_request; - results.callback_args = cb_args; + if (!results) + { + perror("calloc"); + return -1; + } + results->callback = cb_request; + results->callback_args = cb_args; // Set options curl_easy_setopt(curl, CURLOPT_URL, url); @@ -102,47 +107,41 @@ int mstdnt_fetch_curl_async(mastodont_t* mstdnt, // Add curl handle to multi, then run curl_multi_add_handle(mstdnt->curl, curl); - + + // No docs on this? + int running; res = curl_multi_perform(mstdnt->curl, &running); + if (!res) + return -1; - - - - if (list) curl_slist_free_all(list); - return res; + return running; } -int mstdnt_await(enum mstdnt_fetch_await opt) +int mstdnt_await(mastodont_t* mstdnt, enum mstdnt_fetch_await opt) { CURLMsg* msg; int msgs_left = 1; struct mstdnt_fetch_data* data; + int res; // TODO - //curl_easy_getinfo(curl, CURLINFO_PRIVATE, &data); - - do + + res = curl_multi_poll(mstdnt->curl, NULL, 0, 1000, NULL); + + // Check if our socket is done + while ((msg = curl_multi_info_read(mstdnt->curl, &msgs_left))) { - res = curl_multi_poll(mstdnt->curl, NULL, 0, 1000, NULL); - - // 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 && msg->easy_handle == curl) - { - status = msg->data.result; - goto out; - } - } + // Get easy info + curl_easy_getinfo(msg->curl, CURLINFO_PRIVATE, &data); + mstdnt_fetch_data_cleanup(&data); - if (res) break; + curl_multi_remove_handle(mstdnt->curl, curl); + curl_easy_cleanup(curl); + } } while (opt == MSTDNT_AWAIT_ALL && msgs_left); - //mstdnt_fetch_data_cleanup(&results); - // Note: the fetch removed the handle from our multi handle - out: - /* // Looks like we're done here */ - /* curl_multi_remove_handle(mstdnt->curl, curl); */ - //curl_easy_cleanup(curl); + return res; } diff --git a/src/list.c b/src/list.c index f0cf305..0d156af 100644 --- a/src/list.c +++ b/src/list.c @@ -97,7 +97,7 @@ void* cb_args, mstdnt_lists_json_callback }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_get_list(mastodont_t* data, @@ -122,7 +122,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); } static const char* replies_policy_str(enum mstdnt_list_replies_policy pol) @@ -193,7 +193,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_delete_list(mastodont_t* api, @@ -327,7 +327,7 @@ void* cb_args, mstdnt_accounts_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } void mstdnt_cleanup_lists(struct mstdnt_list* lists) diff --git a/src/notification.c b/src/notification.c index b2e104a..1aa1f21 100644 --- a/src/notification.c +++ b/src/notification.c @@ -123,7 +123,7 @@ void* cb_args, struct mstdnt_notification** notifs, size_t* size) { - struct _mstdnt_notifications_result_cb_args cb_args = { notifs, size }; + struct _mstdnt_notifications_result_cb_args req_cb_args = { notifs, size }; union param_value u_exclude_types, u_account_id, u_exclude_visibilities, u_include_types, u_with_muted, u_max_id, u_min_id, @@ -154,11 +154,11 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_notifications_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_notification_dismiss(mastodont_t* data, @@ -182,7 +182,7 @@ void* cb_args, NULL, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_notifications_clear(mastodont_t* data, @@ -202,7 +202,7 @@ void* cb_args, NULL, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_notifications_read(mastodont_t* data, @@ -229,7 +229,7 @@ void* cb_args, mstdnt_notification_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } diff --git a/src/relationship.c b/src/relationship.c index 3ac5de6..1224ef9 100644 --- a/src/relationship.c +++ b/src/relationship.c @@ -106,7 +106,7 @@ void* cb_args, struct mstdnt_relationship* relationships[], size_t* size) { - struct _mstdnt_relationships_cb_args cb_args = { relationships, size }; + struct _mstdnt_relationships_cb_args req_cb_args = { relationships, size }; struct _mstdnt_query_param params[] = { { _MSTDNT_QUERY_ARRAY, "id", { @@ -123,7 +123,7 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_relationships_json_callback }; diff --git a/src/scrobbles.c b/src/scrobbles.c index 253fd05..b99962a 100644 --- a/src/scrobbles.c +++ b/src/scrobbles.c @@ -62,7 +62,7 @@ void* cb_args, struct mstdnt_scrobble* scrobbles[], size_t* size) { - struct _mstdnt_scrobbles_cb_args cb_args = { scrobbles, size }; + struct _mstdnt_scrobbles_cb_args req_cb_args = { scrobbles, size }; char url[MSTDNT_URLSIZE]; snprintf(url, MSTDNT_URLSIZE, "api/v1/pleroma/accounts/%s/scrobbles", id); @@ -81,10 +81,10 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_scrobbles_json_callback }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } diff --git a/src/search.c b/src/search.c index 428c8b3..8893bd5 100644 --- a/src/search.c +++ b/src/search.c @@ -95,7 +95,7 @@ void* cb_args, mstdnt_search_json_callback }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } void mstdnt_cleanup_search_results(struct mstdnt_search_results* res) diff --git a/src/status.c b/src/status.c index 8be406c..5c947ee 100644 --- a/src/status.c +++ b/src/status.c @@ -156,7 +156,7 @@ void* cb_args, size_t* size) { char url[MSTDNT_URLSIZE]; - struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + struct _mstdnt_statuses_cb_args req_cb_args = { statuses, size }; snprintf(url, MSTDNT_URLSIZE, "api/v1/accounts/%s/statuses", id); struct _mstdnt_query_param params[] = { @@ -180,11 +180,11 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_statuses_json_callback }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } /* TODO Populate the arguments! */ @@ -220,7 +220,7 @@ void* cb_args, * (not sure if the api returns it or not) */ }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } static int mstdnt_status_action(mastodont_t* data, @@ -246,7 +246,7 @@ void* cb_args, mstdnt_status_json_callback }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } /* These are all the same */ @@ -291,7 +291,7 @@ MSTDNT_STATUS_ACTION_DECL(delete) mstdnt_status_json_callback }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } /* TODO Mutes can be timed */ @@ -339,7 +339,7 @@ void* cb_args, mstdnt_status_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_status_context_json(struct mstdnt_status* statuses_before[], @@ -432,7 +432,7 @@ void* cb_args, mstdnt_status_context_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_status_favourited_by(mastodont_t* data, @@ -462,7 +462,7 @@ void* cb_args, mstdnt_accounts_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_status_reblogged_by(mastodont_t* data, @@ -492,7 +492,7 @@ void* cb_args, mstdnt_accounts_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } @@ -505,7 +505,7 @@ void* cb_args, struct mstdnt_status* statuses[], size_t* size) { - struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + struct _mstdnt_statuses_cb_args req_cb_args = { statuses, size }; struct _mstdnt_query_param params[] = { { _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } }, @@ -521,11 +521,11 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_statuses_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_get_favourites(mastodont_t* data, @@ -537,7 +537,7 @@ void* cb_args, struct mstdnt_status* statuses[], size_t* size) { - struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + struct _mstdnt_statuses_cb_args req_cb_args = { statuses, size }; struct _mstdnt_query_param params[] = { { _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } }, @@ -552,11 +552,11 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_statuses_json_callback, }; - return mstdnt_request(data, m_args, &req_args); + return mstdnt_request(data, m_args, cb_request, cb_args, &req_args); } int mstdnt_status_emoji_react(mastodont_t* api, diff --git a/src/timeline.c b/src/timeline.c index db5f03a..1bcf317 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -30,7 +30,7 @@ void* cb_args, struct mstdnt_status* statuses[], size_t* size) { - struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + struct _mstdnt_statuses_cb_args req_cb_args = { statuses, size }; char url[MSTDNT_URLSIZE]; snprintf(url, MSTDNT_URLSIZE, "api/v1/timelines/list/%s", list_id); @@ -54,7 +54,7 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_statuses_json_callback, }; @@ -71,7 +71,7 @@ void* cb_args, struct mstdnt_status* statuses[], size_t* size) { - struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + struct _mstdnt_statuses_cb_args req_cb_args = { statuses, size }; char url[MSTDNT_URLSIZE]; snprintf(url, MSTDNT_URLSIZE, "api/v1/timelines/tag/%s", hashtag); @@ -98,7 +98,7 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_statuses_json_callback, }; @@ -128,7 +128,7 @@ void* cb_args, struct mstdnt_status* statuses[], size_t* size) { - struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + struct _mstdnt_statuses_cb_args req_cb_args = { statuses, size }; struct _mstdnt_query_param params[] = { { _MSTDNT_QUERY_BOOL, "local", { .b = args->local } }, { _MSTDNT_QUERY_STRING, "instance", { .s = args->instance } }, @@ -150,7 +150,7 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_statuses_json_callback, }; @@ -167,7 +167,7 @@ void* cb_args, struct mstdnt_status* statuses[], size_t* size) { - struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + struct _mstdnt_statuses_cb_args req_cb_args = { statuses, size }; struct _mstdnt_query_param params[] = { { _MSTDNT_QUERY_STRING, "max_id", { .s = args->max_id } }, @@ -185,7 +185,7 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_statuses_json_callback, }; @@ -202,7 +202,7 @@ void* cb_args, struct mstdnt_status* statuses[], size_t* size) { - struct _mstdnt_statuses_cb_args cb_args = { statuses, size }; + struct _mstdnt_statuses_cb_args req_cb_args = { statuses, size }; struct _mstdnt_query_param params[] = { { _MSTDNT_QUERY_BOOL, "local", { .b = args->local } }, @@ -225,7 +225,7 @@ void* cb_args, NULL, 0, CURLOPT_HTTPGET, NULL, - &cb_args, + &req_cb_args, mstdnt_statuses_json_callback, };