Closed Spoiledpay closed 2 years ago
Yes,
I will soon add cross-platform cURL to standard library (since it's so common it makes sense there).
Will update you within a day or two depending on how long it takes
curl/curl.adept
is now in the standard library!
You can just use it straight out of the box like you would expect.
import 'sys/cstdio.adept'
import 'curl/curl.adept'
func main {
curl *CURL
res CURLcode
curl = curl_easy_init()
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, 'https://example.com')
/* specify certificate bundle (only required for windows) */
#if __windows__
curl_easy_setopt(curl, CURLOPT_CAINFO, 'curl-ca-bundle.crt')
#end
/* example.com is redirected, so we tell libcurl to follow redirection */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1)
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl)
/* Check for errors */
if(res != CURLE_OK) fprintf(stderr, 'curl_easy_perform() failed: %s\n', curl_easy_strerror(res))
/* always cleanup */
curl_easy_cleanup(curl)
}
}
Must have access to libcurl-x64.dll
and (optionally) curl-ca-bundle.crt
at runtime.
If you want to be able to verify SSL certificates, the newer versions of curl on Windows require that you specify a certificate bundle:
curl_easy_setopt(curl, CURLOPT_CAINFO, 'curl-ca-bundle.crt')
The curl-ca-bundle.crt
and libcurl-x64.dll
files are automatically provided when you build your program for the first time, but you can replace them with your own if you want. You can obtain them manually from https://curl.se/download.html
.
Although not recommended, you can disable SSL certificate validation (so that curl-ca-bundle.crt
is not required on Windows):
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0)
Cross-compilation to Windows of programs that use curl/curl.adept
is fully supported.
No runtime dependencies required, the curl dynamic libraries come with macOS by default.
curl shared libraries must be installed.
For compilation, the development package may need to be installed (e.g. libcurl4-openssl-dev
for debian-based distros)
Also, the latest nightly of v2.7
is required to use curl/curl.adept
(it uses recent features and fixes)
Hello! Do we have the future possibility of having download, RPC, CUrl functions in Adept?
include / printf, sprintf /
include / exit /
include / read, write, close /
include / memcpy, memset /
include <sys/socket.h> / socket, connect /
include <netinet/in.h> / struct sockaddr_in, struct sockaddr /
include / struct hostent, gethostbyname /
include <curl/curl.h>