Pelles C forum

Pelles C => General discussions => Topic started by: alderman on November 27, 2017, 12:16:31 AM

Title: Pelles-C and CURL
Post by: alderman on November 27, 2017, 12:16:31 AM
Hello, Pelles friends

1- Can CURL be used in Pelles-C
2- Is there a CURL package for Pelles-C
3- How to convert if needed
4- How to add CURL to Pelles-C

Title: Re: Pelles-C and CURL
Post by: frankie on November 27, 2017, 06:01:24 PM
For points 3 & 4 I'm not sure to have understood what you mean.
Title: Re: Pelles-C and CURL
Post by: alderman on November 27, 2017, 09:57:53 PM
  • I have not tested, but I don't see any reason that should prevent the use of the MSVC precompiled version
  • Not yet
For points 3 & 4 I'm not sure to have understood what you mean.

There are two libs with the same name, I mean this:
https://curl.haxx.se/

I found a curl built for LccWin32:
http://www.q-software-solutions.de/~frido/
(At the bottom) old but it may get well.
Title: Re: Pelles-C and CURL
Post by: frankie on December 02, 2017, 06:33:49 PM
This is a sample of use of a precompiled libcurl.
I compiled url2file demo using Stefan Kanthak libraries that you can download from here (https://skanthak.homepage.t-online.de/curl.html).
I included the relevant libraries in the example.
Note that the demo execute in the library folder so the executable can find the DLL.

I'll try to create a PellesC port when I'll have time
Title: Re: Pelles-C and CURL
Post by: alderman on December 02, 2017, 10:40:39 PM
This is a sample of use of a precompiled libcurl.
I compiled url2file demo using Stefan Kanthak libraries that you can download from here (https://skanthak.homepage.t-online.de/curl.html).
I included the relevant libraries in the example.
Note that the demo execute in the library folder so the executable can find the DLL.

I'll try to create a PellesC port when I'll have time
I'll look at it. Thanks!
Interesting that you are thinking of port it to PellesC, I look forward to it.
Title: Re: Pelles-C and CURL
Post by: frankie on February 18, 2019, 12:03:57 AM
I wasn't aware that Curl was already tuned for PellesC!  :o
Anyway I produced a port, 32/64bits, availabe on github (https://github.com/Frankie-PellesC/Curl).
The sample is compiled with Windows Security Support Provider Interface (SSPI).
Title: Re: Pelles-C and CURL
Post by: alderman on February 18, 2019, 12:27:46 AM
I wasn't aware that Curl was already tuned for PellesC!  :o
Anyway I produced a port, 32/64bits, availabe on github (https://github.com/Frankie-PellesC/Curl).
The sample is compiled with Windows Security Support Provider Interface (SSPI).
Awesome!
How do I install it in Pelles C?
Title: Re: Pelles-C and CURL
Post by: frankie on February 18, 2019, 11:59:24 AM
How do I install it in Pelles C?
Go on github clicking this link (https://github.com/Frankie-PellesC/Curl).
There you can download a zip of the project, or clone it on your computer.
To install it on your system you have to copy lib, dll and header files in the correct directories:
Title: Re: Pelles-C and CURL
Post by: alderman on February 18, 2019, 12:21:20 PM
How do I install it in Pelles C?
Go on github clicking this link (https://github.com/Frankie-PellesC/Curl).
There you can download a zip of the project, or clone it on your computer.
To install it on your system you have to copy lib, dll and header files in the correct directories:
  • Header files:
    Headers are in the directory 'include\Curl'.
    Copy the whole subdirectory 'Curl' under '$(PellesCDir)\Include'
  • 32bits development:
    All 32 bits binaries are under the directory 'X86'.
    • 32 bits libraries:
      Copy all library files '*.lib' from 'X86' to '$(PellesCDir)\Lib\Win'
    • 32bits DLL:
      Copy Dll's from 'X86' to '$(SystemRoot)\SysWOW64' (that normally is "C:\Windows\SysWOW64").
  • 64bits development:
    All 64 bits binaries are under the directory 'X64'.
    • 64 bits libraries:
      Copy all library files '*.lib' from 'X64' to '$(PellesCDir)\Lib\Win64'
    • 64bits DLL:
      Copy Dll's from 'X64' to '$(SystemRoot)\System32' (that normally is "C:\Windows\System32").
  • Executables:
    Depending on your OS/preferences, copy the 32bits executables from 'X86' directory, or the 64bits executables from 'X64' directory.
    Copy them to a directory listed in the system '$(PATH)' if you want have them available from command line.
THANKS!!
You saved hours of my time!
Title: Re: Pelles-C and CURL
Post by: WiiLF23 on December 29, 2023, 11:40:16 PM
Working perfectly. Libs where they should go (architecture), and the DLL along with the application (same directory, no system32).

libcurl/7.64.0 Schannel

Thanks!
Title: Re: Pelles-C and CURL
Post by: Vortex on December 30, 2023, 10:55:13 AM
curl shipped by Microsoft :

Quote
On December 19 2017, Microsoft announced that since insider build 17063 of Windows 10, curl is a default component.

Windows 10/11 bundle curl
All installs of Microsoft Windows 10 and Windows 11 get curl installed by default since then.

The Microsoft provided version is built to use the Schannel TLS backend. Invoking curl -V after the November 22 2023 update shows this on these platforms:

curl 8.4.0 (Windows) libcurl/8.4.0 Schannel WinIDN
Release-Date: 2023-10-11
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI threadsafe Unicode UnixSockets

https://curl.se/windows/microsoft.html
Title: Re: Pelles-C and CURL
Post by: MrBcx on December 30, 2023, 03:08:06 PM
Below is from a normal Windows 10 command prompt.
This seems easy enough to be invoked from batch files and shelled processes:

C:\Temp>curl --help

Usage: curl [options...] <url>
 -d, --data <data>          HTTP POST data
 -f, --fail                 Fail fast with no output on HTTP errors
 -h, --help <category>      Get help for commands
 -i, --include              Include protocol response headers in the output
 -o, --output <file>        Write to file instead of stdout
 -O, --remote-name          Write output to a file named as the remote file
 -s, --silent               Silent mode
 -T, --upload-file <file>   Transfer local FILE to destination
 -u, --user <user:password> Server user and password
 -A, --user-agent <name>    Send User-Agent <name> to server
 -v, --verbose              Make the operation more talkative
 -V, --version              Show version number and quit

This is not the full help, this menu is stripped into categories.
Use "--help category" to get an overview of all categories.
For all options use the manual or "--help all".

Title: Re: Pelles-C and CURL
Post by: Vortex on December 30, 2023, 09:31:19 PM
wget for Windows  :

https://eternallybored.org/misc/wget/
Title: Re: Pelles-C and CURL
Post by: John Z on December 31, 2023, 07:27:28 AM
Maybe we will get EDT for windows next  ;D

John Z
Title: Re: Pelles-C and CURL
Post by: WiiLF23 on January 06, 2024, 08:08:06 PM
I'm using this library extensively. It has allowed me to use my API endpoints back and forth with no MySQL driver! This is amazing and works perfectly. Its used for synchronizing local files with a remote database and uses a writeback function to write the JSON response back to application and loads data from there after remote database updating.

So PHP and C was required for this, which was easy for me (PHP - 21 years exp).

Thanks a lot!

Just a note, so using WININET is much faster than cURL for some procedures in my code, and that is a slight drawback so some parts are cURL-ready while others are cURL-required. I hope to move everything over to cURL but I first need to find out where the delay overhead is taking place.

Get the version of the library:

Code: [Select]
void ShowCurlVersion(HWND hwndDlg) {
    CURLcode res;
    const char* version = curl_version();

    int len = MultiByteToWideChar(CP_UTF8, 0, version, -1, NULL, 0);
    wchar_t* wVersion = (wchar_t*)malloc((len + 1) * sizeof(wchar_t));
    MultiByteToWideChar(CP_UTF8, 0, version, -1, wVersion, len);

    MessageBoxW(hwndDlg, wVersion, L"cURL Version", MB_OK);
    free(wVersion);
}
Code: [Select]
CURLcode initRes = curl_global_init(CURL_GLOBAL_DEFAULT);
if (initRes != CURLE_OK) {
    MessageBoxW(NULL, L"cURL initialization failed!", L"Error", MB_OK | MB_ICONERROR);
}

ShowCurlVersion(NULL);
curl_global_cleanup();

Im still learning the string formats - wide/narrow so ease up on me lol
Title: Re: Pelles-C and CURL
Post by: WiiLF23 on January 16, 2024, 11:29:03 PM
I've developed a cURL POST login procedure that uses cJSON to pass JSON data back to application for parsing, error reporting, etc. The remote login script is a basic (can be any language) PHP file checking username and password POST parameters and echoing JSON back (which can be anything).

- Allows instantly downloading user photo - > Bitmap conversion -> show on window
- Show any of the JSON fields read back and show them in controls (labels, picture, fields, etc)

It uses this library extensively. If anyone wants me to post this, let me know - it is mighty useful ;D