2012-06-12 21:55 UTC+0200 Viktor Szakats (vszakats syenar.net)

- examples/hbapollo
  - examples/hbbtree
  - examples/hscript
  - examples/misc
  - examples/terminal
    - deleted obsolete and/or unmaintained components
This commit is contained in:
Viktor Szakats
2012-06-12 19:56:14 +00:00
parent df87b48bf8
commit 8fdb5c558b
40 changed files with 8 additions and 7576 deletions

View File

@@ -16,6 +16,14 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-06-12 21:55 UTC+0200 Viktor Szakats (vszakats syenar.net)
- examples/hbapollo
- examples/hbbtree
- examples/hscript
- examples/misc
- examples/terminal
- deleted obsolete and/or unmaintained components
2012-06-12 21:14 UTC+0200 Viktor Szakats (harbour syenar.net)
* examples/hbbtree/tests/ctest.c
! converted Windows type to Harbour one

View File

@@ -1,327 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* VistaSoftware's Apollo database driver. See http://www.VistaSoftware.com
*
* Copyright 2001 Patrick Mast <email@PatrickMast.com>
* 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.
*
*/
/* -----------------29/12/2001 19:23-----------------
* NOTE: Functions are listed alfabetically
* --------------------------------------------------*/
/* NOTE: This hack is needed to suppress 'non-ANSI
keyword' warnings inside Sde61.h. */
#if defined( __BORLANDC__ ) || defined( __WATCOMC__ )
#define _declspec __declspec
#endif
#include "hbapi.h"
#if defined( HB_OS_WIN )
#include <windows.h>
#endif
#if defined( HB_WITH_APOLLO_VER61 )
#include "Sde61.h"
#else
#include "sde7.h"
#endif
/* Uncomment for previous version */
/* */
HB_FUNC( SX_APPENDBLANK )
{
sx_AppendBlank();
}
HB_FUNC( SX_CLOSE )
{
sx_Close();
}
HB_FUNC( SX_COMMIT )
{
sx_Commit();
}
HB_FUNC( SX_CREATEEXEC )
{
sx_CreateExec();
}
/* -----------------29/12/2001 19:18-----------------
* sx_CreateField()
* --------------------------------------------------*/
HB_FUNC( SX_CREATEFIELD )
{
sx_CreateField( ( PBYTE ) hb_parc( 1 ), /* Field name */
( PBYTE ) hb_parc( 2 ), /* Field type */
( SHORT ) hb_parni( 3 ), /* Field lenght */
( SHORT ) hb_parni( 4 ) ); /* Field decimals */
}
/* -----------------29/12/2001 19:59-----------------
* sx_CreateNew()
* => The work area number assigned to the database.
* --------------------------------------------------*/
HB_FUNC( SX_CREATENEW )
{
hb_retni(
sx_CreateNew( ( PBYTE ) hb_parc( 1 ), /* Field name */
( PBYTE ) hb_parc( 2 ), /* Alias */
( SHORT ) hb_parni( 3 ), /* RDE Type */
( SHORT ) hb_parni( 4 ) ) ); /* The maximum number of fields to be added to the file structure */
}
HB_FUNC( SX_EOF )
{
hb_retl( sx_Eof() );
}
/* -----------------29/12/2001 20:13-----------------
* sx_GetDateJulian() => The date expressed as a long integer. Useful for date arithmetic.
* Extracts the contents of a date field as a Julian number.
* This number is equal to the number of days since January 1, 4713 BC.
* However, only JULIAN dates equal or greater than January 1, 1000 are supported.
* --------------------------------------------------*/
HB_FUNC( SX_GETDATEJULIAN )
{
hb_retni( sx_GetDateJulian( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
}
/* -----------------30/12/2001 13:04-----------------
* sx_GetLogical() => True if the field evaluates as True, and False if not.
* Determines whether a logical field contains a True or False value.
* --------------------------------------------------*/
HB_FUNC( SX_GETLOGICAL )
{
hb_retl( sx_GetLogical( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
}
HB_FUNC( SX_GETSTRING )
{
hb_retc( ( char * ) sx_GetString( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
}
/* -----------------30/12/2001 12:21-----------------
* sx_GetVariant() => Character fields are returned as untrimmed strings.
* --------------------------------------------------*/
HB_FUNC( SX_GETVARIANT )
{
hb_retc( ( char * ) sx_GetVariant( ( PBYTE ) hb_parc( 1 ) ) ); /* Field name */
}
HB_FUNC( SX_GO )
{
sx_Go( hb_parni( 1 ) );
}
HB_FUNC( SX_GOBOTTOM )
{
sx_GoBottom();
}
HB_FUNC( SX_GOTOP )
{
sx_GoTop();
}
HB_FUNC( SX_INDEXTAG )
{
hb_retni(
sx_IndexTag( ( PBYTE ) hb_parc( 1 ), /* Field name */
( PBYTE ) hb_parc( 2 ), /* Tag name */
( PBYTE ) hb_parc( 3 ), /* Index expression as a string */
( SHORT ) hb_parni( 4 ), /* Option (0=Standard) (1=Unique) (2=Roll-Your-Own) */
hb_parl( 5 ), /* True for a descend index */
( PBYTE ) hb_parc( 6) ) ); /* Condition */
}
HB_FUNC( SX_RECCOUNT )
{
hb_retni( sx_RecCount() );
}
HB_FUNC( SX_RECNO )
{
hb_retni( sx_RecNo() );
}
HB_FUNC( SX_REINDEX )
{
sx_Reindex();
}
HB_FUNC( SX_REPLACE )
{
switch( hb_parni( 2 ) )
{
case R_INTEGER :
case R_JULIAN : sx_Replace( ( PBYTE ) hb_parc( 1 ), ( SHORT ) hb_parni( 2 ), ( void * ) hb_parni( 3 ) ); break;
case R_LOGICAL : sx_Replace( ( PBYTE ) hb_parc( 1 ), ( SHORT ) hb_parni( 2 ), ( void * ) hb_parni( 3 ) ); break; /* TODO: somthing is wrong here... */
case R_LONG : sx_Replace( ( PBYTE ) hb_parc( 1 ), ( SHORT ) hb_parni( 2 ), ( void * ) hb_parnl( 3 ) ); break;
case R_DOUBLE :
{
double d = hb_parnd( 3 );
sx_Replace( ( PBYTE ) hb_parc( 1 ), ( SHORT ) hb_parni( 2 ), ( void * ) &d );
break;
}
case R_CHAR :
case R_DATESTR :
case R_MEMO :
case R_BITMAP :
case R_BLOBFILE:
case R_BLOBPTR : sx_Replace( ( PBYTE ) hb_parc( 1 ), ( SHORT ) hb_parni( 2 ), ( void * ) hb_parc( 3 ) ); break;
default: sx_Replace( ( PBYTE ) hb_parc( 1 ), ( SHORT ) hb_parni( 2 ), ( void * ) hb_parc( 3 ) );
}
}
HB_FUNC( SX_RLOCK )
{
sx_Rlock( hb_parni( 1 ) ); /* The physical record number of the record to be locked. */
}
HB_FUNC( SX_SEEK )
{
hb_retl( sx_Seek( ( PBYTE ) hb_parc( 1 ) ) ); /* The value to search for as a string */
}
/* -----------------20/01/2002 13:36-----------------
* sx_Select() => The previous select area is returned.
* If there was no previous area active, zero is returned.
* --------------------------------------------------*/
HB_FUNC( SX_SELECT )
{
hb_retni( sx_Seek( ( PBYTE ) hb_parc( 1 ) ) ); /* The work area number returned when the file was opened. */
}
/* -----------------30/12/2001 12:30-----------------
* sx_SetCentury() => NILL
* Indicates whether or not the two digits of the year designating
* century are to be returned by sx_GetDateString as part of a date
* string formatted according to the sx_SetDateFormat setting.
* --------------------------------------------------*/
HB_FUNC( SX_SETCENTURY )
{
sx_SetCentury( hb_parl( 1 ) ? 1 : 0 ); /* If True, the century digits will be returned.
* If False, they will not. */
}
/* -----------------30/12/2001 12:32-----------------
* sx_SetDateFormat() => NILL
* Defines the format of date strings returned by sx_GetDateString.
* --------------------------------------------------*/
HB_FUNC( SX_SETDATEFORMAT )
{
sx_SetDateFormat( hb_parl( 1 ) ? 1 : 0 ); /* If True, the century digits will be returned.
* If False, they will not. */
}
HB_FUNC( SX_SETMEMOBLOCKSIZE )
{
sx_SetMemoBlockSize( ( WORD ) hb_parni( 1 ) ); /* The new default block size.
* The size must be a value from 1 through 1024. */
}
/* -----------------20/01/2002 13:33-----------------
* sx_SetOrder() => The previous index order identifier in use is returned.
* If zero, there was no previous index order in use.
* --------------------------------------------------*/
HB_FUNC( SX_SETORDER )
{
hb_retni( sx_SetOrder( ( SHORT ) hb_parni( 1 ) ) ); /* Selects an existing order as the controlling index order. */
}
HB_FUNC( SX_SETSOFTSEEK )
{
sx_SetSoftSeek( hb_parl( 1 ) ? 1 : 0 ); /* True to set softseek ON */
}
HB_FUNC( SX_SKIP )
{
sx_Skip( hb_parnl( 1 ) ); /* Number of records to skip */
}
/* -----------------20/01/2002 14:2-----------------
* sx_SysProp() => Varies depending on the type of data being requested.
* LONG SDEAPI WINAPI sx_SysProp (WORD uiSysItem, PVOID vpData);
* --------------------------------------------------*/
HB_FUNC( SX_SYSPROP )
{
int i = hb_parni( 2 );
hb_retni(
sx_SysProp( ( WORD ) hb_parni( 1 ), /* One of the predefined constant values. See Apollo.ch */
( void * ) &i ) );
}
/*
HB_FUNC( SX_DISABLEAUTOOPEN )
{
int i = 1;
sx_SysProp( 1013, ( void * ) &i );
}
*/
HB_FUNC( SX_USE )
{
hb_retni(
sx_Use( ( PBYTE ) hb_parc( 1 ), /* Filename */
( PBYTE ) hb_parc( 2 ), /* Alias */
( SHORT ) hb_parni( 3 ), /* OpenMode */
( SHORT ) hb_parni( 4 ) ) ); /* RDE Type */
}
HB_FUNC( SX_VERSION )
{
hb_retc( ( char * ) sx_Version() );
}
HB_FUNC( SX_ZAP )
{
sx_Zap();
}

View File

@@ -1,148 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Apollo SIXNSX defines
*
* Copyright 2001 Patrick Mast <email@PatrickMast.com>
* 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.
*
*/
/* ************* */
/* date types */
/* ************* */
#define SX_AMERICAN 0
#define SX_ANSI 1
#define SX_BRITISH 2
#define SX_FRENCH 3
#define SX_GERMAN 4
#define SX_ITALIAN 5
#define SX_SPANISH 6
/* ************************************ */
/* Data type identifiers for sx_Replace */
/* ************************************ */
#define SX_R_INTEGER 1
#define SX_R_LONG 2
#define SX_R_DOUBLE 8
#define SX_R_JULIAN 32
#define SX_R_LOGICAL 128
#define SX_R_CHAR 1024
#define SX_R_DATESTR 1056
#define SX_R_MEMO 3072
#define SX_R_BITMAP 4096
#define SX_R_BLOBFILE 8192
#define SX_R_BLOBPTR 8193
#define SX_R_GENERAL 8195
#define SX_SDENTX 1 // CA-Cl*pper compatible DBF-NTX driver
#define SX_SDEFOX 2 // FoxPro compatible DBF-IDX/CDX driver
#define SX_SDENSX 3 // Vista DBF-NSX driver
#define SX_READWRITE 0
#define SX_READONLY 1
#define SX_EXCLUSIVE 2
/* ******************************** */
/* sx_SysProp Constants */
/* ******************************** */
// Global Task Information
// Gets should always be even numbers
#define SDE_SP_GETSOFTSEEK 1000 // Get the softseek flag
#define SDE_SP_SETSOFTSEEK 1001 // Set the softseek flag
#define SDE_SP_GETEXACT 1002 // Get the extact flag
#define SDE_SP_SETEXACT 1003 // Set the extact flag
#define SDE_SP_GETDELETED 1006 // Get the deleted flag
#define SDE_SP_PUTOBUFFER 1007 // Write the optimistic buffer on commit
#define SDE_SP_GETOBUFFER 1008 // Get the optimistic buffer flag
#define SDE_SP_SETOBUFFER 1009 // Set the optimistic buffer flag
#define SDE_SP_GETSTRINGTYPE 1010 // Get the stringtype flag
#define SDE_SP_SETSTRINGTYPE 1011 // Set the stringtype flag
#define SDE_SP_GETDISABLEAUTO 1012 // Get the disable auto open flag
#define SDE_SP_SETDISABLEAUTO 1013 // Set the disable auto open flag
#define SDE_SP_SETOEMCOLLATE 1101 // Set the collation sequence for OEM tables.
#define SDE_SP_GETOEMCOLLATE 1111 // Get the collation sequence for OEM tables.
#define SDE_SP_SETCHRCOLLATE 1102 // Set the collation sequence for Win tables.
#define SDE_SP_GETCHRCOLLATE 1122 // Get the collation sequence for Win tables.
#define SDE_SP_SETLGTRCOLLATE 1103 // Set the ligatures collation dimmension
#define SDE_SP_GETLGTRCOLLATE 1133 // Get the ligatures collation dimmension
#define SDE_SP_SETSPECIALCOLLATE 1108 // Set the international collation like DUDEN collate flag
#define SDE_SP_GETSPECIALCOLLATE 1109 // Set the international collation like DUDEN collate flag
#define SDE_SP_GETLANGUAGECOLLATE 1110 // Get language, according to collation done
#define SDE_SP_GETDUDENCOLLATE 1104 // get the German DUDEN collate flag
#define SDE_SP_SETDUDENCOLLATE 1105 // set the German DUDEN collate flag
#define SDE_SP_GETLIMITCASECONV 1106 // limit case conv to A-Z, a-z if TRUE
#define SDE_SP_SETLIMITCASECONV 1107 // limit case conv to A-Z, a-z if TRUE
// Behavior settings which bridge the differences between 1.40 and 2.00
#define SDE_SP_GETADDQUERY 1300 // Get the AddQueryFlag
#define SDE_SP_SETADDQUERY 1301 // Set the AddQueryFlag
#define SDE_SP_GETUSECONDITIONAL 1302 // Get the bUseConditional flag
#define SDE_SP_SETUSECONDITIONAL 1303 // Get the bUseConditional flag
#define SDE_SP_SETWRITEBLOBHDR 1305 // Set the bWriteBlobHdr
#define SDE_SP_GETQUERYRELAXFLAG 1306 // Get flag that dictates rules of query
#define SDE_SP_SETQUERYRELAXFLAG 1307 // Set flag that dictates rules of query
// WorkArea information
#define SDE_SP_GETDRIVER 2000 // Get the active driver
#define SDE_SP_SETSTRDEFLEN 2001 // Set the default lenght for STR, if 2nd parameter is absent and field lenght zero
#define SDE_SP_SETSTRDEFDEC 2002 // Set the default decimals for STR, if 3d parameter is absent and field lenght zero
#define SDE_SP_SETDEFAPPEND 2003 // Set default behavior for ordering ordering for non-unique key like FOX/Clipper
#define SDE_SP_SETMEMOMIXED 2004 // Set pure Clipper's memo for NSX driver
#define SDE_SP_BDESPECIFIC 2005 // Set the treatment of LIKE operator in accoring to BDE
#define SDE_SP_DBASEDATEHEADER 2006 // Set the using of DBF header in according to DbaseIII+ specification
#define SDE_SP_SETAUTOPAD 2007
#define SDE_SP_GETAUTOPAD 2008
// Index information for current workarea
#define SDE_SP_GETINDEXCOUNT 3000 // Get the number of indexes
#define SDE_SP_GETDESCENDING 3002 // Get the descending flag
#define SDE_SP_GETEMPTY 3004 // Get the empty index flag

View File

@@ -1,68 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* VistaSoftware's Apollo database driver. See http://www.VistaSoftware.com
*
* Copyright 2001 Patrick Mast <email@PatrickMast.com>
* 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 "rddsys.ch"
/* ANNOUNCE APOLLO */
INIT PROCEDURE ApolloInit
/*
REQUEST _Apollo
rddRegister( "Apollo", RDT_FULL )
*/
RETURN
FUNCTION sx_GetVal( x )
RETURN Val( sx_Getvariant( x ) )

View File

@@ -1,13 +0,0 @@
#
# $Id$
#
{dos}skip=yes
incpaths=.
libpaths=lib/${hb_plat}/${hb_comp}
libs=${hb_name}
libs={win&&HB_WITH_APOLLO_VER61}sde61
libs={win&&!HB_WITH_APOLLO_VER61}sde7

View File

@@ -1,23 +0,0 @@
#
# $Id$
#
-hblib
-inc
-olib/${hb_plat}/${hb_comp}/${hb_name}
-w3 -es2
{HB_WITH_APOLLO_VER61}-depkeyhead=apollo:Sde61.h
{!HB_WITH_APOLLO_VER61}-depkeyhead=apollo:Sde7.h
-depcontrol=apollo:${HB_WITH_APOLLO}
-depincpath=apollo:/usr/include
-depincpath=apollo:/boot/common/include
{HB_WITH_APOLLO_VER61}-cflags=-DHB_WITH_APOLLO_VER61
-instfile=inc:apollo.ch
apollo.c
apollo1.prg

View File

@@ -1,28 +0,0 @@
/*
* $Id$
*/
RDD for VistaSoftware's Apollo Database Engine
(Server and/or Local)
Patrick Mast <email@patrickmast.com>
To build hbapollo.lib you need these files:
- sde62.dll ( you need this to build sde62.lib )
- sde62.lib ( build it using implib sde62.lib sde62.dll )
- sde62.h ( SDE C/C++ header file for sde62.dll )
Don't forget to include hbapollo.lib and sde62.lib to your
the make file or link script to build executables.
To use a application that uses hbapollo.lib you need this file:
- sde62.dll ( The Apollo Engine )
The SDE is VistaSoftware's 32-bit database engine which contains
the database technology that all Apollo products rely on to
perform the low-level data management and manipulation.
Be aware that this is a work in progress. Any comments are welcome.
More to come! ;-)
Patrick Mast
December 2001

View File

@@ -1,158 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Test VistaSoftware's Apollo database driver. See http://www.VistaSoftware.com
*
* Copyright 2001 Patrick Mast <email@PatrickMast.com>
* 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 "apollo.ch"
PROCEDURE Main()
LOCAL nAlias
LOCAL f
SET DATE FRENCH
SET CENTURY ON
sx_SetMemoBlockSize( 32 )
sx_SetDateFormat( SX_FRENCH )
sx_SetCentury( .T. )
? "Apollo version " + sx_Version()
? ""
? "Cleaning up files.."
FErase( "test.dbf" )
FErase( "test.smt" )
FErase( "test.nsx" )
? "OK!"
? ""
? "Creating a new database file.."
nAlias := sx_CreateNew("test.dbf",; // full path filename
"test1",; // Alias
SX_SDENSX,; // rdeType
6) // Maximum fields added by sx_CreateField
IF nAlias == 0
? "Error creating database"
RETURN
ENDIF
sx_CreateField("FIRST" ,"C",40,0)
sx_CreateField("LAST" ,"C",40,0)
sx_CreateField("NOTES" ,"M",10,0)
sx_CreateField("AGE" ,"N", 4,0)
sx_CreateField("MARRIED" ,"L", 1,0)
sx_CreateField("BIRTDATE","D", 8,0)
sx_CreateExec()
sx_Close()
?? "OK!"
nAlias := sx_Use("test.dbf","test2",SX_EXCLUSIVE,SX_SDENSX)
sx_Zap()
IF Valtype(nAlias) == "N" .AND. nAlias != 0
? "OK opening 'test.dbf'"
? "Adding 1000 records..."
FOR f := 1 to 1000
sx_AppendBlank()
sx_Replace("FIRST" , SX_R_CHAR , "Patrick " + Str( f ) )
sx_Replace("LAST" , SX_R_CHAR , LTrim( Str( f ) ) + " Mast" )
sx_Replace("NOTES" , SX_R_MEMO , "This is record " + LTrim( Str( f ) ) )
sx_Replace("AGE" , SX_R_DOUBLE , f )
sx_Replace("BIRTDATE" , SX_R_DATESTR, DtoC( Date() ) )
// sx_Replace("MARRIED" , SX_R_LOGICAL, iif(f%5==2,1,0) ) /* Logical does not work yet.. */
sx_Commit()
NEXT
? "Creating Index..."
sx_IndexTag(,"LAST","LAST+FIRST",0)
? "Created a HiPer-Six index. See 'test.nsx'"
sx_GoTop()
WHILE !sx_Eof()
? ""
? "RecNo...... : " + LTrim( Str( sx_RecNo() ) )
? "Last name.. : " + sx_GetVariant( "LAST" )
? "Birth date. : " + sx_GetVariant( "BIRTDATE" )
? "Married.... : " + iif( sx_GetLogical( "MARRIED" ) , "Yes", "No, SINGLE!!")
sx_Skip(1)
ENDDO
? ""
sx_GoTop()
sx_SetSoftSeek( .F. ) // SetSoftSeek OFF
IF sx_Seek( "928 Mast" )
? "String '928 Mast' found in record number "+ LTrim( Str( sx_RecNo() ) )
ELSE
? "String '928 Mast' NOT Found..."
ENDIF
? ""
? "There are "+LTrim( Str( sx_RecCount() ) )+" records in the database"
?
? "Reindexing now..."
sx_ReIndex()
?? "OK!"
sx_Close()
ELSE
? "ERROR Opening 'test.dbf'"
ENDIF
return

View File

@@ -1,7 +0,0 @@
#
# $Id$
#
../hbapollo.hbc
-w3 -es2

View File

@@ -1,869 +0,0 @@
/*
$Id$
*/
/*
* Harbour Project source code:
* HB_BTree C and Harbour API documentation.
*
* Copyright 2002 April White <april@users.sourceforge.net>
* 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 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) 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 HRL
* and/or HVM code into it.
*
* 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
/* $DOC$
* $FUNCNAME$
* BTree Notes
* $CATEGORY$
* BTree API
* $ONELINER$
* Prentice Hall (publisher) letter of approval
* $DESCRIPTION$
* Subject: RE: B-tree request </par>
* Date: 10 Jul 2000 09:18:50 -0400 </par>
* From: Petra_Recter@prenhall.com </par>
* To: awhite@user.rose.com [now april@users.sourceforge.net] </par>
* </par>
* Dear April: </par>
* </par>
* I have consulted the author and I am happy to grant permission to your request. </par>
* Pls. take my email as formal approval. </par>
* </par>
* Sincerely, </par>
* </par>
* Petra Recter </par>
* Senior Acquisitions Editor, Computer Science </par>
* Prentice Hall </par>
* One Lake Street - #3F66 </par>
* Upper Saddle River, NJ 07458 </par>
* </par>
* Email: petra_recter@prenhall.com </par>
* Tel: (201) 236-7186 Fax: (201) 236-7170 </par>
* </par>
* -----Original Message----- </par>
* From: awhite@user.rose.com [mailto:awhite@user.rose.com] </par>
* Sent: Thursday, June 29, 2000 6:55 PM </par>
* To: webmaster@prenhall.com </par>
* Subject: request for use of copyright material </par>
* </par>
* regarding ISBN 0-13-725649-3 "Data Structures and Program Design in C" </par>
* by Kruse Robert L., Leung Bruce P., and Tondo Clovis L.; (c) 1991 </par>
* Prentice-Hall Inc </par>
* </par>
* Within a chapter of this book (section 10-3, External Searching: </par>
* B-Trees) there are very clear examples for the manipulation of b-trees. </par>
* I have successfully converted this code to perform true file i/o </par>
* (whereas the examples use in-memory b-trees). </par>
* </par>
* I am a member of a group of programmers developing an Open Source </par>
* compiler called 'Harbour'. This compiler is intended as a replacement </par>
* for a commercial product called 'Clipper' (Computer Associates). If you </par>
* are interested in learning more about Harbour, please see </par>
* http://www.harbour-project.org/ </par>
* </par>
* The Harbour project is governed by the GNU Public License [GPL] (please </par>
* see http://www.gnu.org/) with a caveat that applications produced by </par>
* the Harbour compiler may not be covered by GPL. </par>
* </par>
* I wish to contribute my version of the code and possibly code more akin </par>
* to the examples in the book (to create in-memory b-trees). I am willing </par>
* to submit a copy of my code to Prentice-Hall for you perusal. </par>
* </par>
* If you have any questions that I cannot answer myself, I will forward </par>
* them to the project leaders for their consideration. </par>
* </par>
* I eagerly wait your favourable reply. </par>
* </par>
* Thank you, </par>
* April White
* $END$
*/
/* $DOC$
* $FUNCNAME$
* BTree Flags
* $CATEGORY$
* BTree API
* $ONELINER$
* Description of flags used to control access of a BTree file
* $DESCRIPTION$
* BTree file creation/access flags:
*
* HB_BTREE_READONLY:
*
* hb_BTreeNew() - when set, the file I/O mode FC_READONLY is used, creating
* a file with the read-only attribute set; insertions and deletions are
* permitted
*
* hb_BTreeOpen() - when set, the file I/O mode FO_READONLY is used,
* preventing insertions or deletions to the BTree; if the BTree file
* has the read-only file attribute set, the flag HB_BTREE_EXCLUSIVE is
* assumed and activates internal API optimizations
*
* HB_BTREE_EXCLUSIVE - when set, the file I/O mode FO_EXCLUSIVE is used,
* preventing shared access, and activates internal API optimizations
*
* HB_BTREE_SHARED - when set, the file I/O mode FO_SHARED is used, and
* disables all internal API optimizations. This flag cannot be used
* with the HB_BTREE_READONLY flag when calling hb_BTreeNew() - in this
* case, HB_BTREE_READONLY has precedance over HB_BTREE_SHARED
*
* BTree control flags:
*
* HB_BTREE_UNIQUE - when set, the key and data together determine uniqueness;
* when not set, the key alone determines uniqueness. This flag cannot
* be used with the HB_BTREE_INMEMORY flag!
*
* HB_BTREE_CASELESS - when set, comparison of keys is done in a case-insensitive
* manner; when not set, comparisons are case sensitive
*
* HB_BTREE_INMEMORY - when set, the BTree is built and maintained entirely
* in memory; when not set, the BTree is built and maintained as a file.
* The use of this flag precludes the use of the creation/access flags listed
* above - an in-memory BTree cannot be shared, made read-only, and is also
* exclusive by definition. This flag cannot be used with hb_BTreeOpen().
* This flag is mutually exclusive of the HB_BTREE_UNIQUE.
* $SEEALSO$
* hb_BTreeNew(), hb_BTreeOpen()
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeNew()
* $CATEGORY$
* BTree API
* $ONELINER$
* Create a new BTree file
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeNew( CHAR <cFileName>, int <nPageSize>, int <nKeySize>, [ ULONG <nFlags> ], [ USHORT <nBuffers>=1 ] ) -> ( struct hb_BTree * )pHBTree
*
* Harbour Prototype
*
* hb_BTreeNew( CHAR <cFileName>, <nPageSize>, <nKeySize>, [ <nFlags> ], [ <nBuffers>=1 ] ) -> ( int )hb_BTree_Handle
*
* Harbour Class Prototype
*
* TBTreeNew( CHAR <cFileName>, <nPageSize>, <nKeySize>, [ <nFlags> ], [ <nBuffers>=1 ] ) -> <tBTreeInstance>
* $ARGUMENTS$
* <cFileName> Name of BTree file to create. This parameter is optional
* if the flag HB_BTREE_INMEMORY is used
*
* <nPageSize> Number of bytes one file 'page' is to be; must be a multiple of 2048.
* If the hb_btree library is compiled with the value HB_BTREE_HEADERSIZE
* defined to another value, that is used in place of 2048
*
* <nKeySize> Number of bytes a key value is to be; must be 8 bytes or greater
*
* <nFlags> Flags that determine the file access mode(s) and BTree mode(s)
*
* <nBuffers> Number of internal I/O buffers to use - not currently supported for shared/dynamic use
* $RETURNS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, to be used by other hb_BTree C API calls
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, to be used by other hb_BTree Harbour API calls
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
* BTree Flags
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeOpen()
* $CATEGORY$
* BTree API
* $ONELINER$
* Open an existing BTree file
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeOpen( CHAR <cFileName>, [ ULONG <nFlags> ], [ USHORT <nBuffers>=1 ] ] ) -> ( struct hb_BTree * )pHBTree
*
* Harbour Prototype
*
* hb_BTreeOpen( <cFileName>, [ <nFlags> ], [ <nBuffers>=1 ] ) -> ( int )hb_BTree_Handle
*
* Harbour Class Prototype
*
* TBTreeOpen( <cFileName>, [ <nFlags> ], [ <nBuffers>=1 ] ) -> <tBTreeInstance>
* $ARGUMENTS$
* <cFileName> Name of BTree file to open
*
* <nFlags> Flags that determine the file access mode(s) and BTree mode(s)
*
* <nBuffers> Number of internal I/O buffers to use - not currently supported for shared/dynamic use
* $RETURNS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, to be used by other hb_BTree C API calls
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, to be used by other hb_BTree Harbour API calls
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
* BTree Flags
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeClose()
* $CATEGORY$
* BTree API
* $ONELINER$
* Close an active BTree file
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeClose( struct hb_BTree * <pBTree> ) -> NIL
*
* Harbour Prototype
*
* hb_BTreeClose( <hb_BTree_Handle> ) -> NIL
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Close() -> Nil
* $ARGUMENTS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
* $RETURNS$
* Nothing.
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
*
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeInsert()
* $CATEGORY$
* BTree API
* $ONELINER$
* Insert a key/data element into an active BTree file
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeInsert( struct hb_BTree * <pBTree>, CHAR <cKey>, LONG <lData> ) -> <lSuccess>
*
* Harbour Prototype
*
* hb_BTreeInsert( <hb_BTree_Handle>, <cKey>, <lData> | <xData> ) -> <lSuccess>
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Insert( <cKey>, <lData> | <xData> ) -> <lSuccess>
* $ARGUMENTS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <cKey> A pointer to a CHAR buffer, representing a key value to be inserted
*
* <lData> A long data value to associate with the <cKey> value
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <cKey> A string, representing a key value to be inserted
*
* <lData> A numeric data value to associate with the <cKey> value, or </par>
* <xData> Any value to associate with the <cKey> value
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
*
* <cKey> A string, representing a key value to be inserted
*
* <lData> A numeric data value to associate with the <cKey> value, or </par>
* <xData> Any value to associate with the <cKey> value
* $RETURNS$
* <lSuccess> Logical value indicating whether the operation succeeded
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
*
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeDelete()
* $CATEGORY$
* BTree API
* $ONELINER$
* Delete a key/data element from an active BTree file
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeDelete( struct hb_BTree * <pBTree>, CHAR <cKey>, LONG <lData> ) -> <lSuccess>
*
* Harbour Prototype
*
* hb_BTreeDelete( <hb_BTree_Handle>, <cKey>, <lData> ) -> <lSuccess>
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Delete( <cKey>, <lData> ) -> <lSuccess>
* $ARGUMENTS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <cKey> A string, representing a key value to be deleted
*
* <lData> A numeric data value to associate with the <cKey> value
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <cKey> A string, representing a key value to be deleted
*
* <lData> A numeric data value to associate with the <cKey> value
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
*
* <cKey> A string, representing a key value to be deleted
*
* <lData> A numeric data value to associate with the <cKey> value
* $RETURNS$
* <lSuccess> Logical value indicating whether the operation succeeded
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
*
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BtreeKey()
* $CATEGORY$
* BTree API
* $ONELINER$
* Returns active key of an active BTree file
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BtreeKey( struct hb_BTree * <pBTree> ) -> CHAR <cKey>
*
* Harbour Prototype
*
* hb_BtreeKey( <hb_BTree_Handle> ) -> <cKey>
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Key() -> <cKey>
* $ARGUMENTS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
* $RETURNS$
* C Prototype
*
* <cKey> A pointer to a CHAR buffer containing the active key value
*
* Harbour Prototype
*
* <cKey> A string containing the active key value
*
* Harbour Class Prototype
*
* <cKey> A string containing the active key value
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
*
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BtreeData()
* $CATEGORY$
* BTree API
* $ONELINER$
* Returns the active data value for an active BTree file
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BtreeData( struct hb_BTree * <pBTree> ) -> LONG <lData>
*
* Harbour Prototype
*
* hb_BtreeData( <hb_BTree_Handle> ) -> <lData> | <xData>
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Data() -> <lData> | <xData>
* $ARGUMENTS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
* $RETURNS$
* C Prototype
*
* <lData> The long value associated with the active key
*
* Harbour Prototype
*
* <lData> The numeric value associated with the active key, or</par>
* <xData> The value associated with an active key of an in-memory btree
*
* Harbour Class Prototype
*
* <lData> The numeric value associated with the active key, or</par>
* <xData> The value associated with an active key of an in-memory btree
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
* hb_BtreeDataItem()
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BtreeDataItem()
* $CATEGORY$
* BTree C API
* $ONELINER$
* Returns the active data value for an active BTree file
* $SYNTAX$
* #include "hb_btree.api"
* hb_BtreeDataItem( struct hb_BTree * <pBTree> ) -> PHB_ITEM <xData>
* $ARGUMENTS$
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
* $RETURNS$
* <xData> A pointer to a constant PHB_ITEM value, or NIL if none was assigned
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
* hb_BtreeData()
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeGoTop()
* $CATEGORY$
* BTree API
* $ONELINER$
* Position an active BTree file at its logical first key/data entry
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeGoTop( struct hb_BTree * <pBTree> ) -> void
*
* Harbour Prototype
*
* hb_BTreeGoTop( <hb_BTree_Handle> ) -> NIL
*
* Harbour Class Prototype
*
* <tBTreeInstance>:GoTop() -> NIL
* $ARGUMENTS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
* $RETURNS$
* Nothing.
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
*
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeGoBottom()
* $CATEGORY$
* BTree API
* $ONELINER$
* Position an active BTree file at its logical last key/data entry
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeGoBottom( struct hb_BTree * <pBTree> ) -> void
*
* Harbour Prototype
*
* hb_BTreeGoBottom( <hb_BTree_Handle> ) -> NIL
*
* Harbour Class Prototype
*
* <tBTreeInstance>:GoBottom() -> NIL
* $ARGUMENTS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
* $RETURNS$
* Nothing.
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
*
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeSkip()
* $CATEGORY$
* BTree API
* $ONELINER$
* Position an active BTree file forward or backward relative to the active key/data entry
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeSkip( struct hb_BTree * <pBTree>, LONG <nRecords> ) -> LONG <nRecordsSkipped>
*
* Harbour Prototype
*
* hb_BTreeSkip( <hb_BTree_Handle>, LONG <nRecords> ) -> <nRecordsSkipped>
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Skip( LONG <nRecords> ) -> <nRecordsSkipped>
* $ARGUMENTS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <nRecords> Number of BTree entries to skip over
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <nRecords> Number of BTree entries to skip over
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
*
* <nRecords> Number of BTree entries to skip over
* $RETURNS$
* <nRecordsSkipped> Number of records actually skipped
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
*
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeSeek()
* $CATEGORY$
* BTree API
* $ONELINER$
* Position an active BTree file using the passed key/data value
* $SYNTAX$
* C Prototype
*
* #include "hb_btree.api"
* hb_BTreeSeek( struct hb_BTree * <pBTree>, CHAR <cKey>, LONG <lData>, BOOL <lSoftSeek> ) -> BOOL <lSuccess>
*
* Harbour Prototype
*
* hb_BTreeSeek( <hb_BTree_Handle>, <cKey>, <lData>, [ <lSoftSeek> ] ) -> <lSuccess>
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Seek( <cKey>, <lData>, <lSoftSeek> )
* $ARGUMENTS$
* C Prototype
*
* <pBTree> A pointer to an hb_BTree structure, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <cKey> A pointer to a CHAR buffer containing the key to locate
*
* <lData> The long value associated with the key. This may be passed as 0
* if the flag HB_BTREE_UNIQUE is not used (which is also implied when the
* flag HB_BTREE_INMEMORY is used)
*
* <lSoftSeek> Optional. Is a 'soft seek' method to be used?
*
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <cKey> A string containing the key to locate
*
* <lData> The long value associated with the key. This may be passed as 0
* if the flag HB_BTREE_UNIQUE is not used (which is also implied when the
* flag HB_BTREE_INMEMORY is used)
*
* <lSoftSeek> Optional. Is a 'soft seek' method to be used?
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
*
* <cKey> A string containing the key to locate
*
* <lData> The long value associated with the key. This may be passed as 0
* if the flag HB_BTREE_UNIQUE is not used (which is also implied when the
* flag HB_BTREE_INMEMORY is used)
*
* <lSoftSeek> Optional. Is a 'soft seek' method to be used?
* $RETURNS$
* <lSuccess> Logical value indicating whether the operation succeeded
* $DESCRIPTION$
* Note that when a soft seek is used, if a partial match is made, the
* function returns TRUE; this is contrary to the soft seek return value
* of the RDD system!
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
*
* $END$
*/
/* $DOC$
* $FUNCNAME$
* hb_BTreeInfo()
* $CATEGORY$
* BTree API
* $ONELINER$
* Return information about an active BTree file
* $SYNTAX$
* Harbour Prototype
*
* hb_BTreeInfo( <hb_BTree_Handle>, [ <nIndex> ] ) -> <aResult> | <cResult> | <nResult>
*
* Harbour Class Prototype
*
* <tBTreeInstance>:Info( <nIndex> ) -> <aResult> | <cResult> | <nResult>
* $ARGUMENTS$
* Harbour Prototype
*
* <hb_BTree_Handle> A handle, returned from hb_BTreeOpen() or hb_BTreeNew()
*
* <nIndex> Optional. One of:</par>
* HB_BTREEINFO_ALL (0) - default value</par>
* HB_BTREEINFO_FILENAME (1)</par>
* HB_BTREEINFO_PAGESIZE (2)</par>
* HB_BTREEINFO_KEYSIZE (3)</par>
* HB_BTREEINFO_MAXKEYS (4)</par>
* HB_BTREEINFO_MINKEYS (5)</par>
* HB_BTREEINFO_FLAGS (6)</par>
* HB_BTREEINFO_KEYCOUNT (7)</par>
*
* Harbour Class Prototype
*
* <tBTreeInstance> An instance of the TBTree class
*
* <nIndex> (see above)
* $RETURNS$
* <aResult> For the index HB_BTREEINFO_ALL, an array containing all information elements, ordered as for the index values.
*
* <cResult> For the index HB_BTREEINFO_FILENAME, a string containing the file name of the BTree file is returned.
*
* <nResult> For all other index values, the numeric value corresponding to the index name (ie. page size, etc).
* $DESCRIPTION$
*
* $EXAMPLES$
*
* $FILES$
* Library is hb_btree</par>
* Header is hb_btree.ch</par>
* C Header is hb_btree.api</par>
* $PLATFORMS$
* All
* $SEEALSO$
*
* $END$
*/

File diff suppressed because it is too large Load Diff

View File

@@ -1,70 +0,0 @@
/*
$Id$
*/
/*
* Harbour Project source code:
* HB_BTree Harbour API header.
*
* Copyright 2002-2010 April White <april@users.sourceforge.net>
* 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 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) 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 HRL
* and/or HVM code into it.
*
* 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#ifndef HB_BTREE_CH
#define HB_BTREE_CH
/* NOTE: This file is also used by C code. */
/* creation/open control flags */
#define HB_BTREE_READONLY 1 /* for new: creates file w/ RO attrib; for create: opens file for read */
#define HB_BTREE_EXCLUSIVE 2
#define HB_BTREE_SHARED 4
#define HB_BTREE_UNIQUE 128
#define HB_BTREE_CASELESS 256
#define HB_BTREE_INMEMORY 512
#define HB_BTREEINFO_ALL 0
#define HB_BTREEINFO_FILENAME 1
#define HB_BTREEINFO_PAGESIZE 2
#define HB_BTREEINFO_KEYSIZE 3
#define HB_BTREEINFO_MAXKEYS 4
#define HB_BTREEINFO_MINKEYS 5
#define HB_BTREEINFO_FLAGS 6
#define HB_BTREEINFO_KEYCOUNT 7
#define HB_BTREEINFO__SIZE 7 /* do not use! */
/* error codes (SubCode) */
#define HB_BTREE_EC_UNKNOWN 1
#define HB_BTREE_EC_INVALIDARG 2
#define HB_BTREE_EC_TREEHANDLE 3
#define HB_BTREE_EC_WRITEERROR 4
#define HB_BTREE_EC_STACKSKIP 5
/* TODO: add commands/translates */
#endif

View File

@@ -1,63 +0,0 @@
/*
$Id$
*/
/*
* Harbour Project source code:
* HB_BTree Harbour C API header.
*
* Copyright 2002-2010 April White <april@users.sourceforge.net>
* 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 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) 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 HRL
* and/or HVM code into it.
*
* 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#ifndef HB_BTREE_API
#define HB_BTREE_API
HB_EXTERN_BEGIN
#include "hb_btree.ch"
struct hb_BTree;
struct hb_BTree * hb_BTreeNew( const char * FileName, HB_USHORT usPageSize, HB_USHORT usKeySize,
HB_ULONG ulFlags,
HB_ULONG ulBuffers );
struct hb_BTree * hb_BTreeOpen( const char * FileName, HB_ULONG ulFlags, HB_ULONG ulBuffers );
void hb_BTreeClose( struct hb_BTree * pBTree );
HB_BOOL hb_BTreeInsert( struct hb_BTree * pBTree, const char * szKey, PHB_ITEM pData );
HB_BOOL hb_BTreeDelete( struct hb_BTree * pBTree, const char * szKey, HB_LONG lData );
void hb_BTreeGoTop( struct hb_BTree * pBTree );
void hb_BTreeGoBottom( struct hb_BTree * pBTree );
HB_BOOL hb_BTreeSeek( struct hb_BTree * pBTree, const char * szKey, HB_LONG lData,
HB_BOOL bSoftSeek );
HB_LONG hb_BTreeSkip( struct hb_BTree * pBTree, HB_LONG records );
const char * hb_BTreeKey( struct hb_BTree * pBTree );
HB_LONG hb_BTreeData( struct hb_BTree * pBTree );
PHB_ITEM hb_BTreeDataItem( struct hb_BTree * pBTree );
HB_EXTERN_END
#endif

View File

@@ -1,8 +0,0 @@
#
# $Id$
#
incpaths=.
libpaths=lib/${hb_plat}/${hb_comp}
libs=${hb_name}

View File

@@ -1,16 +0,0 @@
#
# $Id$
#
-hblib
-inc
-olib/${hb_plat}/${hb_comp}/${hb_name}
-w3 -es2
-instfile=inc:hb_btree.ch
-instfile=inc:hb_btree.h
hb_btree.c
tbtree.prg

View File

@@ -1,78 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* HB_BTree class.
*
* Copyright 2002-2010 April White <april@users.sourceforge.net>
* 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 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) 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 HRL
* and/or HVM code into it.
*
* 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#include "hbclass.ch"
#include "hb_btree.ch"
CREATE CLASS TBTree STATIC
HIDDEN:
DATA nHandle /* hb_btree handle */
METHOD Open( cFileName, nFlags, nBuffers )
METHOD New( cFileName, nPageSize, nKeySize, nFlags, nBuffers ) CONSTRUCTOR
EXPORTED:
METHOD Close() INLINE hb_BTreeClose( ::nHandle ) , ::nHandle := 0
METHOD Insert( cKey, lData ) INLINE hb_BTreeInsert( ::nHandle, cKey, lData )
METHOD Delete( cKey, lData ) INLINE hb_BTreeDelete( ::nHandle, cKey, lData )
METHOD Key() INLINE hb_BTreeKey( ::nHandle )
METHOD Data() INLINE hb_BTreeData( ::nHandle )
METHOD GoTop() INLINE hb_BTreeGoTop( ::nHandle )
METHOD GoBottom() INLINE hb_BTreeGoBottom( ::nHandle )
METHOD Skip( nRecords ) INLINE hb_BTreeSkip( ::nHandle, nRecords )
METHOD Seek( cKey, lData, lSoftSeek ) INLINE hb_BTreeSeek( ::nHandle, cKey, lData, lSoftSeek )
METHOD Info( nIndex ) INLINE hb_BTreeInfo( ::nHandle, nIndex )
ENDCLASS
METHOD New( cFileName, nPageSize, nKeySize, nFlags, nBuffers ) CLASS TBTree
::nHandle := hb_btreenew( cFileName, nPageSize, nKeySize, nFlags, nBuffers )
IF ::nHandle >= 1
RETURN SELF
ENDIF
RETURN NIL
METHOD Open( cFileName, nFlags, nBuffers ) CLASS TBTree
::nHandle := hb_btreeopen( cFileName, nFlags, nBuffers )
IF ::nHandle >= 1
RETURN SELF
ENDIF
RETURN NIL
FUNCTION TBTreeNew( FileName, PageSize, KeySize, nFlags, Buffers )
RETURN TBTree():New( FileName, PageSize, KeySize, nFlags, Buffers )
FUNCTION TBTreeOpen( FileName, nFlags, Buffers )
RETURN TBTree():Open( FileName, nFlags, Buffers )

View File

@@ -1,224 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* hb_BTree api test
*
* Copyright 2000 April White <april@users.sourceforge.net>
* 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 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) 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 HRL
* and/or HVM code into it.
*
* 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#include "hbapi.h"
#include "hbapiitm.h"
#include "hb_btree.h"
static void display( const char *cKey, HB_LONG lData, HB_BOOL NewLine )
{
int n;
char buffer[ 80 ];
if( *cKey )
n = hb_snprintf( buffer, sizeof( buffer ), "%s %ld", cKey, lData );
else
n = hb_snprintf( buffer, sizeof( buffer ), "%ld", lData );
hb_conOutStd( buffer, n );
if( NewLine )
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
}
static void insertdata( struct hb_BTree * pBTree )
{
PHB_ITEM data = hb_itemNew( NULL );
hb_BTreeInsert( pBTree, "fuweqgsz", hb_itemPutNL( data, 1 ) );
hb_BTreeInsert( pBTree, "sjruexrd", hb_itemPutNL( data, 2 ) );
hb_BTreeInsert( pBTree, "fvveitnz", hb_itemPutNL( data, 3 ) );
hb_BTreeInsert( pBTree, "aqgksjxe", hb_itemPutNL( data, 4 ) );
hb_BTreeInsert( pBTree, "oonrehvj", hb_itemPutNL( data, 5 ) );
hb_BTreeInsert( pBTree, "gvowjwtr", hb_itemPutNL( data, 6 ) );
hb_BTreeInsert( pBTree, "xxidwtvn", hb_itemPutNL( data, 7 ) );
hb_BTreeInsert( pBTree, "rwjbxesd", hb_itemPutNL( data, 8 ) );
hb_BTreeInsert( pBTree, "yaznsaek", hb_itemPutNL( data, 9 ) );
hb_BTreeInsert( pBTree, "wbdhfkfy", hb_itemPutNL( data, 10 ) );
hb_BTreeInsert( pBTree, "lryaezia", hb_itemPutNL( data, 11 ) );
hb_BTreeInsert( pBTree, "tspmnrvk", hb_itemPutNL( data, 12 ) );
hb_BTreeInsert( pBTree, "hpxryhdj", hb_itemPutNL( data, 13 ) );
hb_BTreeInsert( pBTree, "sztcqaby", hb_itemPutNL( data, 14 ) );
hb_BTreeInsert( pBTree, "fcyzsqja", hb_itemPutNL( data, 15 ) );
hb_BTreeInsert( pBTree, "uccxumvg", hb_itemPutNL( data, 16 ) );
hb_BTreeInsert( pBTree, "amwuoout", hb_itemPutNL( data, 17 ) );
hb_BTreeInsert( pBTree, "yaytseln", hb_itemPutNL( data, 18 ) );
hb_BTreeInsert( pBTree, "sfiiozej", hb_itemPutNL( data, 19 ) );
hb_BTreeInsert( pBTree, "xuvsoljy", hb_itemPutNL( data, 20 ) );
hb_BTreeInsert( pBTree, "qmqjbedm", hb_itemPutNL( data, 21 ) );
hb_BTreeInsert( pBTree, "cctzzrkz", hb_itemPutNL( data, 22 ) );
hb_BTreeInsert( pBTree, "ikytgdon", hb_itemPutNL( data, 23 ) );
hb_BTreeInsert( pBTree, "pksobcwu", hb_itemPutNL( data, 24 ) );
hb_BTreeInsert( pBTree, "vmurindj", hb_itemPutNL( data, 25 ) );
hb_BTreeInsert( pBTree, "elvybqwg", hb_itemPutNL( data, 26 ) );
hb_BTreeInsert( pBTree, "ixchaztx", hb_itemPutNL( data, 27 ) );
hb_BTreeInsert( pBTree, "nzpztlhd", hb_itemPutNL( data, 28 ) );
hb_BTreeInsert( pBTree, "aucrchiw", hb_itemPutNL( data, 29 ) );
hb_BTreeInsert( pBTree, "munrytse", hb_itemPutNL( data, 30 ) );
hb_BTreeInsert( pBTree, "kqkhcmls", hb_itemPutNL( data, 31 ) );
hb_BTreeInsert( pBTree, "abqhurbi", hb_itemPutNL( data, 32 ) );
hb_BTreeInsert( pBTree, "ymrldckr", hb_itemPutNL( data, 33 ) );
hb_BTreeInsert( pBTree, "rhsmfflc", hb_itemPutNL( data, 34 ) );
hb_BTreeInsert( pBTree, "apyfkvee", hb_itemPutNL( data, 35 ) );
hb_BTreeInsert( pBTree, "cdntyzrf", hb_itemPutNL( data, 36 ) );
hb_BTreeInsert( pBTree, "iacblqrh", hb_itemPutNL( data, 37 ) );
hb_BTreeInsert( pBTree, "xvewqana", hb_itemPutNL( data, 38 ) );
hb_BTreeInsert( pBTree, "xmybqytj", hb_itemPutNL( data, 39 ) );
hb_BTreeInsert( pBTree, "dnowympf", hb_itemPutNL( data, 40 ) );
hb_BTreeInsert( pBTree, "smloihft", hb_itemPutNL( data, 41 ) );
hb_BTreeInsert( pBTree, "zumppmis", hb_itemPutNL( data, 42 ) );
hb_BTreeInsert( pBTree, "jirucnxu", hb_itemPutNL( data, 43 ) );
hb_BTreeInsert( pBTree, "ecdzikcv", hb_itemPutNL( data, 44 ) );
hb_BTreeInsert( pBTree, "slbwvnpg", hb_itemPutNL( data, 45 ) );
hb_BTreeInsert( pBTree, "yaftlkmz", hb_itemPutNL( data, 46 ) );
hb_BTreeInsert( pBTree, "blcepksd", hb_itemPutNL( data, 47 ) );
hb_BTreeInsert( pBTree, "xufowlpl", hb_itemPutNL( data, 48 ) );
hb_BTreeInsert( pBTree, "xegtjtqc", hb_itemPutNL( data, 49 ) );
hb_BTreeInsert( pBTree, "yplcqumq", hb_itemPutNL( data, 50 ) );
hb_BTreeInsert( pBTree, "vdoycauz", hb_itemPutNL( data, 51 ) );
hb_BTreeInsert( pBTree, "uhqkjuph", hb_itemPutNL( data, 52 ) );
hb_BTreeInsert( pBTree, "prllaeyi", hb_itemPutNL( data, 53 ) );
hb_BTreeInsert( pBTree, "ybzgmwzm", hb_itemPutNL( data, 54 ) );
hb_BTreeInsert( pBTree, "kkvyllnp", hb_itemPutNL( data, 55 ) );
hb_BTreeInsert( pBTree, "nberwsrb", hb_itemPutNL( data, 56 ) );
hb_BTreeInsert( pBTree, "wgetahua", hb_itemPutNL( data, 57 ) );
hb_BTreeInsert( pBTree, "yxcyehcv", hb_itemPutNL( data, 58 ) );
hb_BTreeInsert( pBTree, "oacormks", hb_itemPutNL( data, 59 ) );
hb_BTreeInsert( pBTree, "mcadkdxo", hb_itemPutNL( data, 60 ) );
hb_BTreeInsert( pBTree, "ycsalwqw", hb_itemPutNL( data, 61 ) );
hb_BTreeInsert( pBTree, "qmpysvjl", hb_itemPutNL( data, 62 ) );
hb_BTreeInsert( pBTree, "iqikamew", hb_itemPutNL( data, 63 ) );
hb_BTreeInsert( pBTree, "iaparrva", hb_itemPutNL( data, 64 ) );
hb_BTreeInsert( pBTree, "casbvtay", hb_itemPutNL( data, 65 ) );
hb_BTreeInsert( pBTree, "blaksexr", hb_itemPutNL( data, 66 ) );
hb_BTreeInsert( pBTree, "tbosrbql", hb_itemPutNL( data, 67 ) );
hb_BTreeInsert( pBTree, "ifkywsyt", hb_itemPutNL( data, 68 ) );
hb_BTreeInsert( pBTree, "gvklwevy", hb_itemPutNL( data, 69 ) );
hb_BTreeInsert( pBTree, "krpmpbud", hb_itemPutNL( data, 70 ) );
hb_BTreeInsert( pBTree, "rdvlwbwm", hb_itemPutNL( data, 71 ) );
hb_BTreeInsert( pBTree, "apnvdkww", hb_itemPutNL( data, 72 ) );
hb_BTreeInsert( pBTree, "euqdocvm", hb_itemPutNL( data, 73 ) );
hb_BTreeInsert( pBTree, "ksmkjcwp", hb_itemPutNL( data, 74 ) );
hb_BTreeInsert( pBTree, "bztgclzc", hb_itemPutNL( data, 75 ) );
hb_BTreeInsert( pBTree, "awkdnuxa", hb_itemPutNL( data, 76 ) );
hb_BTreeInsert( pBTree, "abavnpod", hb_itemPutNL( data, 77 ) );
hb_BTreeInsert( pBTree, "dvwvhjmh", hb_itemPutNL( data, 78 ) );
hb_BTreeInsert( pBTree, "dmfmivqb", hb_itemPutNL( data, 79 ) );
hb_BTreeInsert( pBTree, "ewsxanon", hb_itemPutNL( data, 80 ) );
hb_itemRelease( data );
}
HB_FUNC( CTEST )
{
struct hb_BTree * pBTree;
display( "Harbour API test", 0, HB_TRUE );
pBTree = hb_BTreeNew( "test_3.out", 2048, 90, HB_BTREE_UNIQUE, 0 );
if ( pBTree != NULL )
{
/*
a := hb_BTreeInfo( pBTree );
display( "File", a[ hb_BTreeINFO_FILENAME ], HB_FALSE );
display( "Page", a[ hb_BTreeINFO_PAGESIZE ], HB_FALSE );
display( "Key ", a[ hb_BTreeINFO_KEYSIZE ], HB_FALSE );
display( "Max ", a[ hb_BTreeINFO_MAXKEYS ], HB_FALSE );
display( "Min ", a[ hb_BTreeINFO_MINKEYS ], HB_FALSE );
display( "Flag", a[ hb_BTreeINFO_FLAGS ], HB_FALSE );
display( "Keys", a[ hb_BTreeINFO_KEYCOUNT ], HB_TRUE );
*/
insertdata( pBTree );
/*
display( "Keys", hb_BTreeInfo( pBTree, hb_BTreeINFO_KEYCOUNT ), HB_TRUE );
*/
display( "Forward traversal", 0, HB_TRUE );
hb_BTreeGoTop( pBTree );
while ( HB_TRUE )
{
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_TRUE );
if ( 1 != hb_BTreeSkip( pBTree, 1 ) )
break;
}
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Reverse traversal", 0, HB_TRUE );
hb_BTreeGoBottom( pBTree );
while ( HB_TRUE )
{
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_TRUE );
if ( -1 != hb_BTreeSkip( pBTree, -1 ) )
break;
}
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test SEEK", 0, HB_TRUE );
display( hb_BTreeSeek( pBTree, "cdntyzrf", 36, HB_FALSE ) == 1 ? ".T." : ".F.", 0, HB_TRUE );
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_TRUE );
hb_BTreeSkip( pBTree, 1 );
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_FALSE );
display( " dmfmivqb ?", 0, HB_TRUE );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test soft SEEK of a short key", 0, HB_TRUE );
display( hb_BTreeSeek( pBTree, "cd", 0, HB_TRUE ) == 1 ? ".T." : ".F.", 0, HB_TRUE );
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_TRUE );
hb_BTreeSkip( pBTree, 1 );
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_FALSE );
display( " dmfmivqb ?", 0, HB_TRUE );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test soft SEEK of an existing key", 0, HB_TRUE );
display( hb_BTreeSeek( pBTree, "cdntyzrf", 0, HB_TRUE ) == 1 ? ".T." : ".F.", 0, HB_TRUE );
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_TRUE );
hb_BTreeSkip( pBTree, 1 );
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_FALSE );
display( " dmfmivqb ?", 0, HB_TRUE );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
display( "Test soft SEEK of a missing key, that should force EOF", 0, HB_TRUE );
display( hb_BTreeSeek( pBTree, "zzzzzz", 0, HB_FALSE ) == 1 ? ".T." : ".F.", 0, HB_TRUE );
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_TRUE );
hb_BTreeSkip( pBTree, 1 );
display( ( char * ) hb_BTreeKey( pBTree ), hb_BTreeData( pBTree ), HB_FALSE );
display( " dmfmivqb ?", 0, HB_TRUE );
hb_conOutStd( hb_conNewLine(), strlen( hb_conNewLine() ) );
hb_BTreeClose( pBTree );
}
else
display( "error / failure", 0, HB_TRUE );
}

View File

@@ -1,7 +0,0 @@
#
# $Id$
#
../hbbtree.hbc
-w3 -es2

View File

@@ -1,11 +0,0 @@
#
# $Id$
#
-q0
-nulrdd
-gtstd
test.prg ttest.prg ctest.c

View File

@@ -1,329 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* hb_btree api test
*
* Copyright 2000 April White <april@users.sourceforge.net>
* 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 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) 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 HRL
* and/or HVM code into it.
*
* 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#include "simpleio.ch"
#include "hb_btree.ch"
#include "fileio.ch"
Procedure Main()
local c
local attr
// _2 is from ttest.prg; _3 is from ctest.c
FOR EACH c IN { "test_1.out", "test_1a.out", "test_1b.out", "test_2.out", "test_3.out" }
hb_FGetAttr( c, @attr )
if attr == 1 + 32
hb_FSetAttr( c, 32 )
endif
ferase( c )
NEXT
testInMemory()
testInFile()
return
static procedure insertdata( n, s )
if s == NIL ; s := 1; endif
hb_btreeinsert( n, "fuweqgsz", 1 / s )
hb_btreeinsert( n, "sjruexrd", 2 / s )
hb_btreeinsert( n, "fvveitnz", 3 / s )
hb_btreeinsert( n, "aqgksjxe", 4 / s )
hb_btreeinsert( n, "oonrehvj", 5 / s )
hb_btreeinsert( n, "gvowjwtr", 6 / s )
hb_btreeinsert( n, "xxidwtvn", 7 / s )
hb_btreeinsert( n, "rwjbxesd", 8 / s )
hb_btreeinsert( n, "yaznsaek", 9 / s )
hb_btreeinsert( n, "wbdhfkfy", 10 / s )
hb_btreeinsert( n, "lryaezia", 11 / s )
hb_btreeinsert( n, "tspmnrvk", 12 / s )
hb_btreeinsert( n, "hpxryhdj", 13 / s )
hb_btreeinsert( n, "sztcqaby", 14 / s )
hb_btreeinsert( n, "fcyzsqja", 15 / s )
hb_btreeinsert( n, "uccxumvg", 16 / s )
hb_btreeinsert( n, "amwuoout", 17 / s )
hb_btreeinsert( n, "yaytseln", 18 / s )
hb_btreeinsert( n, "sfiiozej", 19 / s )
hb_btreeinsert( n, "xuvsoljy", 20 / s )
hb_btreeinsert( n, "qmqjbedm", 21 / s )
hb_btreeinsert( n, "cctzzrkz", 22 / s )
hb_btreeinsert( n, "ikytgdon", 23 / s )
hb_btreeinsert( n, "pksobcwu", 24 / s )
hb_btreeinsert( n, "vmurindj", 25 / s )
hb_btreeinsert( n, "elvybqwg", 26 / s )
hb_btreeinsert( n, "ixchaztx", 27 / s )
hb_btreeinsert( n, "nzpztlhd", 28 / s )
hb_btreeinsert( n, "aucrchiw", 29 / s )
hb_btreeinsert( n, "munrytse", 30 / s )
hb_btreeinsert( n, "kqkhcmls", 31 / s )
hb_btreeinsert( n, "abqhurbi", 32 / s )
hb_btreeinsert( n, "ymrldckr", 33 / s )
hb_btreeinsert( n, "rhsmfflc", 34 / s )
hb_btreeinsert( n, "apyfkvee", 35 / s )
hb_btreeinsert( n, "cdntyzrf", 36 / s )
hb_btreeinsert( n, "iacblqrh", 37 / s )
hb_btreeinsert( n, "xvewqana", 38 / s )
hb_btreeinsert( n, "xmybqytj", 39 / s )
hb_btreeinsert( n, "dnowympf", 40 / s )
hb_btreeinsert( n, "smloihft", 41 / s )
hb_btreeinsert( n, "zumppmis", 42 / s )
hb_btreeinsert( n, "jirucnxu", 43 / s )
hb_btreeinsert( n, "ecdzikcv", 44 / s )
hb_btreeinsert( n, "slbwvnpg", 45 / s )
hb_btreeinsert( n, "yaftlkmz", 46 / s )
hb_btreeinsert( n, "blcepksd", 47 / s )
hb_btreeinsert( n, "xufowlpl", 48 / s )
hb_btreeinsert( n, "xegtjtqc", 49 / s )
hb_btreeinsert( n, "yplcqumq", 50 / s )
hb_btreeinsert( n, "vdoycauz", 51 / s )
hb_btreeinsert( n, "uhqkjuph", 52 / s )
hb_btreeinsert( n, "prllaeyi", 53 / s )
hb_btreeinsert( n, "ybzgmwzm", 54 / s )
hb_btreeinsert( n, "kkvyllnp", 55 / s )
hb_btreeinsert( n, "nberwsrb", 56 / s )
hb_btreeinsert( n, "wgetahua", 57 / s )
hb_btreeinsert( n, "yxcyehcv", 58 / s )
hb_btreeinsert( n, "oacormks", 59 / s )
hb_btreeinsert( n, "mcadkdxo", 60 / s )
hb_btreeinsert( n, "ycsalwqw", 61 / s )
hb_btreeinsert( n, "qmpysvjl", 62 / s )
hb_btreeinsert( n, "iqikamew", 63 / s )
hb_btreeinsert( n, "iaparrva", 64 / s )
hb_btreeinsert( n, "casbvtay", 65 / s )
hb_btreeinsert( n, "blaksexr", 66 / s )
hb_btreeinsert( n, "tbosrbql", 67 / s )
hb_btreeinsert( n, "ifkywsyt", 68 / s )
hb_btreeinsert( n, "gvklwevy", 69 / s )
hb_btreeinsert( n, "krpmpbud", 70 / s )
hb_btreeinsert( n, "rdvlwbwm", 71 / s )
hb_btreeinsert( n, "apnvdkww", 72 / s )
hb_btreeinsert( n, "euqdocvm", 73 / s )
hb_btreeinsert( n, "ksmkjcwp", 74 / s )
hb_btreeinsert( n, "bztgclzc", 75 / s )
hb_btreeinsert( n, "awkdnuxa", 76 / s )
hb_btreeinsert( n, "abavnpod", 77 / s )
hb_btreeinsert( n, "dvwvhjmh", 78 / s )
hb_btreeinsert( n, "dmfmivqb", 79 / s )
hb_btreeinsert( n, "ewsxanon", 80 / s )
return
STATIC PROCEDURE testInMemory()
LOCAL n
LOCAL c
? "Harbour API test: in-memory"
n := hb_btreenew( , 2048, 90, HB_BTREE_READONLY + HB_BTREE_INMEMORY )
if n > 0
? "successfully opened"
insertdata( n, 100 )
? "# keys", hb_btreeinfo( n, HB_BTREEINFO_KEYCOUNT )
? "skip to EOF test"
hb_btreegobottom( n )
? hb_btreekey( n ), hb_btreedata( n )
? hb_btreeskip( n, 1 )
? "skip to EOF test end"
? "Forward traversal"
hb_btreegotop( n )
c := 0
while .t.
? hb_btreekey( n ), hb_btreedata( n ), ++c
if 1 != hb_btreeskip( n, 1 )// .or. c == hb_btreeinfo( n, HB_BTREEINFO_KEYCOUNT )-1
exit
endif
end
? "Forward traversal end"
?
? "Reverse traversal"
hb_btreegobottom( n )
c := 0
while .t.
? hb_btreekey( n ), hb_btreedata( n ), ++c
if -1 != hb_btreeskip( n, -1 )// .or. c == hb_btreeinfo( n, HB_BTREEINFO_KEYCOUNT )-1
exit
endif
end
? "Reverse traversal end"
?
? "Test SEEK of 'cdntyzrf'"
? hb_btreeseek( n, "cdntyzrf" )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
? "Test soft SEEK of short key 'cd'"
? hb_btreeseek( n, "cd", , .t. )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
? "Test soft SEEK of an existing key 'cdntyzrf'"
? hb_btreeseek( n, "cdntyzrf", , .t. )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
? "Test soft SEEK of a missing key, that should force EOF ('zzzzzz')"
? hb_btreeseek( n, "zzzzzz" )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
hb_btreeclose( n )
else
? "error / failure"
wait
endif
? "Harbour API test: in-memory end"
STATIC PROCEDURE testInFile()
LOCAL n
LOCAL c
LOCAL a
? "Harbour API test"
n := hb_btreenew( "test_1.out", 2048, 90, HB_BTREE_READONLY )
if n > 0
? valtype( a := hb_btreeinfo( n ) )
? "File", a[ HB_BTREEINFO_FILENAME ]
? "Page", a[ HB_BTREEINFO_PAGESIZE ]
? "Key ", a[ HB_BTREEINFO_KEYSIZE ]
? "Max ", a[ HB_BTREEINFO_MAXKEYS ]
? "Min ", a[ HB_BTREEINFO_MINKEYS ]
? "Flag", a[ HB_BTREEINFO_FLAGS ]
? "Keys", a[ HB_BTREEINFO_KEYCOUNT ]
?
insertdata( n )
? "Keys", hb_btreeinfo( n, HB_BTREEINFO_KEYCOUNT )
?
? "Forward traversal"
hb_btreegotop( n )
c := 0
while .t.
? hb_btreekey( n ), hb_btreedata( n ), ++c
if 1 != hb_btreeskip( n, 1 )
exit
endif
end
?
? "Reverse traversal"
hb_btreegobottom( n )
c := 0
while .t.
? hb_btreekey( n ), hb_btreedata( n ), ++c
if -1 != hb_btreeskip( n, -1 )
exit
endif
end
?
? "Test SEEK"
? hb_btreeseek( n, "cdntyzrf" )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
? "Test soft SEEK of a short key"
? hb_btreeseek( n, "cd", , .t. )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
? "Test soft SEEK of an existing key"
? hb_btreeseek( n, "cdntyzrf", , .t. )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
? "Test soft SEEK of a missing key, that should force EOF"
? hb_btreeseek( n, "zzzzzz" )
? hb_btreekey( n ), hb_btreedata( n )
hb_btreeskip( n, 1 )
? hb_btreekey( n ), hb_btreedata( n ), "dmfmivqb ?"
?
hb_btreeclose( n )
TTest()
CTest()
else
? "error / failure"
endif
?
? "Harbour caseless sensitivity API test"
n := hb_btreenew( "test_1a.out", 2048, 90, HB_BTREE_CASELESS )
if n > 0
hb_btreeinsert( n, "alpha", 0 )
if hb_btreeinsert( n, "ALPHA", 0 )
? "inserted 'ALPHA', test failed"
else
? "could not insert 'ALPHA', test passed"
endif
hb_btreeclose( n )
endif
?
? "Harbour case sensitivity API test"
n := hb_btreenew( "test_1b.out", 2048, 90 )
if n > 0
hb_btreeinsert( n, "alpha", 0 )
if hb_btreeinsert( n, "ALPHA", 0 )
? "inserted 'ALPHA', test passed"
else
? "could not insert 'ALPHA', test failed"
endif
hb_btreeclose( n )
endif
?

