Grepping, remove static

FossilOrigin-Name: c789b473998a5b1e2eea245744a39f3bb538672875662bf82e4266b40feaa95f
This commit is contained in:
nekobit 2022-10-26 23:30:02 +00:00
parent a54e0cf0b3
commit 3357bd476e
10 changed files with 103 additions and 172 deletions

View file

@ -27,7 +27,6 @@
#include <mastodont_scrobbles.h>
#include <mastodont_search.h>
#include <mastodont_announcement.h>
#include <mastodont_static.h>
#include <mastodont_chats.h>
//! Initializes libcurl

View file

@ -41,10 +41,13 @@ int mstdnt_nodeinfo_json(struct mstdnt_nodeinfo* nodeinfo, cJSON* js);
int mstdnt_nodeinfo_json_callback(cJSON* json, void* nodeinfo);
int mstdnt_get_nodeinfo(mastodont_t* api, struct mstdnt_args* args,
char* version,
struct mstdnt_storage* storage,
struct mstdnt_nodeinfo* nodeinfo);
int mstdnt_get_nodeinfo(mastodont_t* api,
struct mstdnt_args* args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* version,
struct mstdnt_storage* storage,
struct mstdnt_nodeinfo* nodeinfo);
void mstdnt_cleanup_nodeinfo(struct mstdnt_nodeinfo* nodeinfo);

View file

@ -52,12 +52,15 @@ int mstdnt_relationships_json(struct mstdnt_relationship* relationships[],
int mstdnt_relationships_json_callback(cJSON* json, void* _args);
int mstdnt_get_relationships(mastodont_t* data, struct mstdnt_args* args,
char** ids,
size_t ids_len,
struct mstdnt_storage* storage,
struct mstdnt_relationship* relationships[],
size_t* size);
int mstdnt_get_relationships(mastodont_t* data,
struct mstdnt_args* args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char** ids,
size_t ids_len,
struct mstdnt_storage* storage,
struct mstdnt_relationship* relationships[],
size_t* size);
void mstdnt_cleanup_relationships(struct mstdnt_relationship* rels);

View file

@ -1,29 +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 MSTDNT_STATIC_H
#define MSTDNT_STATIC_H
#include "mastodont_types.h"
#include "mastodont_fetch.h"
int mstdnt_instance_panel(mastodont_t* api,
struct mstdnt_args* args,
struct mstdnt_fetch_data* html);
int mstdnt_terms_of_service(mastodont_t* api,
struct mstdnt_args* args,
struct mstdnt_fetch_data* html);
#endif /* MSTDNT_STATIC_H */

View file

@ -165,34 +165,38 @@ void* cb_args,
size_t* size_before,
size_t* size_after);
int mstdnt_status_favourited_by(mastodont_t* data, struct mstdnt_args* args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
size_t* accts);
int mstdnt_status_favourited_by(mastodont_t* data,
struct mstdnt_args* args,
mstdnt_request_cb_t cb_reqest,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
size_t* accts);
int mstdnt_status_reblogged_by(mastodont_t* data,
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
size_t* accts);
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
size_t* accts);
int mstdnt_create_status(mastodont_t* data,
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
struct mstdnt_status_args* args,
struct mstdnt_storage* storage);
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
struct mstdnt_status_args* args,
struct mstdnt_storage* storage);
/* Generates do and undo functions */
#define MSTDNT_STATUS_ACTION_DECL(type) int mstdnt_##type##_status(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args, char* id, struct mstdnt_storage* storage, struct mstdnt_status* status)
#define MSTDNT_STATUS_ACTION_DECL(type) int mstdnt_##type##_status(mastodont_t* data, struct mstdnt_args* m_args, \
mstdnt_request_cb_t cb_request, void* cb_args, char* id, \
struct mstdnt_storage* storage, struct mstdnt_status* status)
#define MSTDNT_STATUS_ACTION_FUNC_URL(action) { \
return mstdnt_status_action(data, m_args, id, storage, status, "api/v1/statuses/%s/" action); \
return mstdnt_status_action(data, m_args, cb_request, cb_args, id, storage, status, "api/v1/statuses/%s/" action); \
}
MSTDNT_STATUS_ACTION_DECL(favourite);

View file

@ -97,14 +97,15 @@ int mstdnt_relationships_json_callback(cJSON* json, void* _args)
return mstdnt_relationships_json(args->relationships, args->size, json);
}
int mstdnt_get_relationships(mastodont_t* data, struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char** ids,
size_t ids_len,
struct mstdnt_storage* storage,
struct mstdnt_relationship* relationships[],
size_t* size)
int mstdnt_get_relationships(mastodont_t* data,
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char** ids,
size_t ids_len,
struct mstdnt_storage* storage,
struct mstdnt_relationship* relationships[],
size_t* size)
{
struct _mstdnt_relationships_cb_args req_cb_args = { relationships, size };
struct _mstdnt_query_param params[] = {
@ -127,7 +128,7 @@ void* cb_args,
mstdnt_relationships_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_relationships(struct mstdnt_relationship* rels)

View file

@ -71,26 +71,28 @@ static void mime_params_post(curl_mime* mime,
}
static mstdnt_sync_request(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_request_args* args,
struct mstdnt_storage* storage,
mstdnt_request_cb_t cb_request,
void* cb_args,
CURL* curl,
char* url_query)
// TODO
#if 0
static int mstdnt_sync_request(mastodont_t* data,
struct mstdnt_args* m_args,
struct mstdnt_request_args* args,
struct mstdnt_storage* storage,
mstdnt_request_cb_t cb_request,
void* cb_args,
CURL* curl,
char* url_query)
{
int res = 0, curlerror = 0;
cJSON* root;
struct mstdnt_fetch_data results = { 0 };
curlerror = mstdnt_fetch_curl(data,
curl,
m_args,
url_query,
&results,
args->request_type,
args->request_type_custom);
curlerror = mstdnt_fetch_curl_async(data,
curl,
m_args,
url_query,
&results,
args->request_type,
args->request_type_custom);
if (curlerror != CURLE_OK)
{
@ -122,6 +124,7 @@ cleanup:
curl_easy_cleanup(curl);
return res;
}
#endif
int mstdnt_request(mastodont_t* data,
struct mstdnt_args* m_args,

View file

@ -1,53 +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/>.
*/
#include <mastodont_static.h>
#include <mastodont_fetch.h>
int mstdnt_instance_panel(mastodont_t* api,
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
struct mstdnt_fetch_data* html)
{
CURL* curl = curl_easy_init();
int status = mstdnt_fetch_curl(api,
curl,
m_args,
"instance/panel.html",
html,
CURLOPT_HTTPGET,
NULL);
curl_easy_cleanup(curl);
return status;
}
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_data* html)
{
CURL* curl = curl_easy_init();
int status = mstdnt_fetch_curl(api,
curl,
m_args,
"static/terms-of-service.html",
html,
CURLOPT_HTTPGET,
NULL);
curl_easy_cleanup(curl);
return status;
}

View file

@ -225,8 +225,8 @@ void* cb_args,
static int mstdnt_status_action(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_storage* storage,
struct mstdnt_status* status,
@ -296,34 +296,34 @@ MSTDNT_STATUS_ACTION_DECL(delete)
/* TODO Mutes can be timed */
int mstdnt_mute_conversation(mastodont_t* data,
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
{
return mstdnt_status_action(data, m_args, id, storage, status, "api/v1/statuses/%s/mute");
return mstdnt_status_action(data, m_args, cb_request, cb_args, id, storage, status, "api/v1/statuses/%s/mute");
}
int mstdnt_unmute_conversation(mastodont_t* data,
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
{
return mstdnt_status_action(data, m_args, id, storage, status, "api/v1/statuses/%s/unmute");
return mstdnt_status_action(data, m_args, cb_request, cb_args, id, storage, status, "api/v1/statuses/%s/unmute");
}
int mstdnt_get_status(mastodont_t* data,
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_status* status)
{
char url[MSTDNT_URLSIZE];
snprintf(url, MSTDNT_URLSIZE, "api/v1/statuses/%s", id);
@ -436,13 +436,13 @@ void* cb_args,
}
int mstdnt_status_favourited_by(mastodont_t* data,
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
size_t* accts_len)
struct mstdnt_args* m_args,
mstdnt_request_cb_t cb_request,
void* cb_args,
char* id,
struct mstdnt_storage* storage,
struct mstdnt_account* accounts[],
size_t* accts_len)
{
struct _mstdnt_accounts_args args = {
accounts,

View file

@ -58,7 +58,7 @@ void* cb_args,
mstdnt_statuses_json_callback,
};
return mstdnt_request(data, m_args, &req_args, cb_request, cb_args);
return mstdnt_request(data, m_args, cb_request, cb_args, &req_args);
}
int mstdnt_timeline_tag(mastodont_t* data,
@ -102,7 +102,7 @@ void* cb_args,
mstdnt_statuses_json_callback,
};
return mstdnt_request(data, m_args, &req_args, cb_request, cb_args);
return mstdnt_request(data, m_args, cb_request, cb_args, &req_args);
}
static const char* reply_visibility_str(enum mstdnt_reply_visibility vis)
@ -154,7 +154,7 @@ void* cb_args,
mstdnt_statuses_json_callback,
};
return mstdnt_request(data, m_args, &req_args, cb_request, cb_args);
return mstdnt_request(data, m_args, cb_request, cb_args, &req_args);
}
@ -189,7 +189,7 @@ void* cb_args,
mstdnt_statuses_json_callback,
};
return mstdnt_request(data, m_args, &req_args, cb_request, cb_args);
return mstdnt_request(data, m_args, cb_request, cb_args, &req_args);
}
@ -229,6 +229,6 @@ void* cb_args,
mstdnt_statuses_json_callback,
};
return mstdnt_request(data, m_args, &req_args, cb_request, cb_args);
return mstdnt_request(data, m_args, cb_request, cb_args, &req_args);
}