2009-07-09 15:18 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbtip/utils.c
  - contrib/hbtip/base64x.c
  * contrib/hbtip/client.prg
  * contrib/hbtip/smtpcln.prg
  * contrib/hbtip/Makefile
  * contrib/hbvpdf/hbvpsup.prg
    * Using core BASE64 functions.
    ; Left HB_BASE64() as compatibility call in hbtip.

  * contrib/hbwin/wapi_winuser.c
    + Added WAPI_GETDESKTOPWINDOW().
This commit is contained in:
Viktor Szakats
2009-07-09 13:21:43 +00:00
parent dbc73caebb
commit f2c01933de
8 changed files with 30 additions and 177 deletions

View File

@@ -17,6 +17,19 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-07-09 15:18 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbtip/utils.c
- contrib/hbtip/base64x.c
* contrib/hbtip/client.prg
* contrib/hbtip/smtpcln.prg
* contrib/hbtip/Makefile
* contrib/hbvpdf/hbvpsup.prg
* Using core BASE64 functions.
; Left HB_BASE64() as compatibility call in hbtip.
* contrib/hbwin/wapi_winuser.c
+ Added WAPI_GETDESKTOPWINDOW().
2009-07-09 14:58 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* include/hbextern.ch
* source/rtl/Makefile

View File

@@ -9,7 +9,6 @@ LIBNAME=hbtip
ifneq ($(HB_ARCHITECTURE),dos)
C_SOURCES = \
base64x.c \
encmthd.c \
utils.c \

View File

@@ -1,100 +0,0 @@
/*
* $Id$
*/
/*
* xHarbour Project source code:
* 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
* 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"
HB_FUNC( HB_BASE64 )
{
ULONG len = hb_parclen( 1 );
if( len <= INT_MAX ) /* TOFIX */
{
const char * s = hb_parcx( 1 );
char * t, * p;
t = p = ( char * ) hb_xgrab( ( 4 * ( ( len + 2 ) / 3 ) + 1 ) * sizeof( *t ) );
while( len-- > 0 )
{
static const char s_b64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int x, y;
x = *s++;
*p++ = s_b64chars[ ( x >> 2 ) & 0x3F ];
if( len-- <= 0 )
{
*p++ = s_b64chars[ ( x << 4 ) & 0x3F ];
*p++ = '=';
*p++ = '=';
break;
}
y = *s++;
*p++ = s_b64chars[ ( ( x << 4 ) | ( ( y >> 4 ) & 0x0F ) ) & 0x3F ];
if( len-- <= 0 )
{
*p++ = s_b64chars[ ( y << 2 ) & 0x3F ];
*p++ = '=';
break;
}
x = *s++;
*p++ = s_b64chars[ ( ( y << 2 ) | ( ( x >> 6 ) & 3 ) ) & 0x3F ];
*p++ = s_b64chars[ x & 0x3F ];
}
*p = '\0';
hb_retc_buffer( t );
}
else
hb_retc_null();
}

View File

@@ -252,7 +252,7 @@ METHOD OpenProxy( cServer, nPort, cProxy, nProxyPort, cResp, cUserName, cPassWor
cRequest += "User-agent: " + cUserAgent + Chr( 13 ) + Chr( 10 )
ENDIF
IF ! Empty( cUserName )
cRequest += "Proxy-authorization: Basic " + hb_base64( cUserName + ":" + cPassWord ) + Chr( 13 ) + Chr( 10 )
cRequest += "Proxy-authorization: Basic " + hb_base64Encode( cUserName + ":" + cPassWord ) + Chr( 13 ) + Chr( 10 )
ENDIF
cRequest += Chr( 13 ) + Chr( 10 )
::InetSendAll( ::SocketCon, cRequest )

View File

@@ -177,9 +177,9 @@ METHOD Auth( cUser, cPass ) CLASS tIPClientSMTP
::InetSendall( ::SocketCon, "AUTH LOGIN" + ::cCRLF )
IF ::GetOk()
::InetSendall( ::SocketCon, hb_BASE64( StrTran( cUser, "&at;", "@" ) ) + ::cCRLF )
::InetSendall( ::SocketCon, hb_base64Encode( StrTran( cUser, "&at;", "@" ) ) + ::cCRLF )
IF ::GetOk()
::InetSendall( ::SocketCon, hb_BASE64( cPass ) + ::cCRLF )
::InetSendall( ::SocketCon, hb_base64Encode( cPass ) + ::cCRLF )
ENDIF
ENDIF
@@ -187,7 +187,7 @@ METHOD Auth( cUser, cPass ) CLASS tIPClientSMTP
METHOD AuthPlain( cUser, cPass ) CLASS tIPClientSMTP
::InetSendall( ::SocketCon, "AUTH PLAIN" + hb_BASE64( Chr( 0 ) + cUser + Chr( 0 ) + cPass ) + ::cCRLF )
::InetSendall( ::SocketCon, "AUTH PLAIN" + hb_base64Encode( Chr( 0 ) + cUser + Chr( 0 ) + cPass ) + ::cCRLF )
RETURN ::isAuth := ::GetOk()

View File

@@ -737,3 +737,10 @@ HB_FUNC( TIP_HTMLSPECIALCHARS )
else
hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, 1, hb_paramError(1) );
}
HB_FUNC_EXTERN( HB_BASE64ENCODE );
HB_FUNC( HB_BASE64 )
{
HB_FUNC_EXEC( HB_BASE64ENCODE );
}