View File

@@ -1,198 +0,0 @@
*
* $Id$
*/
/*
* Harbour Project source code:
* hb_btree api test
*
* Copyright 2000 April White <april@users.sourceforge.net>
* 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 of the License, or
* (at your option) any later version, with one exception:
*
* The exception is that if you link the Harbour Runtime Library (HRL)
* and/or the Harbour Virtual Machine (HVM) 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 HRL
* and/or HVM code into it.
*
* 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#include "simpleio.ch"
#include "hb_btree.ch"
Procedure TTest()
local n, a
? "Harbour TBTree API test"
n := TBTreeNew( "test_2.out", 2048, 90 )
if n != NIL
? valtype( a := n:info() )
? "File", a[ HB_BTREEINFO_FILENAME ]
? "Page", a[ HB_BTREEINFO_PAGESIZE ]
? "Key ", a[ HB_BTREEINFO_KEYSIZE ]
? "Max ", a[ HB_BTREEINFO_MAXKEYS ]
? "Min ", a[ HB_BTREEINFO_MINKEYS ]
? "Flag", a[ HB_BTREEINFO_FLAGS ]
? "Keys", a[ HB_BTREEINFO_KEYCOUNT ]
?
insertdata( n )
? "Keys", n:info( HB_BTREEINFO_KEYCOUNT )
?
? "Forward traversal"
n:gotop()
while .t.
? n:key(), n:data()
if 1 != n:skip( 1 )
exit
endif
end
?
? "Reverse traversal"
n:gobottom()
while .t.
? n:key(), n:data()
if -1 != n:skip( -1 )
exit
endif
end
?
? "Test SEEK"
? n:seek( "cdntyzrf" )
? n:key(), n:data()
n:skip( 1 )
? n:key(), n:data(), "dmfmivqb ?"
?
? "Test soft SEEK of a short key"
? n:seek( "cd", ,.t. )
? n:key(), n:data()
n:skip( 1 )
? n:key(), n:data(), "dmfmivqb ?"
?
? "Test soft SEEK of an existing key"
? n:seek( "cdntyzrf", , .t. )
? n:key(), n:data()
n:skip( 1 )
? n:key(), n:data(), "dmfmivqb ?"
?
? "Test soft SEEK of a missing key, that should force EOF"
? n:seek( "zzzzzz" )
? n:key(), n:data()
n:skip( 1 )
? n:key(), n:data(), "dmfmivqb ?"
?
n:close()
else
? "error"
endif
return
static procedure insertdata( n )
n:insert( "fuweqgsz", 1 )
n:insert( "sjruexrd", 2 )
n:insert( "fvveitnz", 3 )
n:insert( "aqgksjxe", 4 )
n:insert( "oonrehvj", 5 )
n:insert( "gvowjwtr", 6 )
n:insert( "xxidwtvn", 7 )
n:insert( "rwjbxesd", 8 )
n:insert( "yaznsaek", 9 )
n:insert( "wbdhfkfy", 10 )
n:insert( "lryaezia", 11 )
n:insert( "tspmnrvk", 12 )
n:insert( "hpxryhdj", 13 )
n:insert( "sztcqaby", 14 )
n:insert( "fcyzsqja", 15 )
n:insert( "uccxumvg", 16 )
n:insert( "amwuoout", 17 )
n:insert( "yaytseln", 18 )
n:insert( "sfiiozej", 19 )
n:insert( "xuvsoljy", 20 )
n:insert( "qmqjbedm", 21 )
n:insert( "cctzzrkz", 22 )
n:insert( "ikytgdon", 23 )
n:insert( "pksobcwu", 24 )
n:insert( "vmurindj", 25 )
n:insert( "elvybqwg", 26 )
n:insert( "ixchaztx", 27 )
n:insert( "nzpztlhd", 28 )
n:insert( "aucrchiw", 29 )
n:insert( "munrytse", 30 )
n:insert( "kqkhcmls", 31 )
n:insert( "abqhurbi", 32 )
n:insert( "ymrldckr", 33 )
n:insert( "rhsmfflc", 34 )
n:insert( "apyfkvee", 35 )
n:insert( "cdntyzrf", 36 )
n:insert( "iacblqrh", 37 )
n:insert( "xvewqana", 38 )
n:insert( "xmybqytj", 39 )
n:insert( "dnowympf", 40 )
n:insert( "smloihft", 41 )
n:insert( "zumppmis", 42 )
n:insert( "jirucnxu", 43 )
n:insert( "ecdzikcv", 44 )
n:insert( "slbwvnpg", 45 )
n:insert( "yaftlkmz", 46 )
n:insert( "blcepksd", 47 )
n:insert( "xufowlpl", 48 )
n:insert( "xegtjtqc", 49 )
n:insert( "yplcqumq", 50 )
n:insert( "vdoycauz", 51 )
n:insert( "uhqkjuph", 52 )
n:insert( "prllaeyi", 53 )
n:insert( "ybzgmwzm", 54 )
n:insert( "kkvyllnp", 55 )
n:insert( "nberwsrb", 56 )
n:insert( "wgetahua", 57 )
n:insert( "yxcyehcv", 58 )
n:insert( "oacormks", 59 )
n:insert( "mcadkdxo", 60 )
n:insert( "ycsalwqw", 61 )
n:insert( "qmpysvjl", 62 )
n:insert( "iqikamew", 63 )
n:insert( "iaparrva", 64 )
n:insert( "casbvtay", 65 )
n:insert( "blaksexr", 66 )
n:insert( "tbosrbql", 67 )
n:insert( "ifkywsyt", 68 )
n:insert( "gvklwevy", 69 )
n:insert( "krpmpbud", 70 )
n:insert( "rdvlwbwm", 71 )
n:insert( "apnvdkww", 72 )
n:insert( "euqdocvm", 73 )
n:insert( "ksmkjcwp", 74 )
n:insert( "bztgclzc", 75 )
n:insert( "awkdnuxa", 76 )
n:insert( "abavnpod", 77 )
n:insert( "dvwvhjmh", 78 )
n:insert( "dmfmivqb", 79 )
n:insert( "ewsxanon", 80 )
return

View File

@@ -1,28 +0,0 @@
/*
* $Id$
*/
//+
// 99.05.31 initial posting.
//-
#define CGI_SERVER_SOFTWARE 01
#define CGI_SERVER_NAME 02
#define CGI_GATEWAY_INTERFACE 03
#define CGI_SERVER_PROTOCOL 04
#define CGI_SERVER_PORT 05
#define CGI_REQUEST_METHOD 06
#define CGI_HTTP_ACCEPT 07
#define CGI_HTTP_USER_AGENT 08
#define CGI_HTTP_REFERER 09
#define CGI_PATH_INFO 10
#define CGI_PATH_TRANSLATED 11
#define CGI_SCRIPT_NAME 12
#define CGI_QUERY_STRING 13
#define CGI_REMOTE_HOST 14
#define CGI_REMOTE_ADDR 15
#define CGI_REMOTE_USER 16
#define CGI_AUTH_TYPE 17
#define CGI_CONTENT_TYPE 18
#define CGI_CONTENT_LENGTH 19
#define CGI_ANNOTATION_SERVER 20

View File

@@ -1,54 +0,0 @@
<%
/*
* $Id$
*/
/*
* Written by Felipe Coury <fcoury@flexsys-ci.com>
* www - http://harbour-project.org
*
*/
FUNCTION Start()
LOCAL aDir := Directory( "*.*" )
LOCAL i
IF !Empty( GetEnv( "SERVER_NAME" ) )
OutStd( "HTTP/1.0 200 OK" + chr(10) )
OutStd( "CONTENT-TYPE: TEXT/HTML" + chr(10) + chr(10) )
ENDIF
ASort( aDir,,, { |x, y| x[1] < y[1] } )
%>
<HTML>
<HEAD><TITLE>dir.hs - HarourScript demo of active context</TITLE></HEAD>
<BODY>
<TABLE border=1>
<TR>
<TD><B>File Name</B></TD>
<TD><B>Size</B></TD>
<TD><B>Date</B></TD>
<TD><B>Time</B></TD>
<TD><B>Attributes</B></TD>
</TR>
<%
FOR i := 1 TO Len( aDir )
%>
<TR>
<TD><% OutStd( aDir[i,1] ) %></TD>
<TD><% OutStd( aDir[i,2] ) %></TD>
<TD><% OutStd( aDir[i,3] ) %></TD>
<TD><% OutStd( aDir[i,4] ) %></TD>
<TD><% OutStd( aDir[i,5] ) %></TD>
</TR>
<%
NEXT
%>
</TABLE>
</BODY>
</HTML>
<%
RETURN NIL
%>

