forked from emersonmello/doorlock_raspberrypi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
curlutils.h
47 lines (36 loc) · 1.04 KB
/
curlutils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* File: curlutils.h
* Author: Emerson Ribeiro de Mello <[email protected]>
*
* Created on 30 June 2016, 09:53
*/
#ifndef CURLUTILS_H
#define CURLUTILS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <string.h>
#include <json-c/json.h>
#include <curl/curl.h>
struct MemoryStruct {
char *memory;
size_t size;
} typedef memoryStruct;
/* holder for curl fetch */
struct curl_fetch_st {
char *payload;
size_t size;
} typedef curlFetchStruct;
#define BLOCK_SIZE 250
char* subString (const char* input, int offset, int len, char* dest);
void blockSplit(const char* input, char **result, size_t block);
static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp);
size_t curl_callback (void *contents, size_t size, size_t nmemb, void *userp);
CURLcode curl_fetch_url(CURL *ch, const char *url, struct curl_fetch_st *fetch);
json_object *postHttpRequest(char *url, char *payload);
memoryStruct getHttpRequest(char *);
#ifdef __cplusplus
}
#endif
#endif /* CURLUTILS_H */