From 9f6c8a1dc8d8a8f83564717b4cea27ddff50070c Mon Sep 17 00:00:00 2001 From: Lorenzo Fiorini Date: Tue, 17 Apr 2007 21:03:14 +0000 Subject: [PATCH] 2007-04-17 23:05 UTC+0200 Lorenzo Fiorini (lorenzo.fiorini/at/gmail.com) * harbour/contrib/gd/Makefile * added install of gd.ch * harbour/contrib/gd/gd.prg * removed two unused vars * harbour/contrib/libct/ctnet.c * harbour/contrib/libct/Makefile * added ctnet.c borrowed from xHarbour * harbour/contrib/pgsql/postgres.c * fixes some warnings * harbour/contrib/tip/cgi.prg * added session name parameter * harbour/include/hbcompat.ch * added gtProcessMessages() translate --- harbour/ChangeLog | 15 ++ harbour/contrib/gd/Makefile | 6 + harbour/contrib/gd/gd.prg | 1 - harbour/contrib/libct/Makefile | 1 + harbour/contrib/libct/ctnet.c | 281 +++++++++++++++++++++++++++++++ harbour/contrib/pgsql/postgres.c | 36 ++-- harbour/contrib/tip/cgi.prg | 7 +- harbour/include/hbcompat.ch | 1 + 8 files changed, 335 insertions(+), 13 deletions(-) create mode 100644 harbour/contrib/libct/ctnet.c diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7dc624b16b..524fca21b1 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,21 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-04-17 23:05 UTC+0200 Lorenzo Fiorini (lorenzo.fiorini/at/gmail.com) + * harbour/contrib/gd/Makefile + * added install of gd.ch + * harbour/contrib/gd/gd.prg + * removed two unused vars + * harbour/contrib/libct/ctnet.c + * harbour/contrib/libct/Makefile + * added ctnet.c borrowed from xHarbour + * harbour/contrib/pgsql/postgres.c + * fixes some warnings + * harbour/contrib/tip/cgi.prg + * added session name parameter + * harbour/include/hbcompat.ch + * added gtProcessMessages() translate + 2007-04-17 20:00 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rdd/dbcmd.c ! update NetErr() in ordListAdd() diff --git a/harbour/contrib/gd/Makefile b/harbour/contrib/gd/Makefile index a4c07c8e32..4184861a51 100644 --- a/harbour/contrib/gd/Makefile +++ b/harbour/contrib/gd/Makefile @@ -7,6 +7,9 @@ ROOT = ../../ C_SOURCES=\ gdwrp.c \ +PRG_HEADERS=\ + gd.ch \ + PRG_SOURCES=\ gd.prg \ gdbar.prg \ @@ -23,3 +26,6 @@ ifeq ($(HB_COMPILER),mingw32) else CFLAGS := $(CFLAGS) -I/usr/include endif + +include $(TOP)$(ROOT)config/header.cf + diff --git a/harbour/contrib/gd/gd.prg b/harbour/contrib/gd/gd.prg index bf94c395de..0f82e1be77 100644 --- a/harbour/contrib/gd/gd.prg +++ b/harbour/contrib/gd/gd.prg @@ -239,7 +239,6 @@ PROCEDURE gdImageToFile( oImage, cFile ) RETURN PROCEDURE gdImageToHandle( oImage, nHandle ) - LOCAL cString, cExt DEFAULT nHandle TO 1 diff --git a/harbour/contrib/libct/Makefile b/harbour/contrib/libct/Makefile index d68d0b6b20..eeb9812d82 100644 --- a/harbour/contrib/libct/Makefile +++ b/harbour/contrib/libct/Makefile @@ -26,6 +26,7 @@ C_SOURCES = \ ctc.c \ ctmath.c \ ctmath2.c \ + ctnet.c \ ctset.c \ ctstr.c \ ctchksum.c \ diff --git a/harbour/contrib/libct/ctnet.c b/harbour/contrib/libct/ctnet.c new file mode 100644 index 0000000000..3637ceebb4 --- /dev/null +++ b/harbour/contrib/libct/ctnet.c @@ -0,0 +1,281 @@ +/* + * $Id$ + * + * xHarbour Project source code: + * CT3 NET functions to PC-LAN/MS-NET. + * + * Copyright 2004 Eduardo Fernandes + * www - http://www.xharbour.org + * + ******* + * + * CT3 NET Functions Comments: + * + * NETCANCEL( ) -> lReleased + * Return true if was disconnected. + * + * NETDISK( cDrive ) -> lSuccess + * Return true if is a network drive, otherwise return false if is a local drive. + * + * NETLOCNAME( cSahredDevice ) -> cLocalDevice + * Not implemented yet. + * + * NETPRINTER() -> lSuccess + * Return true if a current local printer seted by SET PRINTER TO was connected to a + * network printer. + * + * NETREDIR( cLocalDevice, cSharedDevice, [ cPassword ], [ lShowError] ) -> lSuccess + * Return true if was connected to with , if any. + * + * NETRMTNAME( cLocalDevice ) -> cSharedName + * Return the shared resource name connected to a . + * The original parameter in CA-Clipper Tools was changed to in + * xHarbour because in Windows Network I didnīt find a number table like in MS-DOS. See + * CA-Tools help for more details. + * + * NETWORK() -> lSuccess + * Return true if a PC-LAN/MS-NET or Netware type is active. + * + * NNETWORK() -> lSuccess + * Return true if a Netware type is active. + * + ****** + * 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. + * + * + * See doc/license.txt for licensing terms. + * + */ + +#include "hbapi.h" +#include "hbapiitm.h" +#include "hbset.h" +#include "hbapierr.h" + +#if defined(HB_OS_WIN_32) + +#include +#include + +#define HB_OS_WIN_32_USED + +BOOL WINAPI WNetErrorHandler(DWORD dwErrorCode, LPSTR lpszFunction) +{ + DWORD dwWNetResult, dwLastError; + CHAR szDescription[256]; + CHAR szProvider[256]; + + HB_ITEM_PTR pError; + + if (dwErrorCode != ERROR_EXTENDED_ERROR) + { + pError = hb_errRT_New( + ES_ERROR, + HB_ERR_SS_TOOLS, + 9999, + 9999, + "Windows Network operation failed", + lpszFunction, + (USHORT) dwErrorCode, + EF_NONE ); + hb_errLaunch( pError ); + hb_itemRelease( pError ); + } + else + { + dwWNetResult = WNetGetLastError(&dwLastError, (LPSTR) szDescription, sizeof(szDescription), + (LPSTR) szProvider, + sizeof(szProvider)); + + if(dwWNetResult != NO_ERROR) { + pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_TOOLS, 9999, 9999, "WNetGetLastError failed", "see OS error", (USHORT) dwWNetResult, EF_NONE ); + hb_errLaunch( pError ); + hb_itemRelease( pError ); + return FALSE; + } + +/* +extern PHB_ITEM HB_EXPORT hb_errRT_New( + USHORT uiSeverity, + char * szSubSystem, + ULONG ulGenCode, + ULONG ulSubCode, + char * szDescription, + char * szOperation, + USHORT uiOsCode, + USHORT uiFlags ); +*/ + pError = hb_errRT_New( ES_ERROR, HB_ERR_SS_TOOLS, 9999, 9999, szDescription, szProvider, (USHORT) dwLastError, EF_NONE ); + hb_errLaunch( pError ); + hb_itemRelease( pError ); + } + + return TRUE; +} + +static BOOL hb_IsNetShared(LPSTR szLocalDevice ) +{ + char szRemoteDevice[80] ; + DWORD dwResult; + DWORD cchBuff = sizeof(szRemoteDevice) ; + + dwResult = WNetGetConnection( (LPSTR) szLocalDevice , (LPSTR) szRemoteDevice , &cchBuff) ; + + if ( dwResult == NO_ERROR ) + { + return TRUE; + } + + return FALSE; +} + +HB_FUNC ( NETCANCEL ) +{ + DWORD dwResult; + char *cDevice = (char *)hb_parc (1); + + dwResult = WNetCancelConnection( cDevice , TRUE ) ; // FALSE = fail if exist open files or print jobs. + // TRUE = force cancel connection even if exist + // open files or print jobs. + hb_retl( dwResult == NO_ERROR ? TRUE : FALSE ); +} + + +HB_FUNC ( NETPRINTER ) +{ + char *cPrn = hb_set.HB_SET_PRINTFILE ; // query default local printer port. + + hb_retl( hb_IsNetShared( cPrn ) ); +} + + +HB_FUNC ( NETDISK ) +{ + char cDrive[3]; + + strncpy( cDrive, hb_parcx( 1 ), 1 ); + cDrive[1] = ':'; + cDrive[2] = '\0'; + + hb_retl( hb_IsNetShared( cDrive ) ); +} + + +HB_FUNC ( NETREDIR ) +{ + DWORD dwResult; + char *cLocalDev = hb_parcx( 1 ); + char *cSharedRes = hb_parcx( 2 ); + char *cPassword = hb_parcx( 3 ); + BOOL bShowError = ( ISLOG(4) ? hb_parl(4) : FALSE ); + char szCommand[80]; + + if ( hb_pcount() >= 3 && ISCHAR( 3 ) ) + { + dwResult = WNetAddConnection( cSharedRes, cPassword, cLocalDev ) ; + } + else + { + dwResult = WNetAddConnection( cSharedRes, NULL, cLocalDev ) ; + } + + if( dwResult == NO_ERROR ) + { + hb_retl( TRUE ); + } + else + { + if ( bShowError ) + { + snprintf( szCommand, 80, "NETREDIR( \"%s\", \"%s\", \"%s\" )", cLocalDev, cSharedRes, cPassword ); + WNetErrorHandler( dwResult, szCommand ); + } + hb_retl( FALSE ); + } + +} + +HB_FUNC ( NETRMTNAME ) +{ + char szRemoteDevice[ 80 ]; + char *szLocalDevice = ( char * )hb_parc ( 1 ) ; + DWORD dwResult; + DWORD cchBuff = sizeof( szRemoteDevice ); + + dwResult = WNetGetConnection( (LPSTR) szLocalDevice, (LPSTR) szRemoteDevice, &cchBuff); + + hb_retc( dwResult == NO_ERROR ? szRemoteDevice : "" ) ; +} + + +HB_FUNC ( NETWORK ) +{ + DWORD dwResult; + char szProviderName[80]; + DWORD cchBuff = sizeof(szProviderName); + + dwResult = WNetGetProviderName( WNNC_NET_MSNET, (LPSTR) szProviderName, &cchBuff); + + if ( dwResult != NO_ERROR ) + { + dwResult = WNetGetProviderName( WNNC_NET_LANMAN, (LPSTR) szProviderName, &cchBuff); + + if ( dwResult != NO_ERROR ) + { + dwResult = WNetGetProviderName( WNNC_NET_NETWARE, (LPSTR) szProviderName, &cchBuff); + } + } + + hb_retl( dwResult == NO_ERROR ? TRUE : FALSE ); +} + + +HB_FUNC ( NNETWORK ) +{ + DWORD dwResult; + char szProviderName[80]; + DWORD cchBuff = sizeof(szProviderName); + + dwResult = WNetGetProviderName( WNNC_NET_NETWARE, (LPSTR) szProviderName, &cchBuff); + + hb_retl( dwResult == NO_ERROR ? TRUE : FALSE ); +} + +#endif diff --git a/harbour/contrib/pgsql/postgres.c b/harbour/contrib/pgsql/postgres.c index baf91aaf95..b7d11498aa 100644 --- a/harbour/contrib/pgsql/postgres.c +++ b/harbour/contrib/pgsql/postgres.c @@ -504,30 +504,46 @@ HB_FUNC(PQESCAPESTRING) } -HB_FUNC(PQESCAPEBYTEA) +HB_FUNC(PQESCAPEBYTEA) /* deprecated */ { - char *from; - char *to; + unsigned const char *from; + unsigned char *to; size_t from_length; size_t to_length; - from = hb_parcx(1); - from_length = strlen(from); - to_length = strlen(from) * 5 + 1; + from = ( BYTE * ) hb_parc(1); + from_length = hb_parclen(1); + to_length = from_length * 5 + 1; to = PQescapeBytea(from, from_length, &to_length); - hb_retc(to); + hb_retc( ( char * ) to ); PQfreemem(to); } +HB_FUNC(PQESCAPEBYTEACONN) +{ + unsigned const char *from; + unsigned char *to; + size_t from_length; + size_t to_length; + + from = ( BYTE * ) hb_parc(2); + from_length = hb_parclen(2); + to_length = from_length * 5 + 1; + + to = PQescapeByteaConn(( PGconn * ) hb_parptr(1), from, from_length, &to_length); + hb_retc( ( char * ) to ); + PQfreemem(to); +} + HB_FUNC(PQUNESCAPEBYTEA) { - char *from; + unsigned char *from; size_t to_length; - from = PQunescapeBytea(hb_parcx(1), &to_length); - hb_retclen(from, to_length); + from = PQunescapeBytea(( BYTE * ) hb_parcx(1), &to_length); + hb_retclen( ( char * ) from, to_length); PQfreemem(from); } diff --git a/harbour/contrib/tip/cgi.prg b/harbour/contrib/tip/cgi.prg index 194bbd069c..e95ecfa01e 100644 --- a/harbour/contrib/tip/cgi.prg +++ b/harbour/contrib/tip/cgi.prg @@ -372,20 +372,23 @@ METHOD SaveHtmlPage( cFile ) CLASS TIpCgi RETURN lSuccess -METHOD StartSession() CLASS TIpCgi +METHOD StartSession( cSID ) CLASS TIpCgi - local cSID local nH local cFile local nFileSize local cBuffer + if empty( cSID ) + if ( nH := hGetPos( ::hGets, 'SESSIONID' ) ) != 0 cSID := hGetValueAt( ::hGets, nH ) elseif ( nH := hGetPos( ::hPosts, 'SESSIONID' ) ) != 0 cSID := hGetValueAt( ::hPosts, nH ) elseif ( nH := hGetPos( ::hCookies, 'SESSIONID' ) ) != 0 cSID := hGetValueAt( ::hCookies, nH ) + endif + endif if empty( ::cSessionSavePath ) diff --git a/harbour/include/hbcompat.ch b/harbour/include/hbcompat.ch index 51fd965429..df212e0c76 100644 --- a/harbour/include/hbcompat.ch +++ b/harbour/include/hbcompat.ch @@ -76,6 +76,7 @@ #xtranslate gtGetClipboard() => hb_gtInfo( GTI_CLIPBOARDDATA ) #xtranslate gtGetClipBoardSize() => len( hb_gtInfo( GTI_CLIPBOARDDATA ) ) #xtranslate gtPasteClipBoard([]) => hb_gtInfo( GTI_CLIPBOARDPAST ) + #xtranslate gtProcessMessages() => nextkey() #xtranslate gfxPrimitive([])=> hb_gfxPrimitive([]) #xtranslate gfxText([]) => hb_gfxText([])