View File

@@ -1,43 +0,0 @@
<%
/*
* $Id$
*/
/*
*
* Famous "Hello World"!
*
* Written by Felipe Coury <fcoury@flexsys-ci.com>
* www - http://harbour-project.org
*
*/
FUNCTION Start()
// Add content-type parameter if using active page on a Web Server
IF !empty( GetEnv( "SERVER_NAME" ) )
OutStd( "HTTP/1.0 200 OK" + chr(10) )
OutStd( "CONTENT-TYPE: TEXT/HTML" + chr(10) + chr(10) )
ENDIF
%>
<HTML>
<HEAD>
<TITLE>Hello world!</TITLE>
</HEAD>
<BODY>
<%
// Now saying hello to the world in 3 different ways:
// 1. Pure harbour:
OutStd( "<H1>Hello world!</H1></P>" )
// 2. Hybrid harbour-html:
%>
<H1><% OutStd( "Hello world!" ) %></H1></P>
<%
// 3. Pure html:
%>
<H1>Hello world!</H1></P>
</BODY>
</HTML>

View File

@@ -1,5 +0,0 @@
#
# $Id$
#
hscript.prg -lhbnf

View File

@@ -1,220 +0,0 @@
/*
* $Id$
*/
/*
* hscript.prg
* HarbourScript translation engine
*
* Copyright (C) 1999 Felipe Coury <fcoury@creation.com.br>
* 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 "cgi.ch"
REQUEST __HB_EXTERN__
#define IF_BUFFER 65535
PROCEDURE Main( cScript )
LOCAL aHRSHandle := {} // Handle for script lines
LOCAL aResult := {} // Handle for transl'd lines
LOCAL cLocation // Location of scripts
LOCAL cHarbourDir := GetEnv( "HARBOURDIR" ) // harbour executable dir with '\'
LOCAL cHost := StrTran( AllTrim( ; // Random (not et al)
Str( Seconds() ) ), '.' ) // file name
LOCAL cScriptName, cFile, cLine, cTrans, c
LOCAL hFile, i, lOpen, nLen
DO WHILE .T.
IF Empty( GetEnv( "SERVER_NAME" ) )
cScriptName := cScript
cLocation := cHarbourDir
ELSE
cScriptName := GetEnv( "QUERY_STRING" )
IF At( "=", cScriptName ) != 0
cScriptName := ParseString( cScriptName, "=", 2 )
ENDIF
cLocation := GetEnv( "PATH_TRANSLATED" ) + ;
StrTran( GetEnv( "SCRIPT_NAME" ), "/", "\" )
cLocation := SubStr( cLocation, 1, RAt( "\", cLocation ) )
cHarbourDir := cLocation
ENDIF
IF Empty( cScriptName )
IF !Empty( GetEnv( "SERVER_NAME" ) )
OutStd( "content-type: text/html" + hb_eol() )
OutStd( hb_eol() )
OutStd( "<HTML><BODY><H1>Server Error</H1><P>" + hb_eol() )
OutStd( "Must specify scriptname using hscript.exe?script=<scriptname>" + hb_eol() )
OutStd( "</BODY></HTML>" + hb_eol() )
ELSE
OutStd( "Please give .hs name" + hb_eol() )
ENDIF
EXIT
ENDIF
// Script not found
IF !File( cScriptName )
IF !Empty( GetEnv( "SERVER_NAME" ) )
OutStd( "CONTENT-TYPE: text/html" + hb_eol() )
ENDIF
OutStd( "<H1>Server Error</H1><P>Script not found: " + cScriptName + hb_eol() )
EXIT
ENDIF
lOpen := .f.
ft_FUse( cScriptName )
DO WHILE !ft_FEof()
cLine := AllTrim( ft_FReadLn() )
cTrans := ""
nLen := Len( cLine )
IF lOpen
cTrans += "OutStd( '"
ENDIF
FOR i := 1 TO nLen
c := SubStr( cLine, i, 1 )
IF c == "%" .AND. SubStr( cLine, i + 1, 1 ) == ">"
IF lOpen
// Error - Already in htm mode
ELSE
// Abre script
IF i > 1
//cTrans += " ; "
cTrans += hb_eol()
ENDIF
IF i + 1 < nLen
cTrans += "OutStd( '"
ENDIF
lOpen := .t.
ENDIF
i++
ELSEIF c == "<" .AND. SubStr( cLine, i + 1, 1 ) == "%"
IF !lOpen
// Error - Not in htm mode
ELSE
// Fecha script
cTrans += "' + chr(10) )"
lOpen := .f.
IF i < nLen
// cTrans += " ; "
cTrans += hb_eol()
ENDIF
ENDIF
i++
ELSE
cTrans += c
ENDIF
NEXT
IF lOpen .AND. !( SubStr( cLine, nLen - 1, 2 ) == "%>" )
cTrans += "' + Chr(10) )"
ENDIF
AAdd( aResult, cTrans )
ft_FSkip()
ENDDO
ft_FUse()
cFile := cLocation + cHost + ".prg" // Output file name
hFile := FCreate( cFile )
FOR i := 1 TO Len( aResult )
FWrite( hFile, aResult[i] + hb_eol() )
NEXT
FClose( hFile )
// Creates the temporary .hrb, erases the .prg
hb_Run( cHarbourDir + "harbour " + cFile + " -q -n -gh -o" + Left( cHarbourDir, Len( cHarbourDir ) - 1 ) + iif( !Empty( Left( cHarbourDir, Len( cHarbourDir ) - 1 ) ), "\", "" ) )
FErase( cFile )
// Runs using Tugboat
cFile := StrTran( Lower( cFile ), ".prg", ".hrb" )
hb_hrbRun( cFile )
// Erases the .hrb file
FErase( cFile )
// That's all, folks!
EXIT
ENDDO
RETURN
FUNCTION ParseString( cString, cDelim, nRet )
LOCAL cBuf, aElem, nPosFim, nSize, i
nSize := Len( cString ) - Len( StrTran( cString, cDelim, '' ) ) + 1
aElem := Array( nSize )
cBuf := cString
FOR i := 1 TO nSize
nPosFim := At( cDelim, cBuf )
IF nPosFim > 0
aElem[i] := SubStr( cBuf, 1, nPosFim - 1 )
ELSE
aElem[i] := cBuf
ENDIF
cBuf := SubStr( cBuf, nPosFim + 1, Len( cBuf ) )
NEXT
RETURN aElem[ nRet ]

View File

@@ -1,54 +0,0 @@
<%
/*
* $Id$
*/
/*
*
* HarbourScript Test
*
* Written by Felipe Coury <fcoury@flexsys-ci.com>
* www - http://harbour-project.org
*
*/
FUNCTION Start()
LOCAL i, j
IF !empty( GetEnv( "SERVER_NAME" ) )
OutStd( "HTTP/1.0 200 OK" + chr(10) )
OutStd( "CONTENT-TYPE: TEXT/HTML" + chr(10) + chr(10) )
ENDIF
%>
<HTML>
<HEAD>
<TITLE>Testing script</TITLE>
</HEAD>
<H1><% OutStd( "HarbourScript Test!" ) %></H1>
<BODY>
<%
FOR i := 1 TO 10
%>
<TABLE border=1>
<TR>
<%
FOR j := 1 TO 10
%>
<TR>
<TD><% OutStd( str( i, 2 ) + " x " + str( j, 2 ) ) %></TD>
<TD><% OutStd( i*j ) %></TD>
</TR>
<%
NEXT
%>
</TABLE>
<BR>
<%
NEXT
%>
</BODY>
</HTML>

View File

@@ -1,89 +0,0 @@
/*
* $Id$
*/
WARNING
-------
This document has serious bugs related to English Language.
I take no responsabilities for any misinformation in any form.
<GG>
HarbourScript Alfa Edition
--------------------------
Inside this .zip file you will find HarbourScript package. This
should be unzipped to /tests/working/hscript directory in order
to work w/o any changes.
To make the HarbourScript Translator, hscript.exe, use hbmk2.
If you are going to test offline, there's no need to make it,
it will be done automatically for you (Batch Power<g>). To test it,
you'll have the following options:
Testing HarbourScript using MS-Personal Web Server
--------------------------------------------------
(and maybe IIS 3.0+ too!)
1. Copy hscript.exe and harbour.exe to your cgi-bin directory
(or any other with Scripting allowed)
2. Copy all the scripts that you want to the same directory
3. You can now test Harbour Script using
http://localhost/cgi-bin/hscript?script=<script>.hs
Note: The hscript.exe program still locks the server sometimes.
This is due to external compilation of the resulting code. As
soon as we start to use macro substitution instead, this will
become more stable.
Testing HarbourScript without a Web Server
------------------------------------------
1. Make the sample scripts with makehtm.
2. Browse the resulting .htm files as reported on screen.
How do this thing work?
-----------------------
Well, the HS (HarbourScript) tecnology is based on the ASP
(Active Server Pages) concept and someway in new Oracle 8i's
too.
A .hs page is like any normal HTML page with Special Tags and
Embedded Code. Those tags are: <% (Start Scripting) and %>
(End Scripting). Once you run this script, the HS translator
translates the Embedded Code into true Harbour Code and executes
it. In other words, you write your PRGs INSIDE your web pages.
This concept is called active content.
Known bugs
----------
- Web Server hanging some times (see above);
Open questions
--------------
Things not working due to lack of knowledge (if you know how
to do any of this things, leave a message on Harbour List with
subject HS Open questions, thanks! ;) ):
- How to associate .hs with hscript.exe safely in PWS and IIS.
I associated it using the Registry Key HKEY_LOCAL_MACHINE\System\>
CurrentControlSet\Services\W3SVC\Parameters\Script Map but
whenever I call the script I get a Server Error 500 without any
further explanation.
Felipe G. Coury
fcoury@flexsys-ci.com

View File

@@ -1,19 +0,0 @@
<% FUNCTION Start()
/*
* $Id$
*/
/* Written by Felipe Coury <fcoury@flexsys-ci.com>
* www - http://harbour-project.org
*
*/
LOCAL a := "Hello Mom!" %><HTML><BODY><%
OutStd( a ) %><P>This is a <B>very ugly</B> script!!!<%
OutStd( "Line 2" )
%>
<P>
<%
OutStd( a, a, a )
%>
</HTML><%RETURN NIL%>

View File

@@ -1,57 +0,0 @@
/*
* $Id$
*/
/*
Guess a number
Date : 1999/04/22
My first application (big word) written in Harbour
Written by Eddie Runia <eddie@runia.com>
www - http://harbour-project.org
Placed in the public domain
*/
EXTERN OutStd
PROCEDURE Main()
local flGuessed
local CRLF := chr(13)+chr(10)
local nSeed := 241
local nPick
QQOut( "Welcome to guess a number....", CRLF )
QQOut( "You have to guess a number between ",0," and 255", CRLF )
do while Upper( Read( "Continue Y/N : " ) ) == "Y"
nSeed := (( nSeed * 11) + 5) % 256
flGuessed := 0
do while flGuessed == 0
nPick := Val( Read( "Value : " ) )
if nPick > 255
QQOut( "More than 255", CRLF )
elseif nPick < 0
QQOut( "Less than 0", CRLF )
elseif nPick > nSeed
QQOut( "Try lower", CRLF )
elseif nPick < nSeed
QQOut( "Try higher", CRLF )
else
QQOut( "Congratulations, you've guessed the number", CRLF, CRLF )
flGuessed := 1
endif
enddo
enddo
RETURN
FUNCTION Read( cPrompt ) /* Simple read function */
RETURN __Accept( cPrompt )

View File

