📄 pbl.h
字号:
#ifndef _PBL_H_#define _PBL_H_/* pbl.h - external include file of library Copyright (C) 2002 Peter Graf This file is part of PBL - The Program Base Library. PBL is free software. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For more information on the Program Base Library or Peter Graf, please see: http://mission.base.com/. $Log: pbl.h,v $ Revision 1.2 2002/09/12 20:47:18 peter added the isam file handling to the library Revision 1.1 2002/09/05 13:44:12 peter Initial revision*/#ifdef __cplusplusextern "C" {#endif/* * make sure "strings <exe> | grep Id | sort -u" shows the source file versions */static char* _PBL_H_id = "$Id: pbl.h,v 1.2 2002/09/12 20:47:18 peter Exp $";static int _PBL_H_fct() { return( _PBL_H_id ? 0 : _PBL_H_fct() ); }#ifdef WIN32 #include <direct.h> #include <io.h>#else #include <sys/dir.h>#endif/*****************************************************************************//* #defines *//*****************************************************************************/#ifdef _WIN32/* * some functions have strange names on windows */#define strcasecmp _stricmp#define strncasecmp _strnicmp#define snprintf _snprintf#else#ifndef O_BINARY#define O_BINARY 0#endif#endif#define PBL_ERRSTR_LEN 2048/** @name B: Files * list of files of component * <P> * <B>FILES</B> * <UL> * <LI> <a href="../pbl.h">pbl.h</a> - the include file of the library * <LI> <a href="../pbl.c">pbl.c</a> - source for the base functions * <LI> <a href="../pblhash.c">pblhash.c</a> - source file for the * hash functions * <LI> <a href="../pblhttst.c">pblhttst.c</a> - source file for the * hash function test frame * <LI> <a href="../pblkf.c">pblkf.c</a> - source file for the key * file functions * <LI> <a href="../pblkftst.c">pblkftst.c</a> - source file for the * key file handling test frame * <LI> <a href="../pblisam.c">pblisam.c</a> - source file for the isam * file functions * <LI> <a href="../pbliftst.c">pbliftst.c</a> - source file for the * isam file handling test frame * <LI> <a href="../makefile">makefile</a> - a Unix makefile for the * component * <LI> <a href="../pblhttstdeb.dsp">pblhttstdeb.dsp</a> - a Microsoft Visual * Studio 6.0 project file for * hash table debug * <LI> <a href="../pblkftstdeb.dsp">pblkftstdeb.dsp</a> - a Microsoft * Visual Studio 6.0 project file * for key file debug * <LI> <a href="../pbliftstdeb.dsp">pbliftstdeb.dsp</a> - a Microsoft Visual * Studio 6.0 project file for * isam file debug * <LI> <a href="../ISAM0001.LOG">ISAM0001.LOG</a> - a test case for the * isam file handling test frame * <LI> <a href="../pbl.dxx">pbl.dxx</a> - the source for this document * </UL> */#define PBL_FILE_LIST/** @name C: Error codes * error codes of the pbl library * * @field PBL_ERROR_OUT_OF_MEMORY out of memory * @field PBL_ERROR_EXISTS record already exists * @field PBL_ERROR_NOT_FOUND record not found * @field PBL_ERROR_BAD_FILE file structure damaged * @field PBL_ERROR_PARAM_MODE parameter mode is not valid * @field PBL_ERROR_PARAM_KEY parameter key is not valid * @field PBL_ERROR_PARAM_KEYLEN parameter keylen is not valid * @field PBL_ERROR_PARAM_DATA parameter data is not valid * @field PBL_ERROR_PARAM_DATALEN parameter datalen is not valid * @field PBL_ERROR_PARAM_INDEX parameter index is not valid * @field PBL_ERROR_CREATE file system create error, see errno * @field PBL_ERROR_OPEN file system open error, see errno * @field PBL_ERROR_SEEK file system seek error, see errno * @field PBL_ERROR_READ file system read error, see errno * @field PBL_ERROR_WRITE file system write error, see errno * @field PBL_ERROR_PROGRAM an internal error in the code, debug it!! * @field PBL_ERROR_NOFIT internal error forcing a block split * @field PBL_ERROR_NOT_ALLOWED file not open for update, operation not allowed * @field PBL_ERROR_POSITION current record is not positioned */#define PBL_ERROR_BASE 1000#define PBL_ERROR_OUT_OF_MEMORY ( PBL_ERROR_BASE + 1 )#define PBL_ERROR_EXISTS ( PBL_ERROR_BASE + 2 )#define PBL_ERROR_NOT_FOUND ( PBL_ERROR_BASE + 3 )#define PBL_ERROR_BAD_FILE ( PBL_ERROR_BASE + 4 )#define PBL_ERROR_PARAM_MODE ( PBL_ERROR_BASE + 5 )#define PBL_ERROR_PARAM_KEY ( PBL_ERROR_BASE + 6 )#define PBL_ERROR_PARAM_KEYLEN ( PBL_ERROR_BASE + 7 )#define PBL_ERROR_PARAM_DATA ( PBL_ERROR_BASE + 8 )#define PBL_ERROR_PARAM_DATALEN ( PBL_ERROR_BASE + 9 )#define PBL_ERROR_PARAM_INDEX ( PBL_ERROR_BASE + 10 )#define PBL_ERROR_CREATE ( PBL_ERROR_BASE + 20 )#define PBL_ERROR_OPEN ( PBL_ERROR_BASE + 21 )#define PBL_ERROR_SEEK ( PBL_ERROR_BASE + 22 )#define PBL_ERROR_READ ( PBL_ERROR_BASE + 23 )#define PBL_ERROR_WRITE ( PBL_ERROR_BASE + 24 )#define PBL_ERROR_PROGRAM ( PBL_ERROR_BASE + 30 )#define PBL_ERROR_NOFIT ( PBL_ERROR_BASE + 31 )#define PBL_ERROR_NOT_ALLOWED ( PBL_ERROR_BASE + 40 )#define PBL_ERROR_POSITION ( PBL_ERROR_BASE + 41 )/** @name D: Definitions for Key File Parameters * DEFINES FOR PARAMETER <B> mode </B> OF \Ref{pblKfFind}() * @field PBLEQ any record that is equal * @field PBLFI first record that is equal * @field PBLLA last record that is equal * @field PBLGE last equal or first that is greater * @field PBLGT first that is greater * @field PBLLE first equal or last that is smaller * @field PBLLT last that is smaller */#define PBLEQ 1#define PBLFI 2#define PBLLA 3#define PBLGE 4#define PBLGT 5#define PBLLE 6#define PBLLT 7/** @name E: Definitions for ISAM Parameters * DEFINES FOR PARAMETER <B> which </B> OF \Ref{pblIsamGet}() * @field PBLTHIS get key and keylen of current record * @field PBLNEXT get key and keylen of next record * @field PBLPREV get key and keylen of previous record * @field PBLFIRST get key and keylen of first record * @field PBLLAST get key and keylen of last record */#define PBLTHIS 1#define PBLNEXT 2#define PBLPREV 3#define PBLFIRST 4#define PBLLAST 5/** * the maximum length of a key of the key file component, * @doc maximum length of a key, 255 for now */#define PBLKEYLENGTH 255/** * maximum data length of data being stored on index blocks of key files, * @doc maximum length of data stored with an item on the level 0 block, 1024 * @doc data that is longer is stored on data blocks. */#define PBLDATALENGTH 1024/*****************************************************************************//* macros *//*****************************************************************************//* * The PBL_MEMTRACE define can be used for debugging the library, * if defined the library will log a line for all memory chunks * that are allocated for more than 3 minutes into the file ./pblmemtrace.log * * This can be used to detect heap memory lost by the code. * See also function pbl_memtrace_out in pbl.c */ /* #define PBL_MEMTRACE */#ifdef PBL_MEMTRACEextern void pbl_memtrace_delete( void * data );extern void pbl_memtrace_out( int checktime );#define PBL_FREE( ptr ) if( ptr ){ pbl_memtrace_delete( ptr );\ free( ptr ); ptr = 0; }#else/** * make free save against NULL pointers, * @doc also the parameter ptr is set to NULL */#define PBL_FREE( ptr ) if( ptr ){ free( ptr ); ptr = 0; }#endif/** * macros for linear list handling, */#define PBL_LIST_( Parameters )/** * push an element to the beginning of a linear list */#define PBL_LIST_PUSH( HEAD, TAIL, ITEM, NEXT, PREV )\{\ (ITEM)->PREV = 0;\ if(( (ITEM)->NEXT = (HEAD) ))\ { (ITEM)->NEXT->PREV = (ITEM); }\ else\ { (TAIL) = (ITEM); }\ (HEAD) = (ITEM);\}/** * append an element to the end of a linear list */#define PBL_LIST_APPEND( HEAD, TAIL, ITEM, NEXT, PREV )\ PBL_LIST_PUSH( TAIL, HEAD, ITEM, PREV, NEXT )/** * remove an element from a linear list */#define PBL_LIST_UNLINK( HEAD, TAIL, ITEM, NEXT, PREV )\{\ if( (ITEM)->NEXT )\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -