2011-05-06 13:38 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbtip/encurl.prg
  * contrib/hbtip/hbtip.hbx
  * contrib/hbtip/cgi.prg
  * contrib/hbtip/url.prg
  * contrib/hbtip/httpcli.prg
  * contrib/hbtip/encurlc.c
    * promoted to documented level (renamed, INCOMPATIBLE):
      __TIP_URL_ENCODE() -> TIP_URL_ENCODE()
      __TIP_URL_DECODE() -> TIP_URL_DECODE()

  * contrib/hbtip/encb64c.c
  * contrib/hbtip/encb64.prg
    % deleted __TIP_BASE64_ENCODE()
      replaced by core HB_BASE64ENCODE()
This commit is contained in:
Viktor Szakats
2011-05-06 11:40:32 +00:00
parent f6db80d78c
commit 8742bbb23d
9 changed files with 38 additions and 106 deletions

View File

@@ -16,6 +16,22 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-05-06 13:38 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbtip/encurl.prg
* contrib/hbtip/hbtip.hbx
* contrib/hbtip/cgi.prg
* contrib/hbtip/url.prg
* contrib/hbtip/httpcli.prg
* contrib/hbtip/encurlc.c
* promoted to documented level (renamed, INCOMPATIBLE):
__TIP_URL_ENCODE() -> TIP_URL_ENCODE()
__TIP_URL_DECODE() -> TIP_URL_DECODE()
* contrib/hbtip/encb64c.c
* contrib/hbtip/encb64.prg
% deleted __TIP_BASE64_ENCODE()
replaced by core HB_BASE64ENCODE()
2011-05-06 13:14 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* INSTALL
* little discouragment to use HB_QTPATH

View File

@@ -136,7 +136,7 @@ METHOD New() CLASS TIpCgi
FOR nCount := 1 TO nLen
aVar := hb_ATokens( aTemp[ nCount ], "=" )
IF Len( aVar ) == 2
::hPosts[ AllTrim( __tip_url_Decode( aVar[ 1 ] ) ) ] := __tip_url_Decode( aVar[ 2 ] )
::hPosts[ AllTrim( tip_URLDecode( aVar[ 1 ] ) ) ] := tip_URLDecode( aVar[ 2 ] )
ENDIF
NEXT
ENDIF
@@ -150,7 +150,7 @@ METHOD New() CLASS TIpCgi
FOR nCount := 1 TO nLen
aVar := hb_ATokens( aTemp[ nCount ], "=" )
IF Len( aVar ) == 2
::hGets[ AllTrim( __tip_url_Decode( aVar[ 1 ] ) ) ] := __tip_url_Decode( aVar[ 2 ] )
::hGets[ AllTrim( tip_URLDecode( aVar[ 1 ] ) ) ] := tip_URLDecode( aVar[ 2 ] )
ENDIF
NEXT
ENDIF
@@ -165,7 +165,7 @@ METHOD New() CLASS TIpCgi
FOR nCount := 1 TO nLen
aVar := hb_ATokens( aTemp[ nCount ], "=" )
IF Len( aVar ) == 2
::hCookies[ AllTrim( __tip_url_Decode( aVar[ 1 ] ) ) ] := __tip_url_Decode( aVar[ 2 ] )
::hCookies[ AllTrim( tip_URLDecode( aVar[ 1 ] ) ) ] := tip_URLDecode( aVar[ 2 ] )
ENDIF
NEXT
ENDIF

View File

@@ -72,4 +72,4 @@ METHOD Encode( cData ) CLASS TIPEncoderBase64
RETURN __tip_base64_encode( cData, ::bHttpExcept )
METHOD Decode( cData ) CLASS TIPEncoderBase64
RETURN __tip_base64_decode( cData )
RETURN hb_base64decode( cData )

View File

@@ -163,86 +163,3 @@ HB_FUNC( __TIP_BASE64_ENCODE )
/* this function also adds a zero */
hb_retclen_buffer( cRet, nPosRet );
}
HB_FUNC( __TIP_BASE64_DECODE )
{
const char * cData = hb_parc( 1 );
HB_UCHAR * cRet;
HB_ISIZ nLen = hb_parclen( 1 );
HB_ISIZ nPos = 0, nPosRet = 0, nPosBlock = 0;
HB_UCHAR cElem;
if( ! cData )
{
hb_errRT_BASE( EG_ARG, 3012, NULL,
HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) );
return;
}
if( ! nLen )
{
hb_retc_null();
return;
}
/* we know exactly the renturned length. */
cRet = ( HB_UCHAR * ) hb_xgrab( ( nLen / 4 + 1 ) * 3 );
while( nPos < nLen )
{
cElem = cData[ nPos ];
if( cElem >= 'A' && cElem <= 'Z' )
cElem -= 'A';
else if( cElem >= 'a' && cElem <= 'z' )
cElem = cElem - 'a' + 26;
else if( cElem >= '0' && cElem <= '9' )
cElem = cElem - '0' + 52;
else if( cElem == '+' )
cElem = 62;
else if( cElem == '/' )
cElem = 63;
else if( cElem == '=' ) /* end of stream? */
break;
else /* RFC 2045 specifies characters not in base64 must be ignored */
{
nPos++;
continue;
}
switch( nPosBlock )
{
case 0:
cRet[ nPosRet ] = cElem << 2;
nPosBlock++;
break;
case 1:
/* higer bits are zeros */
cRet[ nPosRet ] |= cElem >> 4;
nPosRet++;
cRet[ nPosRet ] = cElem << 4;
nPosBlock++;
break;
case 2:
/* higer bits are zeros */
cRet[ nPosRet ] |= cElem >> 2;
nPosRet++;
cRet[ nPosRet ] = cElem << 6;
nPosBlock++;
break;
case 3:
cRet[ nPosRet ] |= cElem;
nPosRet++;
nPosBlock = 0;
break;
}
nPos++;
}
/* this function also adds a zero */
/* hopefully reduce the size of cRet */
cRet = ( HB_UCHAR * ) hb_xrealloc( cRet, nPosRet + 1 );
hb_retclen_buffer( ( char * ) cRet, nPosRet );
}

