Last active
October 18, 2023 19:30
-
-
Save samdphillips/cb18c3975ef47c9e0584e7767ef1719b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
;; Works on Linux, doesn't work on Mac? More minimal version. | |
(require ffi/unsafe | |
ffi/unsafe/define) | |
(define-ffi-definer define-curl (ffi-lib "libcurl")) | |
(define CURL_GLOBAL_ALL #b11) | |
(define-curl curl_global_init (_fun _long -> _int)) | |
(define-curl curl_global_cleanup (_fun -> _void)) | |
(define-cpointer-type _curl) | |
(define-curl curl_easy_init (_fun -> _curl)) | |
(define-curl curl_easy_cleanup (_fun _curl -> _void)) | |
(define-curl curl_easy_perform (_fun _curl -> _int)) | |
(define-curl curl_easy_setopt_url | |
(_fun (h val) :: | |
(h : _curl) (_uint = 10002) (val : _string) -> _int) | |
#:c-id curl_easy_setopt) | |
(define-curl curl_easy_setopt_verbose | |
(_fun (h val) :: | |
(h : _curl) (_uint = 41) (val : _bool) -> _int) | |
#:c-id curl_easy_setopt) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(curl_global_init CURL_GLOBAL_ALL) | |
(define url "https://www.google.com") | |
(define h (curl_easy_init)) | |
(curl_easy_setopt_verbose h #t) | |
(curl_easy_setopt_url h url) | |
(curl_easy_perform h) | |
(curl_easy_cleanup h) | |
(curl_global_cleanup) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment