2008-05-31 12:46 UTC+0100 Viktor Szakats (harbour.01 syenar hu)

+ contrib/hbcurl
   + contrib/hbcurl/Makefile
   + contrib/hbcurl/make_b32.bat
   + contrib/hbcurl/make_vc.bat
   + contrib/hbcurl/common.mak
   + contrib/hbcurl/make_gcc.sh
   + contrib/hbcurl/hbcurl.ch
   + contrib/hbcurl/hbcurl.c
   + contrib/hbcurl/tests
   + contrib/hbcurl/tests/bld_b32.bat
   + contrib/hbcurl/tests/bld_vc.bat
   + contrib/hbcurl/tests/ftp_uldl.prg
     + Added hbcurl - CURL interface library.
     ; Based on original work of Luiz Rafael Culik / xhb, 
       but heavily reworked and fixed, and still a work 
       in progress.
This commit is contained in:
Viktor Szakats
2008-05-31 10:47:47 +00:00
parent 29f5f93b0b
commit cc56d2807e
11 changed files with 1319 additions and 0 deletions

View File

@@ -8,6 +8,24 @@
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2008-05-31 12:46 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
+ contrib/hbcurl
+ contrib/hbcurl/Makefile
+ contrib/hbcurl/make_b32.bat
+ contrib/hbcurl/make_vc.bat
+ contrib/hbcurl/common.mak
+ contrib/hbcurl/make_gcc.sh
+ contrib/hbcurl/hbcurl.ch
+ contrib/hbcurl/hbcurl.c
+ contrib/hbcurl/tests
+ contrib/hbcurl/tests/bld_b32.bat
+ contrib/hbcurl/tests/bld_vc.bat
+ contrib/hbcurl/tests/ftp_uldl.prg
+ Added hbcurl - CURL interface library.
; Based on original work of Luiz Rafael Culik / xhb,
but heavily reworked and fixed, and still a work
in progress.
2008-05-31 11:30 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/debug/debugger.prg
* removed some unused var, formatting

View File

@@ -0,0 +1,15 @@
#
# $Id$
#
ROOT = ../../
C_SOURCES=\
hbcurl.c \
PRG_HEADERS=\
hbcurl.ch \
LIBNAME=hbcurl
CFLAGS := -I/usr/include/curl

View File

@@ -0,0 +1,16 @@
#
# $Id$
#
LIBNAME = $(LIBPREF)hbcurl
LIB_PATH = $(LIB_DIR)$(LIBNAME)$(LIBEXT)
PRG_HEADERS = \
hbcurl.ch \
LIB_OBJS = \
$(OBJ_DIR)hbcurl$(OBJEXT) \
all: \
$(LIB_PATH) \

View File

