1. Error with _curl_
- Posted by euphoric (admin) Apr 18, 2018
- 1415 views
Hi, Jean-Marc,
I'm getting some errors attempting to incorporate your libCurl code.
Running "test_curl_.exw" with Euphoria 4.1, 32-bit, gives me this error: "function +curl_strequal not found"
Running "test_curl_.exw" with Euphoria 4.1, 64-bit, gives me this error: "No libcurl library defined for EU_4_1_WIN_64!"
What do you think is going on here?
2. Re: Error with _curl_
- Posted by jmduro Apr 19, 2018
- 1383 views
First I must apologize: my library is constantly improving. Last release (v1.2.15) is available here: http://jean-marc.duro.pagesperso-orange.fr/
libcurl version used is 7.50.3. Only 32-bit windows DLL is provided. 64-bit version has to be downloaded from libcurl.
_external_.e defines paths to libraries:
* LNX64_PATH = "/usr/lib/x86_64-linux-gnu/", * LNX32_PATH = "/usr/lib/i386-linux-gnu/", * WIN64_PATH = ".\\", * WIN32_PATH = ".\\"
The DLL has to be in the same directory as the test program if you leave WIN32_PATH as is.
If you don't use the complete library, you need to declare exported functions with a "+" prefix in their name (C call).
Regards
Jean-Marc
3. Re: Error with _curl_
- Posted by euphoric (admin) Apr 19, 2018
- 1362 views
First I must apologize: my library is constantly improving. Last release (v1.2.15) is available here: http://jean-marc.duro.pagesperso-orange.fr/
No need to apologize! Thank you for your efforts with this!
I'm getting reference errors now. Even if I use an include path directly to lib/_curl_.e, it still gives me the error below.
It's probably something simple that I've forgotten.
C:\eu_include\lib\demo\curl_demo.exw:52 <0074>:: Errors resolving the following references: 'CURL_GLOBAL_DEFAULT' (curl_demo.exw:61) has not been declared. 'CURL_GLOBAL_DEFAULT' (curl_demo.exw:81) has not been declared. 'CURL_GLOBAL_DEFAULT' (curl_demo.exw:101) has not been declared. 'CURL_GLOBAL_DEFAULT' (curl_demo.exw:121) has not been declared. 'CURL_GLOBAL_DEFAULT' (curl_demo.exw:140) has not been declared. 'log_printf' (curl_demo.exw:23) has not been declared. 'CURLOPT_PROXYTYPE' (curl_demo.exw:28) has not been declared. 'CURLPROXY_HTTP' (curl_demo.exw:28) has not been declared. 'CURLOPT_PROXY' (curl_demo.exw:30) has not been declared. 'SLASH' (curl_demo.exw:37) has not been declared. 'file_exists' (curl_demo.exw:37) has not been declared. 'SLASH' (curl_demo.exw:38) has not been declared. 'write_file' (curl_demo.exw:38) has not been declared. 'CURLOPT_COOKIEFILE' (curl_demo.exw:40) has not been declared. 'SLASH' (curl_demo.exw:40) has not been declared. 'CURLOPT_COOKIEJAR' (curl_demo.exw:41) has not been declared. 'SLASH' (curl_demo.exw:41) has not been declared. 'CURLOPT_VERBOSE' (curl_demo.exw:45) has not been declared. 'CURLOPT_FOLLOWLOCATION' (curl_demo.exw:46) has not been declared. 'CURLOPT_SSL_VERIFYPEER' (curl_demo.exw:49) has not been declared. 'CURLOPT_SSL_VERIFYHOST' (curl_demo.exw:52) has not been declared. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0)
4. Re: Error with _curl_
- Posted by jmduro Apr 20, 2018
- 1257 views
You seem to be missing following includes in curl_demo.exw:
include std/filesys.e -- for SLASH and file_exists include std/io.e -- write_file include lib/_common_.e -- for log_printf include lib/_curl_constants_.e -- for CURL_xxx constants
Jean-Marc
5. Re: Error with _curl_
- Posted by euphoric (admin) Apr 20, 2018
- 1262 views
You seem to be missing following includes in curl_demo.exw:
include std/filesys.e -- for SLASH and file_exists include std/io.e -- write_file include lib/_common_.e -- for log_printf include lib/_curl_constants_.e -- for CURL_xxx constants
Jean-Marc
OK, implemented those into the demo file, but now getting this:
C:\eu_include\lib\demo\curl_demo.ex:154 <0074>:: Errors resolving the following references: 'with_debug' (curl_demo.ex:18) has not been declared. 'with_debug' (curl_demo.ex:17) has not been declared. 'curl_post' (curl_demo.ex:70) has not been declared. 'HTTP_STATUS' (curl_demo.ex:73) has not been declared. 'HTTP_BODY' (curl_demo.ex:74) has not been declared. 'HTTP_BODY' (curl_demo.ex:76) has not been declared. 'curl_put' (curl_demo.ex:90) has not been declared. 'HTTP_STATUS' (curl_demo.ex:93) has not been declared. 'HTTP_BODY' (curl_demo.ex:94) has not been declared. 'HTTP_BODY' (curl_demo.ex:96) has not been declared. 'curl_patch' (curl_demo.ex:110) has not been declared. 'HTTP_STATUS' (curl_demo.ex:113) has not been declared. 'HTTP_BODY' (curl_demo.ex:114) has not been declared. 'HTTP_BODY' (curl_demo.ex:116) has not been declared. 'curl_get' (curl_demo.ex:130) has not been declared. 'HTTP_STATUS' (curl_demo.ex:132) has not been declared. 'HTTP_BODY' (curl_demo.ex:133) has not been declared. 'HTTP_BODY' (curl_demo.ex:135) has not been declared. 'curl_delete' (curl_demo.ex:149) has not been declared. 'HTTP_STATUS' (curl_demo.ex:151) has not been declared. 'HTTP_BODY' (curl_demo.ex:152) has not been declared. 'HTTP_BODY' (curl_demo.ex:154) has not been declared. puts(1, "Result:\n" & res[HTTP_BODY] & "\n")
I'm trying to run with Euphoria 4.1 for Windows, both 32-bit and 64-bit versions.
6. Re: Error with _curl_
- Posted by jmduro Apr 21, 2018
- 1238 views
My bad! It took me long before I understood I didn't check the demo folder.
Here is an updated working demo. The previous one was adapted to Eu3.
-- CURL GET, PUT, POST, PATCH and DELETE -- usage for beginners -- sequences url, headers and body are expected already defined at this step include std/io.e include std/console.e include std/filesys.e include lib/_common_.e include lib/_curl_.e include lib/_curl_constants_.e object res atom curl f_debug = open(InitialDir & SLASH & "debug.log", "w") with_debug = 1 ------------------------------------------------------------------------------ -- common initialization ------------------------------------------------------------------------------ function init_curl_session() atom curl curl = curl_easy_init() log_printf("curl = %d\n", curl) if not curl then return 0 end if -- Proxy settings curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP) -- curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1:8888") -- ex: Fiddler2 proxy curl_easy_setopt(curl, CURLOPT_PROXY, "") -- no proxy -- Cookies settings -- beware of already registered cookies! -- if a connection fails, first remove or empty the cookie file -- before you verify your credentials if file_exists(InitialDir & SLASH & "cookies.txt") then write_file(InitialDir & SLASH & "cookies.txt", "") end if curl_easy_setopt(curl, CURLOPT_COOKIEFILE, InitialDir & SLASH & "cookies.txt") curl_easy_setopt(curl, CURLOPT_COOKIEJAR, InitialDir & SLASH & "cookies.txt") -- Common settings curl_easy_setopt(curl, CURLOPT_VERBOSE, 1) curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1) -- Skip Peer Verification curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0) -- Skip Host Verification curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0) return curl end function -------------------------------------------------------------------------------- -- CURL POST - Beginner -------------------------------------------------------------------------------- res = curl_global_init(CURL_GLOBAL_DEFAULT) curl = init_curl_session() if curl then res = curl_post(curl, "https://jsonplaceholder.typicode.com/posts", {"Content-type: application/json; charset=UTF-8"}, "{ \"title\": \"foo\", \"body\": \"bar\", \"userId\": 1 }") if (res[HTTP_STATUS] < 200) or (res[HTTP_STATUS] > 226) then puts(f_debug, "POST failed!\n" & res[HTTP_BODY] & "\n") end if puts(f_debug, "Result:\n" & res[HTTP_BODY] & "\n") curl_easy_cleanup(curl) end if curl_global_cleanup() -------------------------------------------------------------------------------- -- CURL PUT - Beginner -------------------------------------------------------------------------------- res = curl_global_init(CURL_GLOBAL_DEFAULT) curl = init_curl_session() if curl then res = curl_put(curl, "https://jsonplaceholder.typicode.com/posts/1", {"Content-type: application/json; charset=UTF-8"}, "{ \"id\": 1, \"title\": \"foo\", \"body\": \"bar\", \"userId\": 1 }") if (res[HTTP_STATUS] < 200) or (res[HTTP_STATUS] > 226) then puts(f_debug, "PUT failed!\n" & res[HTTP_BODY] & "\n") end if puts(f_debug, "Result:\n" & res[HTTP_BODY] & "\n") curl_easy_cleanup(curl) end if curl_global_cleanup() -------------------------------------------------------------------------------- -- CURL PATCH - Beginner -------------------------------------------------------------------------------- res = curl_global_init(CURL_GLOBAL_DEFAULT) curl = init_curl_session() if curl then res = curl_patch(curl, "https://jsonplaceholder.typicode.com/posts/1", {"Content-type: application/json; charset=UTF-8"}, "{ \"title\": \"foo\" }") if (res[HTTP_STATUS] < 200) or (res[HTTP_STATUS] > 226) then puts(f_debug, "PATCH failed!\n" & res[HTTP_BODY] & "\n") end if puts(f_debug, "Result:\n" & res[HTTP_BODY] & "\n") curl_easy_cleanup(curl) end if curl_global_cleanup() -------------------------------------------------------------------------------- -- CURL GET - Beginner -------------------------------------------------------------------------------- void = curl_global_init(CURL_GLOBAL_DEFAULT) curl = init_curl_session() if curl then res = curl_get(curl, "https://jsonplaceholder.typicode.com/posts/1", {"Content-type: application/json; charset=UTF-8"}) if (res[HTTP_STATUS] < 200) or (res[HTTP_STATUS] > 226) then puts(f_debug, "GET failed!\n" & res[HTTP_BODY] & "\n") end if puts(f_debug, "Result:\n" & res[HTTP_BODY] & "\n") curl_easy_cleanup(curl) end if curl_global_cleanup() -------------------------------------------------------------------------------- -- CURL DELETE - Beginner -------------------------------------------------------------------------------- res = curl_global_init(CURL_GLOBAL_DEFAULT) curl = init_curl_session() if curl then res = curl_delete(curl, "https://jsonplaceholder.typicode.com/posts/1", {"Content-type: application/json; charset=UTF-8"}) if (res[HTTP_STATUS] < 200) or (res[HTTP_STATUS] > 226) then puts(f_debug, "DELETE failed!\n" & res[HTTP_BODY] & "\n") end if puts(f_debug, "Result:\n" & res[HTTP_BODY] & "\n") curl_easy_cleanup(curl) end if curl_global_cleanup() puts(f_debug, "\nFinished\n") maybe_any_key()
Sorry for beeing slow on the uptake !
Jean-Marc
7. Re: Error with _curl_
- Posted by jmduro Apr 21, 2018
- 1247 views
I have updated Eu4 Standard Library and Win32Lib r2 on my site: http://jean-marc.duro.pagesperso-orange.fr/
Demos have been updated and tested on Eu4 Standard Library.
Win32Lib r2 can now be used side-by-side with Win32Lib: they don't use the same folder nor the same main file name.
Jean-Marc
8. Re: Error with _curl_
- Posted by ChrisB (moderator) Apr 21, 2018
- 1194 views
Hi Jean Marc
Is this an official win32lib? If so then may I adapt it to Phix, perhaps run in parallel with this so there is not too much divergence. Also if so, could you list the changes as you go to make adaptation easier.
If not, which is the official win32lib, could we converge the versions?
Cheers
Chris
9. Re: Error with _curl_
- Posted by jmduro Apr 21, 2018
- 1210 views
No, it is the restructured version, which is fully compatible with official Win32Lib but with fewer files. It is the one used by Greg on UsingEuphoria. Up to the previous version, official Win32Lib could not co-exist with restructured version. Now they can co-exist.
Jean-Marc
10. Re: Error with _curl_
- Posted by ChrisB (moderator) Apr 21, 2018
- 1188 views
No, it is the restructured version, which is fully compatible with official Win32Lib but with fewer files. It is the one used by Greg on UsingEuphoria. Up to the previous version, official Win32Lib could not co-exist with restructured version. Now they can co-exist.
Jean-Marc
Hi
Is that no, I may not adapt it, or no, it is not an official win32lib. I certainly think that convergence of the various win32libs should be a worthwhile project.
Cheers
Chris
11. Re: Error with _curl_
- Posted by euphoric (admin) Apr 21, 2018
- 1209 views
Jean-Marc,
Thank you so much for your help! I'll get back to this on Monday.
12. Re: Error with _curl_
- Posted by jmduro Apr 22, 2018
- 1170 views
Is that no, I may not adapt it, or no, it is not an official win32lib. I certainly think that convergence of the various win32libs should be a worthwhile project.
It is not the official Win32Lib, but it is exactly the same code redesigned to fit in much less files so it should be more maintainable. You are free to adapt it.
Regards
Jean-Marc