summaryrefslogtreecommitdiff
path: root/curl_util.h
blob: 5e86e5a126567131ae39353ec010bd6b43a4dd2f (plain)
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
#ifndef MATRIX_CURL_UTIL_H
#define MATRIX_CURL_UTIL_H

#include <curl/curl.h>
#include <json-c/json.h>
#include <string.h>

CURLcode _curl_get(CURL *curl, const char *url, json_object **resp);
CURLcode _curl_post(CURL *curl, const char *url, const char *postdata,
						  json_object **resp);

static inline int
json_add_string(json_object *j, const char *k, const char *v)
{
	return json_object_object_add(j, k, json_object_new_string(v));
}

static inline
char* copy_str(const char *s)
{
	size_t l = strlen(s)+1;
	char *ss = (char*)malloc(l);
	memcpy(ss, s, l);
	return ss;
}

#endif