diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ddc82680ec..06a557c88b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,44 @@ The license applies to all entries newer than 2009-04-28. */ +2011-04-21 01:00 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbmxml/3rd/minixml/mxml.hbp + * contrib/hbmxml/3rd/minixml/mxml_str.c + ! Fixed isdigit() warning which was result of missing + mxml header. [Tamas Tevesz] + + + contrib/hbcurl/hbcurlt1.ch + + contrib/hbcurl/core_t1.c + + Implemented new way of using HB_CURLOPT_HTTPPOST, now + all meaningful values are supported in any order and + combination. See: + http://curl.haxx.se/libcurl/c/curl_formadd.html + The patch is heavily based on patch/implementation submitted + by Benjamin Jacobs, many thanks for it. Final patch + includes some rework, simplification, compile and + other fixes, plus formatting with uncrustify. Please + make sure to test/review this version as I didn't do + any functional tests, just build ones. + Sample code: + curl_easy_setopt( curl, HB_CURLOPT_HTTPPOST, { ; + { HB_CURLFORM_COPYNAME, "nparam1", ; + HB_CURLFORM_COPYCONTENTS, "value1" }, ; + { HB_CURLFORM_COPYNAME, "nparam2", ; + HB_CURLFORM_COPYCONTENTS, "value" }, ; + { HB_CURLFORM_COPYNAME, "fileparam", ; + HB_CURLFORM_FILE, filename } } ) + WARNING: This implementation is INCOMPATIBLE with the + previous one. + TOFIX: Current implementation does allow to create GPFs because + it allows .prg code manually pass buffer sizes. This must + be fixed and buffer length should always be automatically + taken from Harbour item. This will require more sophisticated + code to build the low-level array (f.e. size calculation). + Benjamin, can you look at it? + NOTE: I'm uploading this unfinished code as new temp files, + because SVN doesn't support light branching, so this poor man's + solution is left to manage it. + 2011-04-20 21:05 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbmxml/3rd/minixml/mxml.hbp * contrib/hbmxml/3rd/minixml/config.h @@ -40,7 +78,7 @@ At last! 2011-04-20 17:55 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) - * contrib/hbmxml/3rd/minixml/config.h + * contrib/hbmxml/3rd/minixml/mxml.hbp * -> -std=gnu89. Details in comment. * contrib/hbunix/hbunix.hbp diff --git a/harbour/contrib/hbcurl/core_t1.c b/harbour/contrib/hbcurl/core_t1.c new file mode 100644 index 0000000000..a3c7b1360b --- /dev/null +++ b/harbour/contrib/hbcurl/core_t1.c @@ -0,0 +1,2301 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * libcurl 'easy' API - Harbour interface. + * + * Copyright 2008-2010 Viktor Szakats (harbour.01 syenar.hu) + * originally based on: + * Copyright 2005 Luiz Rafael Culik Guimaraes + * www - http://harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include +#include +#include + +#include "hbapi.h" +#include "hbapiitm.h" +#include "hbapierr.h" +#include "hbapifs.h" +#include "hbvm.h" +#include "hbhash.h" + +#include "hbcurl.ch" + +#define HB_CURL_OPT_BOOL( n ) ( HB_ISLOG( n ) ? ( long ) hb_parl( n ) : hb_parnldef( n, 1 ) ) +#define HB_CURL_OPT_LARGENUM( n ) ( ( curl_off_t ) hb_parnint( n ) ) + +/* NOTE: Harbour requires libcurl 7.17.0 or upper. + This was the version where curl_easy_setopt() started to + make copies of passed strings, which we currently require. + Update: This requirement is now sorted out by local string + buffering logic used with pre-7.17.0 versions of + libcurl. + [vszakats] */ + +#if LIBCURL_VERSION_NUM < 0x071100 +# ifndef HB_CURL_HASH_STRINGS +# define HB_CURL_HASH_STRINGS +# endif +#endif + +/* Fall back to return simple error if special abort signal is not available. */ +#if ! defined( CURL_READFUNC_ABORT ) /* Introduced in LIBCURL_VERSION_NUM >= 0x070C01 */ + #define CURL_READFUNC_ABORT ( ( size_t ) -1 ) +#endif + +typedef struct _HB_CURL +{ + CURL * curl; + + struct curl_httppost * pHTTPPOST_First; + struct curl_httppost * pHTTPPOST_Last; + struct curl_slist * pHTTPHEADER; + struct curl_slist * pHTTP200ALIASES; + struct curl_slist * pQUOTE; + struct curl_slist * pPOSTQUOTE; + struct curl_slist * pPREQUOTE; + struct curl_slist * pTELNETOPTIONS; + struct curl_slist * pMAIL_RCPT; + struct curl_slist * pRESOLVE; + struct curl_slist * pHTTPPOSTHEADERS; + + char * ul_name; + HB_FHANDLE ul_handle; + + char * dl_name; + HB_FHANDLE dl_handle; + + unsigned char * ul_ptr; + size_t ul_len; + size_t ul_pos; + + unsigned char * dl_ptr; + size_t dl_len; + size_t dl_pos; + + PHB_ITEM pProgressCallback; + + HB_HASH_TABLE_PTR pHash; + +} HB_CURL, * PHB_CURL; + + +/* functions to keep passed string values accessible even if HVM + * destroy them. It's necessary for old CURL versions which do not + * make own copy of passed strings + */ + +#ifdef HB_CURL_HASH_STRINGS + +#define HB_CURL_HASH_TABLE_SIZE 509UL + +/* returns a hash key */ +static HB_HASH_FUNC( hb_curl_HashKey ) /* HB_SIZE func( const void * Value, const void * Cargo ) */ +{ + HB_SIZE ulSum = 0; + const char * szName = ( const char * ) Value; + + while( *szName ) + ulSum += *szName++; + + HB_SYMBOL_UNUSED( HashPtr ); + HB_SYMBOL_UNUSED( Cargo ); + + return ulSum % HB_CURL_HASH_TABLE_SIZE; +} + +/* deletes a string */ +static HB_HASH_FUNC( hb_curl_HashDel ) +{ + hb_xfree( ( void * ) Value ); + HB_SYMBOL_UNUSED( HashPtr ); + HB_SYMBOL_UNUSED( Cargo ); + return 1; +} + +/* compares two strings */ +static HB_HASH_FUNC( hb_curl_HashCmp ) +{ + HB_SYMBOL_UNUSED( HashPtr ); + return strcmp( ( const char * ) Value, ( const char * ) Cargo ); +} + +static const char * hb_curl_StrHashNew( PHB_CURL hb_curl, const char * szValue ) +{ + char * szHash; + + if( ! hb_curl->pHash ) + hb_curl->pHash = hb_hashTableCreate( HB_CURL_HASH_TABLE_SIZE, + hb_curl_HashKey, hb_curl_HashDel, hb_curl_HashCmp ); + + szHash = ( char * ) hb_hashTableFind( hb_curl->pHash, szValue ); + if( ! szHash ) + { + szHash = hb_strdup( szValue ); + hb_hashTableAdd( hb_curl->pHash, szHash, szHash ); + } + return szHash; +} + +# define hb_curl_StrHash( c, s ) hb_curl_StrHashNew( (c), (s) ) + +#else + +# define hb_curl_StrHash( c, s ) (s) + +#endif /* HB_CURL_HASH_STRINGS */ + +/* ---------------------------------------------------------------------------- */ +/* Global initialization/deinitialization */ + +static void * hb_curl_xgrab( size_t size ) +{ + return hb_xgrab( size ); +} + +static void hb_curl_xfree( void * p ) +{ + hb_xfree( p ); +} + +static void * hb_curl_xrealloc( void * p, size_t size ) +{ + return hb_xrealloc( p, size ); +} + +static char * hb_curl_strdup( const char * s ) +{ + return hb_strdup( s ); +} + +static void * hb_curl_calloc( size_t nelem, size_t elsize ) +{ + size_t size = nelem * elsize; + void * ptr = hb_xgrab( size ); + + memset( ptr, '\0', size ); + + return ptr; +} + +HB_FUNC( CURL_GLOBAL_INIT ) +{ +#if LIBCURL_VERSION_NUM >= 0x070A08 /* Not documented. GUESS. */ + hb_retnl( ( long ) curl_global_init_mem( hb_parnldef( 1, CURL_GLOBAL_ALL ), + hb_curl_xgrab, + hb_curl_xfree, + hb_curl_xrealloc, + hb_curl_strdup, + hb_curl_calloc ) ); +#else + hb_retnl( ( long ) curl_global_init_mem( hb_parnldef( 1, CURL_GLOBAL_ALL ) ) ); +#endif +} + +HB_FUNC( CURL_GLOBAL_CLEANUP ) +{ + curl_global_cleanup(); +} + +/* ---------------------------------------------------------------------------- */ +/* Callbacks */ + +static 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; +} + +static size_t hb_curl_read_file_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +{ + PHB_CURL hb_curl = ( PHB_CURL ) Cargo; + + if( hb_curl ) + { + size_t ret; + + if( hb_curl->ul_handle == FS_ERROR ) + { + hb_curl->ul_handle = hb_fsOpen( hb_curl->ul_name, FO_READ ); + + if( hb_curl->ul_handle == FS_ERROR ) + return ( size_t ) -1; + } + + ret = ( size_t ) hb_fsReadLarge( hb_curl->ul_handle, buffer, size * nmemb ); + + return hb_fsError() ? CURL_READFUNC_ABORT : ret; + } + + return ( size_t ) -1; +} + +static size_t hb_curl_read_fhandle_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +{ + PHB_CURL hb_curl = ( PHB_CURL ) Cargo; + + if( hb_curl ) + { + size_t ret; + + if( hb_curl->ul_handle == FS_ERROR ) + return ( size_t ) -1; + + ret = ( size_t ) hb_fsReadLarge( hb_curl->ul_handle, buffer, size * nmemb ); + + return hb_fsError() ? CURL_READFUNC_ABORT : ret; + } + + return ( size_t ) -1; +} + +static size_t hb_curl_read_buff_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +{ + PHB_CURL hb_curl = ( PHB_CURL ) Cargo; + + if( hb_curl ) + { + size_t nTodo = size * nmemb; + size_t nLeft = hb_curl->ul_len - hb_curl->ul_pos; + + if( nTodo > nLeft ) + nTodo = nLeft; + + hb_xmemcpy( buffer, hb_curl->ul_ptr + hb_curl->ul_pos, nTodo ); + + hb_curl->ul_pos += nTodo; + + return nTodo; + } + + return ( size_t ) -1; +} + +static size_t hb_curl_write_file_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +{ + PHB_CURL hb_curl = ( PHB_CURL ) Cargo; + + if( hb_curl ) + { + if( hb_curl->dl_handle == FS_ERROR ) + { + hb_curl->dl_handle = hb_fsCreate( hb_curl->dl_name, FC_NORMAL ); + + if( hb_curl->dl_handle == FS_ERROR ) + return ( size_t ) -1; + } + + return hb_fsWriteLarge( hb_curl->dl_handle, buffer, size * nmemb ); + } + + return ( size_t ) -1; +} + +static size_t hb_curl_write_fhandle_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +{ + PHB_CURL hb_curl = ( PHB_CURL ) Cargo; + + if( hb_curl ) + { + if( hb_curl->dl_handle == FS_ERROR ) + return ( size_t ) -1; + + return hb_fsWriteLarge( hb_curl->dl_handle, buffer, size * nmemb ); + } + + return ( size_t ) -1; +} + +#define HB_CURL_DL_BUFF_SIZE_INIT ( CURL_MAX_WRITE_SIZE * 4 ) +#define HB_CURL_DL_BUFF_SIZE_INCR ( CURL_MAX_WRITE_SIZE * 4 ) + +static size_t hb_curl_write_buff_callback( void * buffer, size_t size, size_t nmemb, void * Cargo ) +{ + PHB_CURL hb_curl = ( PHB_CURL ) Cargo; + + if( hb_curl ) + { + size_t nTodo = size * nmemb; + size_t nLeft = hb_curl->dl_len - hb_curl->dl_pos; + + if( nTodo > nLeft ) + { + hb_curl->dl_len += HB_CURL_DL_BUFF_SIZE_INCR; + hb_curl->dl_ptr = ( unsigned char * ) hb_xrealloc( hb_curl->dl_ptr, hb_curl->dl_len ); + } + + hb_xmemcpy( hb_curl->dl_ptr + hb_curl->dl_pos, buffer, nTodo ); + + hb_curl->dl_pos += nTodo; + + return nTodo; + } + + return ( size_t ) -1; +} + +static int hb_curl_progress_callback( void * Cargo, double dltotal, double dlnow, double ultotal, double ulnow ) +{ + if( Cargo ) + { + if( hb_vmRequestReenter() ) + { + hb_vmPushEvalSym(); + hb_vmPush( ( PHB_ITEM ) Cargo ); + hb_vmPushDouble( ulnow > 0 ? ulnow : dlnow , HB_DEFAULT_DECIMALS ); + hb_vmPushDouble( ultotal > 0 ? ultotal : dltotal, HB_DEFAULT_DECIMALS ); + hb_vmSend( 2 ); + + if( hb_parl( -1 ) ) + return 1; /* Abort */ + + hb_vmRequestRestore(); + } + } + + return 0; +} + +/* ---------------------------------------------------------------------------- */ +/* Helpers */ + +static void hb_curl_form_free( struct curl_httppost ** ptr ) +{ + if( ptr && * ptr ) + { + curl_formfree( * ptr ); + * ptr = NULL; + } +} + +static void hb_curl_slist_free( struct curl_slist ** ptr ) +{ + if( ptr && * ptr ) + { + curl_slist_free_all( * ptr ); + * ptr = NULL; + } +} + +static void hb_curl_file_ul_free( PHB_CURL hb_curl ) +{ + if( hb_curl && hb_curl->ul_name ) + { + hb_xfree( hb_curl->ul_name ); + hb_curl->ul_name = NULL; + + if( hb_curl->ul_handle != FS_ERROR ) + { + hb_fsClose( hb_curl->ul_handle ); + hb_curl->ul_handle = FS_ERROR; + } + } +} + +static void hb_curl_file_dl_free( PHB_CURL hb_curl ) +{ + if( hb_curl && hb_curl->dl_name ) + { + hb_xfree( hb_curl->dl_name ); + hb_curl->dl_name = NULL; + + if( hb_curl->dl_handle != FS_ERROR ) + { + hb_fsClose( hb_curl->dl_handle ); + hb_curl->dl_handle = FS_ERROR; + } + } +} + +static void hb_curl_buff_ul_free( PHB_CURL hb_curl ) +{ + if( hb_curl && hb_curl->ul_ptr ) + { + hb_xfree( hb_curl->ul_ptr ); + hb_curl->ul_ptr = NULL; + hb_curl->ul_len = 0; + hb_curl->ul_pos = 0; + } +} + +static void hb_curl_buff_dl_free( PHB_CURL hb_curl ) +{ + if( hb_curl && hb_curl->dl_ptr ) + { + hb_xfree( hb_curl->dl_ptr ); + hb_curl->dl_ptr = NULL; + hb_curl->dl_len = 0; + hb_curl->dl_pos = 0; + } +} + +#define HB_CURL_FORMADD_TYPE_NOTSUP 0 +#define HB_CURL_FORMADD_TYPE_COPYSTRING 1 +#define HB_CURL_FORMADD_TYPE_STRING 2 +#define HB_CURL_FORMADD_TYPE_PTR 3 +#define HB_CURL_FORMADD_TYPE_LONG 4 +#define HB_CURL_FORMADD_TYPE_SLIST 5 + +static HB_BOOL hb_curl_formadd( PHB_CURL hb_curl, PHB_ITEM pArray ) +{ + HB_BOOL bSuccess = HB_FALSE; + + if( pArray && HB_IS_ARRAY( pArray ) ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + int i = 0; + + struct curl_forms * forms = ( struct curl_forms * ) hb_xgrab( sizeof( struct curl_forms ) * ( ulArrayLen + 1 ) ); + + for( ulPos = 0; ulPos < ulArrayLen; ulPos += 2, ++i ) + { + CURLformoption option = CURLFORM_NOTHING; + int type = HB_CURL_FORMADD_TYPE_NOTSUP; + + PHB_ITEM pOptValue = hb_arrayGetItemPtr( pArray, ulPos + 2 ); + + switch( hb_arrayGetNI( pArray, ulPos + 1 ) ) + { + case HB_CURLFORM_COPYNAME: option = CURLFORM_COPYNAME; type = HB_CURL_FORMADD_TYPE_COPYSTRING; break; + case HB_CURLFORM_PTRNAME: option = CURLFORM_PTRNAME; type = HB_CURL_FORMADD_TYPE_PTR; break; + case HB_CURLFORM_COPYCONTENTS: option = CURLFORM_COPYCONTENTS; type = HB_CURL_FORMADD_TYPE_COPYSTRING; break; + case HB_CURLFORM_PTRCONTENTS: option = CURLFORM_PTRCONTENTS; type = HB_CURL_FORMADD_TYPE_PTR; break; + case HB_CURLFORM_CONTENTSLENGTH: option = CURLFORM_CONTENTSLENGTH; type = HB_CURL_FORMADD_TYPE_LONG; break; + case HB_CURLFORM_FILECONTENT: option = CURLFORM_FILECONTENT; type = HB_CURL_FORMADD_TYPE_STRING; break; + case HB_CURLFORM_FILE: option = CURLFORM_FILE; type = HB_CURL_FORMADD_TYPE_STRING; break; + case HB_CURLFORM_BUFFER: option = CURLFORM_BUFFER; type = HB_CURL_FORMADD_TYPE_STRING; break; + case HB_CURLFORM_BUFFERPTR: option = CURLFORM_BUFFERPTR; type = HB_CURL_FORMADD_TYPE_PTR; break; + case HB_CURLFORM_BUFFERLENGTH: option = CURLFORM_BUFFERLENGTH; type = HB_CURL_FORMADD_TYPE_LONG; break; + case HB_CURLFORM_CONTENTTYPE: option = CURLFORM_CONTENTTYPE; type = HB_CURL_FORMADD_TYPE_STRING; break; + case HB_CURLFORM_CONTENTHEADER: option = CURLFORM_CONTENTHEADER; type = HB_CURL_FORMADD_TYPE_SLIST; break; + case HB_CURLFORM_FILENAME: option = CURLFORM_FILENAME; type = HB_CURL_FORMADD_TYPE_STRING; break; + } + + forms[ i ].option = option; + forms[ i ].value = NULL; + + switch( type ) + { + case HB_CURL_FORMADD_TYPE_PTR: + case HB_CURL_FORMADD_TYPE_COPYSTRING: + forms[ i ].value = hb_itemGetCPtr( pOptValue ); + break; + case HB_CURL_FORMADD_TYPE_STRING: + forms[ i ].value = hb_curl_StrHash( hb_curl, hb_itemGetCPtr( pOptValue ) ); + break; + case HB_CURL_FORMADD_TYPE_LONG: + { + size_t * plong = ( size_t * ) &forms[ i ].value; + *plong = ( size_t ) hb_itemGetNInt( pOptValue ); + break; + } + case HB_CURL_FORMADD_TYPE_SLIST: + if( pOptValue && HB_IS_ARRAY( pOptValue ) ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pOptValue ); + + hb_curl_slist_free( &hb_curl->pHTTPPOSTHEADERS ); + hb_curl->pHTTPPOSTHEADERS = NULL; + + for( ulPos = 0; ulPos < ulArrayLen; ++ulPos ) + hb_curl->pHTTPPOSTHEADERS = curl_slist_append( hb_curl->pHTTPPOSTHEADERS, hb_arrayGetCPtr( pOptValue, ulPos + 1 ) ); + + forms[ i ].value = ( char * ) hb_curl->pHTTPPOSTHEADERS; + } + break; + } + } + + forms[ i ].option = CURLFORM_END; + forms[ i ].value = NULL; + + bSuccess = ( curl_formadd( &hb_curl->pHTTPPOST_First, + &hb_curl->pHTTPPOST_Last, + CURLFORM_ARRAY, + forms, + CURLFORM_END ) == CURL_FORMADD_OK ); + + hb_xfree( forms ); + } + + return bSuccess; +} + +/* ---------------------------------------------------------------------------- */ +/* Constructor/Destructor */ + +static void PHB_CURL_free( PHB_CURL hb_curl, HB_BOOL bFree ) +{ + curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEFUNCTION, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSFUNCTION, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSDATA, NULL ); + + /* Some extra safety. Set these to NULL, before freeing their pointers. */ + curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPPOST, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPHEADER, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_HTTP200ALIASES, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_QUOTE, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_POSTQUOTE, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_PREQUOTE, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_TELNETOPTIONS, NULL ); +#if LIBCURL_VERSION_NUM >= 0x071400 + curl_easy_setopt( hb_curl->curl, CURLOPT_MAIL_RCPT, NULL ); +#endif + + hb_curl_form_free( &hb_curl->pHTTPPOST_First ); + hb_curl_slist_free( &hb_curl->pHTTPHEADER ); + hb_curl_slist_free( &hb_curl->pHTTP200ALIASES ); + hb_curl_slist_free( &hb_curl->pQUOTE ); + hb_curl_slist_free( &hb_curl->pPOSTQUOTE ); + hb_curl_slist_free( &hb_curl->pPREQUOTE ); + hb_curl_slist_free( &hb_curl->pTELNETOPTIONS ); + hb_curl_slist_free( &hb_curl->pMAIL_RCPT ); + hb_curl_slist_free( &hb_curl->pRESOLVE ); + hb_curl_slist_free( &hb_curl->pHTTPPOSTHEADERS ); + + hb_curl_file_ul_free( hb_curl ); + hb_curl_file_dl_free( hb_curl ); + + hb_curl_buff_ul_free( hb_curl ); + hb_curl_buff_dl_free( hb_curl ); + + if( hb_curl->pProgressCallback ) + { + hb_itemRelease( hb_curl->pProgressCallback ); + hb_curl->pProgressCallback = NULL; + } + + if( hb_curl->pHash ) + { + hb_hashTableKill( hb_curl->pHash ); + hb_curl->pHash = NULL; + } + + if( bFree ) + { + curl_easy_cleanup( hb_curl->curl ); + hb_xfree( hb_curl ); + } +#if LIBCURL_VERSION_NUM >= 0x070C01 + else + curl_easy_reset( hb_curl->curl ); +#endif +} + +/* NOTE: Will create a new one. If 'from' is specified, the new one + will be based on the 'from' one. */ + +static PHB_CURL PHB_CURL_create( CURL * from ) +{ + CURL * curl = from ? curl_easy_duphandle( from ) : curl_easy_init(); + + if( curl ) + { + PHB_CURL hb_curl = ( PHB_CURL ) hb_xgrab( sizeof( HB_CURL ) ); + + memset( hb_curl, 0, sizeof( HB_CURL ) ); + hb_curl->curl = curl; + + return hb_curl; + } + else + return NULL; +} + +static HB_GARBAGE_FUNC( PHB_CURL_release ) +{ + PHB_CURL * hb_curl_ptr = ( PHB_CURL * ) Cargo; + /* Check if pointer is not NULL to avoid multiple freeing */ + if( hb_curl_ptr && * hb_curl_ptr ) + { + PHB_CURL hb_curl = * hb_curl_ptr; + + /* set pointer to NULL to avoid multiple freeing */ + * hb_curl_ptr = NULL; + + /* Destroy the object */ + PHB_CURL_free( hb_curl, HB_TRUE ); + } +} + +static HB_GARBAGE_FUNC( PHB_CURL_mark ) +{ + PHB_CURL * hb_curl_ptr = ( PHB_CURL * ) Cargo; + + if( hb_curl_ptr && * hb_curl_ptr ) + { + PHB_CURL hb_curl = * hb_curl_ptr; + + if( hb_curl->pProgressCallback ) + hb_gcMark( hb_curl->pProgressCallback ); + } +} + +static const HB_GC_FUNCS s_gcCURLFuncs = +{ + PHB_CURL_release, + PHB_CURL_mark +}; + + +static void PHB_CURL_ret( PHB_CURL from ) +{ + void ** ph = ( void ** ) hb_gcAllocate( sizeof( PHB_CURL ), &s_gcCURLFuncs ); + + * ph = PHB_CURL_create( from ); + + hb_retptrGC( ph ); +} + +static void * PHB_CURL_is( int iParam ) +{ + return hb_parptrGC( &s_gcCURLFuncs, iParam ); +} + +static PHB_CURL PHB_CURL_par( int iParam ) +{ + void ** ph = ( void ** ) hb_parptrGC( &s_gcCURLFuncs, iParam ); + + return ph ? ( PHB_CURL ) * ph : NULL; +} + +/* ---------------------------------------------------------------------------- */ +/* Harbour interface */ + +HB_FUNC( CURL_EASY_INIT ) +{ + PHB_CURL_ret( NULL ); +} + +HB_FUNC( CURL_EASY_DUPLICATE ) +{ + if( PHB_CURL_is( 1 ) ) + PHB_CURL_ret( PHB_CURL_par( 1 ) ); + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( CURL_EASY_CLEANUP ) +{ + if( PHB_CURL_is( 1 ) ) + { + void ** ph = ( void ** ) hb_parptrGC( &s_gcCURLFuncs, 1 ); + + if( ph && * ph ) + { + PHB_CURL hb_curl = ( PHB_CURL ) * ph; + + /* set pointer to NULL to avoid multiple freeing */ + * ph = NULL; + + /* Destroy the object */ + PHB_CURL_free( hb_curl, HB_TRUE ); + } + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( CURL_EASY_RESET ) +{ + if( PHB_CURL_is( 1 ) ) + { + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + + if( hb_curl ) + PHB_CURL_free( hb_curl, HB_FALSE ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( CURL_EASY_PAUSE ) +{ + if( PHB_CURL_is( 1 ) ) + { +#if LIBCURL_VERSION_NUM >= 0x071200 + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + + hb_retnl( hb_curl ? ( long ) curl_easy_pause( hb_curl->curl, hb_parni( 2 ) ) : HB_CURLE_ERROR ); +#else + hb_retnl( HB_CURLE_ERROR ); +#endif + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( CURL_EASY_PERFORM ) +{ + if( PHB_CURL_is( 1 ) ) + { + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + + hb_retnl( hb_curl ? ( long ) curl_easy_perform( hb_curl->curl ) : HB_CURLE_ERROR ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* NOTE: curl_easy_send( curl, cBuffer, @nSentBytes ) -> nResult */ +HB_FUNC( CURL_EASY_SEND ) +{ + if( PHB_CURL_is( 1 ) ) + { + CURLcode res = ( CURLcode ) HB_CURLE_ERROR; +#if LIBCURL_VERSION_NUM >= 0x071202 + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + + if( hb_curl ) + { + size_t size = 0; + + res = curl_easy_send( hb_curl->curl, hb_parcx( 2 ), ( size_t ) hb_parclen( 2 ), &size ); + + hb_storns( size, 3 ); + } +#endif + hb_retnl( ( long ) res ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* NOTE: curl_easy_recv( curl, @cBuffer ) -> nResult */ +HB_FUNC( CURL_EASY_RECV ) +{ + if( PHB_CURL_is( 1 ) ) + { + CURLcode res = ( CURLcode ) HB_CURLE_ERROR; +#if LIBCURL_VERSION_NUM >= 0x071202 + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + + if( hb_curl ) + { + size_t size = ( size_t ) hb_parclen( 2 ); + void * buffer; + + if( size < 1024 ) + size = 1024; + + buffer = hb_xgrab( size + 1 ); + + res = curl_easy_recv( hb_curl->curl, buffer, size, &size ); + + if( ! hb_storclen_buffer( ( char * ) buffer, size, 2 ) ) + hb_xfree( buffer ); + } +#endif + hb_retnl( ( long ) res ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( CURL_EASY_SETOPT ) +{ + if( PHB_CURL_is( 1 ) && HB_ISNUM( 2 ) ) + { + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + CURLcode res = ( CURLcode ) HB_CURLE_ERROR; + + if( hb_curl ) + { + switch( hb_parni( 2 ) ) + { + /* Behavior */ + + case HB_CURLOPT_VERBOSE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_VERBOSE, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_HEADER: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_HEADER, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_NOPROGRESS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_NOPROGRESS, HB_CURL_OPT_BOOL( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070A00 + case HB_CURLOPT_NOSIGNAL: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_NOSIGNAL, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071500 + case HB_CURLOPT_WILDCARDMATCH: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_WILDCARDMATCH, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif + + /* Callback */ + + /* These are hidden on the Harbour level: */ + /* HB_CURLOPT_WRITEFUNCTION */ + /* HB_CURLOPT_WRITEDATA */ + /* HB_CURLOPT_READFUNCTION */ + /* HB_CURLOPT_READDATA */ +#if LIBCURL_VERSION_NUM >= 0x070C03 + /* HB_CURLOPT_IOCTLFUNCTION */ + /* HB_CURLOPT_IOCTLDATA */ +#endif + /* HB_CURLOPT_SEEKFUNCTION */ + /* HB_CURLOPT_SEEKDATA */ + /* HB_CURLOPT_SOCKOPTFUNCTION */ + /* HB_CURLOPT_SOCKOPTDATA */ + /* HB_CURLOPT_OPENSOCKETFUNCTION */ + /* HB_CURLOPT_OPENSOCKETDATA */ + /* HB_CURLOPT_PROGRESSFUNCTION */ + /* HB_CURLOPT_PROGRESSDATA */ + /* HB_CURLOPT_HEADERFUNCTION */ + /* HB_CURLOPT_HEADERDATA / CURLOPT_WRITEHEADER */ + /* HB_CURLOPT_DEBUGFUNCTION */ + /* HB_CURLOPT_DEBUGDATA */ +#if LIBCURL_VERSION_NUM >= 0x070B00 + /* HB_CURLOPT_SSL_CTX_FUNCTION */ + /* HB_CURLOPT_SSL_CTX_DATA */ +#endif + /* HB_CURLOPT_CONV_TO_NETWORK_FUNCTION */ + /* HB_CURLOPT_CONV_FROM_NETWORK_FUNCTION */ + /* HB_CURLOPT_CONV_FROM_UTF8_FUNCTION */ + + /* Error */ + + /* HB_CURLOPT_ERRORBUFFER */ + /* HB_CURLOPT_STDERR */ + + case HB_CURLOPT_FAILONERROR: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FAILONERROR, HB_CURL_OPT_BOOL( 3 ) ); + break; + + /* Network */ + + /* This is the only option that must be set before curl_easy_perform() is called. */ + case HB_CURLOPT_URL: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_URL, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_PROXY: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROXY, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_PROXYPORT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROXYPORT, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070A00 + case HB_CURLOPT_PROXYTYPE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROXYTYPE, hb_parnl( 3 ) ); + break; +#endif + case HB_CURLOPT_HTTPPROXYTUNNEL: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPPROXYTUNNEL, HB_CURL_OPT_BOOL( 3 ) ); + break; +/* + case HB_CURLOPT_SOCKS5_RESOLVE_LOCAL: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SOCKS5_RESOLVE_LOCAL, HB_CURL_OPT_BOOL( 3 ) ); + break; +*/ + case HB_CURLOPT_INTERFACE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_INTERFACE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070F02 + case HB_CURLOPT_LOCALPORT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_LOCALPORT, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_LOCALPORTRANGE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_LOCALPORTRANGE, hb_parnl( 3 ) ); + break; +#endif + case HB_CURLOPT_DNS_CACHE_TIMEOUT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_DNS_CACHE_TIMEOUT, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_DNS_USE_GLOBAL_CACHE: /* OBSOLETE */ + res = curl_easy_setopt( hb_curl->curl, CURLOPT_DNS_USE_GLOBAL_CACHE, HB_CURL_OPT_BOOL( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070A00 + case HB_CURLOPT_BUFFERSIZE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_BUFFERSIZE, hb_parnl( 3 ) ); + break; +#endif + case HB_CURLOPT_PORT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PORT, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070A08 /* Not documented. GUESS. */ + case HB_CURLOPT_TCP_NODELAY: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_TCP_NODELAY, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071300 + case HB_CURLOPT_ADDRESS_SCOPE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_ADDRESS_SCOPE, hb_parnl( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071304 + case HB_CURLOPT_PROTOCOLS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROTOCOLS, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_REDIR_PROTOCOLS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_REDIR_PROTOCOLS, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_NOPROXY: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_NOPROXY, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_SOCKS5_GSSAPI_SERVICE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SOCKS5_GSSAPI_SERVICE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_SOCKS5_GSSAPI_NEC: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SOCKS5_GSSAPI_NEC, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif + + /* Names and passwords options (Authentication) */ + + case HB_CURLOPT_NETRC: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_NETRC, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070A09 + case HB_CURLOPT_NETRC_FILE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_NETRC_FILE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#endif + case HB_CURLOPT_USERPWD: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_USERPWD, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x071301 + case HB_CURLOPT_USERNAME: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_USERNAME, hb_parc( 3 ) ); + break; + case HB_CURLOPT_PASSWORD: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PASSWORD, hb_parc( 3 ) ); + break; +#endif + case HB_CURLOPT_PROXYUSERPWD: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROXYUSERPWD, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x071301 + case HB_CURLOPT_PROXYUSERNAME: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROXYUSERNAME, hb_parc( 3 ) ); + break; + case HB_CURLOPT_PROXYPASSWORD: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROXYPASSWORD, hb_parc( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070A06 + case HB_CURLOPT_HTTPAUTH: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPAUTH, hb_parnl( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070A07 + case HB_CURLOPT_PROXYAUTH: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROXYAUTH, hb_parnl( 3 ) ); + break; +#endif + + /* HTTP options */ + + case HB_CURLOPT_AUTOREFERER: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_AUTOREFERER, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_ENCODING: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_ENCODING, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_FOLLOWLOCATION: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FOLLOWLOCATION, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_UNRESTRICTED_AUTH: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_UNRESTRICTED_AUTH, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_MAXREDIRS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAXREDIRS, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x071101 + case HB_CURLOPT_POSTREDIR: +#if LIBCURL_VERSION_NUM >= 0x071301 + res = curl_easy_setopt( hb_curl->curl, CURLOPT_POSTREDIR, HB_CURL_OPT_BOOL( 3 ) ); +#else + res = curl_easy_setopt( hb_curl->curl, CURLOPT_POST301, HB_CURL_OPT_BOOL( 3 ) ); +#endif + break; +#endif + case HB_CURLOPT_PUT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PUT, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_POST: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_POST, HB_CURL_OPT_BOOL( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x071101 + case HB_CURLOPT_POSTFIELDS: + case HB_CURLOPT_COPYPOSTFIELDS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_COPYPOSTFIELDS, hb_parc( 3 ) ); + break; +#endif + case HB_CURLOPT_POSTFIELDSIZE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_POSTFIELDSIZE, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070B01 + case HB_CURLOPT_POSTFIELDSIZE_LARGE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_POSTFIELDSIZE_LARGE, HB_CURL_OPT_LARGENUM( 3 ) ); + break; +#endif + case HB_CURLOPT_HTTPPOST: + { + PHB_ITEM pArray = hb_param( 3, HB_IT_ARRAY ); + + if( pArray ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + HB_BOOL bAllOk = HB_TRUE; + + for( ulPos = 0; ulPos < ulArrayLen; ++ulPos ) + { + if( ! hb_curl_formadd( hb_curl, hb_arrayGetItemPtr( pArray, ulPos + 1 ) ) ) + { + bAllOk = HB_FALSE; + break; + } + } + + if( bAllOk ) + res = curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPPOST, hb_curl->pHTTPPOST_First ); + } + + break; + } + case HB_CURLOPT_REFERER: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_REFERER, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_USERAGENT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_USERAGENT, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_HTTPHEADER: + { + PHB_ITEM pArray = hb_param( 3, HB_IT_ARRAY ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPHEADER, NULL ); + hb_curl_slist_free( &hb_curl->pHTTPHEADER ); + + if( pArray ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + + 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 ); + } + } + break; +#if LIBCURL_VERSION_NUM >= 0x070A03 + case HB_CURLOPT_HTTP200ALIASES: + { + PHB_ITEM pArray = hb_param( 3, HB_IT_ARRAY ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_HTTP200ALIASES, NULL ); + hb_curl_slist_free( &hb_curl->pHTTP200ALIASES ); + + if( pArray ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + + 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 ); + } + } + break; +#endif + case HB_CURLOPT_COOKIE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_COOKIE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_COOKIEFILE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_COOKIEFILE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_COOKIEJAR: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_COOKIEJAR, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_COOKIESESSION: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_COOKIESESSION, HB_CURL_OPT_BOOL( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070E01 + case HB_CURLOPT_COOKIELIST: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_COOKIELIST, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#endif + case HB_CURLOPT_HTTPGET: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_HTTPGET, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_HTTP_VERSION: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_HTTP_VERSION, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070E01 + case HB_CURLOPT_IGNORE_CONTENT_LENGTH: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_IGNORE_CONTENT_LENGTH, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071002 + case HB_CURLOPT_HTTP_CONTENT_DECODING: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_HTTP_CONTENT_DECODING, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_HTTP_TRANSFER_DECODING: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_HTTP_TRANSFER_DECODING, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif + + /* SMTP options */ + +#if LIBCURL_VERSION_NUM >= 0x071400 + case HB_CURLOPT_MAIL_FROM: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAIL_FROM, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_MAIL_RCPT: + { + PHB_ITEM pArray = hb_param( 3, HB_IT_ARRAY ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_MAIL_RCPT, NULL ); + hb_curl_slist_free( &hb_curl->pMAIL_RCPT ); + + if( pArray ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + + for( ulPos = 0; ulPos < ulArrayLen; ++ulPos ) + hb_curl->pMAIL_RCPT = curl_slist_append( hb_curl->pMAIL_RCPT, hb_arrayGetCPtr( pArray, ulPos + 1 ) ); + + res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAIL_RCPT, hb_curl->pMAIL_RCPT ); + } + } + break; +#endif + + /* TFTP options */ + +#if LIBCURL_VERSION_NUM >= 0x071304 + case HB_CURLOPT_TFTP_BLKSIZE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_TFTP_BLKSIZE, hb_parnl( 3 ) ); + break; +#endif + + /* FTP options */ + + case HB_CURLOPT_FTPPORT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTPPORT, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_QUOTE: + { + PHB_ITEM pArray = hb_param( 3, HB_IT_ARRAY ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_QUOTE, NULL ); + hb_curl_slist_free( &hb_curl->pQUOTE ); + + if( pArray ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + + for( ulPos = 0; ulPos < ulArrayLen; ++ulPos ) + hb_curl->pQUOTE = curl_slist_append( hb_curl->pQUOTE, hb_arrayGetCPtr( pArray, ulPos + 1 ) ); + + res = curl_easy_setopt( hb_curl->curl, CURLOPT_QUOTE, hb_curl->pQUOTE ); + } + } + break; + case HB_CURLOPT_POSTQUOTE: + { + PHB_ITEM pArray = hb_param( 3, HB_IT_ARRAY ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_POSTQUOTE, NULL ); + hb_curl_slist_free( &hb_curl->pPOSTQUOTE ); + + if( pArray ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + + 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 ); + } + } + break; + case HB_CURLOPT_PREQUOTE: + { + PHB_ITEM pArray = hb_param( 3, HB_IT_ARRAY ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_PREQUOTE, NULL ); + hb_curl_slist_free( &hb_curl->pPREQUOTE ); + + if( pArray ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + + 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 ); + } + } + break; + case HB_CURLOPT_DIRLISTONLY: /* HB_CURLOPT_FTPLISTONLY */ +#if LIBCURL_VERSION_NUM > 0x071004 + res = curl_easy_setopt( hb_curl->curl, CURLOPT_DIRLISTONLY, HB_CURL_OPT_BOOL( 3 ) ); +#else + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTPLISTONLY, HB_CURL_OPT_BOOL( 3 ) ); +#endif + break; + case HB_CURLOPT_APPEND: /* HB_CURLOPT_FTPAPPEND */ +#if LIBCURL_VERSION_NUM > 0x071004 + res = curl_easy_setopt( hb_curl->curl, CURLOPT_APPEND, HB_CURL_OPT_BOOL( 3 ) ); +#else + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTPAPPEND, HB_CURL_OPT_BOOL( 3 ) ); +#endif + break; +#if LIBCURL_VERSION_NUM >= 0x070A05 + case HB_CURLOPT_FTP_USE_EPRT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_USE_EPRT, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif + case HB_CURLOPT_FTP_USE_EPSV: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_USE_EPSV, HB_CURL_OPT_BOOL( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x071400 + case HB_CURLOPT_FTP_USE_PRET: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_USE_PRET, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070A07 + case HB_CURLOPT_FTP_CREATE_MISSING_DIRS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_CREATE_MISSING_DIRS, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070A08 + case HB_CURLOPT_FTP_RESPONSE_TIMEOUT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_RESPONSE_TIMEOUT, hb_parnl( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070F05 + case HB_CURLOPT_FTP_ALTERNATIVE_TO_USER: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_ALTERNATIVE_TO_USER, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070E02 + case HB_CURLOPT_FTP_SKIP_PASV_IP: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_SKIP_PASV_IP, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif + case HB_CURLOPT_USE_SSL: +#if LIBCURL_VERSION_NUM > 0x071004 + res = curl_easy_setopt( hb_curl->curl, CURLOPT_USE_SSL, hb_parnl( 3 ) ); +#elif LIBCURL_VERSION_NUM >= 0x070B00 + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_SSL, hb_parnl( 3 ) ); +#endif + break; +#if LIBCURL_VERSION_NUM >= 0x070C02 + case HB_CURLOPT_FTPSSLAUTH: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTPSSLAUTH, hb_parnl( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071001 + case HB_CURLOPT_FTP_SSL_CCC: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_SSL_CCC, hb_parnl( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070D00 + case HB_CURLOPT_FTP_ACCOUNT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_ACCOUNT, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070F01 + case HB_CURLOPT_FTP_FILEMETHOD: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FTP_FILEMETHOD, hb_parnl( 3 ) ); + break; +#endif + + /* RTSP */ + +#if LIBCURL_VERSION_NUM >= 0x071400 + case HB_CURLOPT_RTSP_REQUEST: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RTSP_REQUEST, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_RTSP_SESSION_ID: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RTSP_SESSION_ID, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_RTSP_STREAM_URI: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RTSP_STREAM_URI, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_RTSP_TRANSPORT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RTSP_TRANSPORT, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_RTSP_CLIENT_CSEQ: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RTSP_CLIENT_CSEQ, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_RTSP_SERVER_CSEQ: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RTSP_SERVER_CSEQ, hb_parnl( 3 ) ); + break; +#endif + + /* Protocol */ + + case HB_CURLOPT_TRANSFERTEXT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_TRANSFERTEXT, HB_CURL_OPT_BOOL( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x071200 + case HB_CURLOPT_PROXY_TRANSFER_MODE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROXY_TRANSFER_MODE, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif + case HB_CURLOPT_CRLF: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CRLF, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_RANGE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RANGE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_RESUME_FROM: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RESUME_FROM, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070B00 + case HB_CURLOPT_RESUME_FROM_LARGE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RESUME_FROM_LARGE, HB_CURL_OPT_LARGENUM( 3 ) ); + break; +#endif + case HB_CURLOPT_CUSTOMREQUEST: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CUSTOMREQUEST, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_FILETIME: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FILETIME, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_NOBODY: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_NOBODY, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_INFILESIZE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_INFILESIZE, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070B00 + case HB_CURLOPT_INFILESIZE_LARGE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_INFILESIZE_LARGE, HB_CURL_OPT_LARGENUM( 3 ) ); + break; +#endif + case HB_CURLOPT_UPLOAD: + 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( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070A08 /* Not documented. GUESS. */ + case HB_CURLOPT_MAXFILESIZE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAXFILESIZE, hb_parnl( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070B00 + case HB_CURLOPT_MAXFILESIZE_LARGE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAXFILESIZE_LARGE, HB_CURL_OPT_LARGENUM( 3 ) ); + break; +#endif + case HB_CURLOPT_TIMECONDITION: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_TIMECONDITION, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_TIMEVALUE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_TIMEVALUE, hb_parnl( 3 ) ); + break; + + /* Connection */ + + case HB_CURLOPT_TIMEOUT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_TIMEOUT, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x071002 + case HB_CURLOPT_TIMEOUT_MS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_TIMEOUT_MS, hb_parnl( 3 ) ); + break; +#endif + case HB_CURLOPT_LOW_SPEED_LIMIT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_LOW_SPEED_LIMIT, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_LOW_SPEED_TIME: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_LOW_SPEED_TIME, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070F05 + case HB_CURLOPT_MAX_SEND_SPEED_LARGE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAX_SEND_SPEED_LARGE, HB_CURL_OPT_LARGENUM( 3 ) ); + break; + case HB_CURLOPT_MAX_RECV_SPEED_LARGE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAX_RECV_SPEED_LARGE, HB_CURL_OPT_LARGENUM( 3 ) ); + break; +#endif + case HB_CURLOPT_MAXCONNECTS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_MAXCONNECTS, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_CLOSEPOLICY: /* OBSOLETE, does nothing. */ + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CLOSEPOLICY, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_FRESH_CONNECT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FRESH_CONNECT, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_FORBID_REUSE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_FORBID_REUSE, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_CONNECTTIMEOUT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CONNECTTIMEOUT, hb_parnl( 3 ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x071002 + case HB_CURLOPT_CONNECTTIMEOUT_MS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CONNECTTIMEOUT_MS, hb_parnl( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070A08 /* Not documented. GUESS. */ + case HB_CURLOPT_IPRESOLVE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_IPRESOLVE, hb_parnl( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x070F02 + case HB_CURLOPT_CONNECT_ONLY: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CONNECT_ONLY, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071503 + case HB_CURLOPT_RESOLVE: + { + PHB_ITEM pArray = hb_param( 3, HB_IT_ARRAY ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_RESOLVE, NULL ); + hb_curl_slist_free( &hb_curl->pRESOLVE ); + + if( pArray ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + + for( ulPos = 0; ulPos < ulArrayLen; ++ulPos ) + hb_curl->pRESOLVE = curl_slist_append( hb_curl->pRESOLVE, hb_arrayGetCPtr( pArray, ulPos + 1 ) ); + + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RESOLVE, hb_curl->pRESOLVE ); + } + } + break; +#endif + + /* SSL and Security */ + + case HB_CURLOPT_SSLCERT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSLCERT, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#if LIBCURL_VERSION_NUM >= 0x070903 + case HB_CURLOPT_SSLCERTTYPE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSLCERTTYPE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#endif + case HB_CURLOPT_SSLKEY: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSLKEY, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_SSLKEYTYPE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSLKEYTYPE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_KEYPASSWD: +#if LIBCURL_VERSION_NUM > 0x071004 + res = curl_easy_setopt( hb_curl->curl, CURLOPT_KEYPASSWD, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); +#elif LIBCURL_VERSION_NUM > 0x070902 + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSLKEYPASSWD, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); +#else + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSLCERTPASSWD, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); +#endif + break; + case HB_CURLOPT_SSLENGINE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSLENGINE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_SSLENGINE_DEFAULT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSLENGINE_DEFAULT, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_SSLVERSION: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSLVERSION, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_SSL_VERIFYPEER: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSL_VERIFYPEER, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_CAINFO: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CAINFO, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_CAPATH: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CAPATH, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_RANDOM_FILE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_RANDOM_FILE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_EGDSOCKET: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_EGDSOCKET, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_SSL_VERIFYHOST: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSL_VERIFYHOST, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_SSL_CIPHER_LIST: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSL_CIPHER_LIST, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_SSL_SESSIONID_CACHE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSL_VERIFYHOST, HB_CURL_OPT_BOOL( 3 ) ); + break; + case HB_CURLOPT_KRBLEVEL: /* HB_CURLOPT_KRB4LEVEL */ +#if LIBCURL_VERSION_NUM > 0x071003 + res = curl_easy_setopt( hb_curl->curl, CURLOPT_KRBLEVEL, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); +#else + res = curl_easy_setopt( hb_curl->curl, CURLOPT_KRB4LEVEL, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); +#endif + break; +#if LIBCURL_VERSION_NUM >= 0x071300 + case HB_CURLOPT_CRLFILE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CRLFILE, hb_parc( 3 ) ); + break; + case HB_CURLOPT_ISSUERCERT: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_ISSUERCERT, hb_parc( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071301 + case HB_CURLOPT_CERTINFO: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_CERTINFO, HB_CURL_OPT_BOOL( 3 ) ); + break; +#endif + + /* SSH options */ + +#if LIBCURL_VERSION_NUM >= 0x071001 + case HB_CURLOPT_SSH_AUTH_TYPES: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSH_AUTH_TYPES, hb_parnl( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071101 + case HB_CURLOPT_SSH_HOST_PUBLIC_KEY_MD5: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, hb_parc( 3 ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071001 + case HB_CURLOPT_SSH_PUBLIC_KEYFILE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSH_PUBLIC_KEYFILE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; + case HB_CURLOPT_SSH_PRIVATE_KEYFILE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSH_PRIVATE_KEYFILE, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#endif +#if LIBCURL_VERSION_NUM >= 0x071306 + case HB_CURLOPT_SSH_KNOWNHOSTS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_SSH_KNOWNHOSTS, hb_curl_StrHash( hb_curl, hb_parc( 3 ) ) ); + break; +#endif + + /* Other options */ + +#if LIBCURL_VERSION_NUM >= 0x070A03 + case HB_CURLOPT_PRIVATE: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PRIVATE, hb_parptr( 3 ) ); + break; +#endif + + /* HB_CURLOPT_SHARE */ + +#if LIBCURL_VERSION_NUM >= 0x071004 + case HB_CURLOPT_NEW_FILE_PERMS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_NEW_FILE_PERMS, hb_parnl( 3 ) ); + break; + case HB_CURLOPT_NEW_DIRECTORY_PERMS: + res = curl_easy_setopt( hb_curl->curl, CURLOPT_NEW_DIRECTORY_PERMS, hb_parnl( 3 ) ); + break; +#endif + + /* Telnet options */ + + case HB_CURLOPT_TELNETOPTIONS: + { + PHB_ITEM pArray = hb_param( 3, HB_IT_ARRAY ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_TELNETOPTIONS, NULL ); + hb_curl_slist_free( &hb_curl->pTELNETOPTIONS ); + + if( pArray ) + { + HB_SIZE ulPos; + HB_SIZE ulArrayLen = hb_arrayLen( pArray ); + + 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 ); + } + } + break; + + /* Undocumented */ + + /* HB_CURLOPT_WRITEINFO */ + + /* Harbour specials */ + + case HB_CURLOPT_PROGRESSBLOCK: + { + PHB_ITEM pProgressCallback = hb_param( 3, HB_IT_BLOCK | HB_IT_SYMBOL ); + + if( hb_curl->pProgressCallback ) + { + curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSFUNCTION, NULL ); + curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSDATA, NULL ); + + hb_itemRelease( hb_curl->pProgressCallback ); + hb_curl->pProgressCallback = NULL; + } + + if( pProgressCallback ) + { + hb_curl->pProgressCallback = hb_itemNew( pProgressCallback ); + /* unlock the item so GC will not mark them as used */ + hb_gcUnlock( hb_curl->pProgressCallback ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSFUNCTION, hb_curl_progress_callback ); + res = curl_easy_setopt( hb_curl->curl, CURLOPT_PROGRESSDATA, hb_curl->pProgressCallback ); + } + } + break; + + case HB_CURLOPT_UL_FILE_SETUP: + { + hb_curl_file_ul_free( hb_curl ); + + if( HB_ISCHAR( 3 ) ) + { + hb_curl->ul_name = hb_strdup( hb_parc( 3 ) ); + hb_curl->ul_handle = FS_ERROR; + + curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, hb_curl_read_file_callback ); + res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, hb_curl ); + } + } + break; + + case HB_CURLOPT_UL_FHANDLE_SETUP: + { + hb_curl_file_ul_free( hb_curl ); + + if( HB_ISNUM( 3 ) ) + { + hb_curl->ul_name = NULL; + hb_curl->ul_handle = hb_numToHandle( hb_parnint( 3 ) ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, hb_curl_read_fhandle_callback ); + res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, hb_curl ); + } + } + break; + + case HB_CURLOPT_UL_FILE_CLOSE: + hb_curl_file_ul_free( hb_curl ); + res = CURLE_OK; + break; + + case HB_CURLOPT_DL_FILE_SETUP: + { + hb_curl_file_dl_free( hb_curl ); + + if( HB_ISCHAR( 3 ) ) + { + hb_curl->dl_name = hb_strdup( hb_parc( 3 ) ); + hb_curl->dl_handle = FS_ERROR; + + curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEFUNCTION, hb_curl_write_file_callback ); + res = curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, hb_curl ); + } + } + break; + + case HB_CURLOPT_DL_FHANDLE_SETUP: + { + hb_curl_file_dl_free( hb_curl ); + + if( HB_ISNUM( 3 ) ) + { + hb_curl->dl_name = NULL; + hb_curl->dl_handle = hb_numToHandle( hb_parnint( 3 ) ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEFUNCTION, hb_curl_write_fhandle_callback ); + res = curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, hb_curl ); + } + } + break; + + case HB_CURLOPT_DL_FILE_CLOSE: + hb_curl_file_dl_free( hb_curl ); + res = CURLE_OK; + break; + + case HB_CURLOPT_UL_BUFF_SETUP: + { + hb_curl_buff_ul_free( hb_curl ); + + if( HB_ISCHAR( 3 ) ) + { + hb_curl->ul_pos = 0; + hb_curl->ul_len = hb_parclen( 3 ); + hb_curl->ul_ptr = ( unsigned char * ) hb_xgrab( hb_curl->ul_len ); + + hb_xmemcpy( hb_curl->ul_ptr, hb_parc( 3 ), hb_curl->ul_len ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, hb_curl_read_buff_callback ); + res = curl_easy_setopt( hb_curl->curl, CURLOPT_READDATA, hb_curl ); + } + } + break; + + case HB_CURLOPT_DL_BUFF_SETUP: + { + hb_curl_buff_dl_free( hb_curl ); + + hb_curl->dl_pos = 0; + hb_curl->dl_len = hb_parnldef( 3, HB_CURL_DL_BUFF_SIZE_INIT ); + hb_curl->dl_ptr = ( unsigned char * ) hb_xgrab( hb_curl->dl_len ); + + curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEFUNCTION, hb_curl_write_buff_callback ); + res = curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEDATA, hb_curl ); + } + break; + + case HB_CURLOPT_DL_BUFF_GET: + hb_storclen( ( char * ) hb_curl->dl_ptr, hb_curl->dl_pos, 3 ); + 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, hb_curl ); + break; + } + } + + hb_retnl( ( long ) res ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* Harbour extension. */ +HB_FUNC( CURL_EASY_DL_BUFF_GET ) +{ + if( PHB_CURL_is( 1 ) ) + { + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + + if( hb_curl ) + hb_retclen( ( char * ) hb_curl->dl_ptr, hb_curl->dl_pos ); + else + hb_retc_null(); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +#define HB_CURL_INFO_TYPE_INVALID 0 +#define HB_CURL_INFO_TYPE_STR 1 +#define HB_CURL_INFO_TYPE_PTR 2 +#define HB_CURL_INFO_TYPE_LONG 3 +#define HB_CURL_INFO_TYPE_DOUBLE 4 +#define HB_CURL_INFO_TYPE_SLIST 5 + +#define HB_CURL_EASY_GETINFO( hb_curl, n, p ) ( hb_curl ? curl_easy_getinfo( hb_curl->curl, n, p ) : ( CURLcode ) HB_CURLE_ERROR ) + +/* NOTE: curl_easy_getinfo( curl, x, @nError ) -> xValue */ +HB_FUNC( CURL_EASY_GETINFO ) +{ + if( PHB_CURL_is( 1 ) && HB_ISNUM( 2 ) ) + { + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + CURLcode res = ( CURLcode ) HB_CURLE_ERROR; + + int type = HB_CURL_INFO_TYPE_INVALID; + + char * ret_string = NULL; + char * ret_ptr = NULL; + long ret_long = 0; + struct curl_slist * ret_slist = NULL; + double ret_double = 0.0; + + switch( hb_parni( 2 ) ) + { + case HB_CURLINFO_EFFECTIVE_URL: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_EFFECTIVE_URL, &ret_string ); + type = HB_CURL_INFO_TYPE_STR; + break; + case HB_CURLINFO_RESPONSE_CODE: +#if LIBCURL_VERSION_NUM > 0x070A07 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_RESPONSE_CODE, &ret_long ); +#else + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_HTTP_CODE, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_HTTP_CONNECTCODE: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_HTTP_CONNECTCODE, &ret_long ); + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_FILETIME: +#if LIBCURL_VERSION_NUM >= 0x070500 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_FILETIME, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_TOTAL_TIME: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_TOTAL_TIME, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_NAMELOOKUP_TIME: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_NAMELOOKUP_TIME, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_CONNECT_TIME: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_CONNECT_TIME, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_PRETRANSFER_TIME: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_PRETRANSFER_TIME, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_STARTTRANSFER_TIME: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_STARTTRANSFER_TIME, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_REDIRECT_TIME: +#if LIBCURL_VERSION_NUM >= 0x070907 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_REDIRECT_TIME, &ret_double ); +#endif + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_REDIRECT_COUNT: +#if LIBCURL_VERSION_NUM >= 0x070907 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_REDIRECT_COUNT, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_REDIRECT_URL: +#if LIBCURL_VERSION_NUM >= 0x071202 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_REDIRECT_URL, &ret_string ); +#endif + type = HB_CURL_INFO_TYPE_STR; + break; + case HB_CURLINFO_SIZE_UPLOAD: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_SIZE_UPLOAD, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_SIZE_DOWNLOAD: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_SIZE_DOWNLOAD, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_SPEED_DOWNLOAD: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_SPEED_DOWNLOAD, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_SPEED_UPLOAD: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_SPEED_UPLOAD, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_HEADER_SIZE: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_HEADER_SIZE, &ret_long ); + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_REQUEST_SIZE: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_REQUEST_SIZE, &ret_long ); + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_SSL_VERIFYRESULT: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_SSL_VERIFYRESULT, &ret_long ); + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_SSL_ENGINES: +#if LIBCURL_VERSION_NUM >= 0x071203 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_SSL_ENGINES, &ret_slist ); +#endif + type = HB_CURL_INFO_TYPE_SLIST; + break; + case HB_CURLINFO_CONTENT_LENGTH_DOWNLOAD: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_CONTENT_LENGTH_UPLOAD: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &ret_double ); + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_CONTENT_TYPE: + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_CONTENT_TYPE, &ret_string ); + type = HB_CURL_INFO_TYPE_STR; + break; + case HB_CURLINFO_PRIVATE: +#if LIBCURL_VERSION_NUM >= 0x070A03 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_PRIVATE, &ret_ptr ); +#endif + type = HB_CURL_INFO_TYPE_PTR; + break; + case HB_CURLINFO_HTTPAUTH_AVAIL: +#if LIBCURL_VERSION_NUM >= 0x070A08 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_HTTPAUTH_AVAIL, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_PROXYAUTH_AVAIL: +#if LIBCURL_VERSION_NUM >= 0x070A08 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_PROXYAUTH_AVAIL, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_OS_ERRNO: +#if LIBCURL_VERSION_NUM >= 0x070C02 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_OS_ERRNO, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_NUM_CONNECTS: +#if LIBCURL_VERSION_NUM >= 0x070C03 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_NUM_CONNECTS, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_COOKIELIST: +#if LIBCURL_VERSION_NUM >= 0x070E01 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_COOKIELIST, &ret_slist ); +#endif + type = HB_CURL_INFO_TYPE_SLIST; + break; + case HB_CURLINFO_LASTSOCKET: +#if LIBCURL_VERSION_NUM >= 0x070F02 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_LASTSOCKET, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_FTP_ENTRY_PATH: +#if LIBCURL_VERSION_NUM >= 0x070F04 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_FTP_ENTRY_PATH, &ret_string ); +#endif + type = HB_CURL_INFO_TYPE_STR; + break; + case HB_CURLINFO_PRIMARY_IP: +#if LIBCURL_VERSION_NUM >= 0x071300 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_PRIMARY_IP, &ret_string ); +#endif + type = HB_CURL_INFO_TYPE_STR; + break; + case HB_CURLINFO_APPCONNECT_TIME: +#if LIBCURL_VERSION_NUM >= 0x071300 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_APPCONNECT_TIME, &ret_double ); +#endif + type = HB_CURL_INFO_TYPE_DOUBLE; + break; + case HB_CURLINFO_CERTINFO: +#if LIBCURL_VERSION_NUM >= 0x071301 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_CERTINFO, &ret_slist ); +#endif + type = HB_CURL_INFO_TYPE_SLIST; + break; + case HB_CURLINFO_CONDITION_UNMET: +#if LIBCURL_VERSION_NUM >= 0x071304 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_CONDITION_UNMET, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_RTSP_SESSION_ID: +#if LIBCURL_VERSION_NUM >= 0x071400 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_RTSP_SESSION_ID, &ret_string ); +#endif + type = HB_CURL_INFO_TYPE_STR; + break; + case HB_CURLINFO_RTSP_CLIENT_CSEQ: +#if LIBCURL_VERSION_NUM >= 0x071400 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_RTSP_CLIENT_CSEQ, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_RTSP_SERVER_CSEQ: +#if LIBCURL_VERSION_NUM >= 0x071400 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_RTSP_SERVER_CSEQ, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_RTSP_CSEQ_RECV: +#if LIBCURL_VERSION_NUM >= 0x071400 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_RTSP_CSEQ_RECV, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_PRIMARY_PORT: +#if LIBCURL_VERSION_NUM >= 0x071500 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_PRIMARY_PORT, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + case HB_CURLINFO_LOCAL_IP: +#if LIBCURL_VERSION_NUM >= 0x071500 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_LOCAL_IP, &ret_string ); +#endif + type = HB_CURL_INFO_TYPE_STR; + break; + case HB_CURLINFO_LOCAL_PORT: +#if LIBCURL_VERSION_NUM >= 0x071500 + res = HB_CURL_EASY_GETINFO( hb_curl, CURLINFO_LOCAL_PORT, &ret_long ); +#endif + type = HB_CURL_INFO_TYPE_LONG; + break; + } + + switch( type ) + { + case HB_CURL_INFO_TYPE_STR: + hb_retc( ret_string ); + break; + case HB_CURL_INFO_TYPE_PTR: + hb_retptr( ret_ptr ); + break; + case HB_CURL_INFO_TYPE_LONG: + hb_retnl( ret_long ); + break; + case HB_CURL_INFO_TYPE_DOUBLE: + hb_retnd( ret_double ); + break; + case HB_CURL_INFO_TYPE_SLIST: + { + if( ret_slist ) + { + PHB_ITEM pArray; + int nCount; + struct curl_slist * walk_ret_slist; + + /* Count */ + for( walk_ret_slist = ret_slist, nCount = 0; walk_ret_slist->next; nCount++ ) + walk_ret_slist = walk_ret_slist->next; + + /* Fill */ + pArray = hb_itemArrayNew( nCount ); + for( walk_ret_slist = ret_slist, nCount = 1; walk_ret_slist->next; ) + { + hb_arraySetC( pArray, nCount++, walk_ret_slist->data ); + walk_ret_slist = walk_ret_slist->next; + } + hb_itemReturnRelease( pArray ); + + curl_slist_free_all( ret_slist ); + } + else + hb_reta( 0 ); + } + break; + } + + hb_stornl( ( long ) res, 3 ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( CURL_EASY_ESCAPE ) +{ + if( PHB_CURL_is( 1 ) ) + { +#if LIBCURL_VERSION_NUM >= 0x070F04 + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + + if( hb_curl ) + { + char * buffer = curl_easy_escape( hb_curl->curl, hb_parcx( 2 ), ( int ) hb_parclen( 2 ) ); + hb_retc( buffer ); + curl_free( buffer ); + } + else +#endif + hb_retc_null(); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( CURL_EASY_UNESCAPE ) +{ + if( PHB_CURL_is( 1 ) ) + { +#if LIBCURL_VERSION_NUM >= 0x070F04 + PHB_CURL hb_curl = PHB_CURL_par( 1 ); + + if( hb_curl ) + { + int nLen = 0; + char * buffer = curl_easy_unescape( hb_curl->curl, hb_parcx( 2 ), ( int ) hb_parclen( 2 ), &nLen ); + hb_retclen( buffer, nLen ); + curl_free( buffer ); + } + else +#endif + hb_retc_null(); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* ---------------------------------------------------------------------------- */ +/* Harbour interface (session independent) */ + +HB_FUNC( CURL_VERSION ) +{ + hb_retc( curl_version() ); +} + +HB_FUNC( CURL_VERSION_INFO ) +{ + curl_version_info_data * data = curl_version_info( CURLVERSION_NOW ); + + if( data ) + { + PHB_ITEM pArray = hb_itemArrayNew( 13 ); + + hb_arraySetC( pArray, 1, data->version ); /* LIBCURL_VERSION */ + hb_arraySetNI( pArray, 2, data->version_num ); /* LIBCURL_VERSION_NUM */ + hb_arraySetC( pArray, 3, data->host ); /* OS/host/cpu/machine when configured */ + hb_arraySetNI( pArray, 4, data->features ); /* bitmask, see defines below */ + hb_arraySetC( pArray, 5, data->ssl_version ); /* human readable string */ + hb_arraySetNI( pArray, 6, data->ssl_version_num ); /* not used anymore, always 0 */ + hb_arraySetC( pArray, 7, data->libz_version ); /* human readable string */ +#if defined( CURLVERSION_SECOND ) + hb_arraySetC( pArray, 9, data->age >= CURLVERSION_SECOND ? data->ares : NULL ); + hb_arraySetNI( pArray, 10, data->age >= CURLVERSION_SECOND ? data->ares_num : 0 ); +#else + hb_arraySetC( pArray, 9, NULL ); + hb_arraySetNI( pArray, 10, 0 ); +#endif +#if defined( CURLVERSION_THIRD ) + hb_arraySetC( pArray, 11, data->age >= CURLVERSION_THIRD ? data->libidn : NULL ); +#else + hb_arraySetC( pArray, 11, NULL ); +#endif +#if defined( CURLVERSION_FOURTH ) + hb_arraySetNI( pArray, 12, data->age >= CURLVERSION_FOURTH ? data->iconv_ver_num : 0 ); /* Same as '_libiconv_version' if built with HAVE_ICONV */ +#else + hb_arraySetNI( pArray, 12, 0 ); +#endif +#if defined( CURLVERSION_FOURTH ) && LIBCURL_VERSION_NUM >= 0x071001 /* Just a guess. It's not documented in which libcurl version this member got added. */ + hb_arraySetC( pArray, 13, data->age >= CURLVERSION_FOURTH ? data->libssh_version : NULL ); /* human readable string */ +#else + hb_arraySetC( pArray, 13, NULL ); /* human readable string */ +#endif + { + PHB_ITEM pProtocols; + int nCount = 0; + const char * const * prot = data->protocols; + + while( *( prot++ ) ) + nCount++; + + pProtocols = hb_arrayGetItemPtr( pArray, 8 ); + hb_arrayNew( pProtocols, nCount ); + + for( prot = data->protocols, nCount = 1; *prot; prot++ ) + hb_arraySetC( pProtocols, nCount++, *prot ); + } + + hb_itemReturnRelease( pArray ); + } + else + hb_reta( 0 ); +} + +HB_FUNC( CURL_EASY_STRERROR ) +{ + if( HB_ISNUM( 1 ) ) +#if LIBCURL_VERSION_NUM >= 0x070C00 + hb_retc( curl_easy_strerror( ( CURLcode ) hb_parnl( 1 ) ) ); +#else + hb_retc_null(); +#endif + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* NOTE: This returns the number of seconds since January 1st 1970 in the UTC time zone. */ +HB_FUNC( CURL_GETDATE ) +{ + if( HB_ISCHAR( 1 ) ) + hb_retnint( ( HB_MAXINT ) curl_getdate( hb_parc( 1 ), NULL ) ); + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* Harbour interface (session independent) */ + +/* NOTE: Obsolete, superceded by curl_easy_escape() */ +HB_FUNC( CURL_ESCAPE ) +{ + if( HB_ISCHAR( 1 ) ) + { + char * buffer = curl_escape( hb_parc( 1 ), ( int ) hb_parclen( 1 ) ); + hb_retc( buffer ); + curl_free( buffer ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* NOTE: Obsolete, superceded by curl_easy_unescape() */ +HB_FUNC( CURL_UNESCAPE ) +{ + if( HB_ISCHAR( 1 ) ) + { + char * buffer = curl_unescape( hb_parc( 1 ), ( int ) hb_parclen( 1 ) ); + hb_retc( buffer ); + curl_free( buffer ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} diff --git a/harbour/contrib/hbcurl/hbcurlt1.ch b/harbour/contrib/hbcurl/hbcurlt1.ch new file mode 100644 index 0000000000..a4e7994a60 --- /dev/null +++ b/harbour/contrib/hbcurl/hbcurlt1.ch @@ -0,0 +1,560 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * libcurl 'easy' API - Harbour header. + * + * Copyright 2008 Viktor Szakats (harbour.01 syenar.hu) + * originally based on: + * Copyright 2005 Luiz Rafael Culik Guimaraes + * www - http://harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +/* NOTE: This file is also used by C code. */ + +#ifndef HBCURL_CH_ +#define HBCURL_CH_ + +/* curl_easy_setopt() parameters. + NOTE: The actual values may be different from the libcurl equivalent. */ + +#define HB_CURLOPT_FILE 1 +#define HB_CURLOPT_URL 2 +#define HB_CURLOPT_PORT 3 +#define HB_CURLOPT_PROXY 4 +#define HB_CURLOPT_USERPWD 5 +#define HB_CURLOPT_PROXYUSERPWD 6 +#define HB_CURLOPT_RANGE 7 +#define HB_CURLOPT_INFILE 9 +#define HB_CURLOPT_ERRORBUFFER 10 +#define HB_CURLOPT_WRITEFUNCTION 11 +#define HB_CURLOPT_READFUNCTION 12 +#define HB_CURLOPT_TIMEOUT 13 +#define HB_CURLOPT_INFILESIZE 14 +#define HB_CURLOPT_POSTFIELDS 15 +#define HB_CURLOPT_REFERER 16 +#define HB_CURLOPT_FTPPORT 17 +#define HB_CURLOPT_USERAGENT 18 +#define HB_CURLOPT_LOW_SPEED_LIMIT 19 +#define HB_CURLOPT_LOW_SPEED_TIME 20 +#define HB_CURLOPT_RESUME_FROM 21 +#define HB_CURLOPT_COOKIE 22 +#define HB_CURLOPT_HTTPHEADER 23 +#define HB_CURLOPT_HTTPPOST 24 +#define HB_CURLOPT_SSLCERT 25 +#define HB_CURLOPT_KEYPASSWD 26 +#define HB_CURLOPT_SSLCERTPASSWD HB_CURLOPT_KEYPASSWD +#define HB_CURLOPT_SSLKEYPASSWD HB_CURLOPT_KEYPASSWD +#define HB_CURLOPT_CRLF 27 +#define HB_CURLOPT_QUOTE 28 +#define HB_CURLOPT_WRITEHEADER 29 +#define HB_CURLOPT_COOKIEFILE 31 +#define HB_CURLOPT_SSLVERSION 32 +#define HB_CURLOPT_TIMECONDITION 33 +#define HB_CURLOPT_TIMEVALUE 34 +#define HB_CURLOPT_CUSTOMREQUEST 36 +#define HB_CURLOPT_STDERR 37 +#define HB_CURLOPT_POSTQUOTE 39 +#define HB_CURLOPT_WRITEINFO 40 +#define HB_CURLOPT_VERBOSE 41 /* talk a lot */ +#define HB_CURLOPT_HEADER 42 /* throw the header out too */ +#define HB_CURLOPT_NOPROGRESS 43 /* shut off the progress meter */ +#define HB_CURLOPT_NOBODY 44 /* use HEAD to get http document */ +#define HB_CURLOPT_FAILONERROR 45 /* no output on http error codes >= 300 */ +#define HB_CURLOPT_UPLOAD 46 /* this is an upload */ +#define HB_CURLOPT_POST 47 /* HTTP POST method */ +#define HB_CURLOPT_DIRLISTONLY 48 /* Use NLST when listing ftp dir */ +#define HB_CURLOPT_FTPLISTONLY HB_CURLOPT_DIRLISTONLY +#define HB_CURLOPT_APPEND 50 /* Append instead of overwrite on upload! */ +#define HB_CURLOPT_FTPAPPEND HB_CURLOPT_APPEND +#define HB_CURLOPT_NETRC 51 +#define HB_CURLOPT_FOLLOWLOCATION 52 /* use Location: Luke! */ +#define HB_CURLOPT_TRANSFERTEXT 53 /* transfer data in text/ASCII format */ +#define HB_CURLOPT_PUT 54 /* HTTP PUT */ +#define HB_CURLOPT_PROGRESSFUNCTION 56 +#define HB_CURLOPT_PROGRESSDATA 57 +#define HB_CURLOPT_AUTOREFERER 58 +#define HB_CURLOPT_PROXYPORT 59 +#define HB_CURLOPT_POSTFIELDSIZE 60 +#define HB_CURLOPT_HTTPPROXYTUNNEL 61 +#define HB_CURLOPT_INTERFACE 62 +#define HB_CURLOPT_KRBLEVEL 63 +#define HB_CURLOPT_KRB4LEVEL HB_CURLOPT_KRBLEVEL +#define HB_CURLOPT_SSL_VERIFYPEER 64 +#define HB_CURLOPT_CAINFO 65 +#define HB_CURLOPT_MAXREDIRS 68 +#define HB_CURLOPT_FILETIME 69 +#define HB_CURLOPT_TELNETOPTIONS 70 +#define HB_CURLOPT_MAXCONNECTS 71 +#define HB_CURLOPT_CLOSEPOLICY 72 +#define HB_CURLOPT_FRESH_CONNECT 74 +#define HB_CURLOPT_FORBID_REUSE 75 +#define HB_CURLOPT_RANDOM_FILE 76 +#define HB_CURLOPT_EGDSOCKET 77 +#define HB_CURLOPT_CONNECTTIMEOUT 78 +#define HB_CURLOPT_HEADERFUNCTION 79 +#define HB_CURLOPT_HTTPGET 80 +#define HB_CURLOPT_SSL_VERIFYHOST 81 +#define HB_CURLOPT_COOKIEJAR 82 +#define HB_CURLOPT_SSL_CIPHER_LIST 83 +#define HB_CURLOPT_HTTP_VERSION 84 +#define HB_CURLOPT_FTP_USE_EPSV 85 +#define HB_CURLOPT_SSLCERTTYPE 86 +#define HB_CURLOPT_SSLKEY 87 +#define HB_CURLOPT_SSLKEYTYPE 88 +#define HB_CURLOPT_SSLENGINE 89 +#define HB_CURLOPT_SSLENGINE_DEFAULT 90 +#define HB_CURLOPT_DNS_USE_GLOBAL_CACHE 91 /* To become OBSOLETE soon */ +#define HB_CURLOPT_DNS_CACHE_TIMEOUT 92 +#define HB_CURLOPT_PREQUOTE 93 +#define HB_CURLOPT_DEBUGFUNCTION 94 +#define HB_CURLOPT_DEBUGDATA 95 +#define HB_CURLOPT_COOKIESESSION 96 +#define HB_CURLOPT_CAPATH 97 +#define HB_CURLOPT_BUFFERSIZE 98 +#define HB_CURLOPT_NOSIGNAL 99 +#define HB_CURLOPT_SHARE 100 +#define HB_CURLOPT_PROXYTYPE 101 +#define HB_CURLOPT_ENCODING 102 +#define HB_CURLOPT_PRIVATE 103 +#define HB_CURLOPT_HTTP200ALIASES 104 +#define HB_CURLOPT_UNRESTRICTED_AUTH 105 +#define HB_CURLOPT_FTP_USE_EPRT 106 +#define HB_CURLOPT_HTTPAUTH 107 +#define HB_CURLOPT_SSL_CTX_FUNCTION 108 +#define HB_CURLOPT_SSL_CTX_DATA 109 +#define HB_CURLOPT_FTP_CREATE_MISSING_DIRS 110 +#define HB_CURLOPT_PROXYAUTH 111 +#define HB_CURLOPT_FTP_RESPONSE_TIMEOUT 112 +#define HB_CURLOPT_IPRESOLVE 113 +#define HB_CURLOPT_MAXFILESIZE 114 +#define HB_CURLOPT_INFILESIZE_LARGE 115 +#define HB_CURLOPT_RESUME_FROM_LARGE 116 +#define HB_CURLOPT_MAXFILESIZE_LARGE 117 +#define HB_CURLOPT_NETRC_FILE 118 +#define HB_CURLOPT_USE_SSL 119 +#define HB_CURLOPT_FTP_SSL HB_CURLOPT_USE_SSL +#define HB_CURLOPT_POSTFIELDSIZE_LARGE 120 +#define HB_CURLOPT_TCP_NODELAY 121 +#define HB_CURLOPT_SOURCE_USERPWD 123 +#define HB_CURLOPT_SOURCE_PREQUOTE 127 +#define HB_CURLOPT_SOURCE_POSTQUOTE 128 +#define HB_CURLOPT_FTPSSLAUTH 129 +#define HB_CURLOPT_IOCTLFUNCTION 130 +#define HB_CURLOPT_IOCTLDATA 131 +#define HB_CURLOPT_SOURCE_URL 132 +#define HB_CURLOPT_SOURCE_QUOTE 133 +#define HB_CURLOPT_FTP_ACCOUNT 134 +#define HB_CURLOPT_COOKIELIST 135 +#define HB_CURLOPT_IGNORE_CONTENT_LENGTH 136 +#define HB_CURLOPT_FTP_SKIP_PASV_IP 137 +#define HB_CURLOPT_FTP_FILEMETHOD 138 +#define HB_CURLOPT_LOCALPORT 139 +#define HB_CURLOPT_LOCALPORTRANGE 140 +#define HB_CURLOPT_CONNECT_ONLY 141 +#define HB_CURLOPT_CONV_FROM_NETWORK_FUNCTION 142 +#define HB_CURLOPT_CONV_TO_NETWORK_FUNCTION 143 +#define HB_CURLOPT_CONV_FROM_UTF8_FUNCTION 144 +#define HB_CURLOPT_MAX_SEND_SPEED_LARGE 145 +#define HB_CURLOPT_MAX_RECV_SPEED_LARGE 146 +#define HB_CURLOPT_FTP_ALTERNATIVE_TO_USER 147 +#define HB_CURLOPT_SOCKOPTFUNCTION 148 +#define HB_CURLOPT_SOCKOPTDATA 149 +#define HB_CURLOPT_SSL_SESSIONID_CACHE 150 +#define HB_CURLOPT_SSH_AUTH_TYPES 151 +#define HB_CURLOPT_SSH_PUBLIC_KEYFILE 152 +#define HB_CURLOPT_SSH_PRIVATE_KEYFILE 153 +#define HB_CURLOPT_FTP_SSL_CCC 154 +#define HB_CURLOPT_TIMEOUT_MS 155 +#define HB_CURLOPT_CONNECTTIMEOUT_MS 156 +#define HB_CURLOPT_HTTP_TRANSFER_DECODING 157 +#define HB_CURLOPT_HTTP_CONTENT_DECODING 158 +#define HB_CURLOPT_NEW_FILE_PERMS 159 +#define HB_CURLOPT_NEW_DIRECTORY_PERMS 160 +#define HB_CURLOPT_POST301 161 +#define HB_CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 162 +#define HB_CURLOPT_OPENSOCKETFUNCTION 163 +#define HB_CURLOPT_OPENSOCKETDATA 164 +#define HB_CURLOPT_COPYPOSTFIELDS 165 +#define HB_CURLOPT_PROXY_TRANSFER_MODE 166 +#define HB_CURLOPT_SEEKFUNCTION 167 +#define HB_CURLOPT_SEEKDATA 168 +#define HB_CURLOPT_CRLFILE 169 +#define HB_CURLOPT_ISSUERCERT 170 +#define HB_CURLOPT_ADDRESS_SCOPE 171 +#define HB_CURLOPT_CERTINFO 172 +#define HB_CURLOPT_POSTREDIR HB_CURLOPT_POST301 +#define HB_CURLOPT_USERNAME 173 +#define HB_CURLOPT_PASSWORD 174 +#define HB_CURLOPT_PROXYUSERNAME 175 +#define HB_CURLOPT_PROXYPASSWORD 176 +#define HB_CURLOPT_NOPROXY 177 +#define HB_CURLOPT_TFTP_BLKSIZE 178 +#define HB_CURLOPT_SOCKS5_GSSAPI_SERVICE 179 +#define HB_CURLOPT_SOCKS5_GSSAPI_NEC 180 +#define HB_CURLOPT_PROTOCOLS 181 +#define HB_CURLOPT_REDIR_PROTOCOLS 182 +#define HB_CURLOPT_SSH_KNOWNHOSTS 183 +#define HB_CURLOPT_MAIL_FROM 186 +#define HB_CURLOPT_MAIL_RCPT 187 +#define HB_CURLOPT_FTP_USE_PRET 188 +#define HB_CURLOPT_RTSP_REQUEST 189 +#define HB_CURLOPT_RTSP_SESSION_ID 190 +#define HB_CURLOPT_RTSP_STREAM_URI 191 +#define HB_CURLOPT_RTSP_TRANSPORT 192 +#define HB_CURLOPT_RTSP_HEADER HB_CURLOPT_HTTPHEADER +#define HB_CURLOPT_RTSP_CLIENT_CSEQ 193 +#define HB_CURLOPT_RTSP_SERVER_CSEQ 194 +#define HB_CURLOPT_WILDCARDMATCH 197 +#define HB_CURLOPT_RESOLVE 198 +#define HB_CURLOPT_DOWNLOAD 1001 /* Harbour special ones */ +#define HB_CURLOPT_PROGRESSBLOCK 1002 +#define HB_CURLOPT_UL_FILE_SETUP 1003 +#define HB_CURLOPT_UL_FILE_CLOSE 1004 +#define HB_CURLOPT_DL_FILE_SETUP 1005 +#define HB_CURLOPT_DL_FILE_CLOSE 1006 +#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 +#define HB_CURLOPT_UL_FHANDLE_SETUP 1011 +#define HB_CURLOPT_DL_FHANDLE_SETUP 1012 +/* 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 +#define HB_CURLOPT_SETDOWNLOADFILE HB_CURLOPT_DL_FILE_SETUP +#define HB_CURLOPT_CLOSEDOWNLOADFILE HB_CURLOPT_DL_FILE_CLOSE +#define HB_CURLOPT_SETPROGRESS HB_CURLOPT_PROGRESSBLOCK + +/* HB_CURLOPT_PROXYTYPE option */ +#define HB_CURLPROXY_HTTP 0 /* added in 7.10 */ +#define HB_CURLPROXY_HTTP_1_0 1 /* added in 7.19.4, force to use CONNECT HTTP/1.0 */ +#define HB_CURLPROXY_SOCKS4 4 /* support added in 7.15.2, enum existed already in 7.10 */ +#define HB_CURLPROXY_SOCKS5 5 /* added in 7.10 */ +#define HB_CURLPROXY_SOCKS4A 6 /* added in 7.18.0 */ +#define HB_CURLPROXY_SOCKS5_HOSTNAME 7 /* Use the SOCKS5 protocol but pass along the host name rather than the IP address. added in 7.18.0 */ + +/* HB_CURLOPT_NETRC option */ +#define HB_CURL_NETRC_IGNORED 0 /* The .netrc will never be read. */ +#define HB_CURL_NETRC_OPTIONAL 1 /* A user:password in the URL will be preferred */ +#define HB_CURL_NETRC_REQUIRED 2 /* A user:password in the URL will be ignored. */ + +/* HB_CURLOPT_HTTPAUTH option */ +#define HB_CURLAUTH_NONE 0 /* nothing */ +#define HB_CURLAUTH_BASIC 1 /* Basic (default) */ +#define HB_CURLAUTH_DIGEST 2 /* Digest */ +#define HB_CURLAUTH_GSSNEGOTIATE 4 /* GSS-Negotiate */ +#define HB_CURLAUTH_NTLM 8 /* NTLM */ +#define HB_CURLAUTH_DIGEST_IE hb_bitShift( 1, 4 ) /* Digest with IE flavour */ +#define HB_CURLAUTH_ONLY hb_bitShift( 1, 31 ) /* used together with a single other type to force no auth or just that single type */ +#define HB_CURLAUTH_ANY hb_bitNot( 0 ) /* all types set */ +#define HB_CURLAUTH_ANYSAFE hb_bitNot( HB_CURLAUTH_BASIC ) + +/* HB_CURLOPT_HTTP_VERSION option */ +#define HB_CURL_HTTP_VERSION_NONE 0 /* setting this means we don't care, and that we'd like the library to choose the best possible for us! */ +#define HB_CURL_HTTP_VERSION_1_0 1 /* please use HTTP 1.0 in the request */ +#define HB_CURL_HTTP_VERSION_1_1 2 /* please use HTTP 1.1 in the request */ + +/* HB_CURLOPT_USE_SSL option */ +#define HB_CURLUSESSL_NONE 0 /* do not attempt to use SSL */ +#define HB_CURLUSESSL_TRY 1 /* try using SSL, proceed anyway otherwise */ +#define HB_CURLUSESSL_CONTROL 2 /* SSL for the control connection or fail */ +#define HB_CURLUSESSL_ALL 3 /* SSL for all communication or fail */ + +/* HB_CURLOPT_FTPSSLAUTH option */ +#define HB_CURLFTPAUTH_DEFAULT 0 /* let libcurl decide */ +#define HB_CURLFTPAUTH_SSL 1 /* use "AUTH SSL" */ +#define HB_CURLFTPAUTH_TLS 2 /* use "AUTH TLS" */ + +/* HB_CURLOPT_FTP_SSL_CCC option */ +#define HB_CURLFTPSSL_CCC_NONE 0 /* do not send CCC */ +#define HB_CURLFTPSSL_CCC_PASSIVE 1 /* Let the server initiate the shutdown */ +#define HB_CURLFTPSSL_CCC_ACTIVE 2 /* Initiate the shutdown */ + +/* HB_CURLOPT_FTP_FILEMETHOD option */ +#define HB_CURLFTPMETHOD_DEFAULT 0 /* let libcurl pick */ +#define HB_CURLFTPMETHOD_MULTICWD 1 /* single CWD operation for each path part */ +#define HB_CURLFTPMETHOD_NOCWD 2 /* no CWD at all */ +#define HB_CURLFTPMETHOD_SINGLECWD 3 /* one CWD to full dir, then work on file */ + +/* HB_CURLOPT_RTSP_REQUEST option */ +#define HB_CURL_RTSPREQ_NONE 0 +#define HB_CURL_RTSPREQ_OPTIONS 1 +#define HB_CURL_RTSPREQ_DESCRIBE 2 +#define HB_CURL_RTSPREQ_ANNOUNCE 3 +#define HB_CURL_RTSPREQ_SETUP 4 +#define HB_CURL_RTSPREQ_PLAY 5 +#define HB_CURL_RTSPREQ_PAUSE 6 +#define HB_CURL_RTSPREQ_TEARDOWN 7 +#define HB_CURL_RTSPREQ_GET_PARAMETER 8 +#define HB_CURL_RTSPREQ_SET_PARAMETER 9 +#define HB_CURL_RTSPREQ_RECORD 10 +#define HB_CURL_RTSPREQ_RECEIVE 11 +#define HB_CURL_RTSPREQ_LAST 12 + +/* HB_CURLOPT_TIMECONDITION option */ +#define HB_CURL_TIMECOND_NONE 0 +#define HB_CURL_TIMECOND_IFMODSINCE 1 +#define HB_CURL_TIMECOND_IFUNMODSINCE 2 +#define HB_CURL_TIMECOND_LASTMOD 3 + +/* HB_CURLOPT_IPRESOLVE option */ +#define HB_CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP versions that your system allows */ +#define HB_CURL_IPRESOLVE_V4 1 /* resolve to ipv4 addresses */ +#define HB_CURL_IPRESOLVE_V6 2 /* resolve to ipv6 addresses */ + +/* HB_CURLOPT_SSLVERSION option */ +#define HB_CURL_SSLVERSION_DEFAULT 0 +#define HB_CURL_SSLVERSION_TLSv1 1 +#define HB_CURL_SSLVERSION_SSLv2 2 +#define HB_CURL_SSLVERSION_SSLv3 3 + +/* HB_CURLOPT_SSH_AUTH_TYPES option */ +#define HB_CURL_CURLSSH_AUTH_ANY hb_bitNot( 0 ) /* all types supported by the server */ +#define HB_CURL_CURLSSH_AUTH_NONE 0 /* none allowed, silly but complete */ +#define HB_CURL_CURLSSH_AUTH_PUBLICKEY 1 /* public/private key files */ +#define HB_CURL_CURLSSH_AUTH_PASSWORD 2 /* password */ +#define HB_CURL_CURLSSH_AUTH_HOST 4 /* host key files */ +#define HB_CURL_CURLSSH_AUTH_KEYBOARD 8 /* keyboard interactive */ +#define HB_CURL_CURLSSH_AUTH_DEFAULT HB_CURLSSH_AUTH_ANY + +/* CURLOPT_*PROTOCOLS options */ +#define HB_CURLPROTO_HTTP hb_bitShift( 1, 0 ) +#define HB_CURLPROTO_HTTPS hb_bitShift( 1, 1 ) +#define HB_CURLPROTO_FTP hb_bitShift( 1, 2 ) +#define HB_CURLPROTO_FTPS hb_bitShift( 1, 3 ) +#define HB_CURLPROTO_SCP hb_bitShift( 1, 4 ) +#define HB_CURLPROTO_SFTP hb_bitShift( 1, 5 ) +#define HB_CURLPROTO_TELNET hb_bitShift( 1, 6 ) +#define HB_CURLPROTO_LDAP hb_bitShift( 1, 7 ) +#define HB_CURLPROTO_LDAPS hb_bitShift( 1, 8 ) +#define HB_CURLPROTO_DICT hb_bitShift( 1, 9 ) +#define HB_CURLPROTO_FILE hb_bitShift( 1, 10 ) +#define HB_CURLPROTO_TFTP hb_bitShift( 1, 11 ) +#define HB_CURLPROTO_IMAP hb_bitShift( 1, 12 ) +#define HB_CURLPROTO_IMAPS hb_bitShift( 1, 13 ) +#define HB_CURLPROTO_POP3 hb_bitShift( 1, 14 ) +#define HB_CURLPROTO_POP3S hb_bitShift( 1, 15 ) +#define HB_CURLPROTO_SMTP hb_bitShift( 1, 16 ) +#define HB_CURLPROTO_SMTPS hb_bitShift( 1, 17 ) +#define HB_CURLPROTO_RTSP hb_bitShift( 1, 18 ) +#define HB_CURLPROTO_RTMP hb_bitShift( 1, 19 ) +#define HB_CURLPROTO_RTMPT hb_bitShift( 1, 20 ) +#define HB_CURLPROTO_RTMPE hb_bitShift( 1, 21 ) +#define HB_CURLPROTO_RTMPTE hb_bitShift( 1, 22 ) +#define HB_CURLPROTO_RTMPS hb_bitShift( 1, 23 ) +#define HB_CURLPROTO_RTMPTS hb_bitShift( 1, 24 ) +#define HB_CURLPROTO_ALL hb_bitNot( 0 ) + +/* curl_easy_pause() parameters. They can be combined with hb_bitOr(). */ +#define HB_CURLPAUSE_RECV 1 +#define HB_CURLPAUSE_RECV_CONT 0 +#define HB_CURLPAUSE_SEND 4 +#define HB_CURLPAUSE_SEND_CONT 0 +#define HB_CURLPAUSE_ALL hb_bitOr( HB_CURLPAUSE_RECV, HB_CURLPAUSE_SEND ) +#define HB_CURLPAUSE_CONT hb_bitOr( HB_CURLPAUSE_RECV_CONT, HB_CURLPAUSE_SEND_CONT ) + +/* curl_global_init() parameters. */ +#define HB_CURL_GLOBAL_SSL 1 +#define HB_CURL_GLOBAL_WIN32 2 +#define HB_CURL_GLOBAL_ALL hb_bitOr( HB_CURL_GLOBAL_SSL, HB_CURL_GLOBAL_WIN32 ) +#define HB_CURL_GLOBAL_NOTHING 0 +#define HB_CURL_GLOBAL_DEFAULT HB_CURL_GLOBAL_ALL + +/* curl_easy_getinfo() parameters. + NOTE: The actual values may be different from the libcurl equivalent. */ + +#define HB_CURLINFO_EFFECTIVE_URL 1 +#define HB_CURLINFO_RESPONSE_CODE 2 +#define HB_CURLINFO_HTTP_CONNECTCODE 3 +#define HB_CURLINFO_FILETIME 4 +#define HB_CURLINFO_TOTAL_TIME 5 +#define HB_CURLINFO_NAMELOOKUP_TIME 6 +#define HB_CURLINFO_CONNECT_TIME 7 +#define HB_CURLINFO_PRETRANSFER_TIME 8 +#define HB_CURLINFO_STARTTRANSFER_TIME 9 +#define HB_CURLINFO_REDIRECT_TIME 10 +#define HB_CURLINFO_REDIRECT_COUNT 11 +#define HB_CURLINFO_REDIRECT_URL 12 +#define HB_CURLINFO_SIZE_UPLOAD 13 +#define HB_CURLINFO_SIZE_DOWNLOAD 14 +#define HB_CURLINFO_SPEED_DOWNLOAD 15 +#define HB_CURLINFO_SPEED_UPLOAD 16 +#define HB_CURLINFO_HEADER_SIZE 17 +#define HB_CURLINFO_REQUEST_SIZE 18 +#define HB_CURLINFO_SSL_VERIFYRESULT 19 +#define HB_CURLINFO_SSL_ENGINES 20 +#define HB_CURLINFO_CONTENT_LENGTH_DOWNLOAD 21 +#define HB_CURLINFO_CONTENT_LENGTH_UPLOAD 22 +#define HB_CURLINFO_CONTENT_TYPE 23 +#define HB_CURLINFO_PRIVATE 24 +#define HB_CURLINFO_HTTPAUTH_AVAIL 25 +#define HB_CURLINFO_PROXYAUTH_AVAIL 26 +#define HB_CURLINFO_OS_ERRNO 27 +#define HB_CURLINFO_NUM_CONNECTS 28 +#define HB_CURLINFO_COOKIELIST 29 +#define HB_CURLINFO_LASTSOCKET 30 +#define HB_CURLINFO_FTP_ENTRY_PATH 31 +#define HB_CURLINFO_PRIMARY_IP 32 +#define HB_CURLINFO_APPCONNECT_TIME 33 +#define HB_CURLINFO_CERTINFO 34 +#define HB_CURLINFO_CONDITION_UNMET 35 +#define HB_CURLINFO_RTSP_SESSION_ID 36 +#define HB_CURLINFO_RTSP_CLIENT_CSEQ 37 +#define HB_CURLINFO_RTSP_SERVER_CSEQ 38 +#define HB_CURLINFO_RTSP_CSEQ_RECV 39 +#define HB_CURLINFO_PRIMARY_PORT 40 +#define HB_CURLINFO_LOCAL_IP 41 +#define HB_CURLINFO_LOCAL_PORT 42 + +/* curl http forms */ +#define HB_CURLFORM_NOTHING 0 +#define HB_CURLFORM_COPYNAME 1 +#define HB_CURLFORM_PTRNAME 2 +#define HB_CURLFORM_COPYCONTENTS 4 +#define HB_CURLFORM_PTRCONTENTS 5 +#define HB_CURLFORM_CONTENTSLENGTH 6 +#define HB_CURLFORM_FILECONTENT 7 +#define HB_CURLFORM_FILE 10 +#define HB_CURLFORM_BUFFER 11 +#define HB_CURLFORM_BUFFERPTR 12 +#define HB_CURLFORM_BUFFERLENGTH 13 +#define HB_CURLFORM_CONTENTTYPE 14 +#define HB_CURLFORM_CONTENTHEADER 15 +#define HB_CURLFORM_FILENAME 16 + +/* curl result codes. */ +#define HB_CURLE_ERROR -1 /* request not passed to libcurl (libcurl not initialized or unknown parameter) */ +#define HB_CURLE_OK 0 +#define HB_CURLE_UNSUPPORTED_PROTOCOL 1 /* */ +#define HB_CURLE_FAILED_INIT 2 /* */ +#define HB_CURLE_URL_MALFORMAT 3 /* */ +#define HB_CURLE_OBSOLETE4 4 /* NOT USED */ +#define HB_CURLE_COULDNT_RESOLVE_PROXY 5 /* */ +#define HB_CURLE_COULDNT_RESOLVE_HOST 6 /* */ +#define HB_CURLE_COULDNT_CONNECT 7 /* */ +#define HB_CURLE_FTP_WEIRD_SERVER_REPLY 8 /* */ +#define HB_CURLE_REMOTE_ACCESS_DENIED 9 /* a service was denied by the server due to lack of access - when login fails this is not returned. */ +#define HB_CURLE_OBSOLETE10 10 /* NOT USED */ +#define HB_CURLE_FTP_WEIRD_PASS_REPLY 11 /* */ +#define HB_CURLE_OBSOLETE12 12 /* NOT USED */ +#define HB_CURLE_FTP_WEIRD_PASV_REPLY 13 /* */ +#define HB_CURLE_FTP_WEIRD_227_FORMAT 14 /* */ +#define HB_CURLE_FTP_CANT_GET_HOST 15 /* */ +#define HB_CURLE_OBSOLETE16 16 /* NOT USED */ +#define HB_CURLE_FTP_COULDNT_SET_TYPE 17 /* */ +#define HB_CURLE_PARTIAL_FILE 18 /* */ +#define HB_CURLE_FTP_COULDNT_RETR_FILE 19 /* */ +#define HB_CURLE_OBSOLETE20 20 /* NOT USED */ +#define HB_CURLE_QUOTE_ERROR 21 /* quote command failure */ +#define HB_CURLE_HTTP_RETURNED_ERROR 22 /* */ +#define HB_CURLE_WRITE_ERROR 23 /* */ +#define HB_CURLE_OBSOLETE24 24 /* NOT USED */ +#define HB_CURLE_UPLOAD_FAILED 25 /* failed upload "command" */ +#define HB_CURLE_READ_ERROR 26 /* could open/read from file */ +#define HB_CURLE_OUT_OF_MEMORY 27 /* */ +#define HB_CURLE_OPERATION_TIMEDOUT 28 /* the timeout time was reached */ +#define HB_CURLE_OBSOLETE29 29 /* NOT USED */ +#define HB_CURLE_FTP_PORT_FAILED 30 /* FTP PORT operation failed */ +#define HB_CURLE_FTP_COULDNT_USE_REST 31 /* the REST command failed */ +#define HB_CURLE_OBSOLETE32 32 /* NOT USED */ +#define HB_CURLE_RANGE_ERROR 33 /* RANGE "command" didn't work */ +#define HB_CURLE_HTTP_POST_ERROR 34 /* */ +#define HB_CURLE_SSL_CONNECT_ERROR 35 /* wrong when connecting with SSL */ +#define HB_CURLE_BAD_DOWNLOAD_RESUME 36 /* couldn't resume download */ +#define HB_CURLE_FILE_COULDNT_READ_FILE 37 /* */ +#define HB_CURLE_LDAP_CANNOT_BIND 38 /* */ +#define HB_CURLE_LDAP_SEARCH_FAILED 39 /* */ +#define HB_CURLE_OBSOLETE40 40 /* NOT USED */ +#define HB_CURLE_FUNCTION_NOT_FOUND 41 /* */ +#define HB_CURLE_ABORTED_BY_CALLBACK 42 /* */ +#define HB_CURLE_BAD_FUNCTION_ARGUMENT 43 /* */ +#define HB_CURLE_OBSOLETE44 44 /* NOT USED */ +#define HB_CURLE_INTERFACE_FAILED 45 /* CURLOPT_INTERFACE failed */ +#define HB_CURLE_OBSOLETE46 46 /* NOT USED */ +#define HB_CURLE_TOO_MANY_REDIRECTS 47 /* catch endless re-direct loops */ +#define HB_CURLE_UNKNOWN_TELNET_OPTION 48 /* User specified an unknown option */ +#define HB_CURLE_TELNET_OPTION_SYNTAX 49 /* Malformed telnet option */ +#define HB_CURLE_OBSOLETE50 50 /* NOT USED */ +#define HB_CURLE_PEER_FAILED_VERIFICATION 51 /* peer's certificate or fingerprint wasn't verified fine */ +#define HB_CURLE_GOT_NOTHING 52 /* when this is a specific error */ +#define HB_CURLE_SSL_ENGINE_NOTFOUND 53 /* SSL crypto engine not found */ +#define HB_CURLE_SSL_ENGINE_SETFAILED 54 /* can not set SSL crypto engine as default */ +#define HB_CURLE_SEND_ERROR 55 /* failed sending network data */ +#define HB_CURLE_RECV_ERROR 56 /* failure in receiving network data */ +#define HB_CURLE_OBSOLETE57 57 /* NOT IN USE */ +#define HB_CURLE_SSL_CERTPROBLEM 58 /* problem with the local certificate */ +#define HB_CURLE_SSL_CIPHER 59 /* couldn't use specified cipher */ +#define HB_CURLE_SSL_CACERT 60 /* problem with the CA cert (path?) */ +#define HB_CURLE_BAD_CONTENT_ENCODING 61 /* Unrecognized transfer encoding */ +#define HB_CURLE_LDAP_INVALID_URL 62 /* Invalid LDAP URL */ +#define HB_CURLE_FILESIZE_EXCEEDED 63 /* Maximum file size exceeded */ +#define HB_CURLE_USE_SSL_FAILED 64 /* Requested FTP SSL level failed */ +#define HB_CURLE_SEND_FAIL_REWIND 65 /* Sending the data requires a rewind that failed */ +#define HB_CURLE_SSL_ENGINE_INITFAILED 66 /* failed to initialise ENGINE */ +#define HB_CURLE_LOGIN_DENIED 67 /* user, password or similar was not accepted and we failed to login */ +#define HB_CURLE_TFTP_NOTFOUND 68 /* file not found on server */ +#define HB_CURLE_TFTP_PERM 69 /* permission problem on server */ +#define HB_CURLE_REMOTE_DISK_FULL 70 /* out of disk space on server */ +#define HB_CURLE_TFTP_ILLEGAL 71 /* Illegal TFTP operation */ +#define HB_CURLE_TFTP_UNKNOWNID 72 /* Unknown transfer ID */ +#define HB_CURLE_REMOTE_FILE_EXISTS 73 /* File already exists */ +#define HB_CURLE_TFTP_NOSUCHUSER 74 /* No such user */ +#define HB_CURLE_CONV_FAILED 75 /* conversion failed */ +#define HB_CURLE_CONV_REQD 76 /* caller must register conversion callbacks using curl_easy_setopt options CURLOPT_CONV_FROM_NETWORK_FUNCTION, CURLOPT_CONV_TO_NETWORK_FUNCTION, and CURLOPT_CONV_FROM_UTF8_FUNCTION */ +#define HB_CURLE_SSL_CACERT_BADFILE 77 /* could not load CACERT file, missing or wrong format */ +#define HB_CURLE_REMOTE_FILE_NOT_FOUND 78 /* remote file not found */ +#define HB_CURLE_SSH 79 /* error from the SSH layer, somewhat generic so the error message will be of interest when this has happened */ +#define HB_CURLE_SSL_SHUTDOWN_FAILED 80 /* Failed to shut down the SSL connection */ +#define HB_CURLE_AGAIN 81 /* socket is not ready for send/recv, wait till it's ready and try again */ +#define HB_CURLE_SSL_CRL_BADFILE 82 /* could not load CRL file, missing or wrong format (Added in 7.19.0) */ +#define HB_CURLE_SSL_ISSUER_ERROR 83 /* Issuer check failed. (Added in 7.19.0) */ +#define HB_CURLE_FTP_PRET_FAILED 84 /* a PRET command failed */ +#define HB_CURLE_RTSP_CSEQ_ERROR 85 /* mismatch of RTSP CSeq numbers */ +#define HB_CURLE_RTSP_SESSION_ERROR 86 /* mismatch of RTSP Session Identifiers */ +#define HB_CURLE_FTP_BAD_FILE_LIST 87 /* unable to parse FTP file list */ +#define HB_CURLE_CHUNK_FAILED 88 /* chunk callback reported error */ + +#endif /* HBCURL_CH_ */ diff --git a/harbour/contrib/hbmxml/3rd/minixml/mxml.hbp b/harbour/contrib/hbmxml/3rd/minixml/mxml.hbp index ea8a80c930..3d4e444ca3 100644 --- a/harbour/contrib/hbmxml/3rd/minixml/mxml.hbp +++ b/harbour/contrib/hbmxml/3rd/minixml/mxml.hbp @@ -16,11 +16,6 @@ {win}-cflag=-DWIN32 -DWIN {win|dos|os2}-cflag=-D_EOL_CRLF -# for snprintf()/vsnprintf(). They can be disabled in config.h -# using HAVE_SNPRINTF and HAVE_VSNPRINTF, but then isdigit() -# becomes the missing bit. [vszakats] -#-cflag=-std=gnu89{!lngcpp&allgcc} - mxml_att.c mxml_ent.c mxml_fil.c diff --git a/harbour/contrib/hbmxml/3rd/minixml/mxml_str.c b/harbour/contrib/hbmxml/3rd/minixml/mxml_str.c index 6be42523f9..455fe35bb6 100644 --- a/harbour/contrib/hbmxml/3rd/minixml/mxml_str.c +++ b/harbour/contrib/hbmxml/3rd/minixml/mxml_str.c @@ -27,6 +27,7 @@ */ #include "config.h" +#include "mxml.h" /* diff --git a/harbour/src/rtl/gtwin/gtwin.c b/harbour/src/rtl/gtwin/gtwin.c index 5d7bbc3c54..f7ea4c2d89 100644 --- a/harbour/src/rtl/gtwin/gtwin.c +++ b/harbour/src/rtl/gtwin/gtwin.c @@ -442,12 +442,27 @@ static const CLIPKEYCODE extKeyTab[CLIP_EXTKEY_COUNT] = { static int hb_gt_win_getKbdState( void ) { - /* Workaround for problems with GetKeyboardState() used with - * MS-Windows console - */ - ( void ) GetKeyState( 0 ); + int iKbdState = 0; - return hb_gt_winapi_getKbdState(); + if( GetKeyState( VK_SHIFT ) & 0x80 ) iKbdState |= HB_GTI_KBD_SHIFT; + if( GetKeyState( VK_CONTROL ) & 0x80 ) iKbdState |= HB_GTI_KBD_CTRL; + if( GetKeyState( VK_MENU ) & 0x80 ) iKbdState |= HB_GTI_KBD_ALT; + if( GetKeyState( VK_LWIN ) & 0x80 ) iKbdState |= HB_GTI_KBD_LWIN; + if( GetKeyState( VK_RWIN ) & 0x80 ) iKbdState |= HB_GTI_KBD_RWIN; + if( GetKeyState( VK_APPS ) & 0x80 ) iKbdState |= HB_GTI_KBD_MENU; + if( GetKeyState( VK_SCROLL ) & 0x01 ) iKbdState |= HB_GTI_KBD_SCROLOCK; + if( GetKeyState( VK_NUMLOCK ) & 0x01 ) iKbdState |= HB_GTI_KBD_NUMLOCK; + if( GetKeyState( VK_CAPITAL ) & 0x01 ) iKbdState |= HB_GTI_KBD_CAPSLOCK; + if( GetKeyState( VK_INSERT ) & 0x01 ) iKbdState |= HB_GTI_KBD_INSERT; + + if( GetKeyState( VK_LSHIFT ) & 0x80 ) iKbdState |= HB_GTI_KBD_LSHIFT; + if( GetKeyState( VK_RSHIFT ) & 0x80 ) iKbdState |= HB_GTI_KBD_RSHIFT; + if( GetKeyState( VK_LCONTROL ) & 0x80 ) iKbdState |= HB_GTI_KBD_LCTRL; + if( GetKeyState( VK_RCONTROL ) & 0x80 ) iKbdState |= HB_GTI_KBD_RCTRL; + if( GetKeyState( VK_LMENU ) & 0x80 ) iKbdState |= HB_GTI_KBD_LALT; + if( GetKeyState( VK_RMENU ) & 0x80 ) iKbdState |= HB_GTI_KBD_RALT; + + return iKbdState; } /* *********************************************************************** */