FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Libreria hbcurl
Posts: 44
Joined: Mon Nov 12, 2007 01:50 PM
Libreria hbcurl
Posted: Sat May 19, 2012 12:33 PM
Hola,

Estoy interesado en usar la libreria hbcurl, que viene en las contrib de Harbour para la presentaci贸n telem谩tica de determinados modelos en la AEAT.
Me he creado un simple prg:

Code (fw): Select all Collapse
#include "FiveWin.ch"
#Include "Common.ch"
#include "Fileio.ch"
#include "hbcurl.ch"

Function Prueba()
聽 聽? curl_version()
Return


Y he includo en el make la libreria hbcur.lib, pero al compilar y linkar me da los siguientes errores:
Code (fw): Select all Collapse
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external '_curl_global_init_mem' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_global_cleanup' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_formfree' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_cleanup' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_reset' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_duphandle' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_init' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_pause' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_perform' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_send' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_recv' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_formadd' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_slist_append' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_setopt' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_getinfo' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_slist_free_all' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_escape' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_unescape' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_version' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_version_info' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_easy_strerror' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_getdate' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_escape' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_unescape' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core
Error: Unresolved external '_curl_free' referenced from C:\HARBOUR300\LIB\WIN\BCC\HBCURL.LIB|core


Entiendo que me falta alguna libreria m谩s para compilar y linkar.

Estoy usando: FWH ver 10.7, Harbour 3.0 y Borland 5.8.
La libreria HBCURL.LIB es la que viene dentro de las lib de Harbour, no la he generado yo.

Alguien que use esta libreria y me pueda orientar un poco.

Muchas gracias,
Un saludo
Ernesto
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Libreria hbcurl
Posted: Mon May 28, 2012 06:56 PM
Ernesto,

Parece que tienes que enlazar la libreria curl que puedes descargar desde aqui:

http://curl.haxx.se/download.html
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Libreria hbcurl
Posted: Thu Feb 07, 2013 12:26 PM
Ejemplos publicados por Carlos Mora:

viewtopic.php?f=6&t=24953&start=0&hilit=curl
Code (fw): Select all Collapse
#include "hbcurl.ch"
聽 聽 聽 聽 聽curl_global_init()

聽 聽 聽 聽 聽IF ! Empty( curl := curl_easy_init() )
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_DOWNLOAD )
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_URL, "http[s]://la direccion de tu pdf")

聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_SSL_VERIFYPEER, .f. )
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_SSL_VERIFYHOST, .f. )
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_DL_BUFF_SETUP )
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_NOPROGRESS, .f. )
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, .T. )

聽 聽 聽 聽 聽 聽 if curl_easy_perform( curl ) == 0
聽 聽 聽 聽 聽 聽 聽 聽tmp := curl_easy_dl_buff_get( curl )

聽 聽 聽 聽 聽 聽 聽 聽If left( tmp, 4 ) == '%PDF'
聽 聽 聽 聽 聽 聽 聽 聽 聽 Memowrit( 'HeBajadoEl.pdf', tmp )
聽 聽 聽 聽 聽 聽 聽 聽EndIf
聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 endif

viewtopic.php?f=6&t=22654&start=0&hilit=hb+curl
Code (fw): Select all Collapse
 聽 聽 聽 聽 MsgWOn( 'Contactando Agencia Tributaria...' )

聽 聽 聽 聽 聽curl_global_init()

聽 聽 聽 聽 聽IF ! Empty( curl := curl_easy_init() )
聽 聽 聽 聽 聽 聽 cTexto:= MemoRead(cFileName)
聽 聽 聽 聽 聽 聽 tmp1 := '<T3030'+cEjercicio+'0A0000><AUX>'+Space(300)+'</AUX><VECTOR>001FIN'+Space(294)+'</VECTOR>'+;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 urlencode( cTexto ) +'</ T3030'+cEjercicio+'0A0000>'
// variables POST
聽 聽 聽 聽 聽 聽 tmp := 'HID=IE13030B&TIA='+If(oRB:TipoDecl$'UG','I',oRB:TipoDecl)+'&NDC='+AllTrim(DatTrib->NIF)+'&NRC=&ING=&NRR=&ICO=&NR1=&IN1=&NR2=&IN2=&NR3=&IN3=&NR4=&IN4=&NR5=&IN5=&NR6=&IN6=&NR7=&IN7=&IDI=ES&F01='+tmp1+;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽'&TXT=&FIR=&FIN=F&EJF='+cEjercicio+'&MOD=303&PRG=EWLINKPS'
聽 聽 聽 聽 聽 聽 #include "hbcurl.ch"
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_DOWNLOAD )
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_URL, "https://www2.agenciatributaria.gob.es/es13/l/zi21zilk0021")
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_POSTFIELDS, tmp)
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_SSL_VERIFYPEER, .f. )
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_SSL_VERIFYHOST, .f. )
聽 聽 聽 聽 聽 聽 curl_easy_setopt( curl, HB_CURLOPT_DL_BUFF_SETUP )

聽 聽 聽 聽 聽 聽 if curl_easy_perform( curl ) == 0
聽 聽 聽 聽 聽 聽 聽 聽MsgWOff()

聽 聽 聽 聽 聽 聽 聽 聽tmp := curl_easy_dl_buff_get( curl )

聽 聽 聽 聽 聽 聽 聽 聽If left( tmp, 4 ) == '%PDF'
聽 聽 聽 聽 聽 聽 聽 聽 聽 Memowrit( 'm303.pdf', tmp )
聽 聽 聽 聽 聽 聽 聽 聽 聽 If MsgYesNo( 'Desea ver el borrador generado?' )// Sociedades O Domiciliacion
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽ShellExecute( , "Open", 'm303.pdf' )
聽 聽 聽 聽 聽 聽 聽 聽 聽 EndIf
聽 聽 聽 聽 聽 聽 聽 聽Else
聽 聽 聽 聽 聽 聽 聽 聽 聽 If 'Err[' $ tmp // Hay una lista de errores
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽tmp:= SubStr( tmp, AT( 'Err[', tmp ) )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽aLista := ListAsArray( SubStr( tmp, AT( 'Err[', tmp ) ), ';', .T. )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽aSize( aLista, 20 )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽tmp:= 'Lista de Errores'+CRLF
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽For i:= 1 To Len( aLista )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 aLista[i] := SubStr( aLista[i], AT( "'", aLista[i] )+1 )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 aLista[i] := Left( aLista[i], Len( aLista[i] ) - 1 )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 if !Empty( aLista[i] )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽tmp+= CRLF + aLista[i]
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽EndFor
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽MsgAlert( tmp )
聽 聽 聽 聽 聽 聽 聽 聽 聽 Else
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽MsgAlert( tmp, 'Error en el procesamiento de la AEAT' )
聽 聽 聽 聽 聽 聽 聽 聽 聽 EndIf
聽 聽 聽 聽 聽 聽 聽 聽EndIf
聽 聽 聽 聽 聽 聽 Else
聽 聽 聽 聽 聽 聽 聽 聽MsgInfo( 'Problemas en la comunicaci贸n' )
聽 聽 聽 聽 聽 聽 EndIf
聽 聽 聽 聽 聽 聽 curl_easy_reset( curl )
聽 聽 聽 聽 聽Else
聽 聽 聽 聽 聽 聽 MsgInfo( 'Problemas para inicializar conexiones' )
聽 聽 聽 聽 聽EndIf
聽 聽 聽 聽 聽MsgWOff()

聽 聽 聽 聽 聽curl_global_cleanup()

Code (fw): Select all Collapse
cUrl := <La url del form>
cVar := <el nombre del INPUT>
cValue := <el valor que quieres cargar en el form>
// ActualizaScr() ser铆a una funci贸n que se ejecuta durante la 
descarga.
// curl es el handle de la conexi贸n de CURL

#include "hbcurl.ch"
curl_global_init()

IF ! Empty( curl := curl_easy_init() )
tmp := cVar + '=' + cValue
curl_easy_setopt( curl, HB_CURLOPT_DOWNLOAD )
curl_easy_setopt( curl, HB_CURLOPT_URL, cUrl)
curl_easy_setopt( curl, HB_CURLOPT_POSTFIELDS, tmp)
// Si usa https, estas lineas ayudan
curl_easy_setopt( curl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
curl_easy_setopt( curl, HB_CURLOPT_SSL_VERIFYHOST, .F. )
curl_easy_setopt( curl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( curl, HB_CURLOPT_PROGRESSBLOCK, ;
{| nPos, nLen | ActualizaScr() } )
curl_easy_setopt( curl, HB_CURLOPT_NOPROGRESS, .F. )
curl_easy_setopt( curl, HB_CURLOPT_VERBOSE, .F. )

if curl_easy_perform( curl ) == 0 // Todo OK
tmp := curl_easy_dl_buff_get( curl )
Memowrit( 'fotos.zip', tmp )
Else
MsgInfo( 'Problemas en la comunicaci贸n' )
EndIf
curl_easy_reset( curl )
Else
MsgInfo( 'Problemas para inicializar conexiones' )
EndIf

curl_global_cleanup()
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Libreria hbcurl
Posted: Thu Feb 07, 2013 12:53 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Libreria hbcurl
Posted: Thu Feb 07, 2013 07:03 PM
Here you have the curl library for Harbour (tested with FWH):

http://code.google.com/p/harbour-and-xharbour-builds/downloads/detail?name=hbcurl.zip&can=2&q=

Thanks to Carlos Mora for his help :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 654
Joined: Mon May 29, 2006 03:14 PM
Re: Libreria hbcurl
Posted: Fri Mar 01, 2013 11:08 AM
Al compilar me da estos errores:
Code (fw): Select all Collapse
Error: Unresolved external '_hb_gcMark' referenced from C:\BASES\FWH1301\CONTRIBUCIONES\CURL\HBCURL.LIB|core
Error: Unresolved external '_hb_gcAllocate' referenced from C:\BASES\FWH1301\CONTRIBUCIONES\CURL\HBCURL.LIB|core
Error: Unresolved external '_hb_storns' referenced from C:\BASES\FWH1301\CONTRIBUCIONES\CURL\HBCURL.LIB|core
Error: Unresolved external '_hb_storclen_buffer' referenced from C:\BASES\FWH1301\CONTRIBUCIONES\CURL\HBCURL.LIB|core
Error: Unresolved external '_hb_parnldef' referenced from C:\BASES\FWH1301\CONTRIBUCIONES\CURL\HBCURL.LIB|core
Mi abuelo dec铆a: Los aviones vuelan porque Dios quiere, y los helic贸pteros ni Dios sabe porque vuelan.

FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Libreria hbcurl
Posted: Fri Mar 01, 2013 02:03 PM

JM,

Usas xHarbour ? Aparece en tu firma

En caso de usar Harbour, que version usas ? Ejecuta harbour.exe y ves la versi贸n :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 654
Joined: Mon May 29, 2006 03:14 PM
Re: Libreria hbcurl
Posted: Fri Mar 01, 2013 07:42 PM
Antonio Linares wrote:Usas xHarbour ? Aparece en tu firma

Si, uso xHarbour (13.01)
Code (fw): Select all Collapse
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 9656)
Copyright 1999-2012, http://www.xharbour.org <!-- m --><a class="postlink" href="http://www.harbour-project.org/">http://www.harbour-project.org/</a><!-- m -->
Mi abuelo dec铆a: Los aviones vuelan porque Dios quiere, y los helic贸pteros ni Dios sabe porque vuelan.

FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Libreria hbcurl
Posted: Fri Mar 01, 2013 09:55 PM
JM,

Esa libreria no es compatible con Harbour. Esta si lo debe ser:

https://code.google.com/p/harbour-and-xharbour-builds/downloads/detail?name=hbcurlx.zip&can=2&q=
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 654
Joined: Mon May 29, 2006 03:14 PM
Re: Libreria hbcurl
Posted: Sun Mar 03, 2013 07:43 PM
Ya solo me queda un error:

Code (fw): Select all Collapse
Error: Unresolved external '_HB_FUN_CURL_EASY_DL_BUFF_GET'
Mi abuelo dec铆a: Los aviones vuelan porque Dios quiere, y los helic贸pteros ni Dios sabe porque vuelan.

FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Libreria hbcurl
Posted: Sun Mar 03, 2013 08:00 PM
JM,

Prueba a a帽adir este c贸digo a tu PRG principal:

Code (fw): Select all Collapse
#pragma BEGINDUMP

HB_FUNC( CURL_EASY_DL_BUFF_GET )
{
      PHB_CURL hb_curl = ( PHB_CURL ) hb_parnl( 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 );
}

#pragma ENDDUMP


No te has planteado pasarte a Harbour ? es la mejor opci贸n actual :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 654
Joined: Mon May 29, 2006 03:14 PM
Re: Libreria hbcurl
Posted: Sun Mar 03, 2013 08:17 PM
Ahora me da estos errores:
Code (fw): Select all Collapse
Error E2451 C:\\Programa\\_PRACTICAS\\HB_cURL.prg 60: Undefined symbol 'PHB_CURL' in function HB_FUN_CURL_EASY_DL_BUFF_GET
Error E2379 C:\\Programa\\_PRACTICAS\\HB_cURL.prg 60: Statement missing ; in function HB_FUN_CURL_EASY_DL_BUFF_GET
Error E2451 C:\\Programa\\_PRACTICAS\\HB_cURL.prg 62: Undefined symbol 'hb_curl' in function HB_FUN_CURL_EASY_DL_BUFF_GET
Error E2040 C:\\Programa\\_PRACTICAS\\HB_cURL.prg 67: Declaration terminated incorrectly
Error E2190 C:\\Programa\\_PRACTICAS\\HB_cURL.prg 69: Unexpected }

