FossilOrigin-Name: 8a539b51cabb162548a6220c5aef0f26c96ded8520eb23142bf12e9980e17478
This commit is contained in:
nekobit 2022-06-23 06:42:43 +00:00
parent e9c376174d
commit a37f407ab0
29 changed files with 120 additions and 209 deletions

View file

@ -76,7 +76,7 @@ struct mstdnt_account_args
int with_relationships; // mastodont_get_mutes
};
int mstdnt_account_action(mastodont_t* data,
int mstdnt_account_action(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_relationship* rel,
@ -86,7 +86,7 @@ int mstdnt_accounts_json(struct mstdnt_account* accounts[],
size_t* size,
cJSON* js);
#define MSTDNT_ACCOUNT_ACTION_DECL(type) int mastodont_##type##_account(mastodont_t* data, char* id, struct mstdnt_storage* storage, struct mstdnt_relationship* relationship)
#define MSTDNT_ACCOUNT_ACTION_DECL(type) int mastodont_##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, id, storage, relationship, "api/v1/accounts/%s/" action); \
}
@ -100,35 +100,35 @@ MSTDNT_ACCOUNT_ACTION_DECL(unblock);
MSTDNT_ACCOUNT_ACTION_DECL(subscribe);
MSTDNT_ACCOUNT_ACTION_DECL(unsubscribe);
int mastodont_verify_credentials(mastodont_t* data,
int mastodont_verify_credentials(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_account* acct,
struct mstdnt_storage* storage);
int mastodont_get_account(mastodont_t* data,
int mastodont_get_account(mastodont_t* data, struct mstdnt_args* args,
int lookup_type,
char* id,
struct mstdnt_account* acct,
struct mstdnt_storage* storage);
int mastodont_get_blocks(mastodont_t* data,
int mastodont_get_blocks(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
size_t* accts_len);
int mastodont_get_mutes(mastodont_t* data,
int mastodont_get_mutes(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
size_t* accts_len);
int mastodont_get_followers(mastodont_t* data,
int mastodont_get_followers(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
size_t* accts_len);
int mastodont_get_following(mastodont_t* data,
int mastodont_get_following(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,

View file

@ -48,12 +48,12 @@ struct mstdnt_oauth_token
time_t time;
};
int mastodont_register_app(mastodont_t* data,
int mastodont_register_app(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_args* args,
struct mstdnt_storage* storage,
struct mstdnt_app* app);
int mastodont_obtain_oauth_token(mastodont_t* data,
int mastodont_obtain_oauth_token(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_args* args,
struct mstdnt_storage* storage,
struct mstdnt_oauth_token* app);

View file

@ -1,73 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MASTODONT_ARGUMENTS_H
#define MASTODONT_ARGUMENTS_H
#include "mastodont_notif_types.h"
/*
* TODO undo this shit, it's actually just gross i'll duplicate the code i do not care
*/
struct mstdnt_args
{
char* client_name;
char* redirect_uris;
char* scopes;
char* website;
char* grant_type;
char* client_id;
char* client_secret;
char* redirect_uri;
char* scope;
char* code;
char* username;
char* password;
int pinned;
char* tagged;
int with_muted;
int exclude_reblogs;
int exclude_replies;
int offset;
int only_media;
char* max_id;
char* since_id;
char* min_id;
int limit;
char* content_type;
int expires_in;
char* in_reply_to_conversation_id;
char* in_reply_to_id;
char* language;
char** media_ids;
void* poll; /* TODO */
int preview;
char* scheduled_at;
int sensitive;
char* spoiler_text;
char* status;
char* visibility;
int media_ids_len;
int remote;
int local;
char** exclude_types;
size_t exclude_types_len;
char* account_id;
char** exclude_visibilities;
size_t exclude_visibilities_len;
enum mstdnt_notification_type* include_types;
};
#endif /* MASTODONT_ARGUMENTS_H */

View file

@ -51,7 +51,7 @@ int mstdnt_attachment_json(cJSON* att_json, struct mstdnt_attachment* att);
void _mstdnt_val_attachments_call(cJSON* v, void* _type);
int mastodont_upload_media(mastodont_t* api,
int mastodont_upload_media(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_upload_media_args* args,
struct mstdnt_storage* storage,
struct mstdnt_attachment* attachment);

View file

@ -23,7 +23,7 @@ struct mstdnt_instance
};
// TODO
int mastodont_instance(mastodont_t* api,
int mastodont_instance(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_instance* inst);
#endif /* MASTODONT_INSTANCE_H */

View file

@ -49,45 +49,45 @@ int mstdnt_lists_json(struct mstdnt_list* lists[],
size_t* size,
cJSON* json);
int mastodont_get_lists(mastodont_t* api,
int mastodont_get_lists(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_storage* storage,
struct mstdnt_list* lists[],
size_t* size);
int mastodont_get_list(mastodont_t* api,
int mastodont_get_list(mastodont_t* api, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_list* lists);
int mastodont_create_list(mastodont_t* api,
int mastodont_create_list(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_list_args* args,
struct mstdnt_storage* storage,
struct mstdnt_list* list);
int mastodont_update_list(mastodont_t* api,
int mastodont_update_list(mastodont_t* api, struct mstdnt_args* args,
char* id,
struct mstdnt_list_args* args,
struct mstdnt_storage* storage,
struct mstdnt_list* list);
int mastodont_delete_list(mastodont_t* api,
int mastodont_delete_list(mastodont_t* api, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage);
int mastodont_list_get_accounts(mastodont_t* data,
int mastodont_list_get_accounts(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
size_t* accts_len);
int mastodont_list_add_accounts(mastodont_t* api,
int mastodont_list_add_accounts(mastodont_t* api, struct mstdnt_args* args,
char* id,
char** account_ids,
size_t account_ids_len,
struct mstdnt_storage* storage);
int mastodont_list_remove_accounts(mastodont_t* api,
int mastodont_list_remove_accounts(mastodont_t* api, struct mstdnt_args* args,
char* id,
char** account_ids,
size_t account_ids_len,

View file

@ -41,7 +41,7 @@ int mstdnt_nodeinfo_json(struct mstdnt_nodeinfo* nodeinfo, cJSON* js);
int mstdnt_nodeinfo_json_callback(cJSON* json, void* nodeinfo);
int mastodont_get_nodeinfo(mastodont_t* api,
int mastodont_get_nodeinfo(mastodont_t* api, struct mstdnt_args* args,
char* version,
struct mstdnt_storage* storage,
struct mstdnt_nodeinfo* nodeinfo);

View file

@ -57,7 +57,7 @@ struct _mstdnt_notifications_result_cb_args
int mstdnt_notifications_json_callback(cJSON* json, void* _args);
int mastodont_get_notifications(mastodont_t* data,
int mastodont_get_notifications(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_get_notifications_args* args,
struct mstdnt_storage* storage,
struct mstdnt_notification** notifs,

View file

@ -44,7 +44,7 @@ struct _mstdnt_query_param
} value;
};
char* _mstdnt_query_string(mastodont_t* data,
char* _mstdnt_query_string(mastodont_t* data,
struct mstdnt_args* args,
char* src,
struct _mstdnt_query_param* params,

View file

@ -52,7 +52,7 @@ int mstdnt_relationships_json(struct mstdnt_relationship* relationships[],
int mstdnt_relationships_json_callback(cJSON* json, void* _args);
int mastodont_get_relationships(mastodont_t* data,
int mastodont_get_relationships(mastodont_t* data, struct mstdnt_args* args,
char** ids,
size_t ids_len,
struct mstdnt_storage* storage,

View file

@ -46,7 +46,7 @@ struct _mstdnt_scrobbles_cb_args
size_t* size;
};
int mastodont_get_scrobbles(mastodont_t* data,
int mastodont_get_scrobbles(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_get_scrobbles_args* args,
struct mstdnt_storage* storage,

View file

@ -54,7 +54,7 @@ int mstdnt_search_json_callback(cJSON* json, void* _args);
int mstdnt_search_json(struct mstdnt_search_results* search_results, cJSON* json);
int mastodont_search(mastodont_t* data,
int mastodont_search(mastodont_t* data, struct mstdnt_args* args,
char* query,
struct mstdnt_storage* storage,
struct mstdnt_search_args* args,

View file

@ -18,10 +18,10 @@
#include "mastodont_types.h"
#include "mastodont_fetch.h"
int mastodont_instance_panel(mastodont_t* api,
int mastodont_instance_panel(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_fetch_results* html);
int mastodont_terms_of_service(mastodont_t* api,
int mastodont_terms_of_service(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_fetch_results* html);
#endif /* MSTDNT_STATIC_H */

View file

@ -96,7 +96,7 @@ void mstdnt_cleanup_statuses(struct mstdnt_status* statuses, size_t s);
void mstdnt_cleanup_status(struct mstdnt_status* status);
int mstdnt_status_json(struct mstdnt_status* status, cJSON* js);
int mastodont_status_emoji_react(mastodont_t* api, char* id, char* emoji,
int mastodont_status_emoji_react(mastodont_t* api, struct mstdnt_args* args, char* id, char* emoji,
struct mstdnt_storage* storage, struct mstdnt_status* status);
// Generated function
@ -113,19 +113,19 @@ int mstdnt_status_context_json(struct mstdnt_status* statuses_before[],
size_t* size_after,
cJSON* js);
int mastodont_get_account_statuses(mastodont_t* data,
int mastodont_get_account_statuses(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_account_statuses_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);
int mastodont_get_status(mastodont_t* data,
int mastodont_get_status(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status);
int mastodont_get_status_context(mastodont_t* data,
int mastodont_get_status_context(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses_before[],
@ -133,24 +133,24 @@ int mastodont_get_status_context(mastodont_t* data,
size_t* size_before,
size_t* size_after);
int mastodont_status_favourited_by(mastodont_t* data,
int mastodont_status_favourited_by(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
size_t* accts);
int mastodont_status_reblogged_by(mastodont_t* data,
int mastodont_status_reblogged_by(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
size_t* accts);
int mastodont_create_status(mastodont_t* data,
int mastodont_create_status(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_args* args,
struct mstdnt_storage* storage);
/* Generates do and undo functions */
#define MSTDNT_STATUS_ACTION_DECL(type) int mastodont_##type##_status(mastodont_t* data, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status)
#define MSTDNT_STATUS_ACTION_DECL(type) int mastodont_##type##_status(mastodont_t* data, struct mstdnt_args* args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status)
#define MSTDNT_STATUS_ACTION_FUNC_URL(action) { \
return mstdnt_status_action(data, id, storage, status, "api/v1/statuses/%s/" action); \
}
@ -165,12 +165,12 @@ MSTDNT_STATUS_ACTION_DECL(bookmark);
MSTDNT_STATUS_ACTION_DECL(unbookmark);
MSTDNT_STATUS_ACTION_DECL(delete);
int mastodont_mute_conversation(mastodont_t* data,
int mastodont_mute_conversation(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status);
int mastodont_unmute_conversation(mastodont_t* data,
int mastodont_unmute_conversation(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status);
@ -205,13 +205,13 @@ struct mstdnt_favourites_args
int limit;
};
int mastodont_get_bookmarks(mastodont_t* data,
int mastodont_get_bookmarks(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_bookmarks_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);
int mastodont_get_favourites(mastodont_t* data,
int mastodont_get_favourites(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_favourites_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],

View file

@ -40,32 +40,32 @@ struct mstdnt_timeline_args
int with_muted;
};
int mastodont_timeline_home(mastodont_t* data,
int mastodont_timeline_home(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);
int mastodont_timeline_list(mastodont_t* data,
int mastodont_timeline_list(mastodont_t* data, struct mstdnt_args* args,
char* list_id,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* size);
int mastodont_timeline_public(mastodont_t* data,
int mastodont_timeline_public(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* statuses_size);
int mastodont_timeline_direct(mastodont_t* data,
int mastodont_timeline_direct(mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
size_t* statuses_size);
int mastodont_timeline_tag(mastodont_t* data,
int mastodont_timeline_tag(mastodont_t* data, struct mstdnt_args* args,
char* hashtag,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,

View file

@ -54,7 +54,7 @@ int mstdnt_accounts_json_callback(cJSON* json, void* _args)
}
static int mastodont_get_accounts_query(char* url,
mastodont_t* data,
mastodont_t* data, struct mstdnt_args* args,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
@ -85,10 +85,10 @@ static int mastodont_get_accounts_query(char* url,
mstdnt_accounts_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_get_followers(mastodont_t* data,
int mastodont_get_followers(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
@ -100,7 +100,7 @@ int mastodont_get_followers(mastodont_t* data,
return mastodont_get_accounts_query(url, data, args, storage, accts, accts_len);
}
int mastodont_get_following(mastodont_t* data,
int mastodont_get_following(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
@ -112,7 +112,7 @@ int mastodont_get_following(mastodont_t* data,
return mastodont_get_accounts_query(url, data, args, storage, accts, accts_len);
}
int mastodont_get_blocks(mastodont_t* data,
int mastodont_get_blocks(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
@ -121,7 +121,7 @@ int mastodont_get_blocks(mastodont_t* data,
return mastodont_get_accounts_query("api/v1/blocks", data, args, storage, accts, accts_len);
}
int mastodont_get_mutes(mastodont_t* data,
int mastodont_get_mutes(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
struct mstdnt_account* accts[],
@ -130,7 +130,7 @@ int mastodont_get_mutes(mastodont_t* data,
return mastodont_get_accounts_query("api/v1/mutes", data, args, storage, accts, accts_len);
}
int mastodont_get_account(mastodont_t* data,
int mastodont_get_account(mastodont_t* data, struct mstdnt_args* m_args,
int lookup, /* TODO move into separate function for consistancy */
char* id,
struct mstdnt_account* acct,
@ -153,10 +153,10 @@ int mastodont_get_account(mastodont_t* data,
mstdnt_account_json_callback, /* callback */
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_verify_credentials(mastodont_t* data,
int mastodont_verify_credentials(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_account* acct,
struct mstdnt_storage* storage)
{
@ -171,7 +171,7 @@ int mastodont_verify_credentials(mastodont_t* data,
mstdnt_account_json_callback, /* callback */
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mstdnt_account_json(struct mstdnt_account* acct, cJSON* js)
@ -217,7 +217,7 @@ int mstdnt_account_json(struct mstdnt_account* acct, cJSON* js)
}
int mstdnt_account_action(mastodont_t* data,
int mstdnt_account_action(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_relationship* rel,
@ -237,7 +237,7 @@ int mstdnt_account_action(mastodont_t* data,
mstdnt_relationship_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
/* These are all the same */

View file

@ -69,7 +69,7 @@ static int mstdnt_token_json_callback(cJSON* json, void* args)
return mstdnt_token_json(json, args);
}
int mastodont_register_app(mastodont_t* data,
int mastodont_register_app(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_args* args,
struct mstdnt_storage* storage,
struct mstdnt_app* app)
@ -92,11 +92,11 @@ int mastodont_register_app(mastodont_t* data,
mstdnt_app_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_obtain_oauth_token(mastodont_t* data,
int mastodont_obtain_oauth_token(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_args* args,
struct mstdnt_storage* storage,
struct mstdnt_oauth_token* token)
@ -125,6 +125,6 @@ int mastodont_obtain_oauth_token(mastodont_t* data,
mstdnt_token_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}

View file

@ -98,7 +98,7 @@ static int mstdnt_attachment_json_callback(cJSON* json, void* _args)
return mstdnt_attachment_json(json, _args);
}
int mastodont_upload_media(mastodont_t* api,
int mastodont_upload_media(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_upload_media_args* args,
struct mstdnt_storage* storage,
struct mstdnt_attachment* attachment)

View file

@ -15,7 +15,7 @@
#include <mastodont_instance.h>
int mastodont_instance(mastodont_t* api,
int mastodont_instance(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_instance* inst)
{
return -1;

View file

@ -72,7 +72,7 @@ static int mstdnt_lists_json_callback(cJSON* json, void* _args)
return mstdnt_lists_json(args->lists, args->size, json);
}
int mastodont_get_lists(mastodont_t* data,
int mastodont_get_lists(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_storage* storage,
struct mstdnt_list* lists[],
size_t* size)
@ -93,10 +93,10 @@ int mastodont_get_lists(mastodont_t* data,
mstdnt_lists_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_get_list(mastodont_t* data,
int mastodont_get_list(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_list* list)
@ -115,7 +115,7 @@ int mastodont_get_list(mastodont_t* data,
mstdnt_list_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
static const char* replies_policy_str(enum mstdnt_list_replies_policy pol)
@ -132,7 +132,7 @@ static const char* replies_policy_str(enum mstdnt_list_replies_policy pol)
}
}
int mastodont_create_list(mastodont_t* data,
int mastodont_create_list(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_list_args* args,
struct mstdnt_storage* storage,
struct mstdnt_list* list)
@ -153,10 +153,10 @@ int mastodont_create_list(mastodont_t* data,
mstdnt_list_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_update_list(mastodont_t* data,
int mastodont_update_list(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_list_args* args,
struct mstdnt_storage* storage,
@ -181,10 +181,10 @@ int mastodont_update_list(mastodont_t* data,
mstdnt_list_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_delete_list(mastodont_t* api,
int mastodont_delete_list(mastodont_t* api, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage)
{
@ -205,7 +205,7 @@ int mastodont_delete_list(mastodont_t* api,
return mastodont_request(api, &req_args);
}
int mastodont_list_add_accounts(mastodont_t* api,
int mastodont_list_add_accounts(mastodont_t* api, struct mstdnt_args* args,
char* id,
char** account_ids,
size_t account_ids_len,
@ -237,7 +237,7 @@ int mastodont_list_add_accounts(mastodont_t* api,
return mastodont_request(api, &req_args);
}
int mastodont_list_remove_accounts(mastodont_t* api,
int mastodont_list_remove_accounts(mastodont_t* api, struct mstdnt_args* args,
char* id,
char** account_ids,
size_t account_ids_len,
@ -269,7 +269,7 @@ int mastodont_list_remove_accounts(mastodont_t* api,
return mastodont_request(api, &req_args);
}
int mastodont_list_get_accounts(mastodont_t* data,
int mastodont_list_get_accounts(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_args* args,
struct mstdnt_storage* storage,
@ -303,7 +303,7 @@ int mastodont_list_get_accounts(mastodont_t* data,
mstdnt_accounts_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
void mstdnt_cleanup_lists(struct mstdnt_list* lists)

View file

@ -13,31 +13,15 @@ void mastodont_global_curl_cleanup()
curl_global_cleanup();
}
int mastodont_init(mastodont_t* data, uint16_t flags)
int mastodont_init(mastodont_t* data, struct mstdnt_args* m_args, uint16_t flags)
{
data->curl = curl_easy_init();
data->token = NULL;
data->token_heap = 0;
data->flags = flags;
return data->curl == NULL;
}
int mastodont_set_token(mastodont_t* data, char* token)
{
char* mtoken = malloc(strlen(token)+1);
if (!mtoken)
return 1;
data->token_heap = 1;
strcpy(mtoken, token);
data->token = mtoken;
return 0;
}
void mastodont_cleanup(mastodont_t* data)
{
curl_easy_cleanup(data->curl);
if (data->token_heap)
free(data->token);
}
void mastodont_free(void* ptr)

View file

@ -94,7 +94,7 @@ int mstdnt_nodeinfo_json_callback(cJSON* json, void* nodeinfo)
return mstdnt_nodeinfo_json(nodeinfo, json);
}
int mastodont_get_nodeinfo(mastodont_t* api,
int mastodont_get_nodeinfo(mastodont_t* api, struct mstdnt_args* args,
char* version,
struct mstdnt_storage* storage,
struct mstdnt_nodeinfo* nodeinfo)

View file

@ -75,7 +75,7 @@ int mstdnt_notifications_json_callback(cJSON* json, void* _args)
return mstdnt_notifications_json(args->notif, args->size, json);
}
int mastodont_get_notifications(mastodont_t* data,
int mastodont_get_notifications(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_get_notifications_args* args,
struct mstdnt_storage* storage,
struct mstdnt_notification** notifs,
@ -116,7 +116,7 @@ int mastodont_get_notifications(mastodont_t* data,
mstdnt_notifications_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
void mstdnt_cleanup_notifications(struct mstdnt_notification* notifs, size_t notifs_len)

View file

@ -96,7 +96,7 @@ int mstdnt_relationships_json_callback(cJSON* json, void* _args)
return mstdnt_relationships_json(args->relationships, args->size, json);
}
int mastodont_get_relationships(mastodont_t* data,
int mastodont_get_relationships(mastodont_t* data, struct mstdnt_args* m_args,
char** ids,
size_t ids_len,
struct mstdnt_storage* storage,
@ -124,7 +124,7 @@ int mastodont_get_relationships(mastodont_t* data,
mstdnt_relationships_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
void mstdnt_cleanup_relationships(struct mstdnt_relationship* rels)

View file

@ -52,7 +52,7 @@ int mstdnt_scrobbles_json_callback(cJSON* json, void* _args)
return mstdnt_scrobbles_json(args->scrobbles, args->size, json);
}
int mastodont_get_scrobbles(mastodont_t* data,
int mastodont_get_scrobbles(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_get_scrobbles_args* args,
struct mstdnt_storage* storage,
@ -82,6 +82,6 @@ int mastodont_get_scrobbles(mastodont_t* data,
mstdnt_scrobbles_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}

View file

@ -61,7 +61,7 @@ int mstdnt_search_json_callback(cJSON* json, void* _args)
return mstdnt_search_json(_args, json);
}
int mastodont_search(mastodont_t* data,
int mastodont_search(mastodont_t* data, struct mstdnt_args* m_args,
char* query,
struct mstdnt_storage* storage,
struct mstdnt_search_args* args,
@ -92,7 +92,7 @@ int mastodont_search(mastodont_t* data,
mstdnt_search_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
void mstdnt_cleanup_search_results(struct mstdnt_search_results* res)

View file

@ -16,13 +16,13 @@
#include <mastodont_static.h>
#include <mastodont_fetch.h>
int mastodont_instance_panel(mastodont_t* api,
int mastodont_instance_panel(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_fetch_results* html)
{
return mastodont_fetch_curl(api, "instance/panel.html", html, CURLOPT_HTTPGET, NULL);
}
int mastodont_terms_of_service(mastodont_t* api,
int mastodont_terms_of_service(mastodont_t* api, struct mstdnt_args* args,
struct mstdnt_fetch_results* html)
{
return mastodont_fetch_curl(api, "static/terms-of-service.html", html, CURLOPT_HTTPGET, NULL);

View file

@ -143,7 +143,7 @@ int mstdnt_statuses_json_callback(cJSON* json, void* _args)
return mstdnt_statuses_json(args->statuses, args->size, json);
}
int mastodont_get_account_statuses(mastodont_t* data,
int mastodont_get_account_statuses(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_account_statuses_args* args,
struct mstdnt_storage* storage,
@ -179,11 +179,11 @@ int mastodont_get_account_statuses(mastodont_t* data,
mstdnt_statuses_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
/* TODO Populate the arguments! */
int mastodont_create_status(mastodont_t* data,
int mastodont_create_status(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_args* args,
struct mstdnt_storage* storage)
{
@ -212,10 +212,10 @@ int mastodont_create_status(mastodont_t* data,
* (not sure if the api returns it or not) */
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
static int mstdnt_status_action(mastodont_t* data,
static int mstdnt_status_action(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status,
@ -235,7 +235,7 @@ static int mstdnt_status_action(mastodont_t* data,
mstdnt_status_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
/* These are all the same */
@ -280,11 +280,11 @@ MSTDNT_STATUS_ACTION_DECL(delete)
mstdnt_status_json_callback
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
/* TODO Mutes can be timed */
int mastodont_mute_conversation(mastodont_t* data,
int mastodont_mute_conversation(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
@ -292,7 +292,7 @@ int mastodont_mute_conversation(mastodont_t* data,
return mstdnt_status_action(data, id, storage, status, "api/v1/statuses/%s/mute");
}
int mastodont_unmute_conversation(mastodont_t* data,
int mastodont_unmute_conversation(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
@ -300,7 +300,7 @@ int mastodont_unmute_conversation(mastodont_t* data,
return mstdnt_status_action(data, id, storage, status, "api/v1/statuses/%s/unmute");
}
int mastodont_get_status(mastodont_t* data,
int mastodont_get_status(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
@ -319,7 +319,7 @@ int mastodont_get_status(mastodont_t* data,
mstdnt_status_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mstdnt_status_context_json(struct mstdnt_status* statuses_before[],
@ -381,7 +381,7 @@ int mstdnt_status_context_json_callback(cJSON* json, void* _args)
json);
}
int mastodont_get_status_context(mastodont_t* data,
int mastodont_get_status_context(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses_before[],
@ -409,10 +409,10 @@ int mastodont_get_status_context(mastodont_t* data,
mstdnt_status_context_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_status_favourited_by(mastodont_t* data,
int mastodont_status_favourited_by(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
@ -436,10 +436,10 @@ int mastodont_status_favourited_by(mastodont_t* data,
mstdnt_accounts_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_status_reblogged_by(mastodont_t* data,
int mastodont_status_reblogged_by(mastodont_t* data, struct mstdnt_args* m_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
@ -463,11 +463,11 @@ int mastodont_status_reblogged_by(mastodont_t* data,
mstdnt_accounts_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_get_bookmarks(mastodont_t* data,
int mastodont_get_bookmarks(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_bookmarks_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -493,10 +493,10 @@ int mastodont_get_bookmarks(mastodont_t* data,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_get_favourites(mastodont_t* data,
int mastodont_get_favourites(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_favourites_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -521,10 +521,10 @@ int mastodont_get_favourites(mastodont_t* data,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_status_emoji_react(mastodont_t* api, char* id, char* emoji,
int mastodont_status_emoji_react(mastodont_t* api, struct mstdnt_args* args, char* id, char* emoji,
struct mstdnt_storage* storage, struct mstdnt_status* status)
{
char url[MSTDNT_URLSIZE];

View file

@ -20,7 +20,7 @@
#include <mastodont_query.h>
#include <mastodont_request.h>
int mastodont_timeline_list(mastodont_t* data,
int mastodont_timeline_list(mastodont_t* data, struct mstdnt_args* m_args,
char* list_id,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
@ -55,10 +55,10 @@ int mastodont_timeline_list(mastodont_t* data,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_timeline_tag(mastodont_t* data,
int mastodont_timeline_tag(mastodont_t* data, struct mstdnt_args* m_args,
char* hashtag,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
@ -96,7 +96,7 @@ int mastodont_timeline_tag(mastodont_t* data,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
static const char* reply_visibility_str(enum mstdnt_reply_visibility vis)
@ -113,7 +113,7 @@ static const char* reply_visibility_str(enum mstdnt_reply_visibility vis)
}
}
int mastodont_timeline_public(mastodont_t* data,
int mastodont_timeline_public(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -145,11 +145,11 @@ int mastodont_timeline_public(mastodont_t* data,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_timeline_direct(mastodont_t* data,
int mastodont_timeline_direct(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -177,11 +177,11 @@ int mastodont_timeline_direct(mastodont_t* data,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}
int mastodont_timeline_home(mastodont_t* data,
int mastodont_timeline_home(mastodont_t* data, struct mstdnt_args* m_args,
struct mstdnt_timeline_args* args,
struct mstdnt_storage* storage,
struct mstdnt_status* statuses[],
@ -214,6 +214,6 @@ int mastodont_timeline_home(mastodont_t* data,
mstdnt_statuses_json_callback,
};
return mastodont_request(data, &req_args);
return mastodont_request(data, m_args,&req_args);
}