Libreria hbcurl

Libreria hbcurl

Postby ermatica » 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: Select all  Expand view
#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: Select all  Expand view
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
ermatica
 
Posts: 44
Joined: Mon Nov 12, 2007 1:50 pm
Location: España

Re: Libreria hbcurl

Postby Antonio Linares » Mon May 28, 2012 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41328
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Libreria hbcurl

Postby Antonio Linares » Thu Feb 07, 2013 12:26 pm

Ejemplos publicados por Carlos Mora:

viewtopic.php?f=6&t=24953&start=0&hilit=curl
Code: Select all  Expand view
#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: Select all  Expand view
        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: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41328
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Libreria hbcurl

Postby Antonio Linares » Thu Feb 07, 2013 12:53 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41328
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Libreria hbcurl

Postby Antonio Linares » Thu Feb 07, 2013 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41328
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Libreria hbcurl

Postby JmGarcia » Fri Mar 01, 2013 11:08 am

Al compilar me da estos errores:
Code: Select all  Expand view
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
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA

Re: Libreria hbcurl

Postby Antonio Linares » Fri Mar 01, 2013 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41328
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Libreria hbcurl

Postby JmGarcia » Fri Mar 01, 2013 7:42 pm

Antonio Linares wrote:Usas xHarbour ? Aparece en tu firma

Si, uso xHarbour (13.01)
Code: Select all  Expand view
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 9656)
Copyright 1999-2012, http://www.xharbour.org http://www.harbour-project.org/
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
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA

Re: Libreria hbcurl

Postby Antonio Linares » Fri Mar 01, 2013 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41328
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Libreria hbcurl

Postby JmGarcia » Sun Mar 03, 2013 7:43 pm

Ya solo me queda un error:

Code: Select all  Expand view
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
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA

Re: Libreria hbcurl

Postby Antonio Linares » Sun Mar 03, 2013 8:00 pm

JM,

Prueba a añadir este código a tu PRG principal:

Code: Select all  Expand view

#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
User avatar
Antonio Linares
Site Admin
 
Posts: 41328
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Libreria hbcurl

Postby JmGarcia » Sun Mar 03, 2013 8:17 pm

Ahora me da estos errores:
Code: Select all  Expand view
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
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA

Re: Libreria hbcurl

Postby Antonio Linares » Mon Mar 04, 2013 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41328
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Libreria hbcurl

Postby JmGarcia » Wed Mar 06, 2013 4: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
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA

Re: Libreria hbcurl

Postby JmGarcia » Sat Mar 09, 2013 3: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
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA

Next

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 9 guests