From ebaee42c220188894ccd3cbd6674095d6a0f0b79 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 17 Nov 2010 11:04:43 +0000 Subject: [PATCH] 2010-11-17 12:03 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * examples/terminal/trm_srv.prg * examples/terminal/readme.txt ! Fixed to use localhost instead of IPV4 specific 127.0.0.1 ; Patches from Tamas: (Thanks a lot!) + debian/postinst + debian/postrm + make deb package run ldconfig when needed * contrib/hbfbird/tests/simple.prg * contrib/hbfbird/tests/test.prg * contrib/hbfbird/tests/stress.prg * Formatting, fixes, cleanup. ; TOFIX: OOP layer in hbfbird. * contrib/sddpg/sddpg.c * contrib/hbpgsql/postgres.c ! Fixed postgres header situation. + contrib/hbgd/tests/test.prg * contrib/hbgd/gdwrp.c + Resolved TODO. + Added new test. --- harbour/ChangeLog | 26 ++++++++++++++++++++ harbour/contrib/hbfbird/tests/simple.prg | 29 +++++++++++++--------- harbour/contrib/hbfbird/tests/stress.prg | 22 +++++++++++------ harbour/contrib/hbfbird/tests/test.prg | 23 ++++++++++++------ harbour/contrib/hbgd/gdwrp.c | 19 +++++++++------ harbour/contrib/hbgd/tests/test.prg | 28 +++++++++++++++++++++ harbour/contrib/hbpgsql/postgres.c | 26 ++------------------ harbour/contrib/sddpg/sddpg.c | 31 ------------------------ harbour/debian/postinst | 22 +++++++++++++++++ harbour/debian/postrm | 22 +++++++++++++++++ harbour/examples/terminal/readme.txt | 4 +-- harbour/examples/terminal/trm_srv.prg | 4 +-- 12 files changed, 163 insertions(+), 93 deletions(-) create mode 100644 harbour/contrib/hbgd/tests/test.prg create mode 100644 harbour/debian/postinst create mode 100644 harbour/debian/postrm diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 15f4e5c68b..2e16f62930 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,32 @@ The license applies to all entries newer than 2009-04-28. */ +2010-11-17 12:03 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * examples/terminal/trm_srv.prg + * examples/terminal/readme.txt + ! Fixed to use localhost instead of IPV4 specific 127.0.0.1 + + ; Patches from Tamas: (Thanks a lot!) + + + debian/postinst + + debian/postrm + + make deb package run ldconfig when needed + + * contrib/hbfbird/tests/simple.prg + * contrib/hbfbird/tests/test.prg + * contrib/hbfbird/tests/stress.prg + * Formatting, fixes, cleanup. + ; TOFIX: OOP layer in hbfbird. + + * contrib/sddpg/sddpg.c + * contrib/hbpgsql/postgres.c + ! Fixed postgres header situation. + + + contrib/hbgd/tests/test.prg + * contrib/hbgd/gdwrp.c + + Resolved TODO. + + Added new test. + 2010-11-16 10:29 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/xhb/xthrow.prg ! removed unreachable RETURN statement reported by extended BREAK() diff --git a/harbour/contrib/hbfbird/tests/simple.prg b/harbour/contrib/hbfbird/tests/simple.prg index 7f93dafbab..a5ac1d65c2 100644 --- a/harbour/contrib/hbfbird/tests/simple.prg +++ b/harbour/contrib/hbfbird/tests/simple.prg @@ -2,27 +2,32 @@ * $Id$ */ -#include "common.ch" #include "simpleio.ch" -Function main() - Local oServer, oQuery, oRow, i, x, aTables, aStruct, aKey +FUNCTION Main() + LOCAL oServer, oQuery, oRow, i, x, aTables, aStruct, aKey - Local cServer := "127.0.0.1:" + hb_dirBase() + "simple.gdb" - Local cUser := "sysdba" - Local cPass := "masterkey" - Local nDialect := 1 - Local cQuery + LOCAL cServer := "localhost:" + LOCAL cDatabase + LOCAL cUser := "SYSDBA" + LOCAL cPass := "masterkey" + LOCAL nPageSize := 1024 + LOCAL cCharSet := "ASCII" + LOCAL nDialect := 1 + LOCAL cQuery, cName - IF hb_FileExists( hb_dirBase() + "simple.gdb" ) - FErase( hb_dirBase() + "simple.gdb" ) + hb_FNameSplit( hb_argv( 0 ), NIL, @cName, NIL ) + cDatabase := hb_DirTemp() + cName + ".fdb" + + IF hb_FileExists( cDatabase ) + FErase( cDatabase ) ENDIF - ? FBCreateDB( hb_dirBase() + "simple.gdb", cuser, cpass, 1024, "ASCII", nDialect ) + ? FBCreateDB( cServer + cDatabase, cUser, cPass, nPageSize, cCharSet, nDialect ) ? "Connecting..." - oServer := TFBServer():New( cServer, cUser, cPass, nDialect ) + oServer := TFBServer():New( cServer + cDatabase, cUser, cPass, nDialect ) IF oServer:NetErr() ? oServer:Error() diff --git a/harbour/contrib/hbfbird/tests/stress.prg b/harbour/contrib/hbfbird/tests/stress.prg index 2a160890e2..311c768a74 100644 --- a/harbour/contrib/hbfbird/tests/stress.prg +++ b/harbour/contrib/hbfbird/tests/stress.prg @@ -4,25 +4,33 @@ /* VERY IMPORTANT: Don't use this query as sample, they are used for stress tests !!! */ +#include "simpleio.ch" + FUNCTION Main() LOCAL oServer, oQuery, oRow, i, x - LOCAL cServer := "127.0.0.1:" + hb_dirBase() + "stress.gdb" - LOCAL cUser := "sysdba" + LOCAL cServer := "localhost:" + LOCAL cDatabase + LOCAL cUser := "SYSDBA" LOCAL cPass := "masterkey" + LOCAL nPageSize := 1024 + LOCAL cCharSet := "WIN1251" LOCAL nDialect := 1 - LOCAL cQuery + LOCAL cQuery, cName CLEAR SCREEN - IF ! hb_FileExists( hb_dirBase() + "stress.gdb" ) - ? FBCreateDB( hb_dirBase() + "stress.gdb", cuser, cpass, 1024, "WIN1251", nDialect ) + hb_FNameSplit( hb_argv( 0 ), NIL, @cName, NIL ) + cDatabase := hb_DirTemp() + cName + ".fdb" + + IF ! hb_FileExists( cDatabase ) + ? FBCreateDB( cServer + cDatabase, cUser, cPass, nPageSize, cCharSet, nDialect ) ENDIF ? "Connecting..." - oServer := TFBServer():New( cServer, cUser, cPass, nDialect ) + oServer := TFBServer():New( cServer + cDatabase, cUser, cPass, nDialect ) IF oServer:NetErr() ? oServer:Error() @@ -65,7 +73,7 @@ FUNCTION Main() oRow:Fieldput(1, i) oRow:Fieldput(2, i+1) oRow:Fieldput(3, "DEPARTMENT NAME " + strzero( i ) ) - oRow:Fieldput(4, (i % 10) == 0) ) + oRow:Fieldput(4, (i % 10) == 0) oRow:Fieldput(5, 3000 + i ) oRow:fieldput(6, Date() ) diff --git a/harbour/contrib/hbfbird/tests/test.prg b/harbour/contrib/hbfbird/tests/test.prg index 10720e8e0c..99b51794a9 100644 --- a/harbour/contrib/hbfbird/tests/test.prg +++ b/harbour/contrib/hbfbird/tests/test.prg @@ -6,9 +6,15 @@ #include "simpleio.ch" FUNCTION Main() - LOCAL cDir, cName - LOCAL cDBName + + LOCAL cServer := "localhost:" + LOCAL cDatabase + LOCAL cUser := "SYSDBA" + LOCAL cPass := "masterkey" + LOCAL nPageSize := 1024 + LOCAL cCharSet := "ASCII" LOCAL nDialect := 1 + LOCAL cName LOCAL trans, qry @@ -18,17 +24,18 @@ FUNCTION Main() LOCAL fetch_stat LOCAL tmp - hb_FNameSplit( hb_argv( 0 ), @cDir, @cName, NIL ) - cDBName := hb_FNameMerge( cDir, cName, ".gdb" ) + hb_FNameSplit( hb_argv( 0 ), NIL, @cName, NIL ) + cDatabase := hb_DirTemp() + cName + ".fdb" - IF hb_FileExists( cDBName ) - FErase( cDBName ) + IF hb_FileExists( cDatabase ) + FErase( cDatabase ) ENDIF - ? tmp := FBCreateDB( cDBName, "sysdba", "masterkey", 1024, "ASCII", nDialect ), FBError( tmp ) + ? tmp := FBCreateDB( cServer + cDatabase, cUser, cPass, nPageSize, cCharSet, nDialect ), FBError( tmp ) + /* Connect rdbms */ - db := FBConnect( "127.0.0.1:" + cDBName, "sysdba", "masterkey" ) + db := FBConnect( cServer + cDatabase, cUser, cPass ) IF ISNUMBER( db ) ? "Error:", db, FBError( db ) QUIT diff --git a/harbour/contrib/hbgd/gdwrp.c b/harbour/contrib/hbgd/gdwrp.c index c1c74fa7de..cf9fc35993 100644 --- a/harbour/contrib/hbgd/gdwrp.c +++ b/harbour/contrib/hbgd/gdwrp.c @@ -921,7 +921,7 @@ HB_FUNC( GDIMAGEPOLYGON ) /* original: void gdImagePolygon(gdImagePtr im, gdPoin int i; /* Max Points of polygon */ - gdPoint points[50]; /* TODO: make this dynamic */ + gdPoint * points; /* Retrieve image pointer */ im = hb_parGdImage( 1 ); @@ -929,6 +929,7 @@ HB_FUNC( GDIMAGEPOLYGON ) /* original: void gdImagePolygon(gdImagePtr im, gdPoin /* Retrieve point array */ pPoints = hb_param( 2, HB_IT_ARRAY ); pointsTotal = ( int ) hb_arrayLen( pPoints ); + points = ( gdPoint * ) hb_xgrab( sizeof( gdPoint ) * pointsTotal ); for( i = 0; i < pointsTotal; i ++ ) { @@ -946,6 +947,7 @@ HB_FUNC( GDIMAGEPOLYGON ) /* original: void gdImagePolygon(gdImagePtr im, gdPoin /* Draw a polygon */ gdImagePolygon( im, ( gdPointPtr ) points, pointsTotal, color ); + hb_xfree( points ); } else { @@ -974,7 +976,7 @@ HB_FUNC( GDIMAGEOPENPOLYGON ) /* original: void gdImageOpenPolygon(gdImagePtr im int i; /* Max Points of polygon */ - gdPoint points[50]; /* TODO: make this dynamic */ + gdPoint * points; /* Retrieve image pointer */ im = hb_parGdImage( 1 ); @@ -982,6 +984,7 @@ HB_FUNC( GDIMAGEOPENPOLYGON ) /* original: void gdImageOpenPolygon(gdImagePtr im /* Retrieve point array */ pPoints = hb_param( 2, HB_IT_ARRAY ); pointsTotal = ( int ) hb_arrayLen( pPoints ); + points = ( gdPoint * ) hb_xgrab( sizeof( gdPoint ) * pointsTotal ); for( i = 0; i < pointsTotal; i ++ ) { @@ -999,6 +1002,7 @@ HB_FUNC( GDIMAGEOPENPOLYGON ) /* original: void gdImageOpenPolygon(gdImagePtr im /* Draw a polygon */ gdImageOpenPolygon( im, ( gdPointPtr ) points, pointsTotal, color ); + hb_xfree( points ); } else { @@ -1542,7 +1546,7 @@ HB_FUNC( GDIMAGESETSTYLE ) /* original: void gdImageSetStyle(gdImagePtr im, int int i; /* Max numbery of Styles */ - int styles[50]; /* TODO: make this dynamic */ + int * styles; /* Retrieve image pointer */ im = hb_parGdImage( 1 ); @@ -1550,14 +1554,17 @@ HB_FUNC( GDIMAGESETSTYLE ) /* original: void gdImageSetStyle(gdImagePtr im, int /* Retrieve style array */ pStyles = hb_param( 2, HB_IT_ARRAY ); styleLength = ( int ) hb_arrayLen( pStyles ); + styles = ( int * ) hb_xgrab( sizeof( int ) * styleLength ); for( i = 0; i < styleLength; i ++ ) { - styles[ i ] = hb_arrayGetNI( pStyles, i+1 ); + styles[ i ] = hb_arrayGetNI( pStyles, i + 1 ); } /* Set style */ gdImageSetStyle( im, ( int * ) styles, styleLength); + + hb_xfree( styles ); } else { @@ -3528,9 +3535,7 @@ HB_FUNC( GDIMAGESQUARETOCIRCLE ) /* void gdImageSquareToCircle(gdImagePtr im, in /* Retrieve radius value */ radius = hb_parni( 2 ); - /* TODO */ - gdImageSquareToCircle( im, radius ); - + hb_retGdImage( gdImageSquareToCircle( im, radius ) ); } else { diff --git a/harbour/contrib/hbgd/tests/test.prg b/harbour/contrib/hbgd/tests/test.prg new file mode 100644 index 0000000000..8b8c3b1459 --- /dev/null +++ b/harbour/contrib/hbgd/tests/test.prg @@ -0,0 +1,28 @@ +/* + * $Id$ + */ + +#define IMAGES_OUT "imgs_out/" + +PROCEDURE Main() + + LOCAL im, im2, col, i + + im := gdImageCreateTrueColor( 100, 100 ) + col := gdImageColorAllocate( im, 255, 255, 255 ) + + FOR i := 0 TO 99 STEP 10 + gdImageLine( im, i, 0, i, 99, col ) + gdImageLine( im, 0, i, 99, i, col ) + NEXT + + gdImagePng( im, IMAGES_OUT + "gdtest.png" ) + + im2 := gdImageSquareToCircle( im, 400 ) + + gdImagePng( im2, IMAGES_OUT + "gdtest_squared.png" ) + + gdImageDestroy( im ) + gdImageDestroy( im2 ) + + RETURN diff --git a/harbour/contrib/hbpgsql/postgres.c b/harbour/contrib/hbpgsql/postgres.c index 0ec5d15ea0..8e394614ba 100644 --- a/harbour/contrib/hbpgsql/postgres.c +++ b/harbour/contrib/hbpgsql/postgres.c @@ -58,30 +58,8 @@ #include "hbapiitm.h" #include "libpq-fe.h" - -#define VARHDRSZ 4 -#define BOOLOID 16 -#define INT8OID 20 -#define INT2OID 21 -#define INT4OID 23 -#define TEXTOID 25 -#define OIDOID 26 -#define FLOAT4OID 700 -#define FLOAT8OID 701 -#define CASHOID 790 -#define BPCHAROID 1042 -#define VARCHAROID 1043 -#define DATEOID 1082 -#define TIMEOID 1083 -#define TIMESTAMPOID 1114 -#define TIMESTAMPTZOID 1184 -#define TIMETZOID 1266 -#define BITOID 1560 -#define VARBITOID 1562 -#define NUMERICOID 1700 - -#define INV_WRITE 0x00020000 -#define INV_READ 0x00040000 +#include "postgres.h" +#include "catalog/pg_type.h" #ifndef HB_PGVERSION # ifdef PG_DIAG_INTERNAL_POSITION diff --git a/harbour/contrib/sddpg/sddpg.c b/harbour/contrib/sddpg/sddpg.c index de8786c9c3..22989a880f 100644 --- a/harbour/contrib/sddpg/sddpg.c +++ b/harbour/contrib/sddpg/sddpg.c @@ -57,39 +57,8 @@ #include "hbrddsql.h" #include "libpq-fe.h" - -/* TOFIX: these are defined in "server/catalog/pg_type.h", - but including this file generates compile errors. --Ic:/pgsql/include;c:/pgsql/include/server #include "postgres.h" #include "catalog/pg_type.h" -*/ - -#define BOOLOID 16 -#define BYTEAOID 17 -#define CHAROID 18 -#define NAMEOID 19 -#define INT8OID 20 -#define INT2OID 21 -#define INT4OID 23 -#define TEXTOID 25 -#define OIDOID 26 -#define CIDROID 650 -#define FLOAT4OID 700 -#define FLOAT8OID 701 -#define CASHOID 790 -#define MACADDROID 829 -#define INETOID 869 -#define BPCHAROID 1042 -#define VARCHAROID 1043 -#define DATEOID 1082 -#define TIMEOID 1083 -#define TIMESTAMPOID 1114 -#define TIMESTAMPTZOID 1184 -#define TIMETZOID 1266 -#define BITOID 1560 -#define VARBITOID 1562 -#define NUMERICOID 1700 typedef struct { diff --git a/harbour/debian/postinst b/harbour/debian/postinst new file mode 100644 index 0000000000..fcef884e0f --- /dev/null +++ b/harbour/debian/postinst @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +case "$1" in + configure|remove) + /sbin/ldconfig + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 + diff --git a/harbour/debian/postrm b/harbour/debian/postrm new file mode 100644 index 0000000000..497a40678f --- /dev/null +++ b/harbour/debian/postrm @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +case "$1" in + remove) + /sbin/ldconfig + ;; + + purge|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 + diff --git a/harbour/examples/terminal/readme.txt b/harbour/examples/terminal/readme.txt index ec24ee98e8..e09056ccde 100644 --- a/harbour/examples/terminal/readme.txt +++ b/harbour/examples/terminal/readme.txt @@ -25,7 +25,7 @@ Terminal Client =============== Source => trm_client.prg Link => GTWVG - Run => trm_client.exe + Run => trm_client.exe [Parameters - Norammly Supplied to Appln - Separated by SPACE ] @@ -37,7 +37,7 @@ Terminal Client Parameters supplied TO Harbour Client can be on command line or as an .ini file. .Ini file may contain these entries: - ServerIP = 127.0.0.1 | vouch.dynalias.com + ServerIP = localhost | vouch.dynalias.com ServerPort = 2011 Application = c:\harbour\contrib\examples\terminal\trm_app.exe Parameters = any number of parameters separated by a space diff --git a/harbour/examples/terminal/trm_srv.prg b/harbour/examples/terminal/trm_srv.prg index 367120eed7..23516292d6 100644 --- a/harbour/examples/terminal/trm_srv.prg +++ b/harbour/examples/terminal/trm_srv.prg @@ -192,14 +192,14 @@ PROCEDURE ServeClient( Socket ) nServerPort++ SvrExecuteAPP( 'trm_app.exe', hb_ntos( nServerPort++ ), hb_dirBase() ) inkey( 5 ) - cReply := 'CONNECT;' + '127.0.0.1' + ';' + hb_ntos( nServerPort++ ) + ';' + cReply := 'CONNECT;' + 'localhost' + ';' + hb_ntos( nServerPort++ ) + ';' case cReq == 'VOUCH' nServerPort++ cCmdLine := a_[ 3 ] +' '+ ltrim( str( nServerPort ) ) SvrExecuteAPP( a_[ 2 ], cCmdLine, a_[ 4 ] ) - cReply := 'CONNECT;' + '127.0.0.1' + ';' + hb_ntos( nServerPort ) + ';' + a_[ 2 ] + ';' + cReply := 'CONNECT;' + 'localhost' + ';' + hb_ntos( nServerPort ) + ';' + a_[ 2 ] + ';' case cReq == 'ARCONNECTED' // No further info required, close connection