From 95db3b539103bdd2bb2413ce6c920b608257ad02 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 7 Mar 2010 12:14:00 +0000 Subject: [PATCH] 2010-03-07 13:13 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbtip/encmthd.c - Deleted __TIP_QP_[ENCODE|DECODE](). Either I'm misunderstanding their purpose or they simply didn't work (pbly because they were not even used by hbtip code). --- harbour/ChangeLog | 8 +- harbour/contrib/hbtip/encmthd.c | 146 -------------------------------- 2 files changed, 7 insertions(+), 147 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 06cfbe7577..4813441c97 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-03-07 13:13 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbtip/encmthd.c + - Deleted __TIP_QP_[ENCODE|DECODE](). Either I'm misunderstanding + their purpose or they simply didn't work (pbly because they + were not even used by hbtip code). + 2010-03-07 13:07 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbtip/encmthd.c * contrib/hbtip/encurl.prg @@ -34,7 +40,7 @@ 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. + seem to work. [DONE - DELETED] ; TODO: Try eliminating redundancy in base64 encoding/decoding between hbtip and core. diff --git a/harbour/contrib/hbtip/encmthd.c b/harbour/contrib/hbtip/encmthd.c index e3d8a37039..131b51714d 100644 --- a/harbour/contrib/hbtip/encmthd.c +++ b/harbour/contrib/hbtip/encmthd.c @@ -247,152 +247,6 @@ HB_FUNC( __TIP_BASE64_DECODE ) hb_retclen_buffer( ( char * ) cRet, nPosRet ); } -HB_FUNC( __TIP_QP_ENCODE ) -{ - const char * cData = hb_parc( 1 ); - int nLen = hb_parclen( 1 ); - char * cRet; - unsigned char cElem; - int nVal, iLineLen = 0; - int nPosRet = 0, nPos = 0; - - if( ! cData ) - { - hb_errRT_BASE( EG_ARG, 3012, NULL, - HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) ); - return; - } - - if( ! nLen ) - { - hb_retc_null(); - return; - } - - /* Preallocating maximum possible length */ - cRet = ( char * ) hb_xgrab( nLen * 3 + ( nLen / 72 ) * 3 + 3 ); - /* last +3 is trailing \r\n\0 */ - while( nPos < nLen ) - { - cElem = ( unsigned char ) cData[ nPos ]; - - /* We chose not to encode spaces and tab here. - cElem is signed and ranges from -126 to +127. - negative values are automatically encoded */ - if( ( cElem >= 33 && cElem <= 60 ) || cElem >= 62 || - cElem == 9 || cElem == 32 ) - { - cRet[ nPosRet++ ] = ( char ) cElem; - iLineLen++; - } - else - { - cRet[ nPosRet++ ] = '='; - nVal = cElem >> 4; - cRet[ nPosRet++ ] = ( char ) ( nVal < 10 ? '0' + nVal : 'A' + nVal - 10 ); - nVal = cElem & 0x0f; - cRet[ nPosRet++ ] = ( char ) ( nVal < 10 ? '0' + nVal : 'A' + nVal - 10 ); - iLineLen += 3; - } - - nPos++; - - if( iLineLen >= 72 ) - { - cRet[ nPosRet++ ] = '='; - cRet[ nPosRet++ ] = '\r'; - cRet[ nPosRet++ ] = '\n'; - iLineLen = 0; - } - } - - /* Securing last line trailing space, if needed */ - cElem = ( unsigned char ) cRet[ nPosRet - 1 ]; - if( cElem == 9 || cElem == 32 ) - { - cRet[ nPosRet++ ] = '='; - cRet[ nPosRet++ ] = '\r'; - cRet[ nPosRet++ ] = '\n'; - } - /* Adding canonical new line for RFC2045 blocks */ - - /* this function also adds a zero */ - cRet = ( char * ) hb_xrealloc( cRet, nPosRet + 1 ); - hb_retclen_buffer( cRet, nPosRet ); -} - -HB_FUNC( __TIP_QP_DECODE ) -{ - const char *cData = hb_parc( 1 ); - int nLen = hb_parclen( 1 ); - char *cRet; - int nPos = 0, nPosRet = 0, nVal; - unsigned char cElem, cCipher; - - if( ! cData ) - { - hb_errRT_BASE( EG_ARG, 3012, NULL, - HB_ERR_FUNCNAME, 1, hb_paramError( 1 ) ); - return; - } - - if( ! nLen ) - { - hb_retc_null(); - return; - } - - - /* allocate maximum possible lenght. */ - cRet = ( char * ) hb_xgrab( nLen + 1 ); - - while( nPos < nLen ) - { - cElem = ( unsigned char ) cData[ nPos ]; - - if( cElem == '=' ) - { - if( nPos < nLen - 2 ) - { - cCipher = ( unsigned char ) cData[ ++nPos ]; - /* soft line break */ - if( cCipher == '\r' ) - { - nPos += 2; - continue; - } - else - { - nVal = cCipher >= 'A' && cCipher <= 'F' ? cCipher - 'A' + 10 : - cCipher - '0'; - nVal *= 16; - - cCipher = ( unsigned char ) cData[ ++nPos ]; - nVal += cCipher >= 'A' && cCipher <= 'F' ? cCipher - 'A' + 10 : - cCipher - '0'; - - cRet[ nPosRet++ ] = ( char ) nVal; - } - } - /* else the encoding is malformed */ - else - { - if( nPosRet > 0 ) - break; - } - } - else - cRet[ nPosRet++ ] = ( char ) cElem; - - nPos ++; - } - - /* this function also adds a zero */ - /* hopefully reduce the size of cRet */ - cRet = ( char * ) hb_xrealloc( cRet, nPosRet + 1 ); - hb_retclen_buffer( cRet, nPosRet ); -} - HB_FUNC( __TIP_URL_ENCODE ) { const char * cData = hb_parc( 1 );