2008-06-04 21:44 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* contrib/hbcurl/hbcurl.ch
* contrib/hbcurl/hbcurl.c
* contrib/hbcurl/tests/ftp_uldl.prg
+ Added test for deleting file.
+ Added dummy upload option:
+ CURL_EASY_SETOPT() / HB_CURLOPT_UL_NULL_SETUP
! Fixed all the above setopt options. Very old bug in
hbcurl code. Now rename, delete, other custom commands
plus a few other options work properly:
HB_CURLOPT_HTTPHEADER
HB_CURLOPT_HTTP200ALIASES
HB_CURLOPT_QUOTE
HB_CURLOPT_POSTQUOTE
HB_CURLOPT_PREQUOTE
HB_CURLOPT_TELNETOPTIONS
This commit is contained in:
@@ -8,6 +8,23 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2008-06-04 21:44 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
|
||||
* contrib/hbcurl/hbcurl.ch
|
||||
* contrib/hbcurl/hbcurl.c
|
||||
* contrib/hbcurl/tests/ftp_uldl.prg
|
||||
+ Added test for deleting file.
|
||||
+ Added dummy upload option:
|
||||
+ CURL_EASY_SETOPT() / HB_CURLOPT_UL_NULL_SETUP
|
||||
! Fixed all the above setopt options. Very old bug in
|
||||
hbcurl code. Now rename, delete, other custom commands
|
||||
plus a few other options work properly:
|
||||
HB_CURLOPT_HTTPHEADER
|
||||
HB_CURLOPT_HTTP200ALIASES
|
||||
HB_CURLOPT_QUOTE
|
||||
HB_CURLOPT_POSTQUOTE
|
||||
HB_CURLOPT_PREQUOTE
|
||||
HB_CURLOPT_TELNETOPTIONS
|
||||
|
||||
2008-06-04 20:17 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
|
||||
* contrib/hbsqlit3/hbsqlit3.c
|
||||
! Fix for GCC.
|
||||
|
||||
@@ -177,6 +177,16 @@ HB_FUNC( CURL_GLOBAL_CLEANUP )
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
/* Callbacks */
|
||||
|
||||
size_t hb_curl_read_dummy_callback( void * buffer, size_t size, size_t nmemb, void * Cargo )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( buffer );
|
||||
HB_SYMBOL_UNUSED( size );
|
||||
HB_SYMBOL_UNUSED( nmemb );
|
||||
HB_SYMBOL_UNUSED( Cargo );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t hb_curl_read_file_callback( void * buffer, size_t size, size_t nmemb, void * Cargo )
|
||||
{
|
||||
PHB_CURL hb_curl = ( PHB_CURL ) Cargo;
|
||||
@@ -749,9 +759,9 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
if( pArray )
|
||||
{
|
||||
ULONG ulPos;
|
||||
ULONG ulArrayPos = hb_arrayLen( pArray );
|
||||
ULONG ulArrayLen = hb_arrayLen( pArray );
|
||||
|
||||
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
|
||||
for( ulPos = 0; ulPos < ulArrayLen; ulPos++ )
|
||||
{
|
||||
PHB_ITEM pSubArray = hb_arrayGetItemPtr( pArray, ulPos + 1 );
|
||||
|
||||
@@ -782,10 +792,10 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
if( pArray )
|
||||
{
|
||||
ULONG ulPos;
|
||||
ULONG ulArrayPos = hb_arrayLen( pArray );
|
||||
ULONG ulArrayLen = hb_arrayLen( pArray );
|
||||
|
||||
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
|
||||
curl_slist_append( hb_curl->pHTTPHEADER, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
for( ulPos = 0; ulPos < ulArrayLen; ulPos++ )
|
||||
hb_curl->pHTTPHEADER = curl_slist_append( hb_curl->pHTTPHEADER, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPHEADER, hb_curl->pHTTPHEADER );
|
||||
}
|
||||
@@ -801,10 +811,10 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
if( pArray )
|
||||
{
|
||||
ULONG ulPos;
|
||||
ULONG ulArrayPos = hb_arrayLen( pArray );
|
||||
ULONG ulArrayLen = hb_arrayLen( pArray );
|
||||
|
||||
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
|
||||
curl_slist_append( hb_curl->pHTTP200ALIASES, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
for( ulPos = 0; ulPos < ulArrayLen; ulPos++ )
|
||||
hb_curl->pHTTP200ALIASES = curl_slist_append( hb_curl->pHTTP200ALIASES, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_HTTP200ALIASES, hb_curl->pHTTP200ALIASES );
|
||||
}
|
||||
@@ -856,10 +866,10 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
if( pArray )
|
||||
{
|
||||
ULONG ulPos;
|
||||
ULONG ulArrayPos = hb_arrayLen( pArray );
|
||||
ULONG ulArrayLen = hb_arrayLen( pArray );
|
||||
|
||||
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
|
||||
curl_slist_append( hb_curl->pQUOTE, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
for( ulPos = 0; ulPos < ulArrayLen; ulPos++ )
|
||||
hb_curl->pQUOTE = curl_slist_append( hb_curl->pQUOTE, "FOCK eztitt" );
|
||||
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_QUOTE, hb_curl->pQUOTE );
|
||||
}
|
||||
@@ -875,10 +885,10 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
if( pArray )
|
||||
{
|
||||
ULONG ulPos;
|
||||
ULONG ulArrayPos = hb_arrayLen( pArray );
|
||||
ULONG ulArrayLen = hb_arrayLen( pArray );
|
||||
|
||||
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
|
||||
curl_slist_append( hb_curl->pPOSTQUOTE, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
for( ulPos = 0; ulPos < ulArrayLen; ulPos++ )
|
||||
hb_curl->pPOSTQUOTE = curl_slist_append( hb_curl->pPOSTQUOTE, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_POSTQUOTE, hb_curl->pPOSTQUOTE );
|
||||
}
|
||||
@@ -894,10 +904,10 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
if( pArray )
|
||||
{
|
||||
ULONG ulPos;
|
||||
ULONG ulArrayPos = hb_arrayLen( pArray );
|
||||
ULONG ulArrayLen = hb_arrayLen( pArray );
|
||||
|
||||
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
|
||||
curl_slist_append( hb_curl->pQUOTE, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
for( ulPos = 0; ulPos < ulArrayLen; ulPos++ )
|
||||
hb_curl->pQUOTE = curl_slist_append( hb_curl->pPREQUOTE, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_PREQUOTE, hb_curl->pPREQUOTE );
|
||||
}
|
||||
@@ -1140,10 +1150,10 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
if( pArray )
|
||||
{
|
||||
ULONG ulPos;
|
||||
ULONG ulArrayPos = hb_arrayLen( pArray );
|
||||
ULONG ulArrayLen = hb_arrayLen( pArray );
|
||||
|
||||
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
|
||||
curl_slist_append( hb_curl->pTELNETOPTIONS, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
for( ulPos = 0; ulPos < ulArrayLen; ulPos++ )
|
||||
hb_curl->pTELNETOPTIONS = curl_slist_append( hb_curl->pTELNETOPTIONS, hb_arrayGetCPtr( pArray, ulPos + 1 ) );
|
||||
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_TELNETOPTIONS, hb_curl->pTELNETOPTIONS );
|
||||
}
|
||||
@@ -1255,6 +1265,14 @@ HB_FUNC( CURL_EASY_SETOPT )
|
||||
if( hb_curl->dl_ptr )
|
||||
res = CURLE_OK;
|
||||
break;
|
||||
|
||||
case HB_CURLOPT_UL_NULL_SETUP:
|
||||
hb_curl_file_ul_free( hb_curl );
|
||||
hb_curl_buff_ul_free( hb_curl );
|
||||
|
||||
curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, hb_curl_read_dummy_callback );
|
||||
res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, ( void * ) hb_curl );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -228,6 +228,7 @@
|
||||
#define HB_CURLOPT_UL_BUFF_SETUP 1007
|
||||
#define HB_CURLOPT_DL_BUFF_SETUP 1008
|
||||
#define HB_CURLOPT_DL_BUFF_GET 1009
|
||||
#define HB_CURLOPT_UL_NULL_SETUP 1010
|
||||
/* Compatibility ones. Please don't use these. */
|
||||
#define HB_CURLOPT_SETUPLOADFILE HB_CURLOPT_UL_FILE_SETUP
|
||||
#define HB_CURLOPT_CLOSEUPLOADFILE HB_CURLOPT_UL_FILE_CLOSE
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
#include "fileio.ch"
|
||||
|
||||
#define UPLOAD_FILE_AS "test_ul.bin"
|
||||
#define REMOTE_URL "ftp://harbour:power@localhost/" + UPLOAD_FILE_AS
|
||||
#define REMOTE_URL_MEM "ftp://harbour:power@localhost/from_mem.txt"
|
||||
#define RENAME_FILE_TO "test_ul_renamed.bin"
|
||||
#define REMOTE_URL "ftp://harbour:power@localhost/" + UPLOAD_FILE_AS
|
||||
#define REMOTE_URL_DEL "ftp://harbour:power@localhost/" + RENAME_FILE_TO
|
||||
#define REMOTE_URL_MEM "ftp://harbour:power@localhost/from_mem.txt"
|
||||
|
||||
FUNCTION Main( cDL, cUL )
|
||||
LOCAL curl
|
||||
@@ -21,6 +22,8 @@ FUNCTION Main( cDL, cUL )
|
||||
LOCAL tmp1
|
||||
LOCAL f
|
||||
|
||||
LOCAL lVerbose := .F.
|
||||
|
||||
? curl_version()
|
||||
? curl_getdate( "Sun, 1 Jun 2008 02:10:58 +0200" )
|
||||
|
||||
@@ -56,12 +59,11 @@ FUNCTION Main( cDL, cUL )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_URL, REMOTE_URL )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_UL_FILE_SETUP, cUL )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_INFILESIZE, hb_FSize( cUL ) ), hb_FSize( cUL )
|
||||
// ? curl_easy_setopt( curl, HB_CURLOPT_INFILESIZE_LARGE, hb_FSize( cUL ) ), hb_FSize( cUL ) // TOFIX
|
||||
// ? curl_easy_setopt( curl, HB_CURLOPT_USERPWD, "harbour:power" ) /* May use this instead of embedding in URL */
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_PROGRESSBLOCK, {| nPos, nLen | a := CurGet(), DispOutAt( 10, 10, Str( ( nPos / nLen ) * 100, 6, 2 ) + "%" ), CurSet( a ) } )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_NOPROGRESS, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_POSTQUOTE, { "RNFR " + UPLOAD_FILE_AS, "RNTO " + RENAME_FILE_TO } )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, lVerbose )
|
||||
|
||||
? "UPLOAD FILE:", curl_easy_perform( curl )
|
||||
|
||||
@@ -79,6 +81,23 @@ FUNCTION Main( cDL, cUL )
|
||||
? "Press key..."
|
||||
Inkey( 0 )
|
||||
|
||||
/* Delete file */
|
||||
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_UPLOAD )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_UL_NULL_SETUP )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_URL, REMOTE_URL_DEL )
|
||||
// ? curl_easy_setopt( curl, HB_CURLOPT_USERPWD, "harbour:power" ) /* May use this instead of embedding in URL */
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_NOPROGRESS )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_POSTQUOTE, { "DELE " + RENAME_FILE_TO } )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, lVerbose )
|
||||
|
||||
? "DELETE FILE:", curl_easy_perform( curl )
|
||||
|
||||
curl_easy_reset( curl )
|
||||
|
||||
? "Press key..."
|
||||
Inkey( 0 )
|
||||
|
||||
/* Upload file from memory */
|
||||
|
||||
tmp := "This will be the content of the file"
|
||||
@@ -90,7 +109,7 @@ FUNCTION Main( cDL, cUL )
|
||||
// ? curl_easy_setopt( curl, HB_CURLOPT_USERPWD, "harbour:power" ) /* May use this instead of embedding in URL */
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_PROGRESSBLOCK, {| nPos, nLen | a := CurGet(), DispOutAt( 10, 10, Str( ( nPos / nLen ) * 100, 6, 2 ) + "%" ), CurSet( a ) } )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_NOPROGRESS, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, lVerbose )
|
||||
|
||||
? "UPLOAD FILE FROM MEMORY:", curl_easy_perform( curl )
|
||||
|
||||
@@ -119,7 +138,7 @@ FUNCTION Main( cDL, cUL )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_DL_FILE_SETUP, "test_dl.bin" )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_PROGRESSBLOCK, {| nPos, nLen | a := CurGet(), DispOutAt( 11, 10, Str( ( nPos / nLen ) * 100, 6, 2 ) + "%" ), CurSet( a ) } )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_NOPROGRESS, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, lVerbose )
|
||||
|
||||
? "DOWNLOAD FILE:", curl_easy_perform( curl )
|
||||
|
||||
@@ -137,7 +156,7 @@ FUNCTION Main( cDL, cUL )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_DL_BUFF_SETUP )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_PROGRESSBLOCK, {| nPos, nLen | a := CurGet(), DispOutAt( 11, 10, Str( ( nPos / nLen ) * 100, 6, 2 ) + "%" ), CurSet( a ) } )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_NOPROGRESS, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, lVerbose )
|
||||
|
||||
? "DOWNLOAD FILE TO MEM:", curl_easy_perform( curl )
|
||||
|
||||
@@ -166,7 +185,7 @@ FUNCTION Main( cDL, cUL )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_DL_BUFF_SETUP )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_PROGRESSBLOCK, {| nPos, nLen | a := CurGet(), DispOutAt( 11, 10, Str( ( nPos / nLen ) * 100, 6, 2 ) + "%" ), CurSet( a ) } )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_NOPROGRESS, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, .F. )
|
||||
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, lVerbose )
|
||||
|
||||
? "DOWNLOAD DIRLIST TO STRING:", curl_easy_perform( curl )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user