00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef OPENISIS_H
00023
00024
00025
00026
00027
00028
00029
00030 #define OPENISIS_VERSION "0.9.1"
00031
00032 #ifndef __STDC__
00033 # ifndef const
00034 # define const
00035 # endif
00036 #endif
00037
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041
00042
00043
00044
00045
00049 typedef struct OpenIsisField {
00050 int tag;
00051 const char *val;
00052 int len;
00053 } OpenIsisField;
00054
00055
00058 typedef struct OpenIsisRec {
00059 int dbid;
00060 int rowid;
00061 int bytes;
00062 int used;
00063 int fields;
00064 int base;
00065 int len;
00066 int state;
00067 OpenIsisField field[1];
00068 } OpenIsisRec;
00069
00070
00071 #define OPENISIS_BASESZ( nfields ) ((int)sizeof(int)*(8 + 3*(nfields)))
00072
00073
00074 #define OPENISIS_INITREC( r, n, f ) \
00075 do { \
00076 memset( r, 0, n ); \
00077 (r)->bytes = (n); \
00078 (r)->fields = (f); \
00079 (r)->used = (r)->base = OPENISIS_BASESZ( (r)->fields ); \
00080 } while (0)
00081
00082
00083 #define OPENISIS_INITSTD( r, n ) OPENISIS_INITREC( r, n, (n)/100 )
00084
00085 #define OPENISIS_INITBUF( x ) OPENISIS_INITSTD( &x.r, sizeof(x) )
00086 #define OPENISIS_CLRREC( r ) \
00087 do { \
00088 (r)->len = (r)->state = 0; \
00089 (r)->used = (r)->base = OPENISIS_BASESZ( (r)->fields ); \
00090 } while (0)
00091
00092
00093 #define OPENISIS_RECOK( r ) \
00094 ( (r)->base <= (r)->used \
00095 && (r)->used <= (r)->bytes \
00096 && (r)->len <= (r)->fields \
00097 && (r)->base == OPENISIS_BASESZ( (r)->fields ) )
00098
00099
00102 enum {
00103 OPENISIS_FTX = 0,
00104 OPENISIS_FTA = 1,
00105 OPENISIS_FTN = 2,
00106 OPENISIS_FTP = 3,
00107 OPENISIS_FTB = 4,
00108 OPENISIS_FTE = 5,
00109 OPENISIS_FTI = 8,
00110 OPENISIS_FTT = 9,
00111 OPENISIS_FTO = 13,
00112 OPENISIS_FTR = 14,
00113 OPENISIS_FTS = 15,
00114 OPENISIS_FTV = 16,
00115 OPENISIS_FTF = 16
00116 };
00117
00118 #define OPENISIS_FD_NAMELEN 32
00119 typedef struct OpenIsisFd {
00120 int id;
00121 char subf;
00122 char type;
00123 char rep;
00124 char slen;
00125 short len;
00126 char name[OPENISIS_FD_NAMELEN];
00127 char desc[OPENISIS_FD_NAMELEN];
00128 char *pat;
00129 char *dflt;
00130 OpenIsisRec *info;
00131 struct OpenIsisFd **subs;
00132 } OpenIsisFd;
00133
00134
00137 typedef struct {
00138 int len;
00139 OpenIsisFd *fd;
00140 OpenIsisRec *rec;
00141
00142 } OpenIsisFdt;
00143
00144
00145 typedef struct {
00146
00147 unsigned mfn;
00148 unsigned short tag;
00149 unsigned short occ;
00150 unsigned short pos;
00151 unsigned short dbn;
00152 } OpenIsisHit;
00153
00154 typedef struct {
00155 unsigned char len;
00156 unsigned char byt[23];
00157 } OpenIsisVal;
00158
00159 typedef struct {
00160 OpenIsisVal val;
00161 unsigned char len;
00162 unsigned char byt[255];
00163 } OpenIsisKey;
00164
00165
00170 enum {
00171 OPENISIS_XCTL = -1,
00172 OPENISIS_XFST = -2,
00173 OPENISIS_XHIT = -3,
00174 OPENISIS_XADD = -4,
00175 OPENISIS_XDEL = -5
00176 };
00177
00178
00186 extern OpenIsisField *openIsisRGet ( OpenIsisRec *r, int tag, int *pos );
00187
00188 extern OpenIsisField *openIsisROccurence ( OpenIsisRec *r, int tag, int occ );
00189
00194 extern int openIsisA2i ( const char *p, int l );
00199 extern int openIsisA2il ( const char *p, int l, int *res );
00203 extern int openIsisA2id ( const char *p, int l, int dflt );
00208 extern int openIsisI2a ( char *p, int i );
00209 extern int openIsisU2a ( char *p, unsigned u );
00210
00216 extern int openIsisRInt ( OpenIsisRec *r, int tag, int def, int *pos );
00217
00223 extern int openIsisRInt2 (OpenIsisRec *rec,
00224 OpenIsisRec *dflt, int tag, int def);
00225
00230 extern int openIsisREnum ( OpenIsisFdt *fdt,
00231 OpenIsisRec *r, int tag, int def, int *pos );
00232
00237 extern char* openIsisRString (OpenIsisRec *r,
00238 int tag, int *pos, char *buf, int len);
00239
00243 extern char* openIsisRString2 (OpenIsisRec *rec,
00244 OpenIsisRec *dflt, int tag, char *buf, int len);
00245
00256 extern int openIsisRSerialize ( char *buf, OpenIsisRec *rec );
00261 extern int openIsisRSerializeBin ( char *buf, OpenIsisRec *rec );
00262
00270 extern char* openIsisRSerializeAlloc (OpenIsisRec *rec, char *buf, int *len);
00271
00277
00278
00279
00280
00283 extern OpenIsisFd* openIsisFById ( const OpenIsisFdt *fdt, int id, int subf );
00284
00287 extern OpenIsisFd* openIsisFByName (const OpenIsisFdt *fdt, const char *name);
00288
00289 enum {
00290 OPENISIS_NOENUM = 0x10000
00291 };
00292
00297 extern int openIsisFEnum ( OpenIsisFdt *fdt, int id, const char *name );
00298
00302 extern OpenIsisFdt* openIsisFFree (OpenIsisFdt *fdt);
00303
00311 extern OpenIsisRec* openIsisFFdt2Rec (
00312 const OpenIsisFdt *fdt, OpenIsisRec *rec, int embchld);
00313
00318 extern OpenIsisFdt* openIsisFRec2Fdt (OpenIsisRec *rec);
00319
00320
00321
00322
00323
00324
00325 typedef struct OpenIsisSes *OpenIsisSession;
00326
00327 extern void *openIsisMAlloc ( int size );
00328 extern void openIsisMFree ( void *mem );
00329 extern void *openIsisMDup ( const void *str, int size );
00330
00338 extern char *openIsisToHtml ( const char *str, int len );
00339 extern int openIsisUtf8Chk ( void *mem, int len, int *tof );
00340
00341
00342
00343
00344
00345
00346 typedef struct OpenIsisIos *OpenIsisStream;
00347 typedef int OpenIsisSFunc ( OpenIsisStream s, int op );
00348
00349 extern int openIsisSOpen ( const char *name, int flags, OpenIsisSFunc *type );
00350
00354 enum {
00355 OPENISIS_ERR_OK = 0,
00356
00357 OPENISIS_ERR_EOF = 0x10000,
00358
00359 OPENISIS_ERR_FAULT = 0x20000,
00360 OPENISIS_ERR_INVAL = 0x30000,
00361 OPENISIS_ERR_BADF = 0x40000,
00362
00363 OPENISIS_ERR_IO = 0x50000,
00364 OPENISIS_ERR_NOMEM = 0x60000,
00365 OPENISIS_ERR_BUSY = 0x70000,
00366
00367 OPENISIS_ERR_TRASH = 0x80000,
00368 OPENISIS_ERR_IDIOT = 0x90000
00369 };
00370
00371 typedef enum {
00372 OPENISIS_LOG_OFF = 0,
00373 OPENISIS_LOG_FATAL = 0x100000,
00374 OPENISIS_LOG_SYSERR = 0x200000,
00375 OPENISIS_LOG_IOERR = 0x300000,
00376 OPENISIS_LOG_ERROR = 0x400000,
00377 OPENISIS_LOG_WARN = 0x500000,
00378 OPENISIS_LOG_INFO = 0x600000,
00379 OPENISIS_LOG_VERBOSE = 0x700000,
00380 OPENISIS_LOG_TRACE = 0x800000,
00381
00382 OPENISIS_LOG_DEBUG = 0x900000,
00383 OPENISIS_LOG_ALL = 0xa00000
00384 } OpenIsisLogLevel;
00385
00386 enum {
00387 OPENISIS_ERR_ERRORS = 10,
00388 OPENISIS_ERR_MASK = 0xf0000,
00389 OPENISIS_ERR_SHIFT = 16,
00390 OPENISIS_LOG_NOCHANGE = -1,
00391 OPENISIS_LOG_LEVELS = 11,
00392 OPENISIS_LOG_MASK = 0xf00000,
00393 OPENISIS_LOG_SHIFT = 20,
00394
00395
00396
00397
00398
00399 OPENISIS_SIN = 0,
00400 OPENISIS_SOUT = 1,
00401 OPENISIS_SERR = 2,
00402 OPENISIS_SMASK = 0xffff,
00403 OPENISIS_MSG_VA = 0x1000000
00404 };
00405
00425 extern int openIsisSMsg ( int to, const char *fmt, ... );
00426
00436 extern int openIsisSGets ( int fd, char **ptr, char delim );
00437 #define openIsisSReadln( p ) openIsisSGets( 0, p, '\n' )
00438
00439 typedef struct OpenIsisRecStream {
00440 OpenIsisStream in;
00441 int flg;
00442 OpenIsisRec *buf;
00443 OpenIsisRec *rec;
00444 OpenIsisRec *dict;
00445 } OpenIsisRecStream;
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477 enum {
00478 OPENISIS_STOPONEMPTY = 0x10,
00479 OPENISIS_AUTOCLONE = 0x20,
00480 OPENISIS_TRANSPARENT = 0x40,
00481 OPENISIS_MAIL = 0x100,
00482 OPENISIS_MBOX = 0x200,
00483 OPENISIS_DETACH = 0x400,
00484 OPENISIS_CONVERT = 0x800
00485 };
00486
00487 extern int openIsisSGetr ( OpenIsisRecStream *stream );
00488
00489
00490
00491
00492
00493
00494
00505 extern OpenIsisRec* openIsisRDup (
00506 OpenIsisRec *r, int room, int discard );
00507
00508
00512 extern OpenIsisRec* openIsisRMsg (
00513 OpenIsisRec *r, int discard, int tag, const char *fmt, ... );
00514
00521 #define OPENISIS_RSPACE( recp, room, disc ) \
00522 do { if ( ! (recp) \
00523 || (recp)->len >= (recp)->fields \
00524 || (recp)->bytes < (recp)->used + (room) \
00525 ) (recp) = openIsisRDup( (recp), (room), (disc) ); } while (0)
00526
00534 #define OPENISIS_RADD( recp, ntag, s, n, disc ) \
00535 do { \
00536 int _ll = (n); \
00537 OPENISIS_RSPACE( recp, _ll, disc ); \
00538 if ( (recp) ) { \
00539 OpenIsisField *_ff = (recp)->field + (recp)->len++; \
00540 _ff->tag = (ntag); \
00541 _ff->val = ((char*)recp)+(recp)->used; \
00542 if ( ! s ) \
00543 _ff->len = 0; \
00544 else \
00545 memcpy( (char*)_ff->val, s, _ff->len = _ll ); \
00546 (recp)->used += _ff->len; \
00547 } \
00548 } while(0)
00549
00556 #define OPENISIS_RCAT( recp, s, n, disc ) \
00557 do { \
00558 OpenIsisField *_ff; \
00559 int _ll = (n); \
00560 assert ( (recp) ); \
00561 assert ( (recp)->len ); \
00562 if ( (recp)->bytes < (recp)->used + _ll ) \
00563 (recp) = openIsisRDup( (recp), _ll, (disc) ); \
00564 _ff = (recp)->field + (recp)->len - 1; \
00565 memcpy( (char*)(_ff->val+_ff->len), s, _ll ); \
00566 _ff->len += _ll; \
00567 (recp)->used += _ll; \
00568 } while(0)
00569
00570
00571 #define OPENISIS_RADDS( recp, ntag, s, disc ) \
00572 OPENISIS_RADD( recp, ntag, s, strlen(s), disc )
00573
00574 #define OPENISIS_RADDF( recp, f, disc ) \
00575 OPENISIS_RADD( recp, (f)->tag, (f)->val, (f)->len, disc )
00576
00577 #define OPENISIS_RCATS( recp, s, disc ) \
00578 OPENISIS_RCAT( recp, s, strlen(s), disc )
00579
00595 extern OpenIsisRec *openIsisRSplitf (
00596 OpenIsisRec *rec, const OpenIsisField* field );
00597
00598
00599 enum {
00600 OPENISIS_RARGC = 0xffff,
00601 OPENISIS_RFDT = 0x0010000,
00602 OPENISIS_RARGV= 0x0020000,
00603 OPENISIS_RDIS = 0x0040000,
00604 OPENISIS_RNOC = 0x0080000,
00605 OPENISIS_RIGN = 0x0100000,
00606
00607 OPENISIS_RCHG = 0x1000000,
00608 OPENISIS_RDEL = 0x2000000,
00609 OPENISIS_RDFLT= 0x4000000,
00610 OPENISIS_ROP = 0xf000000
00611 };
00612
00629 extern OpenIsisRec *openIsisRSet ( OpenIsisRec *rec, int mode, ... );
00630
00636 extern int openIsisRDeserialize (
00637 OpenIsisRec **rec, const char *buf, int len, int flg );
00638
00639
00643 extern OpenIsisRec *openIsisRAddI (
00644 OpenIsisRec *rec, int tag, int value, int discard);
00645
00646 enum {
00647 OPENISIS_FMT_SHARP = 32,
00648 OPENISIS_FMT_SLASH,
00649 OPENISIS_FMT_PERCENT,
00650 OPENISIS_FMT_OPEN,
00651 OPENISIS_FMT_CLOSE,
00652 OPENISIS_FMT_ESC,
00653 OPENISIS_FMT_B,
00654 OPENISIS_FMT_BOX,
00655 OPENISIS_FMT_BPICT,
00656 OPENISIS_FMT_C,
00657 OPENISIS_FMT_CL,
00658 OPENISIS_FMT_COLS,
00659 OPENISIS_FMT_FONTS,
00660 OPENISIS_FMT_FS,
00661 OPENISIS_FMT_F,
00662 OPENISIS_FMT_I,
00663 OPENISIS_FMT_LINK,
00664 OPENISIS_FMT_LW,
00665 OPENISIS_FMT_M,
00666 OPENISIS_FMT_NC,
00667 OPENISIS_FMT_NEWLINE,
00668 OPENISIS_FMT_NP,
00669 OPENISIS_FMT_PICT,
00670 OPENISIS_FMT_QC,
00671 OPENISIS_FMT_QJ,
00672 OPENISIS_FMT_TAB,
00673 OPENISIS_FMT_UL,
00674 OPENISIS_FMT_X
00675 };
00676
00677 extern OpenIsisRec* openIsisRFmt (
00678 OpenIsisRec *buf, const char *fmt, OpenIsisRec *r );
00679
00680
00681
00682
00683
00684
00685
00691 extern int openIsisDMaxId ( int dbid );
00692
00700 extern OpenIsisRec *openIsisDRead ( int db, int rowid );
00701
00705 extern OpenIsisRec *openIsisDFmt (
00706 OpenIsisRec *buf, const char *fmt, int db, int rowid );
00707
00708
00717 extern int openIsisDWritex ( int dbid, OpenIsisRec *rec,
00718 OpenIsisRec *idx );
00719
00724 extern int openIsisDWrite ( int dbid, OpenIsisRec *rec );
00725 #define OPENISIS_DWRITE( rec ) openIsisDWrite( (rec)->dbid, rec )
00726
00727
00738 extern OpenIsisRec *openIsisDScan (
00739 int db, int rowid, int tag, const char *key );
00740
00752 extern OpenIsisRec* openIsisDTerm (
00753 OpenIsisRec *rec, int db, const char *key );
00754
00755
00756 #ifndef OPENISIS_SETLEN
00757 #define OPENISIS_SETLEN 1000
00758 #endif
00759
00765 typedef struct {
00766 int len;
00767 int id[OPENISIS_SETLEN];
00768 } OpenIsisSet;
00769
00770
00771
00772 enum {
00773
00774 OPENISIS_QRY_KEYEQ,
00775 OPENISIS_QRY_KEYPF,
00776 OPENISIS_QRY_KEYAT,
00777
00778 OPENISIS_QRY_SCANE=64,
00779 OPENISIS_QRY_SCANC,
00780
00781 OPENISIS_QRY_SIMPLE=128,
00782 OPENISIS_QRY_PROPER
00783 };
00784
00785
00798 extern int openIsisDQuery ( OpenIsisSet *set, int db,
00799 const char *key, int mode, int skip );
00800
00801
00805 typedef int OpenIsisDXCb ( void *me, OpenIsisKey *key, OpenIsisHit *hit );
00806
00807 typedef struct {
00808 int flg;
00809 void *me;
00810 OpenIsisDXCb *cb;
00811 OpenIsisKey key;
00812 OpenIsisKey to;
00813 } OpenIsisDXLoop;
00814
00815 enum {
00816 OPENISIS_IDXPF = 0,
00817 OPENISIS_IDXEQ = 1,
00818 OPENISIS_IDXUPTO = 2,
00819 OPENISIS_IDXINCL = 3,
00820 OPENISIS_IDXMODE = 0x03,
00821 OPENISIS_IDXTRAD = 0x10000
00822 };
00823
00826 extern int openIsisDXLoop ( int dbid, OpenIsisDXLoop *l );
00827
00828
00829
00830
00831
00832
00833
00834 enum {
00835
00836 OPENISIS_SEA_KEY = 1,
00837 OPENISIS_SEA_NHITS = 2,
00838 OPENISIS_SEA_HIT = 3,
00839
00840 OPENISIS_SPATH = 5,
00841 OPENISIS_SLOGF = 700,
00842 OPENISIS_SLOGV = 701,
00843
00844 OPENISIS_SC_NAME = 710,
00845 OPENISIS_SC_HOST = 711,
00846 OPENISIS_SC_PORT = 712,
00847 OPENISIS_SC_DFLTDB = 721,
00848
00849 OPENISIS_DNAME = 800,
00850 OPENISIS_DTYPE = 801,
00851 OPENISIS_DRO = 802,
00852 OPENISIS_DPATH = 803,
00853 OPENISIS_DDUMP = 804,
00854 OPENISIS_DENC = 810,
00855 OPENISIS_DFDT = 811,
00856 OPENISIS_DFMT = 850,
00857 OPENISIS_DPFT = 851,
00858 OPENISIS_DFST = 852,
00859
00860 OPENISIS_FDID = 860,
00861 OPENISIS_FDSUB = 861,
00862 OPENISIS_FDTYPE = 862,
00863 OPENISIS_FDREP = 863,
00864 OPENISIS_FDNUMC = 864,
00865 OPENISIS_FDLEN = 865,
00866 OPENISIS_FDNAME = 866,
00867 OPENISIS_FDDESC = 867,
00868 OPENISIS_FDPAT = 868,
00869 OPENISIS_FDDFLT = 869,
00870 OPENISIS_FDINFO = 870,
00871 OPENISIS_FDCHLD = 871,
00872 OPENISIS_FDT_LEN = 880,
00873 OPENISIS_FDT_FD = 881,
00874 OPENISIS_FDT_REC = 882,
00875
00876 OPENISIS_COM_SID = 900,
00877 OPENISIS_COM_SER = 901,
00878 OPENISIS_COM_DBN = 902,
00879 OPENISIS_COM_TMS = 903,
00880 OPENISIS_COM_ROW = 904,
00881 OPENISIS_COM_CFG = 907,
00882 OPENISIS_COM_REC = 908,
00883
00884 OPENISIS_RQS_TYPE = 920,
00885 OPENISIS_RQS_FLG = 921,
00886 OPENISIS_RQS_QMOD = 922,
00887 OPENISIS_RQS_SKIP = 923,
00888 OPENISIS_RQS_SIZE = 924,
00889 OPENISIS_RQS_KEY = 925,
00890 OPENISIS_RQS_IDX = 926,
00891 OPENISIS_RQS_KUP = 927,
00892 OPENISIS_RQS_TAG = 928,
00894 OPENISIS_RSP_DBID = 940,
00895 OPENISIS_RSP_ERR = 941,
00896 OPENISIS_RSP_MSG = 942,
00897 OPENISIS_RSP_NUMT = 943,
00898 OPENISIS_RSP_NUMR = 944,
00899 OPENISIS_RSP_CERR = 945
00900 };
00901
00902 extern const OpenIsisFdt *openIsisFdtSyspar;
00903 extern const OpenIsisFdt *openIsisFdtScheme;
00904 extern const OpenIsisFdt *openIsisFdtDbpar;
00905 extern const OpenIsisFdt *openIsisFdtFd;
00906 extern const OpenIsisFdt *openIsisFdtFdt;
00907 extern const OpenIsisFdt *openIsisFdtRqs;
00908 extern const OpenIsisFdt *openIsisFdtRsp;
00909 extern const OpenIsisFdt *openIsisFdtHit;
00910
00912 enum {
00913 OPENISIS_RQST_OPEN = 1,
00914 OPENISIS_RQST_CLOS = 3,
00915 OPENISIS_RQST_MNT = 4,
00916 OPENISIS_RQST_LSDB = 6,
00917 OPENISIS_RQST_MROW = 10,
00918 OPENISIS_RQST_QRY = 11,
00919 OPENISIS_RQST_READ = 12,
00920 OPENISIS_RQST_SEA = 15,
00921 OPENISIS_RQST_INS = 20,
00922 OPENISIS_RQST_UPD = 21,
00923 OPENISIS_RQST_DEL = 22,
00924 OPENISIS_RQST_EVAL = 30
00925 };
00926
00928 enum {
00929 OPENISIS_RQSF_MNT = 0x0001,
00930 OPENISIS_RQSF_QRR = 0x0002,
00931 OPENISIS_RQSF_SENH = 0x0004
00932 };
00933
00935 #define OPENISIS_QRY_KEYLEN 1024
00936
00937 #define OPENISIS_ERRMSGLEN 1024
00938
00939 enum {
00940 OPENISIS_RELE = 0x0000000,
00941 OPENISIS_LOCK = 0x1000000,
00942 OPENISIS_WAKE = 0x2000000,
00943 OPENISIS_WAIT = 0x3000000,
00944 OPENISIS_COND = 0x0ffffff
00945 };
00967 typedef int OpenIsisCLockFunc ( int lock );
00968
00972 extern int openIsisCInit ( int argc, const char **argv,
00973 OpenIsisCLockFunc lock );
00974
00984 extern void openIsisCLog ( int level, const char *filename );
00985
00986
00991 extern OpenIsisSession openIsisCOpen ( OpenIsisRec *args );
00992
00997 extern OpenIsisSession openIsisCSession ( OpenIsisRec *args );
00998
00999
01000
01001
01002
01003
01004 #define OPENISIS_SC_NAMELEN 32
01005 #define OPENISIS_DB_NAMELEN 32
01006
01007 #define OPENISIS_SCIDMSK 0x0ff00
01008 #define OPENISIS_DBIDMSK 0x000ff
01009
01010 typedef struct {
01011 char name[OPENISIS_DB_NAMELEN];
01012 int dbid;
01013 int mntcnt;
01014 int tms;
01015 OpenIsisRec *cfg;
01016 OpenIsisFdt *fdt;
01017 } OpenIsisDb;
01018
01019 typedef struct {
01020 char name[OPENISIS_SC_NAMELEN];
01021 int scid;
01022 int mntcnt;
01023 OpenIsisRec *cfg;
01024 int ndbs;
01025 OpenIsisDb **dbs;
01026 } OpenIsisSchema;
01027
01028
01029
01030
01031
01032 typedef struct OpenIsisStb *OpenIsisStub;
01033
01036 typedef int OpenIsisStbRqsProc (OpenIsisStub stb, OpenIsisRec *rqs);
01037
01041 typedef void OpenIsisStbDelProc (OpenIsisStub stb, void *client_data);
01042
01045 typedef int OpenIsisRspCb (void *client_data,
01046 OpenIsisStub stub, OpenIsisRec *response, OpenIsisDb *db);
01047
01048 typedef struct {
01049
01050
01051
01052 int (*sendproc) (OpenIsisStub stub, OpenIsisRec *rqs);
01053
01054 OpenIsisRspCb *dfltcb;
01055
01056
01057
01058 void (*delcb) (void *cld, OpenIsisStub session, void *cbd);
01059
01060 void *dfltcld;
01061
01062 void *delcld;
01063 } OpenIsisStubCbData;
01064
01065 extern OpenIsisStub openisis_stub0;
01066
01069 extern OpenIsisStub openIsisNInit (
01070 int argc, const char **argv, OpenIsisStubCbData *dta
01071 );
01072
01075 extern void openIsisNDeinit ();
01076
01079 extern OpenIsisStub openIsisNOpen (
01080 const char *name, int argc, const char **argv, OpenIsisStubCbData *dta
01081 );
01082
01085 extern void openIsisNClose (OpenIsisStub stub);
01086
01089 extern OpenIsisSchema* openIsisNSchema (OpenIsisStub stub);
01090
01102 extern int openIsisNSend (
01103 OpenIsisStub stub, OpenIsisRec *rqs,
01104 OpenIsisRspCb *actcb, void *actcld, int rdup
01105 );
01106
01110 extern OpenIsisRec *openIsisNRecv (OpenIsisStub stub, OpenIsisDb **db);
01111
01114 extern void openIsisNClean (OpenIsisStub stub);
01115
01118 extern int openIsisNGetResult (OpenIsisStub stub,
01119 int **rowids, OpenIsisRec ***recs, int *total,
01120 OpenIsisDb **db, OpenIsisRec **rqs);
01121
01127 extern void openIsisNNotifyResponse (OpenIsisStub stub, OpenIsisRec **rsp);
01128
01134 extern void openIsisNNotifyError (OpenIsisStub stub, int errcode);
01135
01138 extern struct CliChnl* openIsisNGetChannel (OpenIsisStub stub);
01139
01142 extern OpenIsisDb *openIsisNDbByName (OpenIsisStub stub, const char *dbname);
01143
01146 extern OpenIsisDb *openIsisNDbById (int dbid);
01147
01148
01149
01150
01151
01152
01187 extern OpenIsisDb* openIsisCDOpen ( const char *dbname,
01188 OpenIsisRec *dbpar, OpenIsisRec *syspar, OpenIsisFdt *fdt );
01196 extern int openIsisCDOpenv ( const char *dbname, const char **argv, int argc );
01197
01198 enum {
01199 OPENISIS_CHK_ONLY = 0x01,
01200 OPENISIS_CHK_XRF = 0x02,
01201 OPENISIS_CHK_FIX = 0xfe,
01202 OPENISIS_CHK_ALL = 0xff
01203 };
01206 extern int openIsisCDCheck ( int dbid, int flags );
01207
01208
01209
01215 extern int openIsisCDClose ( int dbid );
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225 typedef struct OpenIsisIdx *OpenIsisIndex;
01226
01232 extern OpenIsisIndex openIsisCXOpen ( int dbid, int mode );
01233
01239 extern int openIsisCXAdd ( OpenIsisIndex idx,
01240 OpenIsisKey *key, OpenIsisHit *hit );
01241
01242 #define openIsisCXClose( idx ) openIsisCXAdd( idx, 0, 0 )
01243
01244 #ifdef _REENTRANT
01245 extern int openisis_threaded;
01246 #endif
01247
01248
01249
01250
01251
01256 typedef struct {
01257
01258
01259
01260
01261
01262 int tag;
01263 int off;
01264 int len;
01265 } OpenIsisFld;
01266
01269 typedef struct {
01270 int dbid;
01271 int rowid;
01272 int bytes;
01273 int used;
01274 int fields;
01275 int base;
01276 int len;
01277 int state;
01278 OpenIsisFld field[1];
01279 } OpenIsisRaw;
01280
01282 extern OpenIsisRaw *openIsisDRaw ( int db, int rowid );
01283
01284 #ifndef OPENISIS_NOPRE09
01285
01286
01287
01288 #define openIsis2Html( str, len ) \
01289 openIsisToHtml ( str, len )
01290 #define openIsisValidUTF8( mem, len, tof ) \
01291 openIsisUtf8Chk ( mem, len, tof )
01292
01293
01294 #define openIsisClone( r, ro, d ) \
01295 openIsisRDup( r, ro, d )
01296
01297
01298
01299
01300 #define OPENISIS_CHKFREE( recp, room, disc ) \
01301 OPENISIS_RSPACE( recp, room, disc )
01302 #define OPENISIS_ADD( recp, ntag, s, n, disc ) \
01303 OPENISIS_RADD( recp, ntag, s, n, disc )
01304 #define OPENISIS_CAT( recp, s, n, disc ) \
01305 OPENISIS_RCAT( recp, s, n, disc )
01306 #define OPENISIS_SADD( recp, ntag, s, disc ) \
01307 OPENISIS_RADDS( recp, ntag, s, disc )
01308 #define OPENISIS_SCAT( recp, s, disc ) \
01309 OPENISIS_RCATS( recp, s, disc )
01310 #define openIsisReadField( rec, f ) \
01311 openIsisRSplitf( rec, f )
01312 #define openIsisFmt( buf, fmt, r ) \
01313 openIsisRFmt( buf, fmt, r )
01314 #define openIsisReadStream( stream ) \
01315 openIsisSGetr( stream )
01316
01317
01318 #define openIsisMaxRowid( db ) \
01319 openIsisDMaxId( db )
01320 #define openIsisReadRow( db, rowid ) \
01321 openIsisDRead( db, rowid )
01322 #define openIsisReadRaw( db, rowid ) \
01323 openIsisDRaw( db, rowid )
01324 #define openIsisRead( buf, fmt, db, rowid ) \
01325 openIsisDFmt( buf, fmt, db, rowid )
01326 #define openIsisWrite( db, r ) \
01327 openIsisDWrite( db, r )
01328 #define openIsisWritex( db, r, i ) \
01329 openIsisDWritex( db, r, i )
01330 #define openIsisScan( db, rowid, tag, key ) \
01331 openIsisDScan( db, rowid, tag, key )
01332 #define openIsisTerm( rec, db, key ) \
01333 openIsisDTerm( rec, db, key )
01334 #define openIsisQuery( set, db, key, mode, skip ) \
01335 openIsisDQuery( set, db, key, mode, skip )
01336
01337 #define OpenIsisIdxCb OpenIsisDXCb
01338 #define OpenIsisIdxLoop OpenIsisDXLoop
01339 #define openIsisIdxLoop( dbis, cb ) \
01340 openIsisDXLoop( dbis, cb )
01341
01342
01343 #define openIsisLog openIsisCLog
01344 #define OpenIsisLockFunc OpenIsisCLockFunc
01345 #define openIsisInit( argc, argv, lock ) \
01346 openIsisCInit( argc, argv, lock )
01347 #define openIsisSesGet( id, args ) \
01348 (id) ? openIsisCSession( args ) : openIsisCOpen( args )
01349
01350 #define openIsisOpen openIsisCDOpenv
01351 #define openIsisCheck openIsisCDCheck
01352 #define openIsisClose openIsisCDClose
01353
01354 #define openIsisIdxOpen openIsisCXOpen
01355 #define openIsisIdxAdd openIsisCXAdd
01356 #define openIsisIdxDone( idx ) openIsisCXClose( idx )
01357
01358 #endif
01359
01360 #ifdef __cplusplus
01361 }
01362 #endif
01363 #define OPENISIS_H
01364 #endif