2010-12-11 23:31 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* examples/hbbtree/hb_btree.h
  * examples/hbbtree/hb_btree.c
    * Reformatted to Harbour standard using uncrustify tool.

  - examples/hbsqlit2
    - Deleted.
This commit is contained in:
Viktor Szakats
2010-12-11 22:32:25 +00:00
parent fdb590cb97
commit 8a0e15bf88
12 changed files with 1381 additions and 2937 deletions

View File

@@ -16,6 +16,14 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-12-11 23:31 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* examples/hbbtree/hb_btree.h
* examples/hbbtree/hb_btree.c
* Reformatted to Harbour standard using uncrustify tool.
- examples/hbsqlit2
- Deleted.
2010-12-11 23:22 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* config/hbc.cfg
+ Enabled alignment of PP definitions.

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
/*
$Id$
*/
$Id$
*/
/*
* Harbour Project source code:
@@ -42,14 +42,17 @@ HB_EXTERN_BEGIN
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 );
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_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 );

View File

@@ -1,26 +0,0 @@
/*
* $Id$
*/
/*
*------------------------------------------------------------------------
* HARBOUR INTERFACE for SQLITE
*------------------------------------------------------------------------
*
* Copyright 2003 Alejandro de Garate <alex_degarate@hotmail.com>
*
There are many areas for improving HbSQLite; any of them are:
- Mimic the REPLACE command from Clipper
- A better dataset manipulation
- Made available other SQLite commands, etc.
- Changing to OOP, so the harbour code would be more compatible and easy
to use among different SQL databases.
- Enhance the sql query edit window (maybe with memoedit).
- Changing the DOS console user interface with a GUI look and feel.
- Remove or hidden public vars
put here what you want :)
...

View File

@@ -1,241 +0,0 @@
/*
* $Id$
*/
/*
*------------------------------------------------------------------------
* HARBOUR INTERFACE for SQLITE
*------------------------------------------------------------------------
* Copyright 2003 Alejandro de Garate <alex_degarate@hotmail.com>
* License: General Public License (GNU)
*
* History:
* Ver 0.40 30 December 2003 Fixed an opening error not detected
* It seems is a problem with BCC compiler.
* If "xxFile" database is not found, an empty file is
* created with the same name, given an incorrect signal
* to FILE() function. File is empty but exists (Oh man...)
* I fix it from harbour code, when have more spare time
* I will look in depth.
* Ver 0.30 28 December 2003 Pick tables, fields and DB structure,
* you can import some dbf (not finish yet)
* Ver 0.20 5 December 2003 changes in design, A front end is started
* Shows database struc, table struct, field type
* Ver 0.10 26 November 2003 first intempts, open connection, list data
* close connection
*
* 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.
*
*/
#include "hbapi.h"
#include "hbapiitm.h"
#include "sqlite.h"
#include "sqliteInt.h"
/* Public vars */
sqlite * hb_sqlite2_db = NULL; /* public by ale */
char * hb_sqlite2_szErrMsg = NULL;
int hb_sqlite2_iDataRows = 0; /* records */
int hb_sqlite2_iDataCols = 0; /* fields */
/* Returns information about current SQLite package */
HB_FUNC( SQLITE_INFO )
{
hb_reta( 3 );
hb_storc( SQLITE_VERSION , -1, 1 );
hb_storc( sqlite_libversion() , -1, 2 );
hb_storc( sqlite_libencoding(), -1, 3 );
}
/* Open a database file (in SQLite format) and set a public structure */
HB_FUNC( SQLITE_OPEN )
{
if( hb_sqlite2_db )
sqlite_close( hb_sqlite2_db );
hb_sqlite2_db = ( sqlite * ) sqlite_open( hb_parcx( 1 ), 0, &hb_sqlite2_szErrMsg );
hb_retni( hb_sqlite2_db == NULL ? 1 : 0 ); /* error: 1 */
}
/* Close currently open database */
HB_FUNC( SQLITE_CLOSE )
{
if( hb_sqlite2_db )
{
sqlite_close( hb_sqlite2_db );
hb_sqlite2_db = NULL;
}
}
/* Execute a statment (not a query) over the database */
HB_FUNC( SQLITE_EXECUTE )
{
if( hb_sqlite2_db )
hb_retni( sqlite_exec( hb_sqlite2_db, hb_parcx( 1 ), NULL, NULL, &hb_sqlite2_szErrMsg ) );
}
/* Execute a query over the passed table */
HB_FUNC( SQLITE_QUERY )
{
const char * szSQLcom = hb_parcx( 1 );
if( hb_sqlite2_db && sqlite_exec( hb_sqlite2_db, szSQLcom, NULL, NULL, &hb_sqlite2_szErrMsg ) == SQLITE_OK )
{
int iResRows = 0;
int iResCols = 0;
int iRec;
int iField;
char * pErrmsg;
char ** pResStr;
PHB_ITEM paRows;
int i;
/* put here a routine to process results */
sqlite_get_table( hb_sqlite2_db, /* An open database */
szSQLcom, /* SQL to be executed */
&pResStr, /* Result written to a char *[] that this points to */
&iResRows, /* Number of result rows written here */
&iResCols, /* Number of result columns written here */
&pErrmsg /* Error msg written here */
);
/* global results */
hb_sqlite2_iDataRows = iResRows; /* set rows from last operation */
hb_sqlite2_iDataCols = iResCols; /* set cols from last operation */
/* quiero devolver un array bidimensional donde la cantidad de filas
es rows +1 (ó reccords +1 ) y las columnas los campos
la primer fila contiene los encabezados de los campos */
/* dimension rows array */
paRows = hb_itemArrayNew( iResRows + 1 );
for( iRec = 0, i = 0; iRec < iResRows + 1; iRec++ )
{
if( iResCols > 1 ) /* if it's a multidimensional array */
{
PHB_ITEM paCols = hb_itemArrayNew( iResCols );
/* for every field */
for( iField = 0; iField < iResCols; iField++ )
hb_arraySetC( paCols, iField + 1, pResStr[ i++ ] );
/* put data onto subarray of records */
hb_itemArrayPut( paRows, iRec + 1, paCols );
hb_itemRelease( paCols );
}
else /* is an unidimensional array */
hb_arraySetC( paRows, iRec + 1, pResStr[ i++ ] );
}
/* free memory allocated */
sqlite_free_table( pResStr );
hb_itemReturnRelease( paRows );
}
else
hb_reta( 0 );
}
/* Returns an unidimensional array with FIELD NAMES only */
HB_FUNC( SQLITE_SYSCOLUMNS )
{
if( hb_sqlite2_db )
{
struct Table * pTable = ( struct Table * ) sqliteFindTable( hb_sqlite2_db, ( const char * ) hb_parcx( 1 ), NULL );
if( pTable )
{
/* dimension rows array:
1 is table name
2 is field number
3 to n cols data */
PHB_ITEM paRows = hb_itemArrayNew( 2 + pTable->nCol );
int iField;
/* the Table structure itself */
hb_arraySetC( paRows, 1, pTable->zName ); /* save name of table */
hb_arraySetNL( paRows, 2, pTable->nCol ); /* save number of cols/fields */
for( iField = 0; iField < pTable->nCol; iField++ )
{
/* it's a multidimensional array */
/* four data columns name, default, type, isprimarykey per field */
PHB_ITEM paCols = hb_itemArrayNew( 4 );
hb_arraySetC( paCols, 1, pTable->aCol[ iField ].zName );
hb_arraySetC( paCols, 2, pTable->aCol[ iField ].zDflt );
hb_arraySetC( paCols, 3, pTable->aCol[ iField ].zType );
hb_arraySetL( paCols, 4, pTable->aCol[ iField ].isPrimKey );
/* put data onto subarray of records */
hb_itemArrayPut( paRows, 3 + iField, paCols );
hb_itemRelease( paCols );
}
hb_itemReturnRelease( paRows );
return;
}
}
hb_reta( 0 );
}
/* Returns an unidimensional array with field names only */
HB_FUNC( SQLITE_FIELDS )
{
if( hb_sqlite2_db )
{
struct Table * pTable = ( struct Table * ) sqliteFindTable( hb_sqlite2_db, ( const char * ) hb_parcx( 1 ), NULL );
if( pTable )
{
int i;
/* the Table structure itself */
hb_reta( pTable->nCol );
for( i = 0; i < pTable->nCol; i++ )
hb_storc( pTable->aCol[ i ].zName, -1, 1 + i );
return;
}
}
hb_reta( 0 );
}
/* Returns number of tables inside current open database (not table) */
HB_FUNC( SQLITE_NUMOFTABLES )
{
hb_retni( hb_sqlite2_db ? hb_sqlite2_db->nTable - 2 : 0 );
}
/* Returns a string explaining last error */
HB_FUNC( SQLITE_ERROR )
{
hb_retc( hb_sqlite2_szErrMsg );
}
/* Returns the number of rows resulting from last operation */
HB_FUNC( SQLITE_GETROWS )
{
hb_retni( hb_sqlite2_iDataRows );
}
/* Returns the number of columns resulting from last operation */
HB_FUNC( SQLITE_GETCOLS )
{
hb_retni( hb_sqlite2_iDataCols );
}