@@ -1,173 +0,0 @@
/*
* $Id$
*/
//
// Mankala. The first Harbour board game.
//
// Written by Eddie Runia <eddie@runia.com>
// www - http://harbour-project.org
//
// Date : 30/04/1999
// Time : 14:00
//
// Placed in the public domain
//
function Main()
local cAnswer := "X"
local cPlayer
local lWon := .F.
local aBoard := {2,2,2,2}
local nMove
local cMove
local nLoop
local nLoop2
QOut( "Mankala. Another Harbour Game Production")
QOut()
if Upper( Read( "Do you want instructions ? " ) ) == "Y"
aEval ( { ;
" Mankala. The first Harbour board game. " , ;
" " , ;
" It is just you against the computer. The board is as follows : " , ;
" " , ;
" Computer " , ;
" ÚÄÄÄÂÄÄÄ¿ " , ;
" ³X X³X X³ " , ;
" ÃÄÄÄÅÄÄÄ´ " , ;
" ³X X³X X³ " , ;
" ÀÄÄÄÁÄÄÄÙ " , ;
" You " , ;
" " , ;
" The game begins with two stones in each square. " , ;
" " }, ;
{| cItem | QOut( cItem )} )
Read( "Pause : ")
aEval ( { ;
" You can choose to play either the left or the right (L/R) square. " , ;
" " , ;
" If you select a square, the stones are moved anti-clockwise through the " , ;
" squares. " , ;
" " , ;
" Example : You select Left. The board will now become : " , ;
" " , ;
" Computer " , ;
" ÚÄÄÄÂÄÄÄ¿ " , ;
" ³X X³XXX³ " , ;
" ÃÄÄÄÅÄÄÄ´ " , ;
" ³ ³XXX³ " , ;
" ÀÄÄÄÁÄÄÄÙ " , ;
" You " , ;
" " , ;
" The person which gets all the stones has won the game " , ;
" " , ;
" Just try to beat the computer :-) " }, ;
{| cItem | QOut( cItem )} )
Read( "Pause:" )
endif
do while cAnswer != "Y" .and. cAnswer != "N"
cAnswer := Read( "Would you like to play first ?" )
cAnswer := Upper( cAnswer ) // Nested functions ??
enddo
if cAnswer == "N"
cPlayer := "Computer"
else
cPlayer := "Human"
endif
do while !lWon
QOut()
QOut("Computer ",aBoard[2],' ',aBoard[1])
QOut("Human ",aBoard[3],' ',aBoard[4])
QOut()
QOut("Player ",cPlayer)
if (aBoard[2]==0 .and. aBoard[1]==0) .or. ;
(aBoard[3]==0 .and. aBoard[4]==0)
lWon := .T.
endif
if !lWon
if cPlayer == "Computer"
do case
case aBoard[1]==0
nMove := 1
case aBoard[1]==3 .and. aBoard[2]==2 .and. ;
aBoard[3]==2 .and. aBoard[4]==1
nMove := 1
case aBoard[1]==1 .and. aBoard[2]==6 .and. ;
aBoard[3]==1 .and. aBoard[4]==0
nMove := 1
case aBoard[1]==1 .and. aBoard[2]==1 .and. ;
aBoard[3]==6 .and. aBoard[4]==0
nMove := 1
case aBoard[1]==4 .and. aBoard[2]==1 .and. ;
aBoard[3]==3 .and. aBoard[4]==0
nMove := 1
case aBoard[1]==3 .and. aBoard[2]==1 .and. ;
aBoard[3]==4 .and. aBoard[4]==0
nMove := 1
otherwise
nMove := 0
endcase
else
nMove := 0
do while nMove == 0
cMove := Read( "Left/Right :" )
cMove := Upper( cMove )
if cMove == "L"
nMove := 2
else
if cMove == "R"
nMove := 3
endif
endif
enddo
lWon := aBoard[nMove+1] == 0
endif
nLoop2 := nMove
nLoop := aBoard[nMove+1]
aBoard[nMove+1] := 0
do while nLoop != 0
nLoop2++
aBoard[(nLoop2 % 4)+1]++ // It works :-)
nLoop--
enddo
if cPlayer == "Human"
cPlayer := "Computer"
else
cPlayer := "Human"
endif
endif
enddo
if cPlayer == "Human"
QOut( "You have beaten me :-)" )
else
QOut( "You'll never learn !" )
endif
return nil
function Read( cPrompt )
return __Accept( cPrompt )

View File

