Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct curlbuffer {
- char *buff;
- size_t size;
- } curlbuffer;
- bool loginworks() {
- curlbuffer authtest = curlrequest("https://domain.com/some_url_that_returns_json");
- if(strncmp(authtest.buff, "{\"ping\":\"success\"}", 19) == 0) {
- return true;
- }
- return false;
- }
- curlbuffer curlrequest(char *url) {
- CURL *curl;
- CURLcode res;
- /* curl delivers 16KiB of data at once, so this buffer should hold the first request */
- curlbuffer curldata;
- curldata.buff = malloc(CURL_MAX_WRITE_SIZE);
- memset(curldata.buff, '\0', CURL_MAX_WRITE_SIZE);
- curldata.size = CURL_MAX_WRITE_SIZE;
- <I do the request and some stuff>
- curl_global_cleanup();
- return curldata;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement