diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a1aeb60397..adca33bb70 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,18 @@ The license applies to all entries newer than 2009-04-28. */ +2011-05-19 04:32 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + - contrib/hbtip/encb64c.c + * contrib/hbtip/encb64.prg + * contrib/hbtip/hbtip.hbx + * contrib/hbtip/hbtip.hbm + % elminated redundant base64 encoder implementation, now + hbtip used the core one + + TIP_BASE64ENCODE( , [], [] ) -> + function added to create base64 encoded data split into lines, + separated by passed EOL. default EOL is hb_eol(), if is + not specced, there will be no long splitting + 2011-05-18 18:31 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/ideeditor.prg * contrib/hbqt/qtgui/hbqt_hbqsyntaxhighlighter.cpp @@ -28,7 +40,7 @@ * contrib/hbide/idedocks.prg * contrib/hbxbp/xbpdialog.prg * contrib/hbxbp/xbpwindow.prg - ! Fixed: a logical glitch causing X button on hbIDE behaving + ! Fixed: a logical glitch causing X button on hbIDE behaving not as intended. 2011-05-18 20:45 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) diff --git a/harbour/contrib/hbtip/encb64.prg b/harbour/contrib/hbtip/encb64.prg index 63369d54b6..730b3711b3 100644 --- a/harbour/contrib/hbtip/encb64.prg +++ b/harbour/contrib/hbtip/encb64.prg @@ -69,7 +69,27 @@ METHOD New() CLASS TIPEncoderBase64 RETURN Self METHOD Encode( cData ) CLASS TIPEncoderBase64 - RETURN __tip_base64_encode( cData, ::bHttpExcept ) + RETURN TIP_BASE64ENCODE( cData, iif( ::bHttpExcept, NIL, 72 ), Chr( 13 ) + Chr( 10 ) ) METHOD Decode( cData ) CLASS TIPEncoderBase64 RETURN hb_base64decode( cData ) + +FUNCTION TIP_BASE64ENCODE( cBinary, nLineLength, cCRLF ) + LOCAL cTextIn := HB_BASE64ENCODE( cBinary ) + + LOCAL cText + LOCAL tmp + + IF ! hb_isNumeric( nLineLength ) + RETURN cTextIn + ENDIF + IF ! hb_isString( cCRLF ) + cCRLF := hb_eol() + ENDIF + + cText := "" + FOR tmp := 1 TO Len( cTextIn ) STEP nLineLength + cText += SubStr( cTextIn, tmp, nLineLength ) + cCRLF + NEXT + + RETURN cText diff --git a/harbour/contrib/hbtip/encb64c.c b/harbour/contrib/hbtip/encb64c.c deleted file mode 100644 index 319334ca46..0000000000 --- a/harbour/contrib/hbtip/encb64c.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * $Id$ - */ - -/* - * xHarbour Project source code: - * TIP Class oriented Internet protocol library - * - * Copyright 2003 Giancarlo Niccolai - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "hbapi.h" -#include "hbapiitm.h" -#include "hbapierr.h" - -HB_FUNC( __TIP_BASE64_ENCODE ) -{ - const char * cData = hb_parc( 1 ); - char * cRet; - HB_ISIZ nLen = hb_parclen( 1 ); - HB_ISIZ nPos = 0, nPosRet = 0, nPosBlock = 0; - HB_SIZE nFinalLen; - HB_ISIZ nLineCount = 0; - HB_UCHAR cElem, cElem1; - HB_BOOL bExcept; - - if( ! cData ) - { - hb_errRT_BASE( EG_ARG, 3012, NULL, - HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) ); - return; - } - - if( ! nLen ) - { - hb_retc_null(); - return; - } - - bExcept = hb_parl( 2 ); - - /* we know exactly the renturned length. */ - nFinalLen = ( HB_SIZE ) ( ( nLen / 3 + 2 ) * 4 ); - /* add line termination padding, CRLF each 76 output bytes */ - nFinalLen += ( nFinalLen / 72 + 1 ) * 2; - cRet = ( char * ) hb_xgrab( nFinalLen ); - - while( nPos < nLen ) - { - cElem = ( HB_UCHAR ) cData[ nPos ]; - /* NOT using trailing 0 here as some buggy 3dparty func - will create strings without trailing 0. */ - - nPosBlock++; - - switch( nPosBlock ) - { - case 1: - cElem = cElem >> 2; - break; - case 2: - cElem1 = nPos < nLen - 1 ? ( HB_UCHAR ) cData[ nPos + 1 ] : 0; - cElem = ( ( cElem & 0x3 ) << 4 ) | ( cElem1 >> 4 ); - nPos++; - break; - case 3: - cElem1 = nPos < nLen - 1 ? ( HB_UCHAR ) cData[ nPos + 1 ] : 0; - cElem = ( ( cElem & 0xF ) << 2 ) | ( cElem1 >> 6 ); - nPos++; - break; - case 4: - cElem = cElem & 0x3f; - nPos++; - nPosBlock = 0; - break; - } - - if( cElem < 26 ) - cRet[ nPosRet++ ] = cElem + 'A'; - else if( cElem < 52 ) - cRet[ nPosRet++ ] = ( cElem - 26 ) + 'a'; - else if( cElem < 62 ) - cRet[ nPosRet++ ] = ( cElem - 52 ) + '0'; - else if( cElem == 62 ) - cRet[ nPosRet++ ] = '+'; - else - cRet[ nPosRet++ ] = '/'; - - if( ! bExcept ) - { - ++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 */ - if( nLineCount == 72 ) - { - cRet[ nPosRet++ ] = '\r'; - cRet[ nPosRet++ ] = '\n'; - nLineCount = 0; - } - } - } - - switch( nPos % 3 ) - { - case 1: - cRet[ nPosRet++ ] = '='; - /* fallthrough */ - case 2: - cRet[ nPosRet++ ] = '='; - /* fallthrough */ - } - - /* RFC is not explicit, but CRLF SHOULD be added at bottom - during encoding phase */ - if( ! bExcept ) - { - cRet[ nPosRet++ ] = '\r'; - cRet[ nPosRet++ ] = '\n'; - } - - /* this function also adds a zero */ - hb_retclen_buffer( cRet, nPosRet ); -} diff --git a/harbour/contrib/hbtip/hbtip.hbm b/harbour/contrib/hbtip/hbtip.hbm index 9ecf79219a..336f341897 100644 --- a/harbour/contrib/hbtip/hbtip.hbm +++ b/harbour/contrib/hbtip/hbtip.hbm @@ -16,7 +16,6 @@ hbtip.hbx -encb64c.c encurlc.c utils.c diff --git a/harbour/contrib/hbtip/hbtip.hbx b/harbour/contrib/hbtip/hbtip.hbx index 97566cc50e..4f485fe992 100644 --- a/harbour/contrib/hbtip/hbtip.hbx +++ b/harbour/contrib/hbtip/hbtip.hbx @@ -55,6 +55,7 @@ DYNAMIC TIPENCODERQP DYNAMIC TIPENCODERURL DYNAMIC TIPLOG DYNAMIC TIPMAIL +DYNAMIC TIP_BASE64ENCODE DYNAMIC TIP_CHECKSID DYNAMIC TIP_CRLF DYNAMIC TIP_DATETOGMT @@ -71,7 +72,6 @@ DYNAMIC TIP_TIMESTAMP DYNAMIC TIP_URLDECODE DYNAMIC TIP_URLENCODE DYNAMIC TURL -DYNAMIC __TIP_BASE64_ENCODE DYNAMIC __TIP_PSTRCOMPI #if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBTIP__REQUEST )