View File

@@ -1,90 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
* SQLite DBMS defines
*
* Copyright 2003 Alejandro de Garate <alex_degarate@hotmail.com>
* www - http://harbour-project.org
*
*/
#ifndef HBSQLIT2_CH_
#define HBSQLIT2_CH_
/* Generic defines */
/*
* Return values for sqlite_exec() and sqlite_step()
*/
#define HB_SQLITE_OK 0 /* Successful result */
#define HB_SQLITE_ERROR 1 /* SQL error or missing database */
#define HB_SQLITE_INTERNAL 2 /* An internal logic error in SQLite */
#define HB_SQLITE_PERM 3 /* Access permission denied */
#define HB_SQLITE_ABORT 4 /* Callback routine requested an abort */
#define HB_SQLITE_BUSY 5 /* The database file is locked */
#define HB_SQLITE_LOCKED 6 /* A table in the database is locked */
#define HB_SQLITE_NOMEM 7 /* A malloc() failed */
#define HB_SQLITE_READONLY 8 /* Attempt to write a readonly database */
#define HB_SQLITE_INTERRUPT 9 /* Operation terminated by sqlite_interrupt() */
#define HB_SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */
#define HB_SQLITE_CORRUPT 11 /* The database disk image is malformed */
#define HB_SQLITE_NOTFOUND 12 /* (Internal Only) Table or record not found */
#define HB_SQLITE_FULL 13 /* Insertion failed because database is full */
#define HB_SQLITE_CANTOPEN 14 /* Unable to open the database file */
#define HB_SQLITE_PROTOCOL 15 /* Database lock protocol error */
#define HB_SQLITE_EMPTY 16 /* (Internal Only) Database table is empty */
#define HB_SQLITE_SCHEMA 17 /* The database schema changed */
#define HB_SQLITE_TOOBIG 18 /* Too much data for one row of a table */
#define HB_SQLITE_CONSTRAINT 19 /* Abort due to contraint violation */
#define HB_SQLITE_MISMATCH 20 /* Data type mismatch */
#define HB_SQLITE_MISUSE 21 /* Library used incorrectly */
#define HB_SQLITE_NOLFS 22 /* Uses OS features not supported on host */
#define HB_SQLITE_AUTH 23 /* Authorization denied */
#define HB_SQLITE_FORMAT 24 /* Auxiliary database format error */
#define HB_SQLITE_ROW 100 /* sqlite_step() has another row ready */
#define HB_SQLITE_DONE 101 /* sqlite_step() has finished executing */
/* * SQLITE_COPY
** SQLITE_CREATE_INDEX
** SQLITE_CREATE_TABLE
** SQLITE_CREATE_TEMP_INDEX
** SQLITE_CREATE_TEMP_TABLE
** SQLITE_CREATE_TEMP_TRIGGER
** SQLITE_CREATE_TEMP_VIEW
** SQLITE_CREATE_TRIGGER
** SQLITE_CREATE_VIEW
** SQLITE_DELETE
** SQLITE_DROP_INDEX
** SQLITE_DROP_TABLE
** SQLITE_DROP_TEMP_INDEX
** SQLITE_DROP_TEMP_TABLE
** SQLITE_DROP_TEMP_TRIGGER
** SQLITE_DROP_TEMP_VIEW
** SQLITE_DROP_TRIGGER
** SQLITE_DROP_VIEW
** SQLITE_INSERT
** SQLITE_PRAGMA
** SQLITE_READ
** SQLITE_SELECT
** SQLITE_TRANSACTION
** SQLITE_UPDATE
*/
/* Harbour definitions */
#define HB_HB4SQLITE_VER "0.40"
/* SQLite tag
* we use the first part of the tag (defined at btree.c) to not exclude
* any version of the database
* "** This file contains an SQLite 2.1 database **"
*/
#define XSQLITE_TAG "** This file contains an SQLite "
#define XSQLITE_TAG_LEN LEN(XSQLITE_TAG)
#endif
/* End of hbsqlite.ch */

