Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@
RETURN
With above peace of code you can mix HBQT or other QT wrapper with GTQTC.

2022-05-03 08:45 UTC+0200 Antonino Perricone
* contrib\hbcurl\hbcurl.ch
* contrib\hbcurl\core.c
+ added HB_CURLOPT_MAXLIFETIME_CONN to setup max lifetime of connection
see https://curl.se/libcurl/c/CURLOPT_MAXLIFETIME_CONN.html for more
information.

2022-05-02 08:38 UTC+0200 Antonino Perricone
* contrib\hbcurl\core.c
+ added HB_CURLOPT_DEBUGBLOCK to setup a block for debug information
It takes a callback in the form of {|type, msg| ... }
see https://curl.se/libcurl/c/CURLOPT_DEBUGFUNCTION.html for more
information.
* contrib\hbcurl\hbcurl.ch
+ added HB_CURLINFOTYPE_* macros for debug block

2021-04-28 20:02 UTC+0200 Aleksander Czajczynski (hb fki.pl)
* include/hbgtinfo.ch
! fixed comment, Alt+Numpad HB_GTI_KBDALT workaround was disabled by
Expand Down
61 changes: 61 additions & 0 deletions contrib/hbcurl/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ typedef struct _HB_CURL
size_t dl_pos;

PHB_ITEM pProgressCallback;
PHB_ITEM pDebugCallback;

PHB_HASH_TABLE pHash;

Expand Down Expand Up @@ -407,6 +408,27 @@ static int hb_curl_progress_callback( void * Cargo, double dltotal, double dlnow
return 0;
}

static int hb_curl_debug_callback(CURL *handle, curl_infotype type, char *data, size_t size, void *Cargo)
{
HB_SYMBOL_UNUSED( handle );
if( Cargo )
{
PHB_CURL hb_curl = ( PHB_CURL ) Cargo;
if( hb_curl->pDebugCallback && hb_vmRequestReenter() )
{
hb_vmPushEvalSym();
hb_vmPush( hb_curl->pDebugCallback );
hb_vmPushInteger( type );
hb_vmPushStringPcode( data, size);
hb_vmSend( 2 );

hb_vmRequestRestore();
}
}

return 0;
}

/* Helpers */
/* ------- */

Expand Down Expand Up @@ -527,6 +549,12 @@ static void PHB_CURL_free( PHB_CURL hb_curl, HB_BOOL bFree )
hb_curl->pProgressCallback = NULL;
}

if( hb_curl->pDebugCallback )
{
hb_itemRelease( hb_curl->pDebugCallback );
hb_curl->pDebugCallback = NULL;
}

if( hb_curl->pHash )
{
hb_hashTableKill( hb_curl->pHash );
Expand Down Expand Up @@ -587,6 +615,9 @@ static HB_GARBAGE_FUNC( PHB_CURL_mark )

if( hb_curl->pProgressCallback )
hb_gcMark( hb_curl->pProgressCallback );

if( hb_curl->pDebugCallback )
hb_gcMark( hb_curl->pDebugCallback );
}
}

Expand Down Expand Up @@ -1752,6 +1783,36 @@ HB_FUNC( CURL_EASY_SETOPT )
curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, hb_curl_read_dummy_callback );
res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, hb_curl );
break;

case HB_CURLOPT_DEBUGBLOCK:
{
PHB_ITEM pDebugCallback = hb_param( 3, HB_IT_BLOCK | HB_IT_SYMBOL );

if( hb_curl->pDebugCallback )
{
curl_easy_setopt( hb_curl->curl, CURLOPT_DEBUGFUNCTION, NULL );
curl_easy_setopt( hb_curl->curl, CURLOPT_DEBUGDATA, NULL );

hb_itemRelease( hb_curl->pDebugCallback );
hb_curl->pDebugCallback = NULL;
}

if( pDebugCallback )
{
hb_curl->pDebugCallback = hb_itemNew( pDebugCallback );
/* unlock the item so GC will not mark them as used */
hb_gcUnlock( hb_curl->pDebugCallback );

curl_easy_setopt( hb_curl->curl, CURLOPT_DEBUGFUNCTION, hb_curl_debug_callback );
res = curl_easy_setopt( hb_curl->curl, CURLOPT_DEBUGDATA, hb_curl);
}
}
break;

case HB_CURLOPT_MAXLIFETIME_CONN:
res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAXLIFETIME_CONN, hb_parnl( 3 ) );
break;

}
}

Expand Down
2 changes: 2 additions & 0 deletions contrib/hbcurl/hbcurl.ch
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
#define HB_CURLOPT_TCP_KEEPIDLE 205
#define HB_CURLOPT_TCP_KEEPINTVL 206
#define HB_CURLOPT_MAIL_AUTH 207
#define HB_CURLOPT_MAXLIFETIME_CONN 208
#define HB_CURLOPT_DOWNLOAD 1001 /* Harbour special ones */
#define HB_CURLOPT_PROGRESSBLOCK 1002
#define HB_CURLOPT_UL_FILE_SETUP 1003
Expand All @@ -265,6 +266,7 @@
#define HB_CURLOPT_UL_NULL_SETUP 1010
#define HB_CURLOPT_UL_FHANDLE_SETUP 1011
#define HB_CURLOPT_DL_FHANDLE_SETUP 1012
#define HB_CURLOPT_DEBUGBLOCK 1013
/* 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
Expand Down