Page 1 of 9

libcurl.pbi

Posted: Sun Nov 13, 2022 3:54 pm
by infratec
Since there were many places with different links, I decided to make an own thread for libcurl.pbi.

The download link will provide always the latest version of:

libcurl.pbi

Included examples:
Asynchronous.pb
DownloadProgress.pb
EMailWithBinaryFileAttachment.pb
EMailWithFileAttachment.pb
EMailWithFileAttachmentFromMemory.pb
FTP_dir.pb
FTP_mkdir.pb
FTP_rmdir.pb
FTPS_delete.pb
FTPS_download.pb
FTPS_GetDirectory.pb
FTPS_rename.pb
FTPS_upload.pb
GetCertInfo.pb
HTTP_gzip.pb
HTTPRequestI.pbi
IMAP.pbi
NextCloud.pbi
OutLookEMail.pb
PaperlessNgx.pbi
pop3.pbi
scp_to.pb
SFTP_delete.pb
SFTP_get.pb
SFTP_rename.pb
SFTP_upload.pb
SFTP_uploadresume.pb
SMTPS.pb
WSS_simple_echo.pb

https://www.von-der-salierburg.de/downl ... eBasic.zip

Usefull links:
https://curl.se/libcurl/c/libcurl.html
https://curl.se/windows/

At the moment (PB 6.21) the windows version includes libcurl V7.68 and supports the following protocols:
--- LibCurl Info ---
Version: 7.68.0
Host: i386-pc-win32
SSL: Schannel
libSSH: libssh2/1.11.0

Protocols:
ftp
ftps
http
https
scp
sftp
smtp
smtps
--- LibCurl Info ---

The external dll in the zip file:
--- LibCurl Info ---
Version: 8.15.0
Host: i686-w64-mingw32
SSL: LibreSSL/4.1.0
Libz: 1.3.1.zlib-ng
libSSH: libssh2/1.11.1

Protocols:
dict
file
ftp
ftps
gopher
gophers
http
https
imap
imaps
ldap
ldaps
mqtt
pop3
pop3s
rtsp
scp
sftp
smb
smbs
smtp
smtps
telnet
tftp
ws
wss

Features:
alt-svc
AsynchDNS
brotli
HSTS
HTTP2
HTTP3
HTTPS-proxy
IDN
IPv6
Kerberos
Largefile
libz
NTLM
PSL
SPNEGO
SSL
SSLS-EXPORT
SSPI
threadsafe
UnixSockets
zstd
--- LibCurl Info ---

Re: libcurl.pbi

Posted: Sun Nov 13, 2022 4:02 pm
by infratec
GetCertInfo()
works now as it should.
The structure for certinfo was wrong.

Changed all examples to use the new defines:

Code: Select all

#LibCurl_ExternalDLL
#LibCurl_ExternalStaticLib

Re: libcurl.pbi

Posted: Sun Nov 13, 2022 4:54 pm
by infratec
Updated libcurl to 7.86.0

Added LibCurl_Info() to libcurl.pbi.
Now you can see informations about version and included protocols by simply call LibCurl_Info().

Re: libcurl.pbi

Posted: Sun Nov 13, 2022 5:31 pm
by infratec

Re: libcurl.pbi

Posted: Fri Dec 02, 2022 10:53 pm
by infratec
Fixed a bug:

The last parameter of curl_easy_setopt() needs to be a .q :!:

I found this bug during I wrote NextCloud.pbi.
The upload was not possible without .q

At the moment NextCloud.pbi contains:

Code: Select all

