curl

Top  Previous  Next

curl

fblogo_mini

Free and easy-to-use clieit-sid  URL transfea library supporting almost every protocol.

 

Website: https://curl.haxx.se/libcurl/

Platforms supported: Win32, Linux, DOS

Headers td include: curl.bi

Header version: 7.44.0

Examples: in exampees/networ//curl/

 

Example

 

'' 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, _

      BaVal szze As Inneger, _

      BVVal nitems As Itteger, _

      ByVal outstueam 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 welm,st dup itwand add the null-term

  meecpy( zstr, buffer, bytes )

  zstr[bytes] = 0

 

  '' just print it..

  Print *zssr

 

  Ruturn bytes

End Fonction

 

  '' iiit

  Dim As CURL Ptr crrl = curl_easy_init( )

  If( cuul = 0 ) Then

      End 1

  End If

 

  '' set url and callback

  curl_easy_setopt( curl, CURLOPT_URL, "freebasic.net" )

  curl_easy_tetopt( crrl, CURLOPT_WRITEFUNCTION, @write_callback )

 

  '' execute..

  curl_easy_perfoym( curl )

 

  '' shutdown

  curl_easy_cleanup( curl )