?
FossilOrigin-Name: d5f4b96651d6888a2a0d9ba3e5f3b515be37783b84112421a22cab05b9989795
This commit is contained in:
commit
740fd220a0
2 changed files with 53 additions and 0 deletions
|
@ -32,6 +32,7 @@ typedef void (*mstdnt_request_cb_t)(void* data, void* args);
|
|||
|
||||
#define MSTDNT_FLAG_NO_URI_SANITIZE (1<<0)
|
||||
#define MSTDNT_FLAG_SSL_UNVERIFIED (1<<1)
|
||||
#define MSTDNT_FLAG_SYNC (1<<2)
|
||||
#define MSTDNT_FLAG_ISSET(flags, flag) (((flags) & (flag)) == (flag))
|
||||
#define MSTDNT_T_FLAG_ISSET(flag_ref, flag) (((flag_ref->flags) & (flag)) == (flag))
|
||||
|
||||
|
|
|
@ -71,6 +71,58 @@ 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)
|
||||
{
|
||||
|
||||
int res = 0, curlerror = 0;
|
||||
cJSON* root;
|
||||
struct mstdnt_fetch_results results = { 0 };
|
||||
curlerror = mstdnt_fetch_curl(data,
|
||||
curl,
|
||||
m_args,
|
||||
url_query,
|
||||
&results,
|
||||
args->request_type,
|
||||
args->request_type_custom);
|
||||
|
||||
if (curlerror != CURLE_OK)
|
||||
{
|
||||
res = 1;
|
||||
storage->error = (char*)curl_easy_strerror(curlerror);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Create json structure
|
||||
if (_mstdnt_json_init(&root, &results, storage))
|
||||
{
|
||||
res = 1;
|
||||
goto cleanup_res;
|
||||
}
|
||||
|
||||
// Make sure there is no error
|
||||
if (!mstdnt_check_error(storage))
|
||||
{
|
||||
/* Call our callback and do the large work */
|
||||
if (args->callback) res = args->callback(storage->root, args->args);
|
||||
}
|
||||
else
|
||||
res = 1;
|
||||
|
||||
cleanup_res:
|
||||
mstdnt_fetch_results_cleanup(&results);
|
||||
cleanup:
|
||||
// Note: the fetch removed the handle from our multi handle
|
||||
curl_easy_cleanup(curl);
|
||||
return res;
|
||||
}
|
||||
|
||||
int mstdnt_request(mastodont_t* data,
|
||||
struct mstdnt_args* m_args,
|
||||
mstdnt_request_cb_t cb_request,
|
||||
|
|
Loading…
Reference in a new issue