From be8ea5126d803b6ac7b7696fa7b31cca230e8490 Mon Sep 17 00:00:00 2001 From: Bruno Cantero Date: Sat, 24 Jul 1999 19:22:10 +0000 Subject: [PATCH] *** empty log message *** --- harbour/source/rdd/dbcmd.c | 122 +++++++++++++++++++++++++++ harbour/source/rdd/nulsys/nulsys.prg | 33 ++++++++ harbour/source/rdd/rddsys.prg | 35 ++++++++ 3 files changed, 190 insertions(+) create mode 100644 harbour/source/rdd/dbcmd.c create mode 100644 harbour/source/rdd/nulsys/nulsys.prg create mode 100644 harbour/source/rdd/rddsys.prg diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c new file mode 100644 index 0000000000..8c93fba5aa --- /dev/null +++ b/harbour/source/rdd/dbcmd.c @@ -0,0 +1,122 @@ +#include +#include +#include +#include + +/* Change to rdd.api */ +typedef struct _AREA +{ + USHORT uArea; // The number assigned to this workarea +} AREA, * PAREA; + +HARBOUR HB_DBSELECTAREA( void ); +HARBOUR HB_DBSETDRIVER( void ); +HARBOUR HB_RDDSETDEFAULT( void ); + +HB_INIT_SYMBOLS_BEGIN( dbCmd__InitSymbols ) +{ "DBSELECTAREA", FS_PUBLIC, HB_DBSELECTAREA, 0 }, +{ "DBSETDRIVER", FS_PUBLIC, HB_DBSETDRIVER, 0 }, +{ "RDDSETDEFAULT", FS_PUBLIC, HB_RDDSETDEFAULT, 0 } +HB_INIT_SYMBOLS_END( dbCmd__InitSymbols ); +#if ! defined(__GNUC__) +#pragma startup dbCmd__InitSymbols +#endif + +#define WORKAREAS 250 + +/* From strings.c */ +char * hb_strUpper( char * szText, long lLen ); + +static char * szDefDriver = 0; /* Default RDD name */ +static USHORT uCurrArea = 1; /* Selectd area */ + +AREA hb_WorkAreas[ WORKAREAS - 1 ]; + +void hb_rddInitialize( void ) +{ + memset( hb_WorkAreas, 0, sizeof( AREA ) ); +} + +void hb_rddRelease( void ) +{ + if( szDefDriver ) + hb_xfree( szDefDriver ); +} + +BOOL hb_IsRDD( char * szRDDName ) +{ + return 1; /* Not implemented yet */ +} + +static USHORT hb_FindAlias( char * szAlias ) +{ + return 1; /* Not implemented yet */ +} + +static void hb_SelectFirstAvailable( void ) +{ + USHORT uCount; + + for( uCount = 0; uCount < WORKAREAS; uCount++ ) + { + if( hb_WorkAreas[ uCount ].uArea == 0 ) + { + uCurrArea = uCount + 1; + return; + } + } +} + + +static void hb_dbSelectArea( USHORT uNewArea ) +{ + if( uNewArea == 0) + hb_SelectFirstAvailable(); + else if( uNewArea <= WORKAREAS ) + uCurrArea = uNewArea; +} + +HARBOUR HB_DBSELECTAREA( void ) +{ + USHORT uNewArea; + char * szAlias; + + if( ISCHAR( 1 ) ) + { + szAlias = hb_parc( 1 ); + if( ( uNewArea = hb_FindAlias( szAlias ) ) == 0 ) + { + hb_errorRT_BASE( EG_ARG, 1002, "Alias not found", szAlias ); + return; + } + hb_dbSelectArea( uNewArea ); + } + else if( ISNUM( 1 ) ) + hb_dbSelectArea( hb_parni( 1 ) ); +} + +HARBOUR HB_DBSETDRIVER( void ) +{ + HB_RDDSETDEFAULT(); +} + +HARBOUR HB_RDDSETDEFAULT( void ) +{ + char * szNewDriver; + WORD wLen; + + hb_retc( szDefDriver ); + if( ISCHAR( 1 ) ) + { + szNewDriver = hb_parc( 1 ); + if( hb_IsRDD( szNewDriver ) ) + { + if( szDefDriver ) + hb_xfree( szDefDriver ); + wLen = strlen( szNewDriver ); + szDefDriver = ( char * ) hb_xgrab( wLen + 1 ); + strcpy( szDefDriver, hb_strUpper( szNewDriver, wLen ) ); + } + else hb_errorRT_DBCMD( EG_ARG, 1015, "Argument error", "RDDSETDEFAULT" ); + } +} diff --git a/harbour/source/rdd/nulsys/nulsys.prg b/harbour/source/rdd/nulsys/nulsys.prg new file mode 100644 index 0000000000..221737dcdc --- /dev/null +++ b/harbour/source/rdd/nulsys/nulsys.prg @@ -0,0 +1,33 @@ +/* + * $Id$ + + Copyright(C) 1999 by Bruno Cantero. + + 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. + + 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. + + You can contact me at: bruno@issnet.net + */ + +// Harbour without RDD + +procedure RddSys + +return + +init procedure RDDInit + +return diff --git a/harbour/source/rdd/rddsys.prg b/harbour/source/rdd/rddsys.prg new file mode 100644 index 0000000000..f54599b8a2 --- /dev/null +++ b/harbour/source/rdd/rddsys.prg @@ -0,0 +1,35 @@ +/* + * $Id$ + + Copyright(C) 1999 by Bruno Cantero. + + 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. + + 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. + + You can contact me at: bruno@issnet.net + */ + +// Standard Harbour RDDSys system + +procedure RddSys + +return + +init procedure RDDInit + + rddSetDefault( "DBFNTX" ) + +return