Files
harbour-core/harbour/contrib/hbsqlit2/hash.h
Viktor Szakats 603d77d54b 2008-06-02 23:33 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* contrib/make_b32_all.bat
   * contrib/make_gcc_all.sh
   * contrib/make_vc_all.bat
   + contrib/hbsqlit2
   + contrib/hbsqlit2/Makefile
   + contrib/hbsqlit2/make_b32.bat
   + contrib/hbsqlit2/make_vc.bat
   + contrib/hbsqlit2/make_gcc.sh
   + contrib/hbsqlit2/common.mak
   + contrib/hbsqlit2/hbsqlit2.c
   + contrib/hbsqlit2/hbsqlit2.ch
   + contrib/hbsqlit2/LICENSE.txt
   + contrib/hbsqlit2/TODO.txt
   + contrib/hbsqlit2/readme.txt
   + contrib/hbsqlit2/attach.c
   + contrib/hbsqlit2/auth.c
   + contrib/hbsqlit2/btree.c
   + contrib/hbsqlit2/btree.h
   + contrib/hbsqlit2/btree_rb.c
   + contrib/hbsqlit2/build.c
   + contrib/hbsqlit2/config.h
   + contrib/hbsqlit2/copy.c
   + contrib/hbsqlit2/date.c
   + contrib/hbsqlit2/delete.c
   + contrib/hbsqlit2/encode.c
   + contrib/hbsqlit2/expr.c
   + contrib/hbsqlit2/func.c
   + contrib/hbsqlit2/hash.c
   + contrib/hbsqlit2/hash.h
   + contrib/hbsqlit2/insert.c
   + contrib/hbsqlit2/main.c
   + contrib/hbsqlit2/opcodes.c
   + contrib/hbsqlit2/opcodes.h
   + contrib/hbsqlit2/os.c
   + contrib/hbsqlit2/os.h
   + contrib/hbsqlit2/pager.c
   + contrib/hbsqlit2/pager.h
   + contrib/hbsqlit2/parse.c
   + contrib/hbsqlit2/parse.h
   + contrib/hbsqlit2/pragma.c
   + contrib/hbsqlit2/printf.c
   + contrib/hbsqlit2/random.c
   + contrib/hbsqlit2/select.c
   + contrib/hbsqlit2/sqlite.h
   + contrib/hbsqlit2/sqliteInt.h
   + contrib/hbsqlit2/table.c
   + contrib/hbsqlit2/tokenize.c
   + contrib/hbsqlit2/trigger.c
   + contrib/hbsqlit2/update.c
   + contrib/hbsqlit2/util.c
   + contrib/hbsqlit2/vacuum.c
   + contrib/hbsqlit2/vdbe.c
   + contrib/hbsqlit2/vdbe.h
   + contrib/hbsqlit2/vdbeaux.c
   + contrib/hbsqlit2/vdbeInt.h
   + contrib/hbsqlit2/where.c
   + contrib/hbsqlit2/tests/bld_b32.bat
   + contrib/hbsqlit2/tests/bld_vc.bat
   + contrib/hbsqlit2/tests/example.db
   + contrib/hbsqlit2/tests/hbsqlite.prg
     + Added hbsqlit2 SQLite 2.x interface library.

       With kind permission from the author:
       Alejandro de Gárate <alex_degarate/at/hotmail.com>

     + Some renames were done here too to better fit into 
       the contrib structure.
     + Added std make files.
     + Added to 'all' make files.
     + Added foreign SQLite 2.8.16 (final 2.x version)
       source code to the repository.
       Compiles with an okay amount of warnings under BCC but 
       doesn't compile in C++ mode in MSVC (due to missing 
       casts).
     ; NOTE: I've added this because this is the original 
             SQLite Harbour interface, clean and working 
             implementation, and SQLite 2 is incompatible 
             with 3, and some may need to access existing 
             2.x databases from Harbour.
2008-06-02 21:46:01 +00:00

110 lines
3.8 KiB
C

/*
** 2001 September 22
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This is the header file for the generic hash-table implemenation
** used in SQLite.
**
** $Id$
*/
#ifndef _SQLITE_HASH_H_
#define _SQLITE_HASH_H_
/* Forward declarations of structures. */
typedef struct Hash Hash;
typedef struct HashElem HashElem;
/* A complete hash table is an instance of the following structure.
** The internals of this structure are intended to be opaque -- client
** code should not attempt to access or modify the fields of this structure
** directly. Change this structure only by using the routines below.
** However, many of the "procedures" and "functions" for modifying and
** accessing this structure are really macros, so we can't really make
** this structure opaque.
*/
struct Hash {
char keyClass; /* SQLITE_HASH_INT, _POINTER, _STRING, _BINARY */
char copyKey; /* True if copy of key made on insert */
int count; /* Number of entries in this table */
HashElem *first; /* The first element of the array */
int htsize; /* Number of buckets in the hash table */
struct _ht { /* the hash table */
int count; /* Number of entries with this hash */
HashElem *chain; /* Pointer to first entry with this hash */
} *ht;
};
/* Each element in the hash table is an instance of the following
** structure. All elements are stored on a single doubly-linked list.
**
** Again, this structure is intended to be opaque, but it can't really
** be opaque because it is used by macros.
*/
struct HashElem {
HashElem *next, *prev; /* Next and previous elements in the table */
void *data; /* Data associated with this element */
void *pKey; int nKey; /* Key associated with this element */
};
/*
** There are 4 different modes of operation for a hash table:
**
** SQLITE_HASH_INT nKey is used as the key and pKey is ignored.
**
** SQLITE_HASH_POINTER pKey is used as the key and nKey is ignored.
**
** SQLITE_HASH_STRING pKey points to a string that is nKey bytes long
** (including the null-terminator, if any). Case
** is ignored in comparisons.
**
** SQLITE_HASH_BINARY pKey points to binary data nKey bytes long.
** memcmp() is used to compare keys.
**
** A copy of the key is made for SQLITE_HASH_STRING and SQLITE_HASH_BINARY
** if the copyKey parameter to HashInit is 1.
*/
#define SQLITE_HASH_INT 1
/* #define SQLITE_HASH_POINTER 2 // NOT USED */
#define SQLITE_HASH_STRING 3
#define SQLITE_HASH_BINARY 4
/*
** Access routines. To delete, insert a NULL pointer.
*/
void sqliteHashInit(Hash*, int keytype, int copyKey);
void *sqliteHashInsert(Hash*, const void *pKey, int nKey, void *pData);
void *sqliteHashFind(const Hash*, const void *pKey, int nKey);
void sqliteHashClear(Hash*);
/*
** Macros for looping over all elements of a hash table. The idiom is
** like this:
**
** Hash h;
** HashElem *p;
** ...
** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){
** SomeStructure *pData = sqliteHashData(p);
** // do something with pData
** }
*/
#define sqliteHashFirst(H) ((H)->first)
#define sqliteHashNext(E) ((E)->next)
#define sqliteHashData(E) ((E)->data)
#define sqliteHashKey(E) ((E)->pKey)
#define sqliteHashKeysize(E) ((E)->nKey)
/*
** Number of entries in a hash table
*/
#define sqliteHashCount(H) ((H)->count)
#endif /* _SQLITE_HASH_H_ */