about summary refs log blame commit diff stats
path: root/adapter/protocol/curlwrap.nim
blob: c3c69a6812c4f87ea371ae6377e534e64ba263ce (plain) (tree)
1
2
3
4
5
6
7
8
9
10
           








                                                            
 


                                                                            
                                                                           
                                        






                                                                   
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