View File

@@ -63,7 +63,7 @@ METHOD New() CLASS TIPEncoderURL
RETURN Self
METHOD Encode( cData ) CLASS TIPEncoderURL
RETURN __tip_url_encode( cData )
RETURN tip_URLencode( cData )
METHOD Decode( cData ) CLASS TIPEncoderURL
RETURN __tip_url_decode( cData )
RETURN tip_URLdecode( cData )

View File

@@ -54,7 +54,7 @@
#include "hbapiitm.h"
#include "hbapierr.h"
HB_FUNC( __TIP_URL_ENCODE )
HB_FUNC( TIP_URLENCODE )
{
const char * cData = hb_parc( 1 );
HB_ISIZ nLen = hb_parclen( 1 );
@@ -116,7 +116,7 @@ HB_FUNC( __TIP_URL_ENCODE )
hb_retclen_buffer( cRet, nPosRet );
}
HB_FUNC( __TIP_URL_DECODE )
HB_FUNC( TIP_URLDECODE )
{
const char * cData = hb_parc( 1 );
HB_ISIZ nLen = hb_parclen( 1 );

View File

@@ -68,12 +68,11 @@ DYNAMIC TIP_JSONSPECIALCHARS
DYNAMIC TIP_MIMETYPE
DYNAMIC TIP_SSL
DYNAMIC TIP_TIMESTAMP
DYNAMIC TIP_URLDECODE
DYNAMIC TIP_URLENCODE
DYNAMIC TURL
DYNAMIC __TIP_BASE64_DECODE
DYNAMIC __TIP_BASE64_ENCODE
DYNAMIC __TIP_PSTRCOMPI
DYNAMIC __TIP_URL_DECODE
DYNAMIC __TIP_URL_ENCODE
#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBTIP__REQUEST )
#uncommand DYNAMIC <fncs,...> => EXTERNAL <fncs>

View File

@@ -132,9 +132,9 @@ METHOD Post( xPostData, cQuery ) CLASS tIPClientHTTP
cData := ""
y := Len( xPostData )
FOR nI := 1 TO y
cTmp := __tip_url_Encode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) )
cTmp := tip_URLEncode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) )
cData += cTmp + "="
cTmp := __tip_url_Encode( hb_cStr( hb_HValueAt( xPostData, nI ) ) )
cTmp := tip_URLEncode( hb_cStr( hb_HValueAt( xPostData, nI ) ) )
cData += cTmp
IF nI != y
cData += "&"
@@ -144,9 +144,9 @@ METHOD Post( xPostData, cQuery ) CLASS tIPClientHTTP
cData := ""
y := Len( xPostData )
FOR nI := 1 TO y
cTmp := __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) )
cTmp := tip_URLEncode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) )
cData += cTmp + "="
cTmp := __tip_url_Encode( hb_cStr( xPostData[ nI, 2 ] ) )
cTmp := tip_URLEncode( hb_cStr( xPostData[ nI, 2 ] ) )
cData += cTmp
IF nI != y
cData += "&"
@@ -514,17 +514,17 @@ METHOD PostMultiPart( xPostData, cQuery ) CLASS tIPClientHTTP
ELSEIF hb_isHash( xPostData )
y := Len( xPostData )
FOR nI := 1 TO y
cTmp := __tip_url_Encode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) )
cTmp := tip_URLEncode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) )
cData += cBound + cCrlf + 'Content-Disposition: form-data; name="' + cTmp + '"' + cCrlf + cCrLf
cTmp := __tip_url_Encode( AllTrim( hb_cStr( hb_HValueAt( xPostData, nI ) ) ) )
cTmp := tip_URLEncode( AllTrim( hb_cStr( hb_HValueAt( xPostData, nI ) ) ) )
cData += cTmp + cCrLf
NEXT
ELSEIF hb_isArray( xPostData )
y := Len( xPostData )
FOR nI := 1 TO y
cTmp := __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) )
cTmp := tip_URLEncode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) )
cData += cBound + cCrlf + 'Content-Disposition: form-data; name="' + cTmp + '"' + cCrlf + cCrLf
cTmp := __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 2 ] ) ) )
cTmp := tip_URLEncode( AllTrim( hb_cStr( xPostData[ nI, 2 ] ) ) )
cData += cTmp + cCrLf
NEXT

View File

@@ -207,8 +207,8 @@ METHOD AddGetForm( xPostData )
IF hb_isHash( xPostData )
y := Len( xPostData )
FOR nI := 1 TO y
cData += __tip_url_Encode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) ) + "="
cData += __tip_url_Encode( AllTrim( hb_cStr( hb_HValueAt( xPostData, nI ) ) ) )
cData += tip_URLEncode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) ) + "="
cData += tip_URLEncode( AllTrim( hb_cStr( hb_HValueAt( xPostData, nI ) ) ) )
IF nI != y
cData += "&"
ENDIF
@@ -216,8 +216,8 @@ METHOD AddGetForm( xPostData )
ELSEIF hb_isArray( xPostData )
y := Len( xPostData )
FOR nI := 1 TO y
cData += __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) ) + "="
cData += __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 2 ] ) ) )
cData += tip_URLEncode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) ) + "="
cData += tip_URLEncode( AllTrim( hb_cStr( xPostData[ nI, 2 ] ) ) )
IF nI != y
cData += "&"
ENDIF