View File

@@ -3,7 +3,7 @@
*/
FUNCTION vpdf_FontsDat()
RETURN StrB64Decode( ;
RETURN hb_base64Decode( ;
"+gD6APoA+gBNAU0BTQGFAZgBKwKkASsC9AH0AfQB9AH0AfQB9AH0AUED6ANBA0EDCgNBAwoDCgNN" +;
"AU0BTQFNAU0BTQFNAU0BTQFNAU0BTQH0AfQB9AH0ATQCOgKjAjoC+gD6APoA+gBNAU0BTQFNAfoA" +;
"+gD6APoAFgEWARYBFgH0AfQB9AH0AfQB9AH0AfQB9AH0AfQB9AH0AfQB9AH0AfQB9AH0AfQB9AH0" +;
@@ -99,74 +99,3 @@ FUNCTION vpdf_FontsDat()
"WAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJY" +;
"AlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgCWAJYAlgC" +;
"WAJYAlgCWAJYAlgCWAJYAlgC" )
// ; Decodes a base-64 encoded string. (RFC1521)
// ; Based on VB code from: 1999-2004 Antonin Foller, http://www.motobit.com, http://motobit.cz
// ; Converted to Clipper and optimized by Viktor Szakats (harbour.01 syenar.hu).
STATIC FUNCTION StrB64Decode( cString )
LOCAL cResult
LOCAL nLen
LOCAL nGroupPos
LOCAL nGroup
LOCAL nCharPos
LOCAL nDataLen
LOCAL nData
// ; remove white spaces, If any
cString := StrTran( cString, Chr( 10 ), "" )
cString := StrTran( cString, Chr( 13 ), "" )
cString := StrTran( cString, Chr( 9 ), "" )
cString := StrTran( cString, " ", "" )
// ; The source must consists from groups with Len of 4 chars
IF ( nLen := Len( cString ) ) % 4 != 0
RETURN "" // ; Bad Base64 string.
ENDIF
/*
IF nLen > Int( MAXSTRINGLENGTH / 1.34 ) // ; Base64 is 1/3rd larger than source text.
RETURN "" // ; Not enough memory to decode.
ENDIF
*/
cResult := ""
// ; Now decode each group:
FOR nGroupPos := 1 TO nLen STEP 4
// ; Each data group encodes up To 3 actual bytes.
nDataLen := 3
nGroup := 0
FOR nCharPos := 0 TO 3
// ; Convert each character into 6 bits of data, And add it To
// ; an integer For temporary storage. If a character is a '=', there
// ; is one fewer data byte. (There can only be a maximum of 2 '=' In
// ; the whole string.)
nData := At( SubStr( cString, nGroupPos + nCharPos, 1 ), "=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ) - 2
DO CASE
CASE nData >= 0
// ; Do nothing (for speed)
CASE nData == -1
nData := 0
nDataLen--
CASE nData == -2
RETURN "" // ; Bad character In Base64 string.
ENDCASE
nGroup := 64 * nGroup + nData
NEXT
// ; Convert the 24 bits to 3 characters
// ; and add nDataLen characters To out string
cResult += Left( Chr( nGroup / 65536 ) +; // ; bitwise AND 255, which is done by Chr() automatically
Chr( nGroup / 256 ) +; // ; bitwise AND 255, which is done by Chr() automatically
Chr( nGroup ), nDataLen ) // ; bitwise AND 255, which is done by Chr() automatically
NEXT
RETURN cResult

View File

@@ -59,6 +59,11 @@
#include <winuser.h>
HB_FUNC( WAPI_GETDESKTOPWINDOW )
{
hb_retptr( GetDesktopWindow() );
}
HB_FUNC( WAPI_MESSAGEBOX )
{
LPTSTR lpStr1 = HB_TCHAR_CONVTO( hb_parcx( 2 ) );