From b9fa2c3ef9d39de6fbb1dff57b4852772cc9e22e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 4 Jun 2008 15:36:06 +0000 Subject: [PATCH] 2008-06-04 17:32 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/hbcurl/hbcurl.c * Changed all logical options to default to .T.. This way all work the same way, and in real life usage the logical parameter can omitted in most cases. INCOMPATIBLE. * contrib/hbcurl/tests/ftp_uldl.prg + Added small example to get a dir listing. --- harbour/ChangeLog | 10 ++++++++++ harbour/contrib/hbcurl/hbcurl.c | 7 +++---- harbour/contrib/hbcurl/tests/ftp_uldl.prg | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 379479cb33..f9e78c0528 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-04 17:32 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * contrib/hbcurl/hbcurl.c + * Changed all logical options to default to .T.. This + way all work the same way, and in real life usage + the logical parameter can omitted in most cases. + INCOMPATIBLE. + + * contrib/hbcurl/tests/ftp_uldl.prg + + Added small example to get a dir listing. + 2008-06-04 17:21 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/hbcurl/hbcurl.c + Changed to use hb_parc() (instead of hb_parcx()) for all diff --git a/harbour/contrib/hbcurl/hbcurl.c b/harbour/contrib/hbcurl/hbcurl.c index 29f2bde0eb..0a8d350243 100644 --- a/harbour/contrib/hbcurl/hbcurl.c +++ b/harbour/contrib/hbcurl/hbcurl.c @@ -69,8 +69,7 @@ #include "hbcurl.ch" -#define HB_CURL_OPT_BOOL( n ) ( ISLOG( n ) ? ( long ) hb_parl( n ) : hb_parnl( n ) ) -#define HB_CURL_OPT_BOOL_TRUE( n ) ( ISLOG( n ) ? ( long ) hb_parl( n ) : ( ISNUM( n ) ? hb_parnl( n ) : 1 ) ) +#define HB_CURL_OPT_BOOL( n ) ( ISLOG( n ) ? ( long ) hb_parl( n ) : ( ISNUM( n ) ? hb_parnl( n ) : 1 ) ) #define HB_CURL_OPT_LARGENUM( n ) ( ( curl_off_t ) hb_parnint( n ) ) /* NOTE: Since LIBCURL_VERSION_NUM doesn't reflect real revision, @@ -898,10 +897,10 @@ HB_FUNC( CURL_EASY_SETOPT ) res = curl_easy_setopt( hb_curl->curl, CURLOPT_INFILESIZE_LARGE, HB_CURL_OPT_LARGENUM( 3 ) ); break; case HB_CURLOPT_UPLOAD: - res = curl_easy_setopt( hb_curl->curl, CURLOPT_UPLOAD, HB_CURL_OPT_BOOL_TRUE( 3 ) ); + res = curl_easy_setopt( hb_curl->curl, CURLOPT_UPLOAD, HB_CURL_OPT_BOOL( 3 ) ); break; case HB_CURLOPT_DOWNLOAD: /* Harbour extension */ - res = curl_easy_setopt( hb_curl->curl, CURLOPT_UPLOAD, ! HB_CURL_OPT_BOOL_TRUE( 3 ) ); + res = curl_easy_setopt( hb_curl->curl, CURLOPT_UPLOAD, ! HB_CURL_OPT_BOOL( 3 ) ); break; case HB_CURLOPT_MAXFILESIZE: res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAXFILESIZE, hb_parnl( 3 ) ); diff --git a/harbour/contrib/hbcurl/tests/ftp_uldl.prg b/harbour/contrib/hbcurl/tests/ftp_uldl.prg index a02760e86d..2be89662fd 100644 --- a/harbour/contrib/hbcurl/tests/ftp_uldl.prg +++ b/harbour/contrib/hbcurl/tests/ftp_uldl.prg @@ -88,6 +88,26 @@ FUNCTION Main( cDL, cUL ) ? "DOWNLOAD:", curl_easy_perform( curl ) + curl_easy_reset( curl ) + + Inkey( 0 ) + + DEFAULT cDL TO "ftp://ftp.cisco.com/" + + /* Now let's download a dirlist */ + + ? curl_easy_setopt( curl, HB_CURLOPT_DOWNLOAD ) + ? curl_easy_setopt( curl, HB_CURLOPT_DIRLISTONLY ) + ? curl_easy_setopt( curl, HB_CURLOPT_URL, cDL ) + ? curl_easy_setopt( curl, HB_CURLOPT_SSL_VERIFYPEER, .F. ) + ? curl_easy_setopt( curl, HB_CURLOPT_SSL_VERIFYHOST, .F. ) + ? curl_easy_setopt( curl, HB_CURLOPT_SETDOWNLOADFILE, "test_in.txt" ) + ? curl_easy_setopt( curl, HB_CURLOPT_SETPROGRESS, {| 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. ) + + ? "DOWNLOAD:", curl_easy_perform( curl ) + /* Cleanup session */ curl_easy_cleanup( curl )