Ultimo escollo
Publicado: Mar Nov 06, 2012 1:22 pm
Bien, pues decidido a pasar TODAS las aplicaciones mias a Harbour, en la
recta final, me encuentro con este Wrapper que no termina de funcionar.
#pragma BEGINDUMP
#include "hbapi.h"
#include "hbapierr.h"
#include "hbstack.h"
HB_FUNC( URL_ENCODE )
{
char *cData = hb_parc(1);
int nLen = hb_parclen(1);
BOOL bComplete = hb_parl(2);
char *cRet;
int nPos = 0, nPosRet = 0, nVal;
char cElem;
if ( hb_pcount() < 2 )
{
bComplete = TRUE;
}
if ( ! cData )
{
hb_errRT_BASE( EG_ARG, 3012, NULL,
"TIPENCODERBASE64_ENCODE", 1, hb_paramError(1) );
return;
}
if ( ! nLen )
{
hb_retc( "" );
return;
}
// Giving maximum final length possible
cRet = (char *) hb_xgrab( nLen * 3 +1);
while ( nPos < nLen )
{
cElem = cData[ nPos ];
if ( cElem == ' ' )
{
cRet[ nPosRet ] = '+';
}
else if (
(cElem >= 'A' && cElem <= 'Z') ||
(cElem >= 'a' && cElem <= 'z') ||
(cElem >= '0' && cElem <= '9') ||
cElem == '.' || cElem == ',' ||
cElem == '/' || cElem == ';' || cElem =='_' )
{
cRet[ nPosRet ] = cElem;
}
else if ( ! bComplete && ( cElem == ':' || cElem == '?' || cElem ==
'=' ) )
{
cRet[ nPosRet ] = cElem;
}
else // encode!
{
cRet[ nPosRet++] = '%';
nVal = ((unsigned char) cElem) >> 4;
cRet[ nPosRet++] = nVal < 10 ? '0' + nVal : 'A' + nVal - 10;
nVal = ((unsigned char) cElem) & 0x0f;
cRet[ nPosRet ] = nVal < 10 ? '0' + nVal : 'A' + nVal - 10;
}
nPosRet++;
nPos++;
}
cRet[ nPosRet ] = 0;
/* this function also adds a zero */
hb_retclenAdoptRaw( cRet, nPosRet );
}
#pragma ENDDUMP
No se si ya existe esa funcion en Harbour, pues hasta hoy la utilizo para
enviar SMSs en mi aplicación Xailer+xHarbour.
el error de compilado-enlazado...
Compilant TSms.prg...
Compilant DatosPostVenta.prg...
Compilant LlistatsFitxersG520.prg...
Warning W8075 TSms.prg 244: Suspicious pointer conversion in function
HB_FUN_URL_ENCODE
Error E2451 TSms.prg 246: Undefined symbol 'BOOL' in function
HB_FUN_URL_ENCODE
Error E2379 TSms.prg 246: Statement missing ; in function HB_FUN_URL_ENCODE
Error E2140 TSms.prg 247: Declaration is not allowed here in function
HB_FUN_URL_ENCODE
Error E2140 TSms.prg 248: Declaration is not allowed here in function
HB_FUN_URL_ENCODE
Error E2140 TSms.prg 249: Declaration is not allowed here in function
HB_FUN_URL_ENCODE
Error E2451 TSms.prg 253: Undefined symbol 'bComplete' in function
HB_FUN_URL_ENCODE
Error E2451 TSms.prg 253: Undefined symbol 'TRUE' in function
HB_FUN_URL_ENCODE
Warning W8065 TSms.prg 308: Call to function 'hb_retclenAdoptRaw' with no
prototype in function HB_FUN_URL_ENCODE
3 Files, 2 Warnings, 7 Errors
Temps de compilació: 2.53s Temps d'enllaçat: 0s Temp total: 3.14s
Gracias.
Un Saludo,
Xevi
__________ Información de ESET NOD32 Antivirus, versión de la base de firmas de virus 7663 (20121106) __________
ESET NOD32 Antivirus ha comprobado este mensaje.
http://www.eset.com
recta final, me encuentro con este Wrapper que no termina de funcionar.
#pragma BEGINDUMP
#include "hbapi.h"
#include "hbapierr.h"
#include "hbstack.h"
HB_FUNC( URL_ENCODE )
{
char *cData = hb_parc(1);
int nLen = hb_parclen(1);
BOOL bComplete = hb_parl(2);
char *cRet;
int nPos = 0, nPosRet = 0, nVal;
char cElem;
if ( hb_pcount() < 2 )
{
bComplete = TRUE;
}
if ( ! cData )
{
hb_errRT_BASE( EG_ARG, 3012, NULL,
"TIPENCODERBASE64_ENCODE", 1, hb_paramError(1) );
return;
}
if ( ! nLen )
{
hb_retc( "" );
return;
}
// Giving maximum final length possible
cRet = (char *) hb_xgrab( nLen * 3 +1);
while ( nPos < nLen )
{
cElem = cData[ nPos ];
if ( cElem == ' ' )
{
cRet[ nPosRet ] = '+';
}
else if (
(cElem >= 'A' && cElem <= 'Z') ||
(cElem >= 'a' && cElem <= 'z') ||
(cElem >= '0' && cElem <= '9') ||
cElem == '.' || cElem == ',' ||
cElem == '/' || cElem == ';' || cElem =='_' )
{
cRet[ nPosRet ] = cElem;
}
else if ( ! bComplete && ( cElem == ':' || cElem == '?' || cElem ==
'=' ) )
{
cRet[ nPosRet ] = cElem;
}
else // encode!
{
cRet[ nPosRet++] = '%';
nVal = ((unsigned char) cElem) >> 4;
cRet[ nPosRet++] = nVal < 10 ? '0' + nVal : 'A' + nVal - 10;
nVal = ((unsigned char) cElem) & 0x0f;
cRet[ nPosRet ] = nVal < 10 ? '0' + nVal : 'A' + nVal - 10;
}
nPosRet++;
nPos++;
}
cRet[ nPosRet ] = 0;
/* this function also adds a zero */
hb_retclenAdoptRaw( cRet, nPosRet );
}
#pragma ENDDUMP
No se si ya existe esa funcion en Harbour, pues hasta hoy la utilizo para
enviar SMSs en mi aplicación Xailer+xHarbour.
el error de compilado-enlazado...
Compilant TSms.prg...
Compilant DatosPostVenta.prg...
Compilant LlistatsFitxersG520.prg...
Warning W8075 TSms.prg 244: Suspicious pointer conversion in function
HB_FUN_URL_ENCODE
Error E2451 TSms.prg 246: Undefined symbol 'BOOL' in function
HB_FUN_URL_ENCODE
Error E2379 TSms.prg 246: Statement missing ; in function HB_FUN_URL_ENCODE
Error E2140 TSms.prg 247: Declaration is not allowed here in function
HB_FUN_URL_ENCODE
Error E2140 TSms.prg 248: Declaration is not allowed here in function
HB_FUN_URL_ENCODE
Error E2140 TSms.prg 249: Declaration is not allowed here in function
HB_FUN_URL_ENCODE
Error E2451 TSms.prg 253: Undefined symbol 'bComplete' in function
HB_FUN_URL_ENCODE
Error E2451 TSms.prg 253: Undefined symbol 'TRUE' in function
HB_FUN_URL_ENCODE
Warning W8065 TSms.prg 308: Call to function 'hb_retclenAdoptRaw' with no
prototype in function HB_FUN_URL_ENCODE
3 Files, 2 Warnings, 7 Errors
Temps de compilació: 2.53s Temps d'enllaçat: 0s Temp total: 3.14s
Gracias.
Un Saludo,
Xevi
__________ Información de ESET NOD32 Antivirus, versión de la base de firmas de virus 7663 (20121106) __________
ESET NOD32 Antivirus ha comprobado este mensaje.
http://www.eset.com