%{^
#include <curl/curl.h>
%}
absviewtype CURLptr (l:addr) viewtypedef CURLptr0 = [l:addr | l >= null] CURLptr l
viewtypedef CURLptr1 = [l:addr | l > null] CURLptr l
abst@ype CURLoption = $extype "CURLoption"
macdef CURLOPT_URL = $extval(CURLoption, "CURLOPT_URL")
extern fun curl_easy_init
()
: CURLptr0 = "#curl_easy_init"
extern fun curl_easy_setopt {p:type}
(handle: !CURLptr1, option: CURLoption, parameter: p)
: int = "#curl_easy_setopt"
extern fun curl_easy_perform
( handle: !CURLptr1)
: int = "#curl_easy_perform"
extern fun curl_easy_cleanup
(handle: CURLptr1)
: void = "#curl_easy_cleanup"
extern fun CURLptr_is_null {l:addr}
(x: !CURLptr l)
: bool (l == null) = "atspre_ptr_is_null";
extern fun CURLptr_isnot_null {l:addr}
(x: !CURLptr l)
: bool (l > null) = "atspre_ptr_isnot_null";
implement main() = let
val curl = curl_easy_init();
val () = assert_errmsg(CURLptr_isnot_null curl, "curl_easy_init failed");
val res = curl_easy_setopt(curl, CURLOPT_URL, "www.bluishcoder.co.nz");
val res = curl_easy_perform(curl);
val () = curl_easy_cleanup(curl);
in
()
end;