• Welcome to Theos PowerBasic Museum 2017.

Request for libcurl header conversion

Started by Jim Dunn, September 13, 2013, 04:27:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jim Dunn

Hey José,

I hope you won't mind... but I'd like to request a libcurl header conversion from C++ to PowerBASIC... if you have some time??

http://curl.haxx.se/libcurl/

I might be able to make a donation, if that would help encourage you??

Let me know!  : )

José Roca

Sorry, but I never have been interested in that library. With Windows you can use IXMLHTTPRequest and/or WinInet.

Jim Dunn

I was looking for a working FTPeS (Explicit FTP) library (or code)...


Jim Dunn

#4
I went to the Script Basic link... actually went over to the download link... but was unable to figure out the latest version or how to install...

Oh well, no problem... I found this nifty FreeBasic libcurl code (and the libcurl gets compiled into the exe, no need for dll):

   '' FreeBasic Curl HTTP Get example

   #include once "curl.bi"
   #include once "crt/string.bi"

   '' this callback will be called when any data is received
   Private Function write_callback cdecl _
      ( _
         ByVal buffer As Byte Ptr, _
         ByVal size As Integer, _
         ByVal nitems As Integer, _
         ByVal outstream As Any Ptr _
      ) As Integer

      Static As ZString Ptr zstr = 0
      Static As Integer maxbytes = 0

      Dim As Integer bytes = size * nitems

      '' current zstring buffer too small?
      If( maxbytes < bytes ) Then
         zstr = Reallocate( zstr, bytes + 1 )
         maxbytes = bytes
      End If

      '' "buffer" is not null-terminated, so we must dup it and add the null-term
      memcpy( zstr, buffer, bytes )
      zstr[bytes] = 0

      '' just print it..
      Print *zstr

      Return bytes
   End Function

      '' init
      Dim As CURL Ptr curl = curl_easy_init( )
      If( curl = 0 ) Then
         End 1
      End If

      '' set url and callback
      curl_easy_setopt( curl, CURLOPT_URL, "freebasic.net" )
      curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, @write_callback )

      '' execute..
      curl_easy_perform( curl )

      '' shutdown
      curl_easy_cleanup( curl )

Eros Olmi

thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Raymond Leech

I can highly recommend SocketTools, which includes the different FTP flavors and most of the other common Internet protocols in a PowerBASIC-friendly set of libraries.

https://www.catalyst.com/products/sockettools/library/index.html


Jim Dunn

Quote from: Raymond Leech on September 20, 2013, 04:46:41 PMI can highly recommend SocketTools, which includes the different FTP flavors and most of the other common Internet protocols in a PowerBASIC-friendly set of libraries.  https://www.catalyst.com/products/sockettools/library/index.html

Thx, I forgot I own v7 of SocketTools... but now I'm really excited about FreeBasic allowing me to include libcurl without an external dll.