View File

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

View File

@@ -1,21 +0,0 @@
#
# $Id$
#
-hblib
-inc
-o${hb_name}
-w3 -es2
"-stop={dos}'${hb_name}' doesn't support MS-DOS platform."
-depkeyhead=sqlite2:sqlite.h
-depcontrol=sqlite2:${HB_WITH_SQLITE2}
-depincpath=sqlite2:/usr/include
-depincpath=sqlite2:/boot/common/include
-instfile=inc:hbsqlit2.ch
hbsqlit2.c

View File

@@ -1,127 +0,0 @@
/*
* $Id$
*/
/*
*------------------------------------------------------------------------
* HARBOUR INTERFACE for SQLITE
*------------------------------------------------------------------------
*
* Copyright 2003 Alejandro de Garate <alex_degarate@hotmail.com>
*
* License: General Public License or for short GPL (GNU)
*
* Developed using:
* Harbour 0.42 or upper
* Borland C++ BCC 5.5.1
*
*/
Requirements
------------
Any windows platform W95, W98, W98SE or NT family
A C++ compiler, if you use other than Borland some minor changes could
be required.
The program
-----------
The source program is quite small (about 50 Kbytes) and a litle basic,
but gives an easy way of accessing a SQL Database, like SQLite.
Inside the prg you can find several C functions used to connect to the
database, and Clipper/Harbour code used for calling C functions.
Most of the code is commented and is easy to follow.
Of course many enhancement would be done, I will do if I found spare
time :)
The library that come with the program it's based in the SQLite version
2.8.6
Purpose
-------
To access a sqlite database using Clipper/Harbour language.
Use
---
This program is mostly self-contained.
For using you needs:
1- Borland C++ Compiler BCC 5.5 or upper (working)
2- Harbour version 0.42 or upper (working)
3- hbsqlite.prg (main program /front end)
4- hbsqlite.ch (some defines)
5- sqlite.lib (library builded for BCC55 and windows platform)
6- sqlite.h (include file for sqlite code)
7- sqliteInt.h (include file for sqlite code)
8- example.db (a simple sqlite database for testings )
Steps:
1.- Unzip the package to the target directory (ie.: \sqlite)
2.- Keep the zip file at safe place :)
3.- Add sqlite.lib to the list of libraries
You also needs to add sqlite.lib to the list of libraries inside
the build.bat file at harbour\bin directory.
4.- Move the static library sqlite.lib to the harbour\lib directory.
5.- If you have (1) & (2) working, just compile hbsqlite.prg using:
bld_b32 hbsqlite // without extension
Information about SQLITE
------------------------
1. web site at www.sqlite.org
2. User list for sqlite (do not ask about harbour stuffs)
subscribe at:
<sqlite-users-subscribe@sqlite.org> (one by one)
<sqlite-users-digest-subscribe@sqlite.org> (digest mode)
What is inside the source package ?
-----------------------------------
Inside the hbsqlite_src.zip file you will find:
File Size Description
--------------------------------------------------------------------------
1- hbsqlite.prg 46.401 (main program /front end)
2- hbsqlite.ch 3.369 (some defines)
3- sqlite.lib 352.256 (lib builded for BCC55 and windows platform)
4- sqlite.h 31.222 (include file for sqlite code)
5- sqliteInt.h 53.893 (include file for sqlite code)
6- gpl.txt 17.989 (a copy of GPL license)
7- todo.txt (a list of pending things )
8- readme_en.txt (this readme)
Note:
You may want also the sqlite manager and the sample database, in that
case you must download the binary package.
What is inside the binary package ?
-----------------------------------
Inside the hbsqlite_bin.zip file you will find:
File Size Description
--------------------------------------------------------------------------
1- hbsqlite.exe 741.376 (harbour front end to sqlite)
2- sqlite.exe 285.444 (a comand-line Sqlite manager)
3- example.db 77.824 (a simple sqlite database for testings)
4- test.db (another sqlite database for testings)
5- readme_en.txt (this readme)
Final comments
--------------
You can adapt the program to your needs, but if you made any
improvements, fixes or found any error, let me know so I can add it
to the program.
Anyway if you want to ask something, or think a feature is missing
send me a mail.
Enjoy it!
Alejandro

View File

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

File diff suppressed because it is too large Load Diff