@@ -1,134 +0,0 @@
/*
* $Id$
*/
Welcome in the world of Harbour Terminal Protocol
=================================================
Harbour Terminal Protocol is build on three components:
1) Terminal Server
2) Terminal Client
3) The Harbour Application
Terminal Server
===============
Source => trm_server.prg
Link => GTWVG
Run => trm_server.exe 2011
Parameter => <TCP/IP Port number - [D] 8085 ]
Mode => MT ( Multi Threaded )
Terminal Server will reside on the same machine or network ( as of now )
where Harbour Application resides. Harbour Application must be able
to be run by ShellExecute() WINAPI function issued by the Terminal Server.
Terminal Client
===============
Source => trm_client.prg
Link => GTWVG
Run => trm_client.exe <IP - localhost | vouch.dynalias.com>
<Port where Terminal Server is Listening - 2011>
<Harbour Application - c:\harbour\contrib\examples\terminal\trm_app.exe>
[Parameters - Norammly Supplied to Appln - Separated by SPACE ]
[InitDirectory - Harbour Application's Startup Folder ]
Mode => ST ( Single Threaded )
Terminal Client can be distributed anywhere there is ACCESS TO designated TCP/IP port,
be it a network clinet or any computer having internet avalable.
Parameters supplied TO Harbour Client can be on command line or as an .ini file.
.Ini file may contain these entries:
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
InitDirectory = Complete Folder path from where Harbour Appln will be invoked.
IF parameters are supplied as .ini file, then .ini filename ( without path ) will be the
only parameter - note - only one parameter passed on the command line.
Harbour Application
===================
Source(s) => trm_app.prg | Your program sources +
terminal.prg +
terminal.ch
Link => GTWVG
Run => No
Mode => ST ( Single Thread )
Main() FUNCTION in Harbour Application will have TO be modified TO accept
one additional parameter <cServerInfo> at the END of the usual parameters
your application is accepting as ususal. And make sure that you send the same
number of parameter either on the command line or through .ini file.
<cServerInfo> parameter is supplied by Harbour Terminal Server.
At just start of the Harbour Application, immediately after variable definitions
in main() add these lines:
FUNCTION Main( [p1] [, p2] [, p3], cServerInfo )
LOCAL x, y
// Required it initialize the GTWVG window
SetColor( 'N/W,W/B,W+/N' )
CLS
? ' '
#ifdef __REMOTE__
// cServerInfo will be supplied by the Remote Server
//
RmtSvrSetInfo( cServerInfo )
IF ( nServerPort := RmtSvrSetInfo( 1 ) ) != NIL .and. nServerPort > 0
IF !RmtSvrInitialize( NTRIM( nServerPort ), 60/*nTimeoutClient*/, 0.5 /*nTimeRefresh*/ )
Quit
ENDIF
ENDIF
#endif
...
...
RETURN
Must remember to issue - ANNOUNCE HB_NOSTARTUPWINDOW - somewhere in your sources
Please note that we do not want to show up the Harbour console on the server so
HB_NOSTARTUPWINDOW symbol must be defined.
And this is the only requirement for your appln to be NET ready.
Technical Overview
==================
Client connects to Server.
Server looks for a free port - 45000+.
Server invokes Harbour Application with client supplied parameters + <cSerrverInfo==45000+>.
Harbour Application itself behaves as server on start listening on designated port.
Server informs back to Client about this port where Harbour Application is listening.
Client connects to Harbour Application on designated port.
If connection is successful, Server closes the connection from Client and Application.
Client and Application then have the direct communication.
Client transmits the keystrokes and Application reacts TO those events as IF supplied via keyboard.
Application transmits the screen buffer back TO client IF there have been any changes.
Application also transmits special commands, call them 'Remote Procedure Calls'.
Client responds TO received buffer according TO instruction it contains.
Client retrieves buffer per command basis.
Events are not serialized.
The Bottom Line
===============
The protocol above works as expected but is not as sophisticated as it should be.
GTNET as Przemek has been talking about will be the perfect solution though this
can be the basis FOR future enhancements. A lot can be improved, i.e., remote
printing, etc., which I hope you Gurus can implement in no times.
It is my humble contribution TO the Harbour world.
Regards
Pritpal Bedi <pritpal@vouchcac.com>
a student of software analysis & design

View File

@@ -1,7 +0,0 @@
#
# $Id$
#
{win}libs=hbwin
libs=hbct
mt=yes

View File

@@ -1,517 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* 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.
*
*/
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//
// Terminal Server Application
//
// Pritpal Bedi (pritpal@vouchcac.com)
// 13 Feb 2009
//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//#include "wvtwin.ch"
#define WSABASEERR 10000
#define WSAECONNABORTED (WSABASEERR+53)
#define WSAECONNRESET (WSABASEERR+54)
//----------------------------------------------------------------------//
#define TOP t_[ 1 ]
#define LFT t_[ 2 ]
#define BTM t_[ 3 ]
#define RGT t_[ 4 ]
#define ENDBLOCK "|/END\|"
#define TIMER_RECEIVE 1001
#define TIMER_SEND 1002
#define TIMER_PING 1010
#define SND_SCREEN 1 // Through Timer Only
#define SND_CODEBLOCK 2 // Application
#define SND_CLOCKINFO 3
#define SND_CLOCKONOFF 4
#define SND_MUSIC 5
//----------------------------------------------------------------------//
STATIC s_srvrSocket
STATIC s_commSocket
STATIC s_lSendingClient := .F.
STATIC s_mutexSend := hb_mutexCreate()
Function RmtSvrInitialize( cServerInfo, nTimeoutClient, nTimeRefresh )
Local lExit := .t.
s_srvrSocket := NIL
s_commSocket := NIL
hb_default( @nTimeoutClient, 60 ) // in seconds
hb_default( @nTimeRefresh , 0.5 ) // in seconds
nTimeRefresh := 0.1
if !empty( cServerInfo )
if RmtSvrInitAsServer( cServerInfo, @s_srvrSocket, nTimeOutClient*1000 )
if RmtSvrAcceptClient( s_srvrSocket, @s_commSocket )
// Very Important Factor 20-50 No more
//
Hb_INetTimeout( s_commSocket, 10 )
lExit := .f.
RmtSvrRunning( .t. )
hb_threadStart( @Thread_Receive(), 0.05 )
hb_threadStart( @Thread_Send() , nTimeRefresh )
hb_threadStart( @Thread_Ping() , 3 )
// Wvt_SetTimer( TIMER_RECEIVE, 50 ) // 50 ok 1/20 of a second
// Wvt_SetTimer( TIMER_SEND , nTimeRefresh*1000 )
// Wvt_SetTimer( TIMER_PING , 3000 )
endif
endif
endif
if lExit
if s_srvrSocket != NIL
if Hb_INetErrorCode( s_srvrSocket ) == 0
Hb_InetClose( s_srvrSocket )
endif
endif
if s_commSocket != NIL
if Hb_INetErrorCode( s_commSocket ) == 0
Hb_InetClose( s_commSocket )
endif
endif
Hb_INetCleanUp()
endif
Return !( lExit )
//----------------------------------------------------------------------//
Static Function RmtSvrInitAsServer( cServerInfo, Socket, nTimeoutClient )
Local lRet := .f.
Hb_INetInit()
Socket := Hb_INetServer( val( cServerInfo ) )
if Hb_InetErrorCode( Socket ) == 0
lRet := .t.
endif
if lRet
// Wait for 1 minutes maximum : W A T C H INI Controlled
//
Hb_INetTimeout( Socket, nTimeoutClient )
TrmDebug( "SERVER: Connection Established!", hb_INetPort( Socket ) )
else
TrmDebug( "SERVER: Connection Failed" )
endif
Return lRet
//----------------------------------------------------------------------//
//
// Waits for 2 minutes each try
//
Static Function RmtSvrAcceptClient( Socket, pClientSocket )
Local lRet := .t.
// Local i := 0
Do While .t.
pClientSocket := Hb_InetAccept( Socket )
if pClientSocket != NIL
lRet := .t.
endif
exit
//TrmDebug( "SvrConnectClient()", i++, "TRY..." )
enddo
if lRet
TrmDebug( "CLIENT: Connection Established!", hb_INetPort( pClientSocket ) )
else
TrmDebug( "CLIENT: Connection TimedOut!" )
endif
Return .t.
//----------------------------------------------------------------------//
Function RmtSvrSendClient( nMode, xData )
Local cCurs, nError, nBytesSent, nBytesToSend, t_, cOdd, cEvn, cOdd0, cEvn0
Local lSendCurs := .f.
Local lSendScrn := .f.
Local cData := ""
static cCursor := " "
static cSOdd := " "
static cSEvn := " "
static n := 0
static nScreen := 0
n++
if RmtSvrRunning()
if !( s_lSendingClient )
s_lSendingClient := .t.
do case
case nMode == SND_SCREEN
cCurs := hb_ntos( Row() ) +";"+ ;
hb_ntos( Col() ) +";"+ ;
hb_ntos( Set( _SET_CURSOR ) ) +";"
if !( cCurs == cCursor )
lSendCurs := .t.
cCursor := cCurs
endif
t_:= xData
hb_default( @t_, { 0, 0, maxrow( .t. ), maxcol( .t. ) } )
cOdd := ""
cEvn := ""
GETSCREENATTRIB( TOP,LFT,BTM,RGT,@cOdd,@cEvn )
if !( cSOdd == cOdd ) .or. !( cSEvn == cEvn )
lSendScrn := .t.
cSOdd := cOdd
cSEvn := cEvn
endif
if lSendScrn
nScreen++
cOdd0 := hb_zcompress( cOdd )
cEvn0 := hb_zcompress( cEvn )
cData := '<SCR>' +;
hb_ntos( TOP ) +';'+ hb_ntos( LFT ) +';'+ hb_ntos( BTM ) +';'+ hb_ntos( RGT ) +';'+;
hb_ntos( len( cOdd0 ) ) +';'+ ;
hb_ntos( len( cEvn0 ) ) +';'+ ;
'</E?>' +;
cOdd0 +;
cEvn0 +;
'</E?>' +;
'</SCR>' +;
'<CRS>' + cCurs + '</CRS>' +;
'<ID>' + hb_ntos( nScreen )+ '</ID>'
elseif lSendCurs
cData := '<CRS>'+ cCurs +'</CRS>'
endif
case nMode == SND_CODEBLOCK
cData := '<BLK>'+ xData +'</BLK>'
case nMode == SND_CLOCKINFO
cData := '<CLK_INFO>'+ xData +'</CLK_INFO>'
case nMode == SND_CLOCKONOFF
cData := '<CLK_ONOFF>'+ if( xData, 'TRUE','FALSE' ) +'</CLK_ONOFF>'
case nMode == SND_MUSIC
cData := '<MUSIC>'+ upper( xData ) +'</MUSIC>'
endcase
if len( cData ) > 0
cData += ENDBLOCK
nBytesToSend := len( cData )
nBytesSent := hb_INetSendAll( s_commSocket, cData, nBytesToSend )
if nBytesSent != nBytesToSend
nError := hb_INetErrorCode( s_commSocket )
TrmDebug( n,'E','VouchServer - SvrSendClient : ', nError, nBytesSent, nBytesToSend )
do case
case ascan( { -2, WSAECONNABORTED, WSAECONNRESET }, nError ) > 0
TrmDebug( n,'Q','VouchServer - SvrSendClient : ', nError, nBytesSent, nBytesToSend )
DbCloseAll()
Quit
otherwise
endcase
endif
endif
s_lSendingClient := .f.
endif
endif
Return nil
//----------------------------------------------------------------------//
Static Function RmtSvrReceiveClient()
Local cKey, nBytes, nError
static lInProcess := .f.
if !lInProcess
if hb_INetDataReady( s_commSocket ) > 0
lInProcess := .t.
cKey := hb_INetRecvLine( s_commSocket, @nBytes )
if nBytes > 0
hb_KeyPut( Val( cKey ) )
elseif nBytes == 1
else
nError := hb_INetErrorCode( s_commSocket )
if ascan( { -2, WSAECONNABORTED, WSAECONNRESET }, nError ) > 0
TrmDebug( 'VouchAsServer - Quitting : Error =', hb_INetErrorCode( s_commSocket ), 'nBytes =', nBytes )
DbCloseAll()
Quit
endif
endif
lInProcess := .f.
endif
endif
Return nil
//----------------------------------------------------------------------//
// Required as this receive all timer events
//
Function Wvt_Timer( wParam )
switch wParam
case TIMER_RECEIVE
RmtSvrReceiveClient()
exit
case TIMER_SEND
RmtSvrSendClient( 1, NIL )
exit
case TIMER_PING
if !( s_lSendingClient )
hb_INetSendAll( s_commSocket, ENDBLOCK )
endif
exit
end
Return 0
STATIC PROCEDURE Thread_Receive( nWait )
DO WHILE .T.
RmtSvrReceiveClient()
hb_idleSleep( nWait )
ENDDO
RETURN
STATIC PROCEDURE Thread_Send( nWait )
DO WHILE .T.
hb_mutexLock( s_mutexSend )
RmtSvrSendClient( 1, NIL )
hb_mutexUnlock( s_mutexSend )
hb_idleSleep( nWait )
ENDDO
RETURN
STATIC PROCEDURE Thread_Ping( nWait )
DO WHILE .T.
hb_mutexLock( s_mutexSend )
hb_INetSendAll( s_commSocket, ENDBLOCK )
hb_mutexUnlock( s_mutexSend )
hb_idleSleep( nWait )
ENDDO
RETURN
//----------------------------------------------------------------------//
Function RmtSvrSetInfo( cnInfo )
Local xInfo
static aInfo := { NIL,NIL,NIL }
if valtype( cnInfo ) == 'C' // To Retrieve it will be N
aInfo[ 1 ] := val( cnInfo ) // Port to Use
elseif valtype( cnInfo ) == 'N'
xInfo := aInfo[ cnInfo ]
endif
Return xInfo
//----------------------------------------------------------------------//
Function RmtSvrRunning( lYes )
Local sYes
static oYes := .f.
sYes := oYes
if valtype( lYes ) == 'L'
oYes := lYes
endif
return sYes
//----------------------------------------------------------------------//
Function TrmStr2A( cStr, cDel )
Local a_:={}, n
Local nlen
nLen := len( cDel )
do while .t.
if ( n := at( cDel, cStr ) ) == 0
exit
endif
aadd( a_, substr( cStr,1,n-1 ) )
cStr := substr( cStr,n+nLen )
enddo
Return a_
//----------------------------------------------------------------------//
Function TrmDebug( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 )
Local cDebug := ''
if p1 != nil
cDebug += TrmXtoS( p1 )
endif
if p2 != nil
cDebug += ' ' + TrmXtoS( p2 )
endif
if p3 != nil
cDebug += ' ' + TrmXtoS( p3 )
endif
if p4 != nil
cDebug += ' ' + TrmXtoS( p4 )
endif
if p5 != nil
cDebug += ' ' + TrmXtoS( p5 )
endif
if p6 != nil
cDebug += ' ' + TrmXtoS( p6 )
endif
if p7 != nil
cDebug += ' ' + TrmXtoS( p7 )
endif
if p8 != nil
cDebug += ' ' + TrmXtoS( p8 )
endif
if p9 != nil
cDebug += ' ' + TrmXtoS( p9 )
endif
if p10 != nil
cDebug += ' ' + TrmXtoS( p10 )
endif
#if defined( __PLATFORM__WINDOWS )
wapi_OutputDebugString( cDebug )
#endif
Return nil
//----------------------------------------------------------------------//
FUNCTION TrmXtoS( xVar )
SWITCH ValType( xVar )
CASE "C"
RETURN xVar
CASE "N"
RETURN Str( xVar )
CASE "D"
RETURN DToC( xVar )
CASE "L"
RETURN iif( xVar, "T", "F" )
ENDSWITCH
RETURN "NIL"
//----------------------------------------------------------------------//
Function TrmDummy()
Return nil
//----------------------------------------------------------------------//
STATIC PROCEDURE GETSCREENATTRIB( nT, nL, nB, nR, cOdd, cEvn )
LOCAL s := SaveScreen( nT, nL, nB, nR )
cOdd := CharOdd( s )
cEvn := CharEven( s )
RETURN

View File

@@ -1,8 +0,0 @@
#
# $Id$
#
-q0 -w3 -es2 -kmo -l
trm_app.prg
terminal.prg

View File

@@ -1,195 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* 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.
*
*/
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//
// Terminal Application
//
// Pritpal Bedi (pritpal@vouchcac.com)
// 13 Feb 2009
//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
/*
Just comment it out if you want a normal application
This is the only requirement to turn your application
as a remote server.
*/
#include "hbgtinfo.ch"
#define __REMOTE__
#define SND_SCREEN 1 // Through Timer Only
#define SND_CODEBLOCK 2 // Application
#define SND_CLOCKINFO 3
#define SND_CLOCKONOFF 4
#define SND_MUSIC 5
//----------------------------------------------------------------------//
ANNOUNCE HB_NOSTARTUPWINDOW
//----------------------------------------------------------------------//
FUNCTION Main( cServerInfo )
LOCAL aMenu := {}
LOCAL aOptions := {}
LOCAL nSel
LOCAL nServerPort
SetColor( "N/W,W/B,W+/N" )
CLS
? " "
#ifdef __REMOTE__
// This can be redefined in case user want another format
//
// cServerInfo will be supplied by the Remote Server
//
RmtSvrSetInfo( cServerInfo )
IF ( nServerPort := RmtSvrSetInfo( 1 ) ) != NIL .and. nServerPort > 0
IF !RmtSvrInitialize( hb_ntos( nServerPort ), 60/*nTimeoutClient*/, 0.5 /*nTimeRefresh*/ )
Quit
ENDIF
hb_gtInfo( HB_GTI_WINTITLE, hb_ntos( nServerPort ) )
ENDIF
#endif
aadd( aMenu, { "Play Music", {|| App_PlayMusic() } } )
aadd( aMenu, { " " , {|| NIL } } )
aadd( aMenu, { "Show Clock", {|| App_DispClock() } } )
aeval( aMenu, {|e_| aadd( aOptions, e_[ 1 ] ) } )
DO WHILE .t.
nSel := AChoice( 10,30,20,50, aOptions )
IF nSel == 0
EXIT
ENDIF
Eval( aMenu[ nSel,2 ] )
ENDDO
RETURN nil
//----------------------------------------------------------------------//
FUNCTION App_DispClock()
RETURN nil
//----------------------------------------------------------------------//
FUNCTION App_PlayMusic()
LOCAL cTheme := "CHARGE"
LOCAL aOptions := {"THUD","WAITON","WAITOFF","CHARGE","NANNYBOO","BADKEY" }
LOCAL cScr := SaveScreen( 0, 0, maxrow(), maxcol() )
LOCAL nSel
#ifdef __REMOTE__
DO WHILE .t.
nSel := AChoice( 10, 10, 17, 20, aOptions )
RestScreen( 0, 0, maxrow(), maxcol(), cScr )
IF nSel == 0
RETURN nil
ENDIF
cTheme := aOptions[ nSel ]
RmtSvrSendClient( SND_MUSIC, cTheme )
ENDDO
#endif
DO CASE
case cTheme == "THUD"
#ifndef __REMOTE__
tone(60,0.5)
#endif
case cTheme == "WAITON"
#ifndef __REMOTE__
tone(800,1); tone(1600,1)
#endif
case cTheme == "WAITOFF"
#ifndef __REMOTE__
tone(1600,1); tone(800,1)
#endif
case cTheme == "CHARGE"
#ifndef __REMOTE__
Eval( {|| tone(523,2),tone(698,2),tone(880,2),tone(1046,4),tone(880,2),tone(1046,8) } )
#endif
case cTheme == "NANNYBOO"
#ifndef __REMOTE__
AEval( {{196,2},{196,2},{164,2},{220,2},{196,4},{164,4}}, {|a| tone(a[1],a[2]) } )
#endif
case cTheme == "BADKEY"
#ifndef __REMOTE__
tone(480,0.25); tone(240,0.25)
#endif
endcase
#ifdef __REMOTE__
RmtSvrSendClient( SND_MUSIC, cTheme )
#endif
RETURN nil
//----------------------------------------------------------------------//

View File

@@ -1,7 +0,0 @@
#
# $Id$
#
-q0 -w3 -es2 -kmo -l
trm_cli.prg

View File

@@ -1,808 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* 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.
*
*/
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//
// Terminal Client
//
// Pritpal Bedi (pritpal@vouchcac.com)
// 13 Feb 2009
//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
#include "hbgtinfo.ch"
#include "fileio.ch"
#include "inkey.ch"
#include "setcurs.ch"
//----------------------------------------------------------------------//
#define WSABASEERR 10000
#define WSAECONNABORTED (WSABASEERR+53)
//----------------------------------------------------------------------//
#define TIMER_RECEIVE 5001
#define TIMER_SEND 5002
#define TIMER_PING 5010
#define TIMER_CLOCK 5020
#define TIMER_REFRESH 5030
#define COMPILE( cStr ) &( "{|v| "+cStr+ "}" )
#define CR_LF chr(13)+chr(10)
#define VouchClientVersion "0.9.4"
#define __TRACE__
//----------------------------------------------------------------------//
REQUEST Tone
//----------------------------------------------------------------------//
Static s_commSocket
static s_nTotalBytes := 0
static s_nScreens := 0
static s_nPing := 0
static s_lReceiving := .f.
static s_lSending := .f.
static s_lTraceLog := .f.
static s_nTrace := 0
static s_aDat := { {"",""} }
Function Main( cAddress, cPort, cAppln, cParams, cDirectory )
LOCAL Socket, n, cText, cResponse
ResolveParams( @cAddress, @cPort, @cAppln, @cParams, @cDirectory )
TrmInitFont()
SetCursor( SC_NONE )
SetColor( "W/N" )
SetBlink( .T. )
CLS
/* Comment out following line if you wish to receive log */
// s_lTraceLog := .t.
Hb_InetInit()
TrmDispLogin( cAddress, cPort )
Socket := Hb_InetConnect( cAddress, Val( cPort ) )
IF Hb_InetErrorCode( Socket ) != 0
DispOutAt( 17,0, padc( "Can't connect with " + cAddress +" : " + Hb_InetErrorDesc( Socket ),maxcol()+1 ), "w+/n" )
DispOutAt( 18,0, padc( "Press a key to terminate the program...", maxcol()+1 ), "w+/n" )
Inkey( 0 )
RETURN nil
ENDIF
// Wvt_SetTitle( "[ "+cAddress+" ][ "+cPort+" ]" )
hb_gtInfo( HB_GTI_WINTITLE, "[ "+cAddress+" ][ "+cPort+" ]" )
DispOutAt( 18,0, padc( "Connection Secured",maxcol()+1 ), "w+/n" )
// Wvt_SetTitle( "[ "+cAddress+" ][ "+cPort+" ]"+"[Secured]" )
hb_gtInfo( HB_GTI_WINTITLE, "[ "+cAddress+" ][ "+cPort+" ]"+"[Secured]" )
cText := "VOUCH|"+ cAppln +"|"+ cParams +"|"+ cDirectory +"|"
Hb_InetSend( Socket, cText + CR_LF )
if TrmReceiveALine( Socket, @cResponse )
if ( n := at( ";", cResponse ) ) > 0
if substr( cResponse,1,n-1 ) == "CONNECT"
TrmServeServer( Socket, cAddress, substr( cResponse,n+1 ) )
endif
endif
endif
Hb_InetClose( Socket )
Hb_InetCleanup()
RETURN 0
//----------------------------------------------------------------------//
STATIC FUNCTION ResolveParams( cAddress, cPort, cAppln, cParams, cDirectory )
Local i, n, cLine, cVal, nLines, cTxt, cPath, cFile
Local dat_ := {}
LOCAL lFile
if PCount() == 1
cFile := cAddress
cAddress := ""
else
cFile := "vclient.ini"
endif
cPath := hb_DirBase()
if !empty( cPath )
n := rat( "\", cPath )
if n > 0
cPath := substr( cPath, 1, n )
endif
endif
cFile := cPath + cFile
lFile := hb_FileExists( cFile )
if empty( cAddress ) .and. lFile
alert( "File found: "+cFile )
cTxt := memoread( cFile )
nLines := mlCount( cTxt,254,3,.f. )
for i := 1 to nLines
if !empty( cLine := memoLine( cTxt,254,i,3,.f. ) )
if ( n := at( "#",cLine ) ) > 0
cLine := substr( cLine,1,n-1 )
endif
if ( n := at( "=",cLine ) ) > 0
if !empty( cVal := alltrim( substr( cLine,n+1 ) ) )
aadd( dat_,{ lower( alltrim( substr( cLine,1,n-1 ) ) ),cVal } )
endif
endif
endif
next
if !empty( dat_ )
if ( n := ascan( dat_, {|e_| e_[ 1 ] == "serverip" } ) ) > 0
cAddress := dat_[ n,2 ]
endif
if ( n := ascan( dat_, {|e_| e_[ 1 ] == "serverport" } ) ) > 0
cPort := dat_[ n,2 ]
endif
if ( n := ascan( dat_, {|e_| e_[ 1 ] == "application" } ) ) > 0
cAppln := dat_[ n,2 ]
endif
if ( n := ascan( dat_, {|e_| e_[ 1 ] == "parameters" } ) ) > 0
cParams := dat_[ n,2 ]
endif
if ( n := ascan( dat_, {|e_| e_[ 1 ] == "initdirectory" } ) ) > 0
cDirectory := dat_[ n,2 ]
endif
endif
endif
if !empty( cAddress )
if empty( cPort ) .or. empty( cAppln )
cAddress := ""
endif
endif
// Defaults to Vouch Server
//
if empty( cAddress )
cAddress := "localhost"
cPort := "8085"
cAppln := "trm_app.exe"
cParams := ""
cDirectory := hb_DirBase()
endif
if empty( cParams )
cParams := ""
endif
if empty( cDirectory )
cDirectory := ""
endif
Return nil
//----------------------------------------------------------------------//
Function TrmServeServer( Socket, cAddress, cServerInfo )
Local nPort, a_, nError
Local nSeconds := Seconds()
Local nKey
a_:= hb_aTokens( cServerInfo, ";" )
nPort := val( a_[ 2 ] )
s_commSocket := Hb_INetConnect( cAddress, nPort )
do while Hb_INetErrorCode( s_commSocket ) != 0
s_commSocket := Hb_INetConnect( cAddress, nPort )
if Seconds()-nSeconds > 60 .or. Seconds()-nSeconds < 0
exit
endif
enddo
IF Hb_InetErrorCode( s_commSocket ) != 0
Hb_INetClose( Socket )
DispOutAt( 17,0, padc( "Can't connect with " + cAddress+": " + Hb_InetErrorDesc( s_commSocket ),maxcol()+1), "w+/n" )
DispOutAt( 18,0, padc( "Press a key to terminate the program", maxcol()+1 ), "w+/n" )
Inkey(0)
quit
ENDIF
// Very Important Factor 10-50 ok
//
Hb_INetTimeout( s_commSocket, -1 )
Hb_INetSend( Socket, "ARCONNECTED" + CR_LF )
Hb_INetClose( Socket )
// Wvt_SetTimer( TIMER_RECEIVE, 10 )
// Wvt_SetTimer( TIMER_SEND , 1 )
// Wvt_SetTimer( TIMER_CLOCK , 5000 )
// Wvt_SetTimer( TIMER_PING , 3000 )
hb_threadStart( @Thread_Receive(), 0.01 )
hb_threadStart( @Thread_Send() , 1 / 1000 )
hb_threadStart( @Thread_Ping() , 3 )
hb_threadStart( @Thread_Clock() , 5 )
do while .t.
nKey := Inkey( 0, INKEY_ALL )
IF s_commSocket != NIL .AND. ! Empty( nKey )
s_lSending := .T.
hb_inetSendAll( s_commSocket, hb_ntos( nKey ) + CR_LF )
s_lSending := .F.
ENDIF
nError := hb_inetErrorCode( s_commSocket )
IF AScan( { -2, WSAECONNABORTED, 10054 }, nError ) > 0
EXIT
ENDIF
enddo
// Wvt_KillTimer( TIMER_RECEIVE )
// Wvt_KillTimer( TIMER_SEND )
// Wvt_KillTimer( TIMER_CLOCK )
// Wvt_KillTimer( TIMER_PING )
Return nil
//----------------------------------------------------------------------//
Function TrmReceiveServer()
Local a_, b_, cBuffer, nBytes, cCommand, cData, cOdd, cEvn, n
LOCAL cOdd1, cEvn1
if !( s_lReceiving ) .and. ( s_commSocket != NIL )
s_lReceiving := .t.
if ( nBytes := Hb_INetDataReady( s_commSocket ) ) > 0
Hb_INetTimeout( s_commSocket, 10 )
cBuffer := Hb_INetRecvEndBlock( s_commSocket, "|/END\|", @nBytes )
Hb_INetTimeout( s_commSocket, -1 )
if nBytes > 0 .and. !empty( cBuffer )
s_nTotalBytes += nBytes
do while .t.
cCommand := TrmFetchCommand( @cBuffer, @cData )
if empty( cCommand )
exit
endif
do case
case cCommand == "SCR"
s_nScreens++
a_:= Str2A( cData, "</E?>" )
b_:= hb_aTokens( a_[ 1 ], ";" )
aeval( b_, {|e,i| b_[ i ] := val( e ) } )
n := ( b_[ 3 ]-b_[ 1 ]+1 ) * ( b_[ 4 ]-b_[ 2 ]+1 )
cOdd1 := substr( a_[ 2 ], 1, b_[ 5 ] )
cOdd := hb_zuncompress( cOdd1, n )
cEvn1 := substr( a_[ 2 ], b_[ 5 ]+1 )
cEvn := hb_zuncompress( cEvn1, n )
RestScreen( b_[ 1 ], b_[ 2 ], b_[ 3 ], b_[ 4 ], CharMix( cOdd, cEvn ) )
case cCommand == "CRS"
a_:= hb_aTokens( @cData, ";" )
SetPos( val( a_[ 1 ] ), val( a_[ 2 ] ) )
SetCursor( val( a_[ 3 ] ) )
case cCommand == "ID"
// Verify if objects are serialized and executed accordingly
case cCommand == "MUSIC"
PlayMusic( cData )
case cCommand == "CLK_ONOFF"
SetClock( cData == "TRUE" )
case cCommand == "CLK_INFO"
SetClockInfo( cData )
case cCommand == "BLK"
BEGIN SEQUENCE
Eval( COMPILE( cData ) )
ENDSEQUENCE
endcase
enddo
endif
ENDIF
s_lReceiving := .f.
endif
Return 0
STATIC PROCEDURE Thread_Receive( nWait )
DO WHILE .T.
TrmReceiveServer()
hb_idleSleep( nWait )
ENDDO
RETURN
STATIC PROCEDURE Thread_Send( nWait )
DO WHILE .T.
inkey()
hb_idleSleep( nWait )
ENDDO
RETURN
STATIC PROCEDURE Thread_Ping( nWait )
DO WHILE .T.
Keyboard( 1021 )
hb_idleSleep( nWait )
ENDDO
RETURN
STATIC PROCEDURE Thread_Clock( nWait )
DO WHILE .T.
DispClock()
hb_idleSleep( nWait )
ENDDO
RETURN
//----------------------------------------------------------------------//
Static Function TrmFetchCommand( cBuffer, cData )
Local cToken, c, cCmd := ""
Local n
if left( @cBuffer,1 ) == "<"
if ( n := at( ">", @cBuffer ) ) > 0
c := substr( cBuffer, 2, n-2 )
cBuffer := substr( cBuffer, n+1 )
cToken := "</"+ c +">"
if ( n := at( cToken, cBuffer ) ) > 0
cData := substr( cBuffer, 1, n-1 )
cBuffer := substr( cBuffer, n+len( cToken ) )
cCmd := c
endif
endif
endif
Return cCmd
//----------------------------------------------------------------------//
Static Function TrmReceiveALine( Socket, cInfo )
Local lRet := .t.
Local nBytes
do while .t.
if Hb_InetDataReady( Socket, 100 ) > 0
BEGIN SEQUENCE
cInfo := Hb_InetRecvLine( Socket, @nBytes )
RECOVER
lRet := .f.
END
exit
endif
enddo
Return lRet
//----------------------------------------------------------------------//
Static Function uiDebug( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 )
#ifdef __TRACE__
Local cDebug := ""
if p1 != nil
cDebug += uiXtos( p1 )
endif
if p2 != nil
cDebug += " " + uiXtos( p2 )
endif
if p3 != nil
cDebug += " " + uiXtos( p3 )
endif
if p4 != nil
cDebug += " " + uiXtos( p4 )
endif
if p5 != nil
cDebug += " " + uiXtos( p5 )
endif
if p6 != nil
cDebug += " " + uiXtos( p6 )
endif
if p7 != nil
cDebug += " " + uiXtos( p7 )
endif
if p8 != nil
cDebug += " " + uiXtos( p8 )
endif
if p9 != nil
cDebug += " " + uiXtos( p9 )
endif
if p10 != nil
cDebug += " " + uiXtos( p10 )
endif
if s_lTraceLog
DbgTraceLog( cDebug )
else
wapi_OutputDebugString( cDebug )
endif
#endif
Return nil
//----------------------------------------------------------------------//
Static Function TrmXtoS( xVar )
Local cType := valtype( xVar )
do case
case cType $ "CM"
case cType == "N"
xVar := ltrim( str( xVar ) )
case cType == "D"
xVar := dtoc( xVar )
case cType == "L"
xVar := if( xVar, "T","F" )
otherwise
xVar := ""
endcase
Return xVar
//----------------------------------------------------------------------//
Static Function Str2A( cStr, cDel )
Local a_:={}, n
Local nlen
nLen := len( cDel )
do while .t.
if ( n := at( cDel, cStr ) ) == 0
exit
endif
aadd( a_, substr( cStr,1,n-1 ) )
cStr := substr( cStr,n+nLen )
enddo
Return a_
//----------------------------------------------------------------------//
FUNCTION uiXtos( xVar )
SWITCH ValType( xVar )
CASE "C"
RETURN xVar
CASE "N"
RETURN Str( xVar )
CASE "D"
RETURN DToC( xVar )
CASE "L"
RETURN iif( xVar, "Yes", "No " )
ENDSWITCH
RETURN "NIL"
//----------------------------------------------------------------------//
Static Function TrmInitFont()
#define __JUSTGT__
#ifdef __JUSTGT__
/* set OEM font encoding for non unicode modes */
hb_gtInfo( HB_GTI_CODEPAGE, 255 )
/* Set EN CP-437 encoding */
hb_cdpSelect( "EN" )
hb_setTermCP( "EN" )
#ifdef __WINCE__
/* Set font size */
hb_gtInfo( HB_GTI_FONTSIZE, 10 )
hb_gtInfo( HB_GTI_FONTWIDTH, 5 )
#endif
#else
Local cFont := GetEnv( "VouchFont" )
Local nSize := val( GetEnv( "VouchFontSize" ) )
Local nScrWidth
Wvt_SetCodepage( 255 )
hb_cdpSelect( "EN" )
hb_setTermCP( "EN" )
if empty( cFont )
cFont := "Courier New"
endif
if empty( nSize )
nScrWidth := Wvt_GetScreenWidth()
if nScrWidth >= 1280
nSize := 28
elseif nScrWidth >= 1200
nSize := 22
elseif nScrWidth >= 1000
nSize := 18
elseif nScrWidth >= 800
nSize := 16
else
nSize := 15
endif
endif
Wvt_SetFont( cFont, nSize, 0, 0 )
#endif
SetMode( 25,80 )
return nil
//----------------------------------------------------------------------//
Static Function TrmDispLogin( cAddress, cPort )
Local nMaxCol := maxcol()+1
DispOutAt( 0,0, padc( "Vouch Client "+VouchClientVersion, nMaxCol ), "W+/r" )
DispOutAt( 10,0, padc( "...Please Wait...", nMaxCol ), "W+/N" )
DispOutAt( 12,0, padc( "Securing Server Connection", nMaxCol ), "W+/N" )
DispOutAt( 13,0, padc( "Address[ "+cAddress+" ] Port[ "+cPort+" ]", nMaxCol ), "W+/N" )
DispOutAt( maxrow(), 0, padc( "the software that GROWS with you", nMaxCol ), "W+/r" )
Return nil
//----------------------------------------------------------------------//
Static Function SetClockInfo( cData )
Local lInfo, a_
static aInfo := {}
lInfo := aclone( aInfo )
if cData != NIL
a_:= hb_aTokens( cData, ";" )
if len( a_ ) >= 3
aInfo := { val( a_[ 1 ] ), val( a_[ 2 ] ), a_[ 3 ] }
endif
endif
Return lInfo
//----------------------------------------------------------------------//
Static Function SetClock( lOnOff )
Local oClock
static lClock := .f.
oClock := lClock
if valtype( lOnOff ) == "L"
lClock := lOnOff
endif
Return oClock
//----------------------------------------------------------------------//
Static Function DispClock()
Local aInfo, nCrs, nRow, nCol
if SetClock()
if !empty( aInfo := SetClockInfo() )
nCrs := SetCursor( SC_NONE )
nRow := row()
nCol := col()
DispOutAt( aInfo[ 1 ], aInfo[ 2 ], time(), aInfo[ 3 ] )
setpos( nRow,nCol )
SetCursor( nCrs )
endif
endif
Return nil
//----------------------------------------------------------------------//
Static Function PlayMusic( cTheme )
do case
case cTheme == "THUD"
tone(60,0.5)
case cTheme == "WAITON"
tone(800,1); tone(1600,1)
case cTheme == "WAITOFF"
tone(1600,1); tone(800,1)
case cTheme == "CHARGE"
Eval( {|| tone(523,2),tone(698,2),tone(880,2),tone(1046,4),tone(880,2),tone(1046,8) } )
case cTheme == "NANNYBOO"
AEval( {{196,2},{196,2},{164,2},{220,2},{196,4},{164,4}}, {|a| tone(a[1],a[2]) } )
case cTheme == "BADKEY"
tone(480,0.25); tone(240,0.25)
endcase
Return nil
//----------------------------------------------------------------------//
#define S_LBL 1
#define S_TYP 2
#define S_LEN 3
#define S_DEC 4
#define S_PIC 5
#define S_ROW 6
#define S_COL 7
#define S_CLR 8
#define S_DEF 9
Static Function GetForm( cForm )
Local cReply := ""
Local i, scr
Local aFields
Local a_
Local frm_:={}
Local getlist := {}
aFields := hb_aTokens( cForm, "^" )
for i := 1 to len( aFields )
//a_:= Str2A( aFields[ i ], "," )
a_:= hb_aTokens( aFields[ i ], "," )
a_[ S_LEN ] := val(a_[ S_LEN ])
a_[ S_DEC ] := val(a_[ S_DEC ])
a_[ S_ROW ] := val(a_[ S_ROW ])
a_[ S_COL ] := val(a_[ S_COL ])
if empty( a_[ S_CLR ] )
a_[ S_CLR ] := "W+/BG,W+/B"
endif
if empty( a_[ S_PIC ] )
a_[ S_PIC ] := "@ "
endif
do case
case a_[ S_TYP ] == "C"
a_[ S_DEF ] := pad( a_[ S_DEF ], a_[ S_LEN ] )
case a_[ S_TYP ] == "N"
a_[ S_DEF ] := val( a_[ S_DEF ] )
case a_[ S_TYP ] == "D"
a_[ S_DEF ] := ctod( a_[ S_DEF ] )
case a_[ S_TYP ] == "L"
a_[ S_DEF ] := if( a_[ S_DEF ] == "T", .t., .f. )
endcase
/*
aadd( frm_, { a_[ S_LBL ], a_[ S_TYP ], a_[ S_LEN ], a_[ S_DEC ], ;
a_[ S_PIC ], a_[ S_ROW ], a_[ S_COL ], a_[ S_CLR ], a_[ S_DEF ] } )
*/
aadd( frm_, a_ )
next
scr := savescreen( 0,0,maxrow(),maxcol() )
cls
for i := 1 to len( frm_ )
DispOutAt( frm_[ i,S_ROW ], frm_[ i,S_COL ]-10, frm_[ i,S_LBL ], "W+/B" )
@ frm_[ i,S_ROW ], frm_[ i,S_COL ] GET frm_[ i,S_DEF ] ;
PICTURE frm_[ i,S_PIC ] COLOR frm_[ i,S_CLR ]
next
READ
RestScreen( 0,0,maxrow(),maxcol(),scr )
for i := 1 to len( frm_ )
cReply += TrmXtos( frm_[ i,S_DEF ] ) + "^"
next
Return cReply
//----------------------------------------------------------------------//
Static Function dbgTraceLog( cString, cFile )
Local lRet := .f.
Local nBytes
static nHandle
if nHandle == NIL
if ( nHandle := fopen( cFile,FO_WRITE ) ) == F_ERROR
if ( nHandle := fcreate( cFile ) ) == F_ERROR
Return .f.
endif
endif
endif
if nHandle != F_ERROR
fseek( nHandle, 0, FS_END )
nBytes := fwrite( nHandle, cString+chr(13)+chr(10), len( cString )+2 )
lRet := nBytes == len( cString )+2
endif
Return lRet
//----------------------------------------------------------------------//

View File

@@ -1,7 +0,0 @@
#
# $Id$
#
-q0 -w3 -es2 -kmo -l
trm_srv.prg

View File

@@ -1,437 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* 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.
*
*/
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//
// Terminal Server
//
// Pritpal Bedi (pritpal@vouchcac.com)
// 13 Feb 2009
//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
//----------------------------------------------------------------------//
#include "inkey.ch"
#include "setcurs.ch"
//----------------------------------------------------------------------//
static g_nUserCount
static g_nTotalCount
static MutexDB
static MutexCount
Static nMaxCol
//----------------------------------------------------------------------//
Function Main( cPort )
LOCAL socket
LOCAL nKey
nMaxCol := maxcol()+1
IF Empty( cPort ) .OR. Val( cPort ) == 0
cPort := "8085"
ENDIF
g_nUserCount := 0
g_nTotalCount := 0
MutexDB := HB_MutexCreate()
MutexCount := HB_MutexCreate()
SetColor( "W+/N" )
SetCursor( SC_NONE )
BuildScreen()
hb_InetInit()
Socket := hb_InetServer( val( cPort ) )
DispOutAt( 3, 0, padc( "Waiting for connections on port " + cPort, nMaxCol ), "W+/N" )
hb_ThreadStart( @ViewUpdate() , Socket )
hb_ThreadStart( @AcceptIncoming(), Socket )
DO WHILE .T.
nKey := inkey(0)
if nKey == K_CTRL_F12
//hb_ThreadStop( hView )
// closing the socket will release the accept() request
//hb_InetClose( Socket )
//hb_ThreadStop( hAccept )
EXIT
ENDIF
ENDDO
DispOutAt( maxrow()-2, 0, padc( "Please kill the window if not closed automatically",nMaxCol ), "W+/N" )
hb_InetClose( Socket )
hb_InetCleanup()
RETURN nil
//----------------------------------------------------------------------//
//
// Server Socket manager
//
PROCEDURE AcceptIncoming( Socket )
LOCAL pClientSocket
DO WHILE .T.
pClientSocket := hb_InetAccept( Socket )
IF pClientSocket != NIL
hb_mutexLock( MutexCount )
g_nUserCount++
g_nTotalCount++
hb_mutexUnlock( MutexCount )
hb_ThreadStart( @ServeClient(), pClientSocket )
hb_gcAll( .T. )
ELSE
? "Catched error ", hb_InetErrorCode( Socket ), hb_InetErrorDesc( Socket )
//EXIT
ENDIF
ENDDO
RETURN
//----------------------------------------------------------------------//
//
// Service incoming connection
//
PROCEDURE ServeClient( Socket )
LOCAL cRequest, cReply, cReq, cCmdLine, lExit
LOCAL nLength := 0
LOCAL nn := 0
LOCAL a_
static nServerPort := 45000
do while .t.
lExit := .f.
BEGIN SEQUENCE
*** First of all, we must take the request of the user
cRequest := alltrim( hb_InetRecvLine( Socket, @nLength ) )
RECOVER
lExit := .t.
END SEQUENCE
if lExit
EXIT
endif
if nLength < 0
exit
elseif nLength > 1
a_:= hb_aTokens( cRequest, '|' )
cReq := upper( a_[ 1 ] )
do case
case cReq == 'AR'
nServerPort++
SvrExecuteAPP( 'trm_app.exe', hb_ntos( nServerPort++ ), hb_dirBase() )
inkey( 5 )
cReply := 'CONNECT;' + 'localhost' + ';' + hb_ntos( nServerPort++ ) + ';'
case cReq == 'VOUCH'
nServerPort++
cCmdLine := a_[ 3 ] +' '+ ltrim( str( nServerPort ) )
SvrExecuteAPP( a_[ 2 ], cCmdLine, a_[ 4 ] )
cReply := 'CONNECT;' + 'localhost' + ';' + hb_ntos( nServerPort ) + ';' + a_[ 2 ] + ';'
case cReq == 'ARCONNECTED'
// No further info required, close connection
EXIT
case cReq == 'FORM'
#if 0
oXmlDoc := TXmlDocument():new( '<?xml version="1.0"?>' )
oXmlNode := TXmlNode():New( ,'form', { 'name' => 'CLIENT' } )
oXmlDoc:oRoot:addBelow( oXmlNode )
cFields := 'Code,C,8,0,@!,10,20,,^'+;
'Name,C,20,0,@!,12,20,,^'+;
'Salary,N,10,2,@Z 9999999.99,14,20,,^'+;
'Job,C,20,0,,16,20,,^'+;
'Birth,D,8,0,,18,20,,^'
oXmlNode := TXmlNode():New( ,'fields', { 'fields' => cFields } )
oXmlDoc:oRoot:addBelow( oXmlNode )
cData := 'C01|JOHNY WALKER|200|DRUMMER|01/01/1956|'
oXmlNode := TXmlNode():New( ,'data', { 'data' => cData } )
oXmlDoc:oRoot:addBelow( oXmlNode )
cReply := 'FORM;'+oXmlDoc:ToString( 1 )
/*
cReply := 'FORM;'+;
'<NAME>'+;
'CLIENT'+;
'</NAME>'+;
'<FORM>'+;
'Code,C,8,0,@!,10,20,,^'+;
'Name,C,20,0,@!,12,20,,^'+;
'Salary,N,10,2,@Z 9999999.99,14,20,,^'+;
'Job,C,20,0,,16,20,,^'+;
'Birth,D,8,0,,18,20,,^'+;
'</FORM>'+;
'<DATA>'+;
'C01|JOHNY WALKER|200|DRUMMER|01/01/1956|'+;
'</DATA>'
*/
#endif
case cReq == 'SCREEN'
cReply := 'SCREEN;'+SaveScreen( 0,0,MAXROW(),MAXCOL() )
case cReq == 'INFO'
cReply := 'INFO;' + hb_ntos( hb_INetPort( Socket ) ) + ';' + hb_INetAddress( Socket ) + ';'
otherwise
cReply := 'GENERIC;' + 'Request # '+ hb_ntos( ++nn, 10, 0 )
endcase
DispOutAt( 15, 0, " REQ: " + Substr( cRequest, 0 , 75 ) + Space( 80 ),'W+/BG' )
DispOutAt( 16, 0, " RLY: " + Substr( cReply, 0 , 75 ) + Space( 80 ), 'W+/B' )
cReply += chr(13)+chr(10)
hb_InetSend( Socket, @cReply )
else
//ThreadSleep( 50 )
inkey( 0.05 )
endif
enddo
hb_InetClose( Socket )
RETURN
//----------------------------------------------------------------------//
Function SvrExecuteApp( cAppln, cParams, cDirectory )
#if defined( __PLATFORM__WINDOWS )
RETURN wapi_ShellExecute( NIL, "open", cAppln, cParams, cDirectory )
#else
HB_SYMBOL_UNUSED( cDirectory )
RETURN hb_run( cAppln + " " + cParams )
#endif
//----------------------------------------------------------------------//
//
// Managing visual updates
//
PROCEDURE ViewUpdate( Socket )
LOCAL nProgress := 0
DO WHILE .T.
HB_MutexLock( MutexCount )
Looping( @nProgress, 5, 39 )
DispOutAt( 8, 5, "Main socket status : " + Str( hb_InetErrorCode( Socket ) ) +" :"+;
hb_InetErrorDesc( Socket ) )
DispOutAt( 9, 5, "Connected Users : " + Str( g_nUserCount ) )
DispOutAt( 10, 5, "Total users : " + Str( g_nTotalCount ) )
HB_MutexUnlock( MutexCount )
inkey( 0.1 )
ENDDO
RETURN
//----------------------------------------------------------------------//
PROCEDURE Progress( nProgress, nDrow, nDcol )
DispOutAt( nDrow, nDcol, "[ ]" )
DO CASE
CASE nProgress == 0
DispOutAt( nDrow, nDcol+1, "-" )
CASE nProgress == 1
DispOutAt( nDrow, nDcol+1, "\" )
CASE nProgress == 2
DispOutAt( nDrow, nDcol+1, "|" )
CASE nProgress == 3
DispOutAt( nDrow, nDcol+1, "/" )
ENDCASE
nProgress++
IF nProgress == 4
nProgress := 0
ENDIF
RETURN
//----------------------------------------------------------------------//
PROCEDURE Looping( nProgress, nDrow, nDcol )
IF nProgress > 3 .OR. nProgress < 0
nProgress := 0
ENDIF
DispOutAt( nDrow, nDcol, "[ ]" )
DO CASE
CASE nProgress == 0
DispOutAt( nDrow, nDcol+1, "-" )
CASE nProgress == 1
DispOutAt( nDrow, nDcol+1, "\" )
CASE nProgress == 2
DispOutAt( nDrow, nDcol+1, "|" )
CASE nProgress == 3
DispOutAt( nDrow, nDcol+1, "/" )
ENDCASE
nProgress++
IF nProgress == 4
nProgress := 0
ENDIF
RETURN
//----------------------------------------------------------------------//
Function BuildScreen()
CLEAR SCREEN
DispOutAt( 0,0, padc( "Welcome to V o u c h Server", maxcol()+1 ), 'w+/r' )
DispOutAt( maxrow(),0,padc( 'Press CTRL+F12 to QUIT',maxcol()+1 ), 'w+/r' )
Return nil
//----------------------------------------------------------------------//
Function uiDebug( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 )
Local cDebug := ''
if p1 != nil
cDebug += uiXtos( p1 )
endif
if p2 != nil
cDebug += ' ' + uiXtos( p2 )
endif
if p3 != nil
cDebug += ' ' + uiXtos( p3 )
endif
if p4 != nil
cDebug += ' ' + uiXtos( p4 )
endif
if p5 != nil
cDebug += ' ' + uiXtos( p5 )
endif
if p6 != nil
cDebug += ' ' + uiXtos( p6 )
endif
if p7 != nil
cDebug += ' ' + uiXtos( p7 )
endif
if p8 != nil
cDebug += ' ' + uiXtos( p8 )
endif
if p9 != nil
cDebug += ' ' + uiXtos( p9 )
endif
if p10 != nil
cDebug += ' ' + uiXtos( p10 )
endif
#if defined( __PLATFORM__WINDOWS )
wapi_OutputDebugString( cDebug )
#endif
Return nil
//----------------------------------------------------------------------//
FUNCTION uiXtos( xVar )
SWITCH ValType( xVar )
CASE "C"
RETURN xVar
CASE "N"
RETURN Str( xVar )
CASE "D"
RETURN DToC( xVar )
CASE "L"
RETURN iif( xVar, "Yes", "No " )
ENDSWITCH
RETURN "NIL"