@@ -0,0 +1,881 @@
/*
* $Id$
*/
/*
* xHarbour Project source code:
* CURL lib low level (Client API) interface code.
*
* Copyright 2008 Viktor Szakats <harbour.01 syenar.hu>
* Copyright 2005 Luiz Rafael Culik Guimaraes <luiz at xharbour.com.br>
* www - http://www.xharbour.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.
*
* See doc/license.txt for licensing terms.
*
*/
#include "curl/curl.h"
#include "curl/types.h"
#include "curl/easy.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbvm.h"
#include <sys/stat.h>
#include "hbcurl.ch"
#define HB_CURL_OPT_BOOL( n ) ( ISLOG( n ) ? ( long ) hb_parl( n ) : hb_parnl( n ) )
#define HB_CURL_OPT_BOOL_TRUE( n ) ( ISLOG( n ) ? ( long ) hb_parl( n ) : ( ISNUM( 1 ) ? hb_parnl( n ) : 1 ) )
typedef struct _FTPFILE
{
char * name;
FILE * handle;
} FTPFILE, * PFTPFILE;
typedef struct _CURLHANDLE
{
CURL * curl;
struct curl_httppost * sHttpPostf;
struct curl_httppost * sHttpPostl;
struct curl_slist * sHttpHeader;
struct curl_slist * sQuote;
struct curl_slist * sPostQuote;
struct curl_slist * sPreQuote;
FTPFILE file_ul;
FTPFILE file_dl;
PHB_ITEM pProgress;
} CURLHANDLE, * PCURLHANDLE;
/* ---------------------------- */
HB_FUNC( CURL_GLOBAL_INIT )
{
hb_retnl( ( long ) curl_global_init( ISNUM( 1 ) ? hb_parnl( 1 ) : CURL_GLOBAL_ALL ) );
}
HB_FUNC( CURL_GLOBAL_CLEANUP )
{
curl_global_cleanup();
}
/* ---------------------------- */
int hb_curlReadFunction( void * buffer, size_t size, size_t nmemb, void * Cargo )
{
printf( "hb_curlReadFunction()\n" );
if( Cargo )
{
PFTPFILE pfile_ul = ( PFTPFILE ) Cargo;
if( ! pfile_ul->handle )
{
pfile_ul->handle = fopen( pfile_ul->name, "rb" );
if( ! pfile_ul->handle )
return -1;
}
if( ferror( pfile_ul->handle ) )
return CURL_READFUNC_ABORT;
else
return fread( buffer, size, nmemb, pfile_ul->handle ) * size;
}
return -1;
}
int hb_curlWriteFunction( void * buffer, size_t size, size_t nmemb, void * Cargo )
{
printf( "hb_curlWriteFunction()\n" );
if( Cargo )
{
PFTPFILE pfile_dl = ( PFTPFILE ) Cargo;
if( ! pfile_dl->handle )
{
pfile_dl->handle = fopen( pfile_dl->name, "wb" );
if( ! pfile_dl->handle )
return -1;
}
return fwrite( buffer, size, nmemb, pfile_dl->handle );
}
return -1;
}
int hb_curlProgress( void * Cargo,
double t, /* dltotal */
double d, /* dlnow */
double ultotal,
double ulnow )
{
if( Cargo )
{
PHB_ITEM p1 = hb_itemPutND( NULL, ulnow > 0 ? ulnow : d );
PHB_ITEM p2 = hb_itemPutND( NULL, ultotal > 0 ? ultotal : t );
BOOL bResult = hb_itemGetL( hb_vmEvalBlockV( ( PHB_ITEM ) Cargo, 2, p1, p2 ) );
hb_itemRelease( p1 );
hb_itemRelease( p2 );
/* Abort */
if( bResult )
return 1;
}
return 0;
}
static PCURLHANDLE PCURLHANDLE_New( void )
{
PCURLHANDLE pConn = ( PCURLHANDLE ) hb_xgrab( sizeof( CURLHANDLE ) );
memset( ( void * ) pConn, 0, sizeof( CURLHANDLE ) );
pConn->curl = curl_easy_init();
return pConn;
}
static void PCURLHANDLE_free( PCURLHANDLE pConn )
{
curl_easy_setopt( pConn->curl, CURLOPT_READFUNCTION, NULL );
curl_easy_setopt( pConn->curl, CURLOPT_READDATA, NULL );
curl_easy_setopt( pConn->curl, CURLOPT_WRITEFUNCTION, NULL );
curl_easy_setopt( pConn->curl, CURLOPT_WRITEDATA, NULL );
curl_easy_setopt( pConn->curl, CURLOPT_PROGRESSFUNCTION, NULL );
curl_easy_setopt( pConn->curl, CURLOPT_PROGRESSDATA, NULL );
if( pConn->sHttpPostf )
curl_formfree( pConn->sHttpPostf );
if( pConn->sHttpPostl )
curl_formfree( pConn->sHttpPostl );
if( pConn->sHttpHeader )
curl_slist_free_all( pConn->sHttpHeader );
if( pConn->sQuote )
curl_slist_free_all( pConn->sQuote );
if( pConn->sPostQuote )
curl_slist_free_all( pConn->sPostQuote );
if( pConn->sPreQuote )
curl_slist_free_all( pConn->sPreQuote );
if( pConn->file_ul.name )
hb_xfree( pConn->file_ul.name );
if( pConn->file_ul.handle )
fclose( pConn->file_ul.handle);
if( pConn->file_dl.name )
hb_xfree( pConn->file_dl.name );
if( pConn->file_dl.handle )
fclose( pConn->file_dl.handle);
if( pConn->pProgress )
hb_itemRelease( pConn->pProgress );
curl_easy_cleanup( pConn->curl );
hb_xfree( pConn );
}
static HB_GARBAGE_FUNC( PCURLHANDLE_release )
{
void ** ph = ( void ** ) Cargo;
/* Check if pointer is not NULL to avoid multiple freeing */
if( ph && * ph )
{
/* Destroy the object */
PCURLHANDLE_free( ( PCURLHANDLE ) * ph );
/* set pointer to NULL to avoid multiple freeing */
* ph = NULL;
}
}
static PCURLHANDLE PCURLHANDLE_par( int iParam )
{
/*
void ** ph = ( void ** ) hb_parptrGC( PCURLHANDLE_release, iParam );
return ph ? ( PCURLHANDLE ) * ph : NULL;
*/
return ( PCURLHANDLE ) hb_parptr( iParam );
}
HB_FUNC( CURL_EASY_INIT )
{
/*
void ** ph = ( void ** ) hb_gcAlloc( sizeof( PCURLHANDLE ), PCURLHANDLE_release );
* ph = ( void * ) PCURLHANDLE_New();
hb_retptrGC( ph );
*/
hb_retptr( ( void * ) PCURLHANDLE_New() );
}
HB_FUNC( CURL_EASY_CLEANUP )
{
PCURLHANDLE pConn = PCURLHANDLE_par( 1 );
if( pConn )
PCURLHANDLE_free( pConn );
}
HB_FUNC( CURL_EASY_PERFORM )
{
PCURLHANDLE pConn = PCURLHANDLE_par( 1 );
if( pConn )
hb_retnl( curl_easy_perform( pConn->curl ) );
}
HB_FUNC( CURL_EASY_SETOPT )
{
PCURLHANDLE pConn = PCURLHANDLE_par( 1 );
CURLcode res = CURLE_UNSUPPORTED_PROTOCOL;
if( pConn )
{
switch( hb_parni( 2 ) )
{
case HB_CURLOPT_INFILESIZE:
case HB_CURLOPT_INFILESIZE_LARGE:
res = curl_easy_setopt( pConn->curl, CURLOPT_INFILESIZE_LARGE, ( curl_off_t ) hb_parnl( 3 ) );
break;
case HB_CURLOPT_RESUME_FROM:
case HB_CURLOPT_RESUME_FROM_LARGE:
res = curl_easy_setopt( pConn->curl, CURLOPT_RESUME_FROM_LARGE, ( curl_off_t ) hb_parnl( 3 ) );
break;
case HB_CURLOPT_MAXFILESIZE:
case HB_CURLOPT_MAXFILESIZE_LARGE:
res = curl_easy_setopt( pConn->curl, CURLOPT_MAXFILESIZE_LARGE, ( curl_off_t ) hb_parnl( 3 ) );
break;
case HB_CURLOPT_POSTFIELDSIZE:
case HB_CURLOPT_POSTFIELDSIZE_LARGE:
res = curl_easy_setopt( pConn->curl, CURLOPT_POSTFIELDSIZE_LARGE, ( curl_off_t ) hb_parnl( 3 ) );
break;
case HB_CURLOPT_PORT:
res = curl_easy_setopt( pConn->curl, CURLOPT_PORT, hb_parnl( 3 ) );
break;
case HB_CURLOPT_TIMEOUT:
res = curl_easy_setopt( pConn->curl, CURLOPT_TIMEOUT, hb_parnl( 3 ) );
break;
case HB_CURLOPT_LOW_SPEED_TIME:
res = curl_easy_setopt( pConn->curl, CURLOPT_LOW_SPEED_TIME, hb_parnl( 3 ) );
break;
case HB_CURLOPT_CRLF:
res = curl_easy_setopt( pConn->curl, CURLOPT_CRLF, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_SSLVERSION:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSLVERSION, hb_parnl( 3 ) );
break;
case HB_CURLOPT_TIMECONDITION:
res = curl_easy_setopt( pConn->curl, CURLOPT_TIMECONDITION, hb_parnl( 3 ) );
break;
case HB_CURLOPT_TIMEVALUE:
res = curl_easy_setopt( pConn->curl, CURLOPT_TIMEVALUE, hb_parnl( 3 ) );
break;
case HB_CURLOPT_VERBOSE:
res = curl_easy_setopt( pConn->curl, CURLOPT_VERBOSE, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_HEADER:
res = curl_easy_setopt( pConn->curl, CURLOPT_HEADER, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_NOPROGRESS:
res = curl_easy_setopt( pConn->curl, CURLOPT_NOPROGRESS, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_FAILONERROR:
res = curl_easy_setopt( pConn->curl, CURLOPT_FAILONERROR, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_UPLOAD:
res = curl_easy_setopt( pConn->curl, CURLOPT_UPLOAD, HB_CURL_OPT_BOOL_TRUE( 3 ) );
break;
case HB_CURLOPT_POST:
res = curl_easy_setopt( pConn->curl, CURLOPT_POST, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_FTPLISTONLY: /* CURLOPT_DIRLISTONLY */
res = curl_easy_setopt( pConn->curl, CURLOPT_FTPLISTONLY, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_FTPAPPEND: /* CURLOPT_APPEND */
res = curl_easy_setopt( pConn->curl, CURLOPT_FTPAPPEND, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_NETRC:
res = curl_easy_setopt( pConn->curl, CURLOPT_NETRC, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_FOLLOWLOCATION:
res = curl_easy_setopt( pConn->curl, CURLOPT_FOLLOWLOCATION, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_TRANSFERTEXT:
res = curl_easy_setopt( pConn->curl, CURLOPT_TRANSFERTEXT, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_PUT:
res = curl_easy_setopt( pConn->curl, CURLOPT_PUT, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_AUTOREFERER:
res = curl_easy_setopt( pConn->curl, CURLOPT_AUTOREFERER, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_PROXYPORT:
res = curl_easy_setopt( pConn->curl, CURLOPT_PROXYPORT, hb_parnl( 3 ) );
break;
case HB_CURLOPT_HTTPPROXYTUNNEL:
res = curl_easy_setopt( pConn->curl, CURLOPT_HTTPPROXYTUNNEL, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_SSL_VERIFYPEER:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSL_VERIFYPEER, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_MAXREDIRS:
res = curl_easy_setopt( pConn->curl, CURLOPT_MAXREDIRS, hb_parnl( 3 ) );
break;
case HB_CURLOPT_FILETIME:
res = curl_easy_setopt( pConn->curl, CURLOPT_FILETIME, hb_parnl( 3 ) );
break;
case HB_CURLOPT_MAXCONNECTS:
res = curl_easy_setopt( pConn->curl, CURLOPT_MAXCONNECTS, hb_parnl( 3 ) );
break;
case HB_CURLOPT_CLOSEPOLICY:
res = curl_easy_setopt( pConn->curl, CURLOPT_CLOSEPOLICY, hb_parnl( 3 ) );
break;
case HB_CURLOPT_FRESH_CONNECT:
res = curl_easy_setopt( pConn->curl, CURLOPT_FRESH_CONNECT, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_FORBID_REUSE:
res = curl_easy_setopt( pConn->curl, CURLOPT_FORBID_REUSE, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_CONNECTTIMEOUT:
res = curl_easy_setopt( pConn->curl, CURLOPT_CONNECTTIMEOUT, hb_parnl( 3 ) );
break;
case HB_CURLOPT_HTTPGET:
res = curl_easy_setopt( pConn->curl, CURLOPT_HTTPGET, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_SSL_VERIFYHOST:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSL_VERIFYHOST, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_HTTP_VERSION:
res = curl_easy_setopt( pConn->curl, CURLOPT_HTTP_VERSION, hb_parnl( 3 ) );
break;
case HB_CURLOPT_FTP_USE_EPSV:
res = curl_easy_setopt( pConn->curl, CURLOPT_FTP_USE_EPSV, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_SSLENGINE_DEFAULT:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSLENGINE_DEFAULT, hb_parnl( 3 ) );
break;
case HB_CURLOPT_DNS_USE_GLOBAL_CACHE:
res = curl_easy_setopt( pConn->curl, CURLOPT_DNS_USE_GLOBAL_CACHE, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_DNS_CACHE_TIMEOUT:
res = curl_easy_setopt( pConn->curl, CURLOPT_DNS_CACHE_TIMEOUT, hb_parnl( 3 ) );
break;
case HB_CURLOPT_COOKIESESSION:
res = curl_easy_setopt( pConn->curl, CURLOPT_COOKIESESSION, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_BUFFERSIZE:
res = curl_easy_setopt( pConn->curl, CURLOPT_BUFFERSIZE, hb_parnl( 3 ) );
break;
case HB_CURLOPT_NOSIGNAL:
res = curl_easy_setopt( pConn->curl, CURLOPT_NOSIGNAL, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_PROXYTYPE:
res = curl_easy_setopt( pConn->curl, CURLOPT_PROXYTYPE, hb_parnl( 3 ) );
break;
case HB_CURLOPT_UNRESTRICTED_AUTH:
res = curl_easy_setopt( pConn->curl, CURLOPT_UNRESTRICTED_AUTH, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_FTP_USE_EPRT:
res = curl_easy_setopt( pConn->curl, CURLOPT_FTP_USE_EPRT, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_HTTPAUTH:
res = curl_easy_setopt( pConn->curl, CURLOPT_HTTPAUTH, hb_parnl( 3 ) );
break;
case HB_CURLOPT_FTP_CREATE_MISSING_DIRS:
res = curl_easy_setopt( pConn->curl, CURLOPT_FTP_CREATE_MISSING_DIRS, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_PROXYAUTH:
res = curl_easy_setopt( pConn->curl, CURLOPT_PROXYAUTH, hb_parnl( 3 ) );
break;
case HB_CURLOPT_FTP_RESPONSE_TIMEOUT:
res = curl_easy_setopt( pConn->curl, CURLOPT_FTP_RESPONSE_TIMEOUT, hb_parnl( 3 ) );
break;
case HB_CURLOPT_IPRESOLVE:
res = curl_easy_setopt( pConn->curl, CURLOPT_IPRESOLVE, hb_parnl( 3 ) );
break;
case HB_CURLOPT_FTP_SSL: /* USE_SSL */
res = curl_easy_setopt( pConn->curl, CURLOPT_FTP_SSL, hb_parnl( 3 ) );
break;
case HB_CURLOPT_TCP_NODELAY:
res = curl_easy_setopt( pConn->curl, CURLOPT_TCP_NODELAY, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_FTPSSLAUTH:
res = curl_easy_setopt( pConn->curl, CURLOPT_FTPSSLAUTH, hb_parnl( 3 ) );
break;
case HB_CURLOPT_IGNORE_CONTENT_LENGTH:
res = curl_easy_setopt( pConn->curl, CURLOPT_IGNORE_CONTENT_LENGTH, HB_CURL_OPT_BOOL( 3 ) );
break;
case HB_CURLOPT_URL:
res = curl_easy_setopt( pConn->curl, CURLOPT_URL, hb_parcx( 3 ) );
break;
case HB_CURLOPT_PROXY:
res = curl_easy_setopt( pConn->curl, CURLOPT_PROXY, hb_parcx( 3 ) );
break;
case HB_CURLOPT_USERPWD:
res = curl_easy_setopt( pConn->curl, CURLOPT_USERPWD, hb_parcx( 3 ) );
break;
case HB_CURLOPT_PROXYUSERPWD:
res = curl_easy_setopt( pConn->curl, CURLOPT_PROXYUSERPWD, hb_parcx( 3 ) );
break;
case HB_CURLOPT_RANGE:
res = curl_easy_setopt( pConn->curl, CURLOPT_RANGE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_ERRORBUFFER:
res = curl_easy_setopt( pConn->curl, CURLOPT_ERRORBUFFER, hb_parcx( 3 ) );
break;
case HB_CURLOPT_POSTFIELDS:
res = curl_easy_setopt( pConn->curl, CURLOPT_POSTFIELDS, hb_parcx( 3 ) );
break;
case HB_CURLOPT_REFERER:
res = curl_easy_setopt( pConn->curl, CURLOPT_REFERER, hb_parcx( 3 ) );
break;
case HB_CURLOPT_FTPPORT:
res = curl_easy_setopt( pConn->curl, CURLOPT_FTPPORT, hb_parcx( 3 ) );
break;
case HB_CURLOPT_USERAGENT:
res = curl_easy_setopt( pConn->curl, CURLOPT_USERAGENT, hb_parcx( 3 ) );
break;
case HB_CURLOPT_COOKIE:
res = curl_easy_setopt( pConn->curl, CURLOPT_COOKIE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_SSLCERT:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSLCERT, hb_parcx( 3 ) );
break;
case HB_CURLOPT_SSLKEYPASSWD:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSLKEYPASSWD, hb_parcx( 3 ) );
break;
case HB_CURLOPT_WRITEHEADER:
res = curl_easy_setopt( pConn->curl, CURLOPT_WRITEHEADER, hb_parcx( 3 ) ); /* pointer or file * */
break;
case HB_CURLOPT_COOKIEFILE:
res = curl_easy_setopt( pConn->curl, CURLOPT_COOKIEFILE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_CUSTOMREQUEST:
res = curl_easy_setopt( pConn->curl, CURLOPT_CUSTOMREQUEST, hb_parcx( 3 ) );
break;
case HB_CURLOPT_STDERR:
res = curl_easy_setopt( pConn->curl, CURLOPT_STDERR, hb_parcx( 3 ) ); /* File * */
break;
case HB_CURLOPT_WRITEINFO: /* verificar */
res = curl_easy_setopt( pConn->curl, CURLOPT_WRITEINFO, hb_parcx( 3 ) );
break;
case HB_CURLOPT_PROGRESSDATA:
res = curl_easy_setopt( pConn->curl, CURLOPT_PROGRESSDATA, hb_parcx( 3 ) );
break;
case HB_CURLOPT_INTERFACE:
res = curl_easy_setopt( pConn->curl, CURLOPT_INTERFACE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_KRB4LEVEL:
res = curl_easy_setopt( pConn->curl, CURLOPT_KRB4LEVEL, hb_parcx( 3 ) );
break;
case HB_CURLOPT_CAINFO:
res = curl_easy_setopt( pConn->curl, CURLOPT_CAINFO, hb_parcx( 3 ) );
break;
case HB_CURLOPT_TELNETOPTIONS:
res = curl_easy_setopt( pConn->curl, CURLOPT_TELNETOPTIONS, hb_parcx( 3 ) ); /* use curl_slist */
break;
case HB_CURLOPT_RANDOM_FILE:
res = curl_easy_setopt( pConn->curl, CURLOPT_RANDOM_FILE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_EGDSOCKET:
res = curl_easy_setopt( pConn->curl, CURLOPT_EGDSOCKET, hb_parcx( 3 ) );
break;
case HB_CURLOPT_COOKIEJAR:
res = curl_easy_setopt( pConn->curl, CURLOPT_COOKIEJAR, hb_parcx( 3 ) );
break;
case HB_CURLOPT_SSL_CIPHER_LIST:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSL_CIPHER_LIST, hb_parcx( 3 ) );
break;
case HB_CURLOPT_SSLCERTTYPE:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSLCERTTYPE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_SSLKEY:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSLKEY, hb_parcx( 3 ) );
break;
case HB_CURLOPT_SSLKEYTYPE:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSLKEYTYPE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_SSLENGINE:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSLENGINE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_DEBUGDATA:
res = curl_easy_setopt( pConn->curl, CURLOPT_DEBUGDATA, hb_parcx( 3 ) ); /* use pointer */
break;
case HB_CURLOPT_CAPATH:
res = curl_easy_setopt( pConn->curl, CURLOPT_CAPATH, hb_parcx( 3 ) );
break;
case HB_CURLOPT_ENCODING:
res = curl_easy_setopt( pConn->curl, CURLOPT_ENCODING, hb_parcx( 3 ) );
break;
case HB_CURLOPT_PRIVATE:
res = curl_easy_setopt( pConn->curl, CURLOPT_PRIVATE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_HTTP200ALIASES:
res = curl_easy_setopt( pConn->curl, CURLOPT_HTTP200ALIASES, hb_parcx( 3 ) ); /* use struct curl_slist structs */
break;
case HB_CURLOPT_SSL_CTX_DATA:
res = curl_easy_setopt( pConn->curl, CURLOPT_SSL_CTX_DATA, hb_parcx( 3 ) ); /* use pointer */
break;
case HB_CURLOPT_NETRC_FILE:
res = curl_easy_setopt( pConn->curl, CURLOPT_NETRC_FILE, hb_parcx( 3 ) );
break;
case HB_CURLOPT_IOCTLDATA:
res = curl_easy_setopt( pConn->curl, CURLOPT_IOCTLDATA, hb_parcx( 3 ) ); /* pointer */
break;
case HB_CURLOPT_FTP_ACCOUNT:
res = curl_easy_setopt( pConn->curl, CURLOPT_FTP_ACCOUNT, hb_parcx( 3 ) );
break;
case HB_CURLOPT_COOKIELIST:
res = curl_easy_setopt( pConn->curl, CURLOPT_COOKIELIST, hb_parcx( 3 ) );
break;
case HB_CURLOPT_HTTPHEADER:
{
PHB_ITEM pHttpHeaders = hb_param( 3, HB_IT_ARRAY );
ULONG ulPos;
ULONG ulArrayPos = hb_arrayLen( pHttpHeaders );
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
curl_slist_append( pConn->sHttpHeader, hb_arrayGetCPtr( pHttpHeaders, ulPos + 1 ) );
res = curl_easy_setopt( pConn->curl, CURLOPT_HTTPHEADER, pConn->sHttpHeader );
}
break;
case HB_CURLOPT_HTTPPOST:
{
PHB_ITEM pHttpPost = hb_param( 3, HB_IT_ARRAY );
ULONG ulPos;
ULONG ulArrayPos = hb_arrayLen( pHttpPost );
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
{
PHB_ITEM pArray = hb_arrayGetItemPtr( pHttpPost, ulPos + 1 );
curl_formadd( &pConn->sHttpPostf,
&pConn->sHttpPostl,
CURLFORM_COPYNAME, hb_arrayGetCPtr( pArray, 1 ),
CURLFORM_FILE, hb_arrayGetCPtr( pArray, 2 ),
CURLFORM_END );
}
res = curl_easy_setopt( pConn->curl, CURLOPT_HTTPPOST, pConn->sHttpPostf );
}
break;
case HB_CURLOPT_QUOTE:
{
PHB_ITEM pHttpHeaders = hb_param( 3, HB_IT_ARRAY );
ULONG ulPos;
ULONG ulArrayPos = hb_arrayLen( pHttpHeaders );
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
curl_slist_append( pConn->sQuote, hb_arrayGetCPtr( pHttpHeaders, ulPos + 1 ) );
res = curl_easy_setopt( pConn->curl, CURLOPT_QUOTE, pConn->sQuote );
}
break;
case HB_CURLOPT_PREQUOTE:
{
PHB_ITEM pHttpHeaders = hb_param( 3, HB_IT_ARRAY );
ULONG ulPos;
ULONG ulArrayPos = hb_arrayLen( pHttpHeaders );
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
curl_slist_append( pConn->sQuote, hb_arrayGetCPtr( pHttpHeaders, ulPos + 1 ) );
res = curl_easy_setopt( pConn->curl, CURLOPT_PREQUOTE, pConn->sPreQuote );
}
break;
case HB_CURLOPT_POSTQUOTE:
{
PHB_ITEM pHttpHeaders = hb_param( 3, HB_IT_ARRAY );
ULONG ulPos;
ULONG ulArrayPos = hb_arrayLen( pHttpHeaders );
for( ulPos = 0; ulPos < ulArrayPos; ulPos++ )
curl_slist_append( pConn->sPostQuote, hb_arrayGetCPtr( pHttpHeaders, ulPos + 1 ) );
res = curl_easy_setopt( pConn->curl, CURLOPT_POSTQUOTE, pConn->sPostQuote );
}
break;
/* Harbour special ones */
case HB_CURLOPT_SETPROGRESS:
{
PHB_ITEM pProgress = hb_param( 3, HB_IT_BLOCK );
if( pConn->pProgress )
{
curl_easy_setopt( pConn->curl, CURLOPT_PROGRESSFUNCTION, NULL );
curl_easy_setopt( pConn->curl, CURLOPT_PROGRESSDATA, NULL );
hb_itemRelease( pConn->pProgress );
pConn->pProgress = NULL;
}
if( pProgress )
{
pConn->pProgress = hb_itemNew( NULL );
hb_itemCopy( pConn->pProgress, pProgress );
curl_easy_setopt( pConn->curl, CURLOPT_PROGRESSFUNCTION, hb_curlProgress );
res = curl_easy_setopt( pConn->curl, CURLOPT_PROGRESSDATA, ( void * ) pConn->pProgress );
}
}
break;
case HB_CURLOPT_SETUPLOADFILE:
{
if( pConn->file_ul.name )
{
hb_xfree( pConn->file_ul.name );
pConn->file_ul.name = NULL;
}
if( pConn->file_ul.handle )
{
fclose( pConn->file_ul.handle );
pConn->file_ul.handle = NULL;
}
pConn->file_ul.name = hb_strdup( hb_parc( 3 ) );
curl_easy_setopt( pConn->curl, CURLOPT_READFUNCTION, hb_curlReadFunction );
res = curl_easy_setopt( pConn->curl, CURLOPT_READDATA, ( void * ) &pConn->file_ul );
}
break;
case HB_CURLOPT_CLOSEUPLOADFILE:
{
if( pConn->file_ul.name )
{
hb_xfree( pConn->file_ul.name );
pConn->file_ul.name = NULL;
}
if( pConn->file_ul.handle )
{
fclose( pConn->file_ul.handle );
pConn->file_ul.handle = NULL;
res = CURLE_OK;
}
else
res = ( CURLcode ) -1;
}
break;
case HB_CURLOPT_SETDOWNLOADFILE:
{
if( pConn->file_dl.name )
{
hb_xfree( pConn->file_dl.name );
pConn->file_dl.name = NULL;
}
if( pConn->file_dl.handle )
{
fclose( pConn->file_dl.handle );
pConn->file_dl.handle = NULL;
}
pConn->file_dl.name = hb_strdup( hb_parc( 3 ) );
curl_easy_setopt( pConn->curl, CURLOPT_WRITEFUNCTION, hb_curlWriteFunction );
res = curl_easy_setopt( pConn->curl, CURLOPT_WRITEDATA, ( void * ) &pConn->file_dl );
}
break;
case HB_CURLOPT_CLOSEDOWNLOADFILE:
{
if( pConn->file_dl.name )
{
hb_xfree( pConn->file_dl.name );
pConn->file_dl.name = NULL;
}
if( pConn->file_dl.handle )
{
fclose( pConn->file_dl.handle );
pConn->file_dl.handle = NULL;
res = CURLE_OK;
}
else
res = ( CURLcode ) -1;
}
break;
}
case HB_CURLOPT_DOWNLOAD:
res = curl_easy_setopt( pConn->curl, CURLOPT_UPLOAD, HB_CURL_OPT_BOOL_TRUE( 3 ) ? 0 : 1 );
break;
}
hb_retnl( res );
}

View File

@@ -0,0 +1,153 @@
/*
* $Id$
*/
#ifndef HBCURL_CH_
#define HBCURL_CH_
#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_SSLCERTPASSWD 26
#define HB_CURLOPT_SSLKEYPASSWD 26
#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_FTPLISTONLY 48 /* Use NLST when listing ftp dir */
#define HB_CURLOPT_FTPAPPEND 50 /* Append instead of overwrite on upload! */
#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_KRB4LEVEL 63
#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_FTP_SSL 119
#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
/* Harbour special ones */
#define HB_CURLOPT_SETUPLOADFILE 1001
#define HB_CURLOPT_CLOSEUPLOADFILE 1002
#define HB_CURLOPT_SETDOWNLOADFILE 1003
#define HB_CURLOPT_CLOSEDOWNLOADFILE 1004
#define HB_CURLOPT_SETPROGRESS 1005
#define HB_CURLOPT_DOWNLOAD 1006
#endif /* HBCURL_CH_ */

View File

@@ -0,0 +1,64 @@
@echo off
rem
rem $Id$
rem
if not "%HB_DIR_CURL%" == "" goto DIR_OK
echo ---------------------------------------------------------------
echo IMPORTANT: You'll need the CURL package and this envvar
echo to be set to successfully build this library:
echo set HB_DIR_CURL=C:\curl
echo ---------------------------------------------------------------
goto POST_EXIT
:DIR_OK
if "%HB_INC_CURL%" == "" set HB_INC_CURL=%HB_DIR_CURL%\include
set CFLAGS=-I"%HB_INC_CURL%"
set _HB_DLL_NAME=libcurl
set _HB_DLL_DIR=%HB_DIR_CURL%
rem ---------------------------------------------------------------
call ..\mtpl_b32.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
rem ---------------------------------------------------------------
set _HB_INSTALL_PREFIX=%HB_INSTALL_PREFIX%
if "%_HB_INSTALL_PREFIX%" == "" set _HB_INSTALL_PREFIX=..\..
set _HB_LIB_INSTALL=%HB_LIB_INSTALL%
if "%_HB_LIB_INSTALL%" == "" set _HB_LIB_INSTALL=%_HB_INSTALL_PREFIX%\lib
if "%1" == "clean" goto POST_CLEAN
if "%1" == "Clean" goto POST_CLEAN
if "%1" == "CLEAN" goto POST_CLEAN
if "%1" == "install" goto POST_INSTALL
if "%1" == "Install" goto POST_INSTALL
if "%1" == "INSTALL" goto POST_INSTALL
:POST_BUILD
implib -a ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib "%_HB_DLL_DIR%\%_HB_DLL_NAME%.dll" >> %_HB_MAKELOG%
goto POST_EXIT
:POST_CLEAN
if exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib del ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib > nul
if exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.exp del ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.exp > nul
if exist %_HB_LIB_INSTALL%\%_HB_DLL_NAME%.lib del %_HB_LIB_INSTALL%\%_HB_DLL_NAME%.lib > nul
goto POST_EXIT
:POST_INSTALL
if exist %_HB_LIB_INSTALL%\%_HB_DLL_NAME%.lib del %_HB_LIB_INSTALL%\%_HB_DLL_NAME%.lib
if exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib copy ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib %_HB_LIB_INSTALL%
goto POST_EXIT
:POST_EXIT
set CFLAGS=
set _HB_DLL_NAME=
set _HB_DLL_DIR=
set _HB_INSTALL_PREFIX=
set _HB_LIB_INSTALL=

View File

@@ -0,0 +1,24 @@
#!/bin/sh
#
# $Id$
#
if [ "${HB_INC_CURL}" == "" ]
then
echo "---------------------------------------------------------------"
echo "IMPORTANT: You will need the CURL package installed and this"
echo " envvar to be set to successfully build this library:"
echo " export HB_INC_CURL=C:/curl"
echo " or"
echo " export HB_INC_CURL=/usr/include/curl"
echo "---------------------------------------------------------------"
exit 1
fi
export CFLAGS=""
for I in ${HB_INC_CURL}; do
CFLAGS="${CFLAGS} -I${I}"
done
../mtpl_gcc.sh $1 $2 $3 $4 $5 $6 $7 $8 $9
unset CFLAGS

View File

@@ -0,0 +1,65 @@
@echo off
rem
rem $Id$
rem
if not "%HB_DIR_CURL%" == "" goto DIR_OK
echo ---------------------------------------------------------------
echo IMPORTANT: You'll need the CURL package and this envvar
echo to be set to successfully build this library:
echo set HB_DIR_CURL=C:\curl
echo ---------------------------------------------------------------
goto POST_EXIT
:DIR_OK
if "%HB_INC_CURL%" == "" set HB_INC_CURL=%HB_DIR_CURL%\include
set CFLAGS=-I"%HB_INC_CURL%"
set _HB_DLL_NAME=libcurl
set _HB_DLL_DIR=%HB_DIR_CURL%
rem ---------------------------------------------------------------
call ..\mtpl_vc.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
rem ---------------------------------------------------------------
set _HB_INSTALL_PREFIX=%HB_INSTALL_PREFIX%
if "%_HB_INSTALL_PREFIX%" == "" set _HB_INSTALL_PREFIX=..\..
set _HB_LIB_INSTALL=%HB_LIB_INSTALL%
if "%_HB_LIB_INSTALL%" == "" set _HB_LIB_INSTALL=%_HB_INSTALL_PREFIX%\lib
if "%1" == "clean" goto POST_CLEAN
if "%1" == "Clean" goto POST_CLEAN
if "%1" == "CLEAN" goto POST_CLEAN
if "%1" == "install" goto POST_INSTALL
if "%1" == "Install" goto POST_INSTALL
if "%1" == "INSTALL" goto POST_INSTALL
:POST_BUILD
rem Use supplied .lib file.
if not exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib copy "%HB_DIR_CURL%\%_HB_DLL_NAME%.lib" ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib > nul
goto POST_EXIT
:POST_CLEAN
if exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib del ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib > nul
if exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.exp del ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.exp > nul
if exist %_HB_LIB_INSTALL%\%_HB_DLL_NAME%.lib del %_HB_LIB_INSTALL%\%_HB_DLL_NAME%.lib > nul
goto POST_EXIT
:POST_INSTALL
if exist %_HB_LIB_INSTALL%\%_HB_DLL_NAME%.lib del %_HB_LIB_INSTALL%\%_HB_DLL_NAME%.lib
if exist ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib copy ..\..\lib\%_HB_CC_NAME%\%_HB_DLL_NAME%.lib %_HB_LIB_INSTALL%
goto POST_EXIT
:POST_EXIT
set CFLAGS=
set _HB_DLL_NAME=
set _HB_DLL_DIR=
set _HB_INSTALL_PREFIX=
set _HB_LIB_INSTALL=

View File

@@ -0,0 +1,14 @@
@echo off
rem
rem $Id$
rem
if "%HB_BIN_INSTALL%" == "" set HB_BIN_INSTALL=..\..\..\bin
if "%HB_LIB_INSTALL%" == "" set HB_LIB_INSTALL=..\..\..\lib
if "%HB_INC_INSTALL%" == "" set HB_INC_INSTALL=..\..\..\include
set HB_ARCHITECTURE=w32
set HB_COMPILER=bcc32
set HB_USER_LIBS=hbcurl.lib libcurl.lib
call %HB_BIN_INSTALL%\bld.bat %1 %2 %3 %4 %5 %6 %7 %8 %9

View File

@@ -0,0 +1,14 @@
@echo off
rem
rem $Id$
rem
if "%HB_BIN_INSTALL%" == "" set HB_BIN_INSTALL=..\..\..\bin
if "%HB_LIB_INSTALL%" == "" set HB_LIB_INSTALL=..\..\..\lib
if "%HB_INC_INSTALL%" == "" set HB_INC_INSTALL=..\..\..\include
set HB_ARCHITECTURE=w32
set HB_COMPILER=msvc
set HB_USER_LIBS=hbcurl.lib libcurl.lib
call %HB_BIN_INSTALL%\bld.bat %1 %2 %3 %4 %5 %6 %7 %8 %9

View File

@@ -0,0 +1,55 @@
/*
* $Id$
*/
/* Redirect STDERR to a file to see the verbose output. */
#include "hbcurl.ch"
#define LOCAL_FILE "ftp_up.prg"
#define UPLOAD_FILE_AS "ftp_upped.prg"
#define REMOTE_URL "ftp://harbour:power@localhost/" + UPLOAD_FILE_AS
#define RENAME_FILE_TO "ftp_upped_renamed.prg"
FUNCTION Main()
LOCAL curl
? "INIT:", curl_global_init()
IF ! Empty( curl := curl_easy_init() )
? curl_easy_setopt( curl, HB_CURLOPT_UPLOAD )
? curl_easy_setopt( curl, HB_CURLOPT_URL, REMOTE_URL )
? curl_easy_setopt( curl, HB_CURLOPT_SETUPLOADFILE, LOCAL_FILE )
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, .T. )
? curl_easy_setopt( curl, HB_CURLOPT_USERPWD, "harbour:power" ) /* May use this instead of embedding in URL */
? curl_easy_setopt( curl, HB_CURLOPT_SETPROGRESS, {| nPos, nLen | DispOutAt( 10, 10, Str( ( nPos / nLen ) * 100, 6, 2 ) + "%" ) } )
? curl_easy_setopt( curl, HB_CURLOPT_NOPROGRESS, .F. )
? curl_easy_setopt( curl, HB_CURLOPT_POSTQUOTE, { "RNFR " + UPLOAD_FILE_AS, "RNTO " + RENAME_FILE_TO } )
? "UPLOAD:", curl_easy_perform( curl )
curl_easy_cleanup( curl )
ENDIF
? "-------------------------"
IF ! Empty( curl := curl_easy_init() )
/* Now let's download something */
? curl_easy_setopt( curl, HB_CURLOPT_DOWNLOAD )
? curl_easy_setopt( curl, HB_CURLOPT_URL, "ftp://ftp.cisco.com/README" )
? curl_easy_setopt( curl, HB_CURLOPT_SETDOWNLOADFILE, "test_dl.bin" )
? curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, .T. )
? "DOWNLOAD:", curl_easy_perform( curl )
/* Cleanup session */
curl_easy_cleanup( curl )
ENDIF
curl_global_cleanup()
RETURN NIL