Procedure.i NextCloud_GetShares(URL$, Username$, Password$, List ShareList$())
Procedure.i NextCloud_FileExists(URL$, Username$, Password$, File$)
Procedure.i NextCloud_CreateFolder(URL$, Username$, Password$, Path$)
Procedure.i NextCloud_UploadFile(URL$, Username$, Password$, LocalFile$, RemoteFile$)
Procedure$ NextCloud_CreateShareLink(URL$, Username$, Password$, RemoteFile$, SharePassword$=#Null$)
Procedure.i NextCloud_CopyFile(URL$, Username$, Password$, RemoteSource$, RemoteDestination$, OverwriteIfExists.i=#False)
And a demo.

Re: libcurl.pbi

Posted: Sat Dec 03, 2022 12:09 pm
by Joubarbe
Thank you for that! The NextCloud library is definitely interesting for me!

Re: libcurl.pbi

Posted: Sun Dec 04, 2022 11:04 am
by infratec
I added new procedures to NextCloud.pbi:

Code: Select all

Procedure.i NextCloud_GetShares(URL$, Username$, Password$, List ShareList$())
Procedure.i NextCloud_FileExists(URL$, Username$, Password$, File$)
Procedure.i NextCloud_CreateFolder(URL$, Username$, Password$, Path$)
Procedure.i NextCloud_UploadMemoryToFile(URL$, Username$, Password$, *Memory, Size.i, RemoteFile$)
Procedure.i NextCloud_UploadFile(URL$, Username$, Password$, LocalFile$, RemoteFile$)
Procedure.i NextCloud_DeleteFileOrFolder(URL$, Username$, Password$, File$)
Procedure.i NextCloud_DownloadFile(URL$, Username$, Password$, FileToDownload$, TargetFile$)
Procedure.s NextCloud_CreateShareLink(URL$, Username$, Password$, RemoteFile$, SharePassword$=#Null$)
Procedure.i NextCloud_CopyFile(URL$, Username$, Password$, RemoteSource$, RemoteDestination$, OverwriteIfExists.i=#False)
NextCloud_UploadFile() reads now from the file and don't need additional RAM.
I did this, because uploading a DVD file is to large for the internal RAM.
But I added NextCloud_UploadMemoryToFile() where you can directly upload *Memory to a file.

I also changed the name of the 2 callback procedures to reflect the CURL_OPTION parameter names.

Re: libcurl.pbi

Posted: Mon Dec 05, 2022 10:14 am
by infratec
Changed NextCloud.pbi a bit:

Code: Select all

Procedure.i NextCloud_GetShares(URL$, Username$, Password$, List ShareList$())
Procedure.i NextCloud_ExistsFileOrFolder(URL$, Username$, Password$, File$)
Procedure.i NextCloud_CreateFolder(URL$, Username$, Password$, Path$)
Procedure.i NextCloud_UploadMemoryToFile(URL$, Username$, Password$, *Memory, Size.i, RemoteFile$)
Procedure.i NextCloud_UploadFile(URL$, Username$, Password$, LocalFile$, RemoteFile$)
Procedure.i NextCloud_DeleteFileOrFolder(URL$, Username$, Password$, File$)
Procedure.i NextCloud_DownloadFile(URL$, Username$, Password$, FileToDownload$, TargetFile$)
Procedure.s NextCloud_CreateShareLink(URL$, Username$, Password$, RemoteFile$, SharePassword$=#Null$)
Procedure.i NextCloud_CopyFile(URL$, Username$, Password$, RemoteSource$, RemoteDestination$, OverwriteIfExists.i=#False)
I also extended the Demo at the end of the code.

Re: libcurl.pbi

Posted: Tue Dec 06, 2022 8:56 pm
by infratec
I forgot to add curl_mime_name() :oops:
This is fixed now. It is needed for multipart forms.

To show an example I added PaperlessNgx.pbi:

Code: Select all

Procedure.i PaperlessNgx_UploadFile(URL$, Username$, Password$, File$, List TagList.PaperlessNgx_IdNameResultList_Structure(), *Correspondent.PaperlessNgx_IdNameResultList_Structure=#Null, *DocumentType.PaperlessNgx_IdNameResultList_Structure=#Null)

Re: libcurl.pbi

Posted: Sat Dec 17, 2022 10:03 am
by loulou2522
HI infratec
The link in first page isn't good or downloading libcurl.zip , it retrun on a dog site. Can you see. THanks

Re: libcurl.pbi

Posted: Sat Dec 17, 2022 1:40 pm
by infratec
Ups... was a problem of capital letters.
I fixed the link above.

Re: libcurl.pbi

Posted: Sat Dec 17, 2022 7:39 pm
by loulou2522
Thanks Unfratec,
That's work well for downloading. I will try now with example

Re: libcurl.pbi

Posted: Thu Dec 22, 2022 10:02 am
by loulou2522
Hello infratec,
I use you outlookemail.pb and i want to embed an image in the text of the mail . How can i proramm it ?
Thanks in advance

Re: libcurl.pbi

Posted: Thu Dec 22, 2022 3:18 pm
by infratec
1. This question is not libcurl related.
2. I don't use outlook, so I can test nothing.

Write an e-mail in outlook with embedded picture, send it to yourself and inspect the source code of the e-mail.

Maybe this is also useful:
https://stackoverflow.com/questions/670 ... html-email

But it looks that outlook does not accept inline Base64 images (which is the easiest way).
So you need the cid way with additional boundary and the binary image.
And even then outlook may not show it depending if the sender is trusted or not.

Re: libcurl.pbi

Posted: Thu Dec 22, 2022 5:02 pm
by loulou2522
In fact i don't use outlook to send mail i use my own provider free.fr and curlib but i have modify your outlook.mb like following
#MailServer = "smtp.free.fr:587"

#FROM = "<xxxx@free.fr>"
#To = "<xxx@sxxxxxx>"

#SMTP_User = "xxx@free.fr"
#SMTP_Password = "xxxxx"
I can send outline attachements with
*part = curl_mime_addpart(*mime)
curl_mime_filedata(*part, "index.php")