1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import curl
template setopt*(curl: CURL; opt: CURLoption; arg: typed) =
discard curl_easy_setopt(curl, opt, arg)
template setopt*(curl: CURL; opt: CURLoption; arg: string) =
discard curl_easy_setopt(curl, opt, cstring(arg))
template getinfo*(curl: CURL; info: CURLINFO; arg: typed) =
discard curl_easy_getinfo(curl, info, arg)
template set*(url: CURLU; part: CURLUPart; content: cstring; flags: cuint) =
discard curl_url_set(url, part, content, flags)
template set*(url: CURLU; part: CURLUPart; content: string; flags: cuint) =
url.set(part, cstring(content), flags)
template get*(url: CURLU; part: CURLUPart; flags: cuint): cstring =
var outs: cstring
if curl_url_get(url, part, addr outs, flags) == CURLUE_OK:
outs
else:
nil
|