Antonio Linares wrote:No te has planteado pasarte a Harbour ? es la mejor opci贸n actual :-)
驴 Y solo tengo que quitar la "X" ?
驴 Ser谩 tan facil como poner Harbour donde pone xHarbour ?
驴 Puedo seguir usando FWH ?
驴 Por donde empiezo ?
Mi abuelo dec铆a: Los aviones vuelan porque Dios quiere, y los helic贸pteros ni Dios sabe porque vuelan.

FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Libreria hbcurl
Posted: Mon Mar 04, 2013 02:50 AM
JM,

Descarga la versi贸n m谩s reciente de Harbour (tienes que usar bcc582) desde aqui:
https://code.google.com/p/harbour-and-xharbour-builds/downloads/detail?name=harbour_bcc582_20130228.zip&can=2&q=

y modifica tus ficheros makes o batch, usando FWH/samples/buildh.bat como guia.

y recompila todos tus PRGs

asi de sencillo :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 654
Joined: Mon May 29, 2006 03:14 PM
Re: Libreria hbcurl
Posted: Wed Mar 06, 2013 04:18 PM
Antonio Linares wrote:...y modifica tus ficheros makes o batch, usando FWH/samples/buildh.bat como guia...

Pues con alg煤n que otro problemilla he conseguido mi primer programa en Harbour (sin X).

He enlazado las librerias hbcurl.lib y libcurl.lib y ha compilado bien, pero al ejacutar no encontraba las DLLs libcurl.dll, libeay32.dll y libssl32.dll. Las he colocado en el directorio del executable y funcionando.

Pero una cosa que odio a mas no poder es que un ejecutable no sea "libre" el solo de por si. Es decir que tenga que depender de DLLs.
Entonces 驴 como paso las DLL a LIB ?
Mi abuelo dec铆a: Los aviones vuelan porque Dios quiere, y los helic贸pteros ni Dios sabe porque vuelan.

FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
Posts: 654
Joined: Mon May 29, 2006 03:14 PM
Re: Libreria hbcurl
Posted: Sat Mar 09, 2013 03:25 PM
JmGarcia wrote:驴 como paso las DLL a LIB ?

驴 Alguna idea ?
Mi abuelo dec铆a: Los aviones vuelan porque Dios quiere, y los helic贸pteros ni Dios sabe porque vuelan.

FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013