00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef __XB_XBASE_H__
00043 #define __XB_XBASE_H__
00044
00045 #ifdef __GNU LesserG__
00046 #pragma interface
00047 #endif
00048
00049 #ifdef __WIN32__
00050 #include <xbase64/xbwincfg.h>
00051 #else
00052 #include <xbase64/xbconfig.h>
00053 #endif
00054
00055 #include <string.h>
00056
00057 #if defined(__WIN32__)
00058 #include "windows.h"
00059
00060
00061
00062
00063 #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__GNU LesserC__)
00064 # ifdef XBMAKINGDLL
00065 # define XBDLLEXPORT __declspec( dllexport )
00066 # define XBDLLEXPORT_DATA(type) __declspec( dllexport ) type
00067 # define XBDLLEXPORT_CTORFN
00068 # elif defined(XBUSINGDLL)
00069 # define XBDLLEXPORT __declspec( dllimport )
00070 # define XBDLLEXPORT_DATA(type) __declspec( dllimport ) type
00071 # define XBDLLEXPORT_CTORFN
00072 # else
00073 # define XBDLLEXPORT
00074 # define XBDLLEXPORT_DATA(type) type
00075 # define XBDLLEXPORT_CTORFN
00076 # endif
00077
00078 #else
00079
00080 # define XBDLLEXPORT
00081 # define XBDLLEXPORT_DATA(type) type
00082 # define XBDLLEXPORT_CTORFN
00083 #endif
00084
00085 #else // !Windows
00086 # define XBDLLEXPORT
00087 # define XBDLLEXPORT_DATA(type) type
00088 # define XBDLLEXPORT_CTORFN
00089 #endif // Win/!Win
00090
00091
00092 #define XB_SINGLE_USER_MODE 0
00093 #define XB_UNLOCK 200
00094 #define XB_LOCK 201
00095 #define XB_LOCK_HOLD 202
00096
00097 #ifdef XB_LOCKING_ON
00098
00099 #ifdef HAVE_SYS_LOCKING_H
00100 #include <sys/locking.h>
00101 #ifdef __MINGW32__
00102 #defibe locking _locking
00103 #endif
00104 #endif
00105
00106 #ifdef HAVE_FCNTL_H
00107 #include <fcntl.h>
00108 #endif
00109
00110 #ifdef HAVE_UNISTD_H
00111 #include <unistd.h>
00112 #endif
00113
00114 #define XB_XBASE_LOCK_MODE 200
00115 #define XB_DBASE5_LOCK_MODE 201
00116 #define XB_CLIPPER5_LOCK_MODE 202
00117 #define XB_FOXPRO3_LOCK_MODE 203
00118
00119 #endif // XB_LOCKING_ON
00120
00121 #include "xbtypes.h"
00122 #include "xbretcod.h"
00123 #include "xbdate.h"
00124 #include "xbstring.h"
00125
00126 #ifndef XB_MIN
00127 #define XB_MIN(a, b) (((a) < (b)) ? (a) : (b))
00128 #endif
00129
00130
00131
00132
00133
00134
00138 class XBDLLEXPORT xbDbf;
00139
00141
00143 struct XBDLLEXPORT xbDbList{
00144 xbDbList * NextDbf;
00145 char * DbfName;
00146 xbDbf * dbf;
00147 };
00148
00150
00152 class XBDLLEXPORT xbXBase {
00153 public:
00154 ~xbXBase();
00155 xbXBase();
00156 xbShort AddDbfToDbfList(xbDbf *d, const char *DatabaseName);
00157 xbDbf * GetDbfPtr( const char *Name );
00158 xbShort DirectoryExistsInName( const char *Name );
00159 xbShort GetEndianType() { return EndianType; }
00160 void DisplayError( xbShort ErrorCode ) const;
00161 static const char* GetErrorMessage( xbShort ErrorCode );
00162 xbString & GetDefaultDateFormat() { return DefaultDateFormat; }
00163 void SetDefaultDateFormat( const xbString & f ){ DefaultDateFormat = f; }
00164
00165
00166 xbDouble GetDouble( const char *p );
00167 xbLong GetLong ( const char *p );
00168 xbULong GetULong ( const char *p );
00169 xbShort GetShort ( const char *p );
00170 xbULong GetHBFULong( const char *p );
00171 xbShort GetHBFShort ( const char *p );
00172
00173 void PutLong ( char *p, const xbLong l );
00174 void PutShort ( char *p, const xbShort s );
00175 void PutULong ( char *p, const xbULong l );
00176 void PutUShort( char *p, const xbUShort s );
00177 void PutDouble( char *p, const xbDouble d );
00178
00179 xbShort RemoveDbfFromDbfList( xbDbf * );
00180
00181 #ifdef XB_LOCKING_ON
00182 xbShort GetLockRetryCount(){ return LockRetryCount; }
00183 void SetLockRetryCount( xbShort lrc ) { LockRetryCount = lrc; }
00184 xbShort LockFile( int fn, xbShort type, xbOffT len );
00185 xbShort GetLockMode() { return LockMode; }
00186 xbShort SetLockMode( xbShort nlm );
00187 #endif
00188
00189 protected:
00190 xbDbList * DbfList;
00191 xbDbList * FreeDbfList;
00192 xbShort EndianType;
00193
00194 private:
00195 xbString DefaultDateFormat;
00196
00197 #ifdef XB_LOCKING_ON
00198 xbShort LockRetryCount;
00199 xbShort LockMode;
00200 #endif
00201 };
00202
00203 #include "xbdbf.h"
00204
00205 #if defined(XB_EXPRESSIONS)
00206 #include "xbexp.h"
00207 #endif
00208
00209 #if defined(XB_INDEX_ANY)
00210 #include "xbindex.h"
00211 #include "xbmindex.h"
00212 #endif
00213
00214 #ifdef XB_LOCKING_ON
00215 #include "xblock.h"
00216 #endif
00217
00218 #ifdef XB_INDEX_NDX
00219 #include "xbndx.h"
00220 #endif
00221
00222 #ifdef XB_INDEX_NTX
00223 #include "xbntx.h"
00224 #endif
00225
00226 #ifdef XB_INDEX_CDX
00227 #include "xbcdx.h"
00228 #endif
00229
00230 #if defined(XB_FILTERS) && !defined(XB_INDEX_ANY)
00231 #error XB_FILTERS cant be used without index support
00232 #elif defined(XB_FILTERS)
00233 #include "xbfilter.h"
00234 #endif
00235
00236 #endif // __XB_XBASE_H__
00237
00238
00239