2010-03-07 13:07 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbtip/encmthd.c
* contrib/hbtip/encurl.prg
* contrib/hbtip/encb64.prg
! Cleaned this quite strange and dangerous hack which made the
exact nature of the logic fully hidden for anyone expecting
regular programming techniques. I even reimplemented QP
encoding not knowing about it.
Now the class/function interface is completely standard
without any hidden interdependencies and internal logic
to access class vars from C level function and mapping C
level functions as methods.
Now it's possible to replace these TIP specific encoder/decoder
functions with core ones, or move these ones to core.
INCOMPATIBLE: Old function names have been changed from
TIPENCODER*_[DECODE|ENCODE]() to __TIP_*_[ENCODE|DECODE]().
; TOFIX: Old C implementation of QP encoding/decoding doesn't
seem to work.
; TODO: Try eliminating redundancy in base64 encoding/decoding
between hbtip and core.
* contrib/hbtip/cgi.prg
* contrib/hbtip/url.prg
* contrib/hbtip/httpcli.prg
* Changed to use new internal function names for encoding/decoding.
* src/rdd/dbf1.c
* Minor formatting.
This commit is contained in:
@@ -17,6 +17,35 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-03-07 13:07 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbtip/encmthd.c
|
||||
* contrib/hbtip/encurl.prg
|
||||
* contrib/hbtip/encb64.prg
|
||||
! Cleaned this quite strange and dangerous hack which made the
|
||||
exact nature of the logic fully hidden for anyone expecting
|
||||
regular programming techniques. I even reimplemented QP
|
||||
encoding not knowing about it.
|
||||
Now the class/function interface is completely standard
|
||||
without any hidden interdependencies and internal logic
|
||||
to access class vars from C level function and mapping C
|
||||
level functions as methods.
|
||||
Now it's possible to replace these TIP specific encoder/decoder
|
||||
functions with core ones, or move these ones to core.
|
||||
INCOMPATIBLE: Old function names have been changed from
|
||||
TIPENCODER*_[DECODE|ENCODE]() to __TIP_*_[ENCODE|DECODE]().
|
||||
; TOFIX: Old C implementation of QP encoding/decoding doesn't
|
||||
seem to work.
|
||||
; TODO: Try eliminating redundancy in base64 encoding/decoding
|
||||
between hbtip and core.
|
||||
|
||||
* contrib/hbtip/cgi.prg
|
||||
* contrib/hbtip/url.prg
|
||||
* contrib/hbtip/httpcli.prg
|
||||
* Changed to use new internal function names for encoding/decoding.
|
||||
|
||||
* src/rdd/dbf1.c
|
||||
* Minor formatting.
|
||||
|
||||
2010-03-07 12:24 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/src/rdd/dbf1.c
|
||||
* removed unnecessary function call
|
||||
@@ -24,7 +53,7 @@
|
||||
2010-03-07 12:21 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbtip/encmthd.c
|
||||
* Formatting.
|
||||
; TOFIX: I've just realized the nature of this hack.
|
||||
; TOFIX: I've just realized the nature of this hack. [DONE]
|
||||
|
||||
2010-03-07 12:06 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbtip/sendmail.prg
|
||||
|
||||
@@ -137,7 +137,7 @@ METHOD New() CLASS TIpCgi
|
||||
FOR nCount := 1 TO nLen
|
||||
aVar := hb_ATokens( aTemp[ nCount ], "=" )
|
||||
IF Len( aVar ) == 2
|
||||
::hPosts[ AllTrim( TipEncoderUrl_Decode( aVar[ 1 ] ) ) ] := TipEncoderUrl_Decode( aVar[ 2 ] )
|
||||
::hPosts[ AllTrim( __tip_url_Decode( aVar[ 1 ] ) ) ] := __tip_url_Decode( aVar[ 2 ] )
|
||||
ENDIF
|
||||
NEXT
|
||||
ENDIF
|
||||
@@ -151,7 +151,7 @@ METHOD New() CLASS TIpCgi
|
||||
FOR nCount := 1 TO nLen
|
||||
aVar := hb_ATokens( aTemp[ nCount ], "=" )
|
||||
IF Len( aVar ) == 2
|
||||
::hGets[ AllTrim( TipEncoderUrl_Decode( aVar[ 1 ] ) ) ] := TipEncoderUrl_Decode( aVar[ 2 ] )
|
||||
::hGets[ AllTrim( __tip_url_Decode( aVar[ 1 ] ) ) ] := __tip_url_Decode( aVar[ 2 ] )
|
||||
ENDIF
|
||||
NEXT
|
||||
ENDIF
|
||||
@@ -166,7 +166,7 @@ METHOD New() CLASS TIpCgi
|
||||
FOR nCount := 1 TO nLen
|
||||
aVar := hb_ATokens( aTemp[ nCount ], "=" )
|
||||
IF Len( aVar ) == 2
|
||||
::hCookies[ AllTrim( TipEncoderUrl_Decode( aVar[ 1 ] ) ) ] := TipEncoderUrl_Decode( aVar[ 2 ] )
|
||||
::hCookies[ AllTrim( __tip_url_Decode( aVar[ 1 ] ) ) ] := __tip_url_Decode( aVar[ 2 ] )
|
||||
ENDIF
|
||||
NEXT
|
||||
ENDIF
|
||||
|
||||
@@ -67,3 +67,9 @@ METHOD New() CLASS TIPEncoderBase64
|
||||
::cName := "Base64"
|
||||
::bHttpExcept := .F.
|
||||
RETURN Self
|
||||
|
||||
METHOD Encode( cData ) CLASS TIPEncoderBase64
|
||||
RETURN __tip_base64_encode( cData, ::bHttpExcept )
|
||||
|
||||
METHOD Decode( cData ) CLASS TIPEncoderBase64
|
||||
RETURN __tip_base64_decode( cData )
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
* TIP Class oriented Internet protocol library
|
||||
*
|
||||
* Copyright 2003 Giancarlo Niccolai <gian@niccolai.ws>
|
||||
*
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -53,11 +52,9 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicls.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbstack.h"
|
||||
|
||||
HB_FUNC( TIPENCODERBASE64_ENCODE )
|
||||
HB_FUNC( __TIP_BASE64_ENCODE )
|
||||
{
|
||||
const char * cData = hb_parc( 1 );
|
||||
char * cRet;
|
||||
@@ -81,17 +78,7 @@ HB_FUNC( TIPENCODERBASE64_ENCODE )
|
||||
return;
|
||||
}
|
||||
|
||||
/* read the status of bHttpExcept */
|
||||
if( hb_pcount() > 1 )
|
||||
{
|
||||
/* this makes this function static!!!! */
|
||||
bExcept = hb_parl( 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_objSendMsg( hb_stackSelfItem(), "BHTTPEXCEPT", 0 );
|
||||
bExcept = hb_parl( -1 );
|
||||
}
|
||||
bExcept = hb_parl( 2 );
|
||||
|
||||
/* we know exactly the renturned length. */
|
||||
nFinalLen = ( HB_SIZE ) ( ( nLen / 3 + 2 ) * 4 );
|
||||
@@ -113,12 +100,12 @@ HB_FUNC( TIPENCODERBASE64_ENCODE )
|
||||
cElem = cElem >> 2;
|
||||
break;
|
||||
case 2:
|
||||
cElem1 = nPos < nLen -1 ? ( unsigned char ) cData[ nPos + 1 ] : 0;
|
||||
cElem1 = nPos < nLen - 1 ? ( unsigned char ) cData[ nPos + 1 ] : 0;
|
||||
cElem = ( ( cElem & 0x3 ) << 4 ) | ( cElem1 >> 4 );
|
||||
nPos++;
|
||||
break;
|
||||
case 3:
|
||||
cElem1 = nPos < nLen -1 ? ( unsigned char ) cData[ nPos + 1 ] : 0;
|
||||
cElem1 = nPos < nLen - 1 ? ( unsigned char ) cData[ nPos + 1 ] : 0;
|
||||
cElem = ( ( cElem & 0xF ) << 2 ) | ( cElem1 >> 6 );
|
||||
nPos++;
|
||||
break;
|
||||
@@ -142,7 +129,7 @@ HB_FUNC( TIPENCODERBASE64_ENCODE )
|
||||
|
||||
if( ! bExcept )
|
||||
{
|
||||
nLineCount ++ ;
|
||||
++nLineCount;
|
||||
/* RFC says to add a CRLF each 76 chars, but is pretty unclear about
|
||||
the fact of this 76 chars counting CRLF or not. Common
|
||||
practice is to limit line size to 72 chars */
|
||||
@@ -177,7 +164,7 @@ HB_FUNC( TIPENCODERBASE64_ENCODE )
|
||||
hb_retclen_buffer( cRet, nPosRet );
|
||||
}
|
||||
|
||||
HB_FUNC( TIPENCODERBASE64_DECODE )
|
||||
HB_FUNC( __TIP_BASE64_DECODE )
|
||||
{
|
||||
const char * cData = hb_parc( 1 );
|
||||
unsigned char * cRet;
|
||||
@@ -260,7 +247,7 @@ HB_FUNC( TIPENCODERBASE64_DECODE )
|
||||
hb_retclen_buffer( ( char * ) cRet, nPosRet );
|
||||
}
|
||||
|
||||
HB_FUNC( TIPENCODERQP_ENCODE )
|
||||
HB_FUNC( __TIP_QP_ENCODE )
|
||||
{
|
||||
const char * cData = hb_parc( 1 );
|
||||
int nLen = hb_parclen( 1 );
|
||||
@@ -334,7 +321,7 @@ HB_FUNC( TIPENCODERQP_ENCODE )
|
||||
hb_retclen_buffer( cRet, nPosRet );
|
||||
}
|
||||
|
||||
HB_FUNC( TIPENCODERQP_DECODE )
|
||||
HB_FUNC( __TIP_QP_DECODE )
|
||||
{
|
||||
const char *cData = hb_parc( 1 );
|
||||
int nLen = hb_parclen( 1 );
|
||||
@@ -406,7 +393,7 @@ HB_FUNC( TIPENCODERQP_DECODE )
|
||||
hb_retclen_buffer( cRet, nPosRet );
|
||||
}
|
||||
|
||||
HB_FUNC( TIPENCODERURL_ENCODE )
|
||||
HB_FUNC( __TIP_URL_ENCODE )
|
||||
{
|
||||
const char * cData = hb_parc( 1 );
|
||||
int nLen = hb_parclen( 1 );
|
||||
@@ -447,7 +434,7 @@ HB_FUNC( TIPENCODERURL_ENCODE )
|
||||
( cElem >= 'a' && cElem <= 'z' ) ||
|
||||
( cElem >= '0' && cElem <= '9' ) ||
|
||||
cElem == '.' || cElem == ',' || cElem == '&' ||
|
||||
cElem == '/' || cElem == ';' || cElem =='_' )
|
||||
cElem == '/' || cElem == ';' || cElem == '_' )
|
||||
{
|
||||
cRet[ nPosRet ] = cElem;
|
||||
}
|
||||
@@ -471,7 +458,7 @@ HB_FUNC( TIPENCODERURL_ENCODE )
|
||||
hb_retclen_buffer( cRet, nPosRet );
|
||||
}
|
||||
|
||||
HB_FUNC( TIPENCODERURL_DECODE )
|
||||
HB_FUNC( __TIP_URL_DECODE )
|
||||
{
|
||||
const char * cData = hb_parc( 1 );
|
||||
int nLen = hb_parclen( 1 );
|
||||
|
||||
@@ -61,3 +61,9 @@ ENDCLASS
|
||||
METHOD New() CLASS TIPEncoderURL
|
||||
::cName := "urlencoded"
|
||||
RETURN Self
|
||||
|
||||
METHOD Encode( cData ) CLASS TIPEncoderURL
|
||||
RETURN __tip_url_encode( cData )
|
||||
|
||||
METHOD Decode( cData ) CLASS TIPEncoderURL
|
||||
RETURN __tip_url_decode( cData )
|
||||
|
||||
@@ -132,9 +132,9 @@ METHOD Post( xPostData, cQuery ) CLASS tIPClientHTTP
|
||||
cData := ""
|
||||
y := Len( xPostData )
|
||||
FOR nI := 1 TO y
|
||||
cTmp := TipEncoderUrl_Encode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) )
|
||||
cTmp := __tip_url_Encode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) )
|
||||
cData += cTmp + "="
|
||||
cTmp := TipEncoderUrl_Encode( hb_cStr( hb_HValueAt( xPostData, nI ) ) )
|
||||
cTmp := __tip_url_Encode( 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 := TipEncoderUrl_Encode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) )
|
||||
cTmp := __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) )
|
||||
cData += cTmp + "="
|
||||
cTmp := TipEncoderUrl_Encode( hb_cStr( xPostData[ nI, 2 ] ) )
|
||||
cTmp := __tip_url_Encode( 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 := TipEncoderUrl_Encode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) )
|
||||
cTmp := __tip_url_Encode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) )
|
||||
cData += cBound + cCrlf + 'Content-Disposition: form-data; name="' + cTmp + '"' + cCrlf + cCrLf
|
||||
cTmp := TipEncoderUrl_Encode( AllTrim( hb_cStr( hb_HValueAt( xPostData, nI ) ) ) )
|
||||
cTmp := __tip_url_Encode( AllTrim( hb_cStr( hb_HValueAt( xPostData, nI ) ) ) )
|
||||
cData += cTmp + cCrLf
|
||||
NEXT
|
||||
ELSEIF hb_isArray( xPostData )
|
||||
y := Len( xPostData )
|
||||
FOR nI := 1 TO y
|
||||
cTmp := TipEncoderUrl_Encode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) )
|
||||
cTmp := __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) )
|
||||
cData += cBound + cCrlf + 'Content-Disposition: form-data; name="' + cTmp + '"' + cCrlf + cCrLf
|
||||
cTmp := TipEncoderUrl_Encode( AllTrim( hb_cStr( xPostData[ nI, 2 ] ) ) )
|
||||
cTmp := __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 2 ] ) ) )
|
||||
cData += cTmp + cCrLf
|
||||
NEXT
|
||||
|
||||
|
||||
@@ -207,8 +207,8 @@ METHOD AddGetForm( xPostData )
|
||||
IF hb_isHash( xPostData )
|
||||
y := Len( xPostData )
|
||||
FOR nI := 1 TO y
|
||||
cData += TipEncoderUrl_Encode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) ) + "="
|
||||
cData += TipEncoderUrl_Encode( AllTrim( hb_cStr( hb_HValueAt( xPostData, nI ) ) ) )
|
||||
cData += __tip_url_Encode( AllTrim( hb_cStr( hb_HKeyAt( xPostData, nI ) ) ) ) + "="
|
||||
cData += __tip_url_Encode( 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 += TipEncoderUrl_Encode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) ) + "="
|
||||
cData += TipEncoderUrl_Encode( AllTrim( hb_cStr( xPostData[ nI, 2 ] ) ) )
|
||||
cData += __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 1 ] ) ) ) + "="
|
||||
cData += __tip_url_Encode( AllTrim( hb_cStr( xPostData[ nI, 2 ] ) ) )
|
||||
IF nI != y
|
||||
cData += "&"
|
||||
ENDIF
|
||||
|
||||
@@ -533,7 +533,7 @@ static HB_BOOL hb_dbfPasswordSet( DBFAREAP pArea, PHB_ITEM pPasswd, HB_BOOL fRaw
|
||||
|
||||
ulLen = hb_itemGetCLen( pPasswd );
|
||||
|
||||
fSet = !pArea->fHasMemo && HB_IS_STRING( pPasswd ) && (!fRaw || ulLen == 8);
|
||||
fSet = !pArea->fHasMemo && HB_IS_STRING( pPasswd ) && ( !fRaw || ulLen == 8 );
|
||||
if( fSet )
|
||||
{
|
||||
if( ulLen > 0 )
|
||||
|
||||
Reference in New Issue
Block a user