Created
May 25, 2009 12:26
-
-
Save ldfallas/117523 to your computer and use it in GitHub Desktop.
Small experiment of using libcurl with Newspeak FFI
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
Newsqueak2 | |
'LangexplrExperiments | |
' | |
class FFIExperiments usingLib: platform = ( | |
"Experiment for calling libcurl" | |
| | |
Transcript = platform Transcript. | |
Alien = platform Alien. | |
Callback = platform Callback. | |
UnsafeAlien = platform UnsafeAlien. | |
| | |
) | |
('as yet unclassified' | |
basicCurlExperiment = ( | |
|c r| | |
Alien ensureLoaded: libcurlPath, 'libidn-11.dll'. | |
Alien ensureLoaded: libcurlPath, 'libeay32.dll'. | |
Alien ensureLoaded: libcurlPath, 'libssl32.dll'. | |
(Alien lookup: 'curl_easy_init' inLibrary: curlLibName ) | |
primFFICallResult: (c:: Alien new: 4). | |
(Alien lookup: 'curl_easy_setopt' inLibrary: curlLibName ) | |
primFFICallResult: nil | |
withArguments: { c. | |
10002. | |
UnsafeAlien forPointerTo: 'http://www.yahoo.com/'. }. | |
(Alien lookup: 'curl_easy_perform' inLibrary: curlLibName ) | |
primFFICallResult: (r:: Alien new: 4) | |
withArguments: { c. }. | |
(Alien lookup: 'curl_easy_cleanup' inLibrary: curlLibName ) | |
primFFICallResult: nil | |
withArguments: { c } . | |
^ (r signedLongAt: 1). | |
) | |
curlLibName = ( | |
^libcurlPath , 'libcurl.dll' | |
) | |
libcurlPath = ( | |
^'C:\development\curl-7.19.4-devel-mingw32\bin\' | |
) | |
test: t = ( | |
Transcript show: t. | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment