GnuCOBOL  2.0
A free COBOL compiler
isinternal.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003 Trevor van Bremen
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 2.1,
7  * or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; see the file COPYING.LIB. If
16  * not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor
17  * Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef VB_LIBVBISAM_H
21 #define VB_LIBVBISAM_H
22 
23 #include "config.h"
24 
25 /* Note : following are pulled in from config.h : */
26 /* ISAMMODE - ISAM Mode */
27 /* HAVE_LFS64 - 64 bit file I/O */
28 /* VBDEBUG - Debugging mode */
29 
30 #ifdef WITH_LFS64
31 #define _LFS64_LARGEFILE 1
32 #define _LFS64_STDIO 1
33 #define _FILE_OFFSET_BITS 64
34 #define _LARGEFILE64_SOURCE 1
35 #define __USE_LARGEFILE64 1
36 #define __USE_FILE_OFFSET64 1
37 #ifdef _AIX
38 #define _LARGE_FILES 1
39 #endif /* _AIX */
40 #if defined(__hpux__) && !defined(__LP64__)
41 #define _APP32_64BIT_OFF_T 1
42 #endif
43 #endif
44 
45 #ifdef HAVE_UNISTD_H
46 #include <unistd.h>
47 #endif
48 #include <stdio.h>
49 #include <sys/types.h>
50 #include <sys/stat.h>
51 #include <ctype.h>
52 #ifdef HAVE_FCNTL_H
53 #include <fcntl.h>
54 #endif
55 #include <stdlib.h>
56 #include <string.h>
57 #include <errno.h>
58 #include <time.h>
59 #include <limits.h>
60 #include <float.h>
61 
62 #ifdef _WIN32
63 #define WINDOWS_LEAN_AND_MEAN
64 #include <windows.h>
65 #include <io.h>
66 #include <sys/locking.h>
67 #define open(x, y, z) _open(x, y, z)
68 #define read(x, y, z) _read(x, y, z)
69 #define write(x, y, z) _write(x, y, z)
70 #ifdef WITH_LFS64
71 #define lseek(x, y, z) _lseeki64(x, y, z)
72 #else
73 #define lseek(x, y, z) _lseek(x, y, z)
74 #endif
75 #define close(x) _close(x)
76 #define unlink(x) _unlink(x)
77 #define fsync _commit
78 typedef int uid_t;
79 #ifndef _PID_T_
80 typedef int pid_t;
81 #endif
82 #ifndef _MODE_T_
83 typedef unsigned short mode_t;
84 #endif
85 #ifndef _SSIZE_T_
86 typedef int ssize_t;
87 #endif
88 #endif
89 
90 #ifdef _MSC_VER
91 
92 #define _CRT_SECURE_NO_DEPRECATE 1
93 #define inline _inline
94 #include <malloc.h>
95 #pragma warning(disable: 4996)
96 #define strncasecmp _strnicmp
97 #define strcasecmp _stricmp
98 #define __attribute__(x)
99 #define __i386__
100 
101 #endif /* _MSC_VER */
102 
103 #ifdef __370__
104 #define inline __inline
105 #endif
106 
107 #if ISAMMODE == 1
108 #define QUADSIZE 8
109 #define VB_OFFLEN_7F 0x7fffffffffffffffLL
110 #define VB_OFFLEN_3F 0x3fffffffffffffffLL
111 #define VB_OFFLEN_40 0x4000000000000000LL
112 #else
113 #define QUADSIZE 4
114 #define VB_OFFLEN_7F 0x7FFFFFFF
115 #define VB_OFFLEN_3F 0x3FFFFFFF
116 #define VB_OFFLEN_40 0x40000000
117 #endif
118 
119 #define MAXSUBS 32 /* Maximum number of indexes per table */
120 #define VB_MAX_FILES 128 /* Maximum number of open VBISAM files */
121 
122 #define VBISAM_LIB
123 #include "vbisam.h"
124 #include "byteswap.h"
125 
126 #if defined(__GNUC__) && defined(linux) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
127 #define VB_HIDDEN __attribute__ ((visibility("hidden")))
128 #else
129 #define VB_HIDDEN
130 #endif
131 
132 #ifndef O_BINARY
133 #define O_BINARY 0
134 #endif
135 
136 #ifdef WITH_LFS64
137 #ifdef _MSC_VER
138 #define off_t __int64
139 #endif
140 #endif
141 
142 #ifdef HAVE_BUILTIN_EXPECT
143 #define likely(x) __builtin_expect(!!(x), 1)
144 #define unlikely(x) __builtin_expect(!!(x), 0)
145 #else
146 #define likely(x) (x)
147 #define unlikely(x) (x)
148 #endif
149 
150 typedef unsigned char * ucharptr;
151 
152 #if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__ppc__) && !defined(__amd64__)
153  #if defined(_MSC_VER)
154  #define ALLOW_MISALIGNED
155  #define MISALIGNED __unaligned
156  #else
157  #define MISALIGNED
158  #endif
159 #else
160  #define ALLOW_MISALIGNED
161  #define MISALIGNED
162 #endif
163 
164 /* Inline versions of load/store routines */
165 
166 #if defined(ALLOW_MISALIGNED) && !defined(WORDS_BIGENDIAN)
167 #define inl_ldint(x) (int)(VB_BSWAP_16(*((unsigned short MISALIGNED *)(x))))
168 #else
169 static inline int
170 inl_ldint (void *pclocation)
171 {
172 #ifndef WORDS_BIGENDIAN
173  return (int)VB_BSWAP_16(*(unsigned short MISALIGNED *)pclocation);
174 #else
175  short ivalue = 0;
176  unsigned char *pctemp = (unsigned char *) &ivalue;
177  unsigned char *pctemp2 = (unsigned char *) pclocation;
178 
179  *(pctemp + 0) = *(pctemp2 + 0);
180  *(pctemp + 1) = *(pctemp2 + 1);
181  return (int)ivalue;
182 #endif
183 }
184 #endif
185 
186 #if defined(ALLOW_MISALIGNED) && !defined(WORDS_BIGENDIAN)
187 #define inl_stint(x,y) *(unsigned short MISALIGNED *)(y) = VB_BSWAP_16((unsigned short)(x));
188 #else
189 static inline void
190 inl_stint (int ivalue, void *pclocation)
191 {
192 #ifndef WORDS_BIGENDIAN
193  *(unsigned short MISALIGNED *)pclocation = VB_BSWAP_16((unsigned short)ivalue);
194 #else
195  unsigned char *pctemp = (char *) &ivalue;
196  unsigned char *pctemp2 = (unsigned char *) pclocation;
197 
198  *(pctemp2 + 0) = *(pctemp + 0 + INTSIZE);
199  *(pctemp2 + 1) = *(pctemp + 1 + INTSIZE);
200 #endif
201  return;
202 }
203 #endif
204 
205 #if defined(ALLOW_MISALIGNED) && !defined(WORDS_BIGENDIAN)
206 #define inl_ldlong(x) (int)(VB_BSWAP_32(*((unsigned short MISALIGNED *)(x))))
207 #else
208 static inline int
209 inl_ldlong (void *pclocation)
210 {
211 #ifndef WORDS_BIGENDIAN
212  return VB_BSWAP_32(*(unsigned int MISALIGNED *)pclocation);
213 #else
214  int lvalue;
215 
216  memcpy((unsigned char *)&lvalue, (unsigned char *)pclocation, 4);
217  return lvalue;
218 #endif
219 }
220 #endif
221 
222 #if defined(ALLOW_MISALIGNED) && !defined(WORDS_BIGENDIAN)
223 #define inl_stlong(x,y) *(unsigned int MISALIGNED *)(y) = VB_BSWAP_32((unsigned int)(x));
224 #else
225 static inline void
226 inl_stlong (int lvalue, void *pclocation)
227 {
228 #ifndef WORDS_BIGENDIAN
229  *(unsigned int MISALIGNED *)pclocation = VB_BSWAP_32((unsigned int)lvalue);
230 #else
231  memcpy((unsigned char *)pclocation, (unsigned char *)&lvalue, 4);
232 #endif
233  return;
234 }
235 #endif
236 
237 static inline off_t
238 inl_ldquad (void *pclocation)
239 {
240 
241 #ifndef WORDS_BIGENDIAN
242 #if ISAMMODE == 1
243  return VB_BSWAP_64(*(unsigned long long MISALIGNED *)pclocation);
244 #else
245  return VB_BSWAP_32(*(unsigned int MISALIGNED *)pclocation);
246 #endif
247 #else
248  off_t tvalue = 0;
249 
250 #if ISAMMODE == 1
251  memcpy((unsigned char *)&tvalue, (unsigned char *)pclocation, 8);
252 #else
253  memcpy((unsigned char *)&tvalue, (unsigned char *)pclocation, 4);
254 #endif
255  return tvalue;
256 #endif
257 }
258 
259 static inline void
260 inl_stquad (off_t tvalue, void *pclocation)
261 {
262 #ifndef WORDS_BIGENDIAN
263 #if ISAMMODE == 1
264  *(unsigned long long MISALIGNED *)pclocation = VB_BSWAP_64((unsigned long long)tvalue);
265 #else
266  *(unsigned int MISALIGNED *)pclocation = VB_BSWAP_32((unsigned int)tvalue);
267 #endif
268 #else
269 #if ISAMMODE == 1
270  memcpy((unsigned char *)pclocation, (unsigned char *)&tvalue, 8);
271 #else
272  memcpy((unsigned char *)pclocation, (unsigned char *)&tvalue, 4);
273 #endif
274 #endif
275  return;
276 }
277 
278 /* Implementation limits */
279 /* 64-bit versions have a maximum node length of 4096 bytes */
280 /* 32-bit versions have a maximum node length of 1024 bytes */
281 
282 #if ISAMMODE == 1
283 #define MAX_NODE_LENGTH 4096
284 #else
285 #define MAX_NODE_LENGTH 1024
286 #endif
287 
288 #define VB_NODE_MAX 4096
289 #define MAX_ISREC_LENGTH 32511
290 #define MAX_RESERVED_LENGTH 32768 /* Greater then MAX_ISREC_LENGTH */
291 #define MAX_BUFFER_LENGTH 65536
292 
293 /* Arguments to ivblock */
294 #define VBUNLOCK 0 /* Unlock */
295 #define VBRDLOCK 1 /* A simple read lock, non-blocking */
296 #define VBRDLCKW 2 /* A simple read lock, blocking */
297 #define VBWRLOCK 3 /* An exclusive write lock, non-blocking */
298 #define VBWRLCKW 4 /* An exclusive write lock, blocking */
299 
300 /* Values for ivbrcvmode (used to control how isrecover works) */
301 #define RECOV_C 0x00 /* Boring old buggy C-ISAM mode */
302 #define RECOV_VB 0x01 /* New, improved error detection */
303 #define RECOV_LK 0x02 /* Use locks in isrecover (See documentation) */
304 
305 /* Values for ivbintrans */
306 #define VBNOTRANS 0 /* NOT in a transaction at all */
307 #define VBBEGIN 1 /* An isbegin has been issued but no more */
308 #define VBNEEDFLUSH 2 /* Something BEYOND just isbegin has been issued */
309 #define VBCOMMIT 3 /* We're in 'iscommit' mode */
310 #define VBROLLBACK 4 /* We're in 'isrollback' mode */
311 #define VBRECOVER 5 /* We're in 'isrecover' mode */
312 
313 VB_HIDDEN extern int ivbintrans;
314 VB_HIDDEN extern int ivblogfilehandle;
315 VB_HIDDEN extern int ivbmaxusedhandle;
316 
317 struct VBLOCK {
318  struct VBLOCK *psnext;
319  int ihandle; /* The handle that 'applied' this lock */
320  off_t trownumber;
321 };
322 
323 struct VBKEY {
324  struct VBKEY *psnext; /* Next key in this node */
325  struct VBKEY *psprev; /* Previous key in this node */
326  struct VBTREE *psparent; /* Pointer towards ROOT */
327  struct VBTREE *pschild; /* Pointer towards LEAF */
328  off_t trownode; /* The row / node number */
329  off_t tdupnumber; /* The duplicate number (1st = 0) */
330  unsigned char iisnew; /* If this is a new entry (split use) */
331  unsigned char iishigh; /* Is this a GREATER THAN key? */
332  unsigned char iisdummy; /* A simple end of node marker */
333  unsigned char spare[5]; /* Spare */
334  unsigned char ckey[1]; /* Placeholder for the key itself */
335 };
336 
337 struct VBTREE {
338  struct VBTREE *psnext; /* Used for the free list only! */
339  struct VBTREE *psparent; /* The next level up from this node */
340  struct VBKEY *pskeyfirst; /* Pointer to the FIRST key in this node */
341  struct VBKEY *pskeylast; /* Pointer to the LAST key in this node */
342  struct VBKEY *pskeycurr; /* Pointer to the CURRENT key */
343  off_t tnodenumber; /* The actual node */
344  off_t ttransnumber; /* Transaction number stamp */
345  unsigned int ilevel; /* The level number (0 = LEAF) */
346  unsigned int ikeysinnode; /* # keys in pskeylist */
347  unsigned char iisroot; /* 1 = This is the ROOT node */
348  unsigned char iistof; /* 1 = First entry in index */
349  unsigned char iiseof; /* 1 = Last entry in index */
350  unsigned char spare[5]; /* Spare */
351 #if ISAMMODE == 1 /* Highly non-portable.. kind of */
352  struct VBKEY *pskeylist[512];
353 #else
354  struct VBKEY *pskeylist[256];
355 #endif
356 };
357 
358 struct DICTNODE { /* Offset 32Val 64Val */
359  /* 32IO 64IO */
360  char cvalidation[2]; /* 0x00 0x00 0xfe53 0x5642 */
361  char cheaderrsvd; /* 0x02 0x02 0x02 Same */
362  char cfooterrsvd; /* 0x03 0x03 0x02 Same */
363  char crsvdperkey; /* 0x04 0x04 0x04 0x08 */
364  char crfu1; /* 0x05 0x05 0x04 Same */
365  char cnodesize[INTSIZE]; /* 0x06 0x06 0x03ff 0x0fff */
366  char cindexcount[INTSIZE]; /* 0x08 0x08 Varies Same */
367  char crfu2[2]; /* 0x0a 0x0a 0x0704 Same */
368  char cfileversion; /* 0x0c 0x0c 0x00 Same */
369  char cminrowlength[INTSIZE]; /* 0x0d 0x0d Varies Same */
370  char cnodekeydesc[QUADSIZE]; /* 0x0f 0x0f Normally 2 */
371  char clocalindex; /* 0x13 0x17 0x00 Same */
372  char crfu3[5]; /* 0x14 0x18 0x00... Same */
373  char cdatafree[QUADSIZE]; /* 0x19 0x1d Varies Same */
374  char cnodefree[QUADSIZE]; /* 0x1d 0x25 Varies Same */
375  char cdatacount[QUADSIZE]; /* 0x21 0x2d Varies Same */
376  char cnodecount[QUADSIZE]; /* 0x25 0x35 Varies Same */
377  char ctransnumber[QUADSIZE]; /* 0x29 0x3d Varies Same */
378  char cuniqueid[QUADSIZE]; /* 0x2d 0x45 Varies Same */
379  char cnodeaudit[QUADSIZE]; /* 0x31 0x4d Varies Same */
380  char clockmethod[INTSIZE]; /* 0x35 0x55 0x0008 Same */
381  char crfu4[QUADSIZE]; /* 0x37 0x57 0x00... Same */
382  char cmaxrowlength[INTSIZE]; /* 0x3b 0x5f Varies Same */
383  char cvarleng0[QUADSIZE]; /* 0x3d 0x61 Varies Same */
384  char cvarleng1[QUADSIZE]; /* 0x41 0x69 Varies Same */
385  char cvarleng2[QUADSIZE]; /* 0x45 0x71 Varies Same */
386  char cvarleng3[QUADSIZE]; /* 0x49 0x79 Varies Same */
387  char cvarleng4[QUADSIZE]; /* 0x4d 0x81 Varies Same */
388 #if ISAMMODE == 1
389  char cvarleng5[QUADSIZE]; /* 0x89 Varies Same */
390  char cvarleng6[QUADSIZE]; /* 0x91 Varies Same */
391  char cvarleng7[QUADSIZE]; /* 0x99 Varies Same */
392  char cvarleng8[QUADSIZE]; /* 0xa1 Varies Same */
393 #endif
394  char crfulocalindex[36]; /* 0x51 0xa9 0x00... Same */
395  /* ---- ---- */
396  /* Length Total 0x75 0xcd */
397 };
398 
399 struct DICTINFO {
400  int inkeys; /* Number of keys */
401  int iactivekey; /* Which key is the active key */
402  int inodesize; /* Number of bytes in an index block */
403  int iminrowlength; /* Minimum data row length */
404  int imaxrowlength; /* Maximum data row length */
405  int idatahandle; /* file descriptor of the .dat file */
406  int iindexhandle; /* file descriptor of the .idx file */
407  int iisopen; /* 0: Table open, Files open, Buffers OK */
408  /* 1: Table closed, Files open, Buffers OK */
409  /* Used to retain locks */
410  /* 2: Table closed, Files closed, Buffers OK */
411  /* Basically, just caching */
412  int iopenmode; /* The type of open which was used */
413  int ivarlenlength; /* Length of varlen component */
414  int ivarlenslot; /* The slot number within tvarlennode */
415  int dspare1;
416  off_t trownumber; /* Which data row is "CURRENT" 0 if none */
417  off_t tdupnumber; /* Which duplicate number is "CURRENT" (0=First) */
418  off_t trowstart; /* ONLY set to nonzero by isstart() */
419  off_t ttranslast; /* Used to see whether to set iindexchanged */
420  off_t tnrows; /* Number of rows (0 IF EMPTY, 1 IF NOT) */
421  off_t tvarlennode; /* Node containing 1st varlen data */
422  char *cfilename;
423  char *ppcrowbuffer; /* tminrowlength buffer for key (re)construction */
424  const unsigned char *collating_sequence; /* Collating sequence */
425  unsigned char iisdisjoint; /* If set, CURR & NEXT give same result */
426  unsigned char iisdatalocked; /* If set, islock() is active */
427  unsigned char iisdictlocked; /* Relates to sdictnode below */
428  /* 0x00: Content on file MIGHT be different */
429  /* 0x01: Dictionary node is LOCKED */
430  /* 0x02: sdictnode needs to be rewritten */
431  /* 0x04: do NOT increment Dict.Trans */
432  /* isrollback () is in progress */
433  /* (Thus, suppress some ivbenter/ivbexit) */
434  unsigned char iindexchanged; /* Various */
435  /* 0: Index has NOT changed since last time */
436  /* 1: Index has changed, blocks invalid */
437  /* 2: Index has changed, blocks are valid */
438  unsigned char itransyet; /* Relates to isbegin () et al */
439  /* 0: FO Trans not yet written */
440  /* 1: FO Trans written outside isbegin */
441  /* 2: FO Trans written within isbegin */
442  unsigned char iisammode; /* ISAM mode */
443  unsigned char dspare2[2]; /* spare */
444  struct DICTNODE sdictnode; /* Holds dictionary node data */
445  struct keydesc *pskeydesc[MAXSUBS]; /* Array of key description info */
446  struct VBTREE *pstree[MAXSUBS]; /* Linked list of index nodes */
447  struct VBKEY *pskeyfree[MAXSUBS]; /* An array of linked lists of free VBKEYs */
448  struct VBKEY *pskeycurr[MAXSUBS]; /* An array of 'current' VBKEY pointers */
449 };
450 
451 VB_HIDDEN extern struct DICTINFO *psvbfile[VB_MAX_FILES + 1];
452 
453 struct VBFILE {
454  struct VBLOCK *pslockhead; /* Ordered linked list of locked row numbers */
456  int ihandle;
457  int irefcount; /* How many times we are 'open' */
458  dev_t tdevice;
459  ino_t tinode;
460 #ifdef _WIN32
461  HANDLE whandle;
462  char *cfilename;
463 #endif
464 };
465 
466 VB_HIDDEN extern struct VBFILE svbfile[VB_MAX_FILES * 3];
467 
468 #define VBL_BUILD ("BU")
469 #define VBL_BEGIN ("BW")
470 #define VBL_CREINDEX ("CI")
471 #define VBL_CLUSTER ("CL")
472 #define VBL_COMMIT ("CW")
473 #define VBL_DELETE ("DE")
474 #define VBL_DELINDEX ("DI")
475 #define VBL_FILEERASE ("ER")
476 #define VBL_FILECLOSE ("FC")
477 #define VBL_FILEOPEN ("FO")
478 #define VBL_INSERT ("IN")
479 #define VBL_RENAME ("RE")
480 #define VBL_ROLLBACK ("RW")
481 #define VBL_SETUNIQUE ("SU")
482 #define VBL_UNIQUEID ("UN")
483 #define VBL_UPDATE ("UP")
484 
485 struct SLOGHDR {
486  char clength[INTSIZE];
487  char coperation[2];
488  char cpid[INTSIZE];
489  char cuid[INTSIZE];
490  char ctime[LONGSIZE];
491  char crfu1[INTSIZE];
492  char clastposn[INTSIZE];
493  char clastlength[INTSIZE];
494 };
495 
496 /* isopen.c */
497 VB_HIDDEN extern int ivbforceexit (const int ihandle);
498 VB_HIDDEN extern int ivbclose2 (const int ihandle);
499 VB_HIDDEN extern void ivbclose3 (const int ihandle);
500 
501 /* isread.c */
502 VB_HIDDEN extern int ivbcheckkey (const int ihandle, struct keydesc *pskey,
503  const int imode, int irowlength, const int iisbuild);
504 
505 /* istrans.c */
506 VB_HIDDEN extern int ivbtransbuild (const char *pcfilename, const int iminrowlen, const int imaxrowlen,
507  struct keydesc *pskeydesc, const int imode);
508 VB_HIDDEN extern int ivbtranscreateindex (const int ihandle, struct keydesc *pskeydesc);
509 VB_HIDDEN extern int ivbtranscluster (void);
510 VB_HIDDEN extern int ivbtransdelete (const int ihandle, off_t trownumber, int irowlength);
511 VB_HIDDEN extern int ivbtransdeleteindex (const int ihandle, struct keydesc *pskeydesc);
512 VB_HIDDEN extern int ivbtranserase (const char *pcfilename);
513 VB_HIDDEN extern int ivbtransclose (const int ihandle, const char *pcfilename);
514 VB_HIDDEN extern int ivbtransopen (const int ihandle, const char *pcfilename);
515 VB_HIDDEN extern int ivbtransinsert (const int ihandle, const off_t trownumber,
516  int irowlength, char *pcrow);
517 VB_HIDDEN extern int ivbtransrename (char *pcoldname, char *pcnewname);
518 VB_HIDDEN extern int ivbtranssetunique (const int ihandle, const off_t tuniqueid);
519 VB_HIDDEN extern int ivbtransuniqueid (const int ihandle, const off_t tuniqueid);
520 VB_HIDDEN extern int ivbtransupdate (const int ihandle, const off_t trownumber,
521  const int ioldrowlen, const int inewrowlen,
522  const char *pcrow);
523 
524 /* iswrite.c */
525 VB_HIDDEN extern int ivbwriterow (const int ihandle, char *pcrow,
526  const off_t trownumber);
527 
528 /* vbdataio.c */
529 VB_HIDDEN extern int ivbdataread (const int ihandle, char *pcbuffer,
530  int *pideletedrow, const off_t trownumber);
531 VB_HIDDEN extern int ivbdatawrite (const int ihandle, char *pcbuffer,
532  int ideletedrow, const off_t trownumber);
533 
534 /* vbindexio.c */
535 VB_HIDDEN extern off_t tvbnodecountgetnext (const int ihandle);
536 VB_HIDDEN extern int ivbnodefree (const int ihandle, const off_t tnodenumber);
537 VB_HIDDEN extern int ivbdatafree (const int ihandle, const off_t trownumber);
538 VB_HIDDEN extern off_t tvbnodeallocate (const int ihandle);
539 VB_HIDDEN extern off_t tvbdataallocate (const int ihandle);
540 VB_HIDDEN extern int ivbforcedataallocate (const int ihandle, const off_t trownumber);
541 
542 /* vbkeysio.c */
543 VB_HIDDEN extern void vvbmakekey (const struct keydesc *pskeydesc,
544  char *pcrow_buffer, unsigned char *pckeyvalue);
545 VB_HIDDEN extern int ivbkeysearch (const int ihandle, const int imode,
546  const int ikeynumber, int ilength,
547  unsigned char *pckeyvalue, off_t tdupnumber);
548 VB_HIDDEN extern int ivbkeylocaterow (const int ihandle, const int ikeynumber, off_t trownumber);
549 VB_HIDDEN extern int ivbkeyload (const int ihandle, const int ikeynumber, const int imode,
550  const int isetcurr, struct VBKEY **ppskey);
551 VB_HIDDEN extern void vvbkeyvalueset (const int ihigh, struct keydesc *pskeydesc,
552  unsigned char *pckeyvalue);
553 VB_HIDDEN extern int ivbkeyinsert (const int ihandle, struct VBTREE *pstree,
554  const int ikeynumber, unsigned char *pckeyvalue,
555  off_t trownode, off_t tdupnumber,
556  struct VBTREE *pschild);
557 VB_HIDDEN extern int ivbkeydelete (const int ihandle, const int ikeynumber);
558 VB_HIDDEN extern int ivbkeycompare (const int ihandle, const int ikeynumber, int ilength,
559  unsigned char *pckey1, unsigned char *pckey2);
560 
561 /* vblocking.c */
562 VB_HIDDEN extern int ivbenter (const int ihandle, const unsigned int imodifying,
563  const unsigned int ispecial);
564 VB_HIDDEN extern int ivbexit (const int ihandle);
565 VB_HIDDEN extern int ivbfileopenlock (const int ihandle, const int imode);
566 VB_HIDDEN extern int ivbdatalock (const int ihandle, const int imode,
567  const off_t trownumber);
568 
569 /* vblowlovel.c */
570 VB_HIDDEN extern int ivbopen (const char *pcfilename, const int iflags,
571  const mode_t tmode);
572 VB_HIDDEN extern int ivbclose (const int ihandle);
573 VB_HIDDEN extern off_t tvblseek (const int ihandle, off_t toffset, const int iwhence);
574 
575 VB_HIDDEN extern ssize_t tvbread (const int ihandle, void *pvbuffer, const size_t tcount);
576 VB_HIDDEN extern ssize_t tvbwrite (const int ihandle, const void *pvbuffer, const size_t tcount);
577 
578 VB_HIDDEN extern int ivbblockread (const int ihandle, const int iisindex,
579  const off_t tblocknumber, char *cbuffer);
580 VB_HIDDEN extern int ivbblockwrite (const int ihandle, const int iisindex,
581  const off_t tblocknumber, const char *cbuffer);
582 VB_HIDDEN extern int ivblock (const int ihandle, const off_t toffset,
583  const off_t tlength, const int imode);
584 
585 /* vbmemio.c */
586 VB_HIDDEN extern struct VBLOCK *psvblockallocate (const int ihandle);
587 VB_HIDDEN extern void vvblockfree (struct VBLOCK *pslock);
588 VB_HIDDEN extern struct VBTREE *psvbtreeallocate (const int ihandle);
589 VB_HIDDEN extern void vvbtreeallfree (const int ihandle, const int ikeynumber,
590  struct VBTREE *pstree);
591 VB_HIDDEN extern struct VBKEY *psvbkeyallocate (const int ihandle, const int ikeynumber);
592 VB_HIDDEN extern void vvbkeyallfree (const int ihandle, const int ikeynumber,
593  struct VBTREE *pstree);
594 VB_HIDDEN extern void vvbkeyfree (const int ihandle, const int ikeynumber,
595  struct VBKEY *pskey);
596 VB_HIDDEN extern void vvbkeyunmalloc (const int ihandle, const int ikeynumber);
597 VB_HIDDEN extern void *pvvbmalloc (const size_t size);
598 VB_HIDDEN extern void vvbfree (void *mptr);
599 VB_HIDDEN extern void vvbunmalloc (void);
600 
601 /* vbnodememio.c */
602 VB_HIDDEN extern int ivbnodeload (const int ihandle, const int ikeynumber,
603  struct VBTREE *pstree, const off_t tnodenumber,
604  const int iprevlvl);
605 VB_HIDDEN extern int ivbnodesave (const int ihandle, const int ikeynumber,
606  struct VBTREE *pstree, const off_t tnodenumber,
607  const int imode, const int iposn);
608 
609 #endif /* VB_LIBVBISAM_H */
ssize_t tvbwrite(const int ihandle, const void *pvbuffer, const size_t tcount)
Definition: vblowlevel.c:127
int ivblock(const int ihandle, const off_t toffset, const off_t tlength, const int imode)
Definition: vblowlevel.c:197
int ivbopen(const char *pcfilename, const int iflags, const mode_t tmode)
Definition: vblowlevel.c:32
unsigned char spare[5]
Definition: isinternal.h:333
unsigned char iishigh
Definition: isinternal.h:331
int inkeys
Definition: isinternal.h:400
int ivbforcedataallocate(const int ihandle, const off_t trownumber)
Definition: vbindexio.c:355
char cvarleng2[8]
Definition: isinternal.h:385
struct VBFILE svbfile[128 *3]
Definition: vblowlevel.c:24
int ivbtranserase(const char *pcfilename)
Definition: istrans.c:777
int imaxrowlength
Definition: isinternal.h:404
static int inl_ldint(void *pclocation)
Definition: isinternal.h:170
int ivbtransdelete(const int ihandle, off_t trownumber, int irowlength)
Definition: istrans.c:698
char cuid[2]
Definition: isinternal.h:489
char cvarleng6[8]
Definition: isinternal.h:390
struct VBLOCK * psvblockallocate(const int ihandle)
Definition: vbmemio.c:67
int ivbtranssetunique(const int ihandle, const off_t tuniqueid)
Definition: istrans.c:948
char cfooterrsvd
Definition: isinternal.h:362
char cvarleng8[8]
Definition: isinternal.h:392
int ivbtransclose(const int ihandle, const char *pcfilename)
Definition: istrans.c:806
struct VBLOCK * pslocktail
Definition: isinternal.h:455
int ivbdatafree(const int ihandle, const off_t trownumber)
Definition: vbindexio.c:150
char crfu4[8]
Definition: isinternal.h:381
void vvbkeyvalueset(const int ihigh, struct keydesc *pskeydesc, unsigned char *pckeyvalue)
Definition: vbkeysio.c:659
struct VBTREE * psvbtreeallocate(const int ihandle)
Definition: vbmemio.c:88
unsigned char iindexchanged
Definition: isinternal.h:434
struct VBTREE * pschild
Definition: isinternal.h:327
struct VBKEY * pskeylast
Definition: isinternal.h:341
struct VBLOCK * psnext
Definition: isinternal.h:318
int ihandle
Definition: isinternal.h:319
int ivbkeysearch(const int ihandle, const int imode, const int ikeynumber, int ilength, unsigned char *pckeyvalue, off_t tdupnumber)
Definition: vbkeysio.c:372
off_t tnrows
Definition: isinternal.h:420
int ivbblockread(const int ihandle, const int iisindex, const off_t tblocknumber, char *cbuffer)
Definition: vblowlevel.c:137
int ivbcheckkey(const int ihandle, struct keydesc *pskey, const int imode, int irowlength, const int iisbuild)
Definition: isread.c:124
unsigned char ckey[1]
Definition: isinternal.h:334
int ivbtransupdate(const int ihandle, const off_t trownumber, const int ioldrowlen, const int inewrowlen, const char *pcrow)
Definition: istrans.c:1014
int ivbkeylocaterow(const int ihandle, const int ikeynumber, off_t trownumber)
Definition: vbkeysio.c:435
struct VBKEY * psvbkeyallocate(const int ihandle, const int ikeynumber)
Definition: vbmemio.c:120
int ivbkeycompare(const int ihandle, const int ikeynumber, int ilength, unsigned char *pckey1, unsigned char *pckey2)
Definition: vbkeysio.c:230
char clockmethod[2]
Definition: isinternal.h:380
unsigned char iisammode
Definition: isinternal.h:442
unsigned char iisroot
Definition: isinternal.h:347
char cminrowlength[2]
Definition: isinternal.h:369
char crfu2[2]
Definition: isinternal.h:367
int ivbdatawrite(const int ihandle, char *pcbuffer, int ideletedrow, const off_t trownumber)
Definition: vbdataio.c:611
static void inl_stlong(int lvalue, void *pclocation)
Definition: isinternal.h:226
int ivbtranscreateindex(const int ihandle, struct keydesc *pskeydesc)
Definition: istrans.c:648
int ivarlenslot
Definition: isinternal.h:414
int ihandle
Definition: isinternal.h:456
int iindexhandle
Definition: isinternal.h:406
int dspare1
Definition: isinternal.h:415
char cuniqueid[8]
Definition: isinternal.h:378
int ivbenter(const int ihandle, const unsigned int imodifying, const unsigned int ispecial)
Definition: vblocking.c:178
char cnodeaudit[8]
Definition: isinternal.h:379
struct VBLOCK * pslockhead
Definition: isinternal.h:454
unsigned char iisdummy
Definition: isinternal.h:332
char cvarleng3[8]
Definition: isinternal.h:386
int ivbkeyload(const int ihandle, const int ikeynumber, const int imode, const int isetcurr, struct VBKEY **ppskey)
Definition: vbkeysio.c:503
int ivbtransrename(char *pcoldname, char *pcnewname)
Definition: istrans.c:914
char cnodekeydesc[8]
Definition: isinternal.h:370
int ivbtransinsert(const int ihandle, const off_t trownumber, int irowlength, char *pcrow)
Definition: istrans.c:878
const unsigned char * collating_sequence
Definition: isinternal.h:424
void vvbfree(void *mptr)
Definition: vbmemio.c:59
int iminrowlength
Definition: isinternal.h:403
struct VBTREE * psnext
Definition: isinternal.h:338
int ivbnodeload(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int iprevlvl)
Definition: vbnodememio.c:285
#define MISALIGNED
Definition: isinternal.h:157
ino_t tinode
Definition: isinternal.h:459
char * cfilename
Definition: isinternal.h:422
void ivbclose3(const int ihandle)
Definition: isopen.c:125
char crfu1
Definition: isinternal.h:364
char crfu1[2]
Definition: isinternal.h:491
char clastposn[2]
Definition: isinternal.h:492
int ivbmaxusedhandle
Definition: vblocking.c:26
unsigned char * ucharptr
Definition: isinternal.h:150
off_t tvarlennode
Definition: isinternal.h:421
char cdatacount[8]
Definition: isinternal.h:375
#define VB_BSWAP_64(val)
Definition: byteswap.h:186
int iisopen
Definition: isinternal.h:407
unsigned char spare[5]
Definition: isinternal.h:350
char cvarleng1[8]
Definition: isinternal.h:384
static void inl_stint(int ivalue, void *pclocation)
Definition: isinternal.h:190
int ivbtransdeleteindex(const int ihandle, struct keydesc *pskeydesc)
Definition: istrans.c:734
void vvbunmalloc(void)
char crfu3[5]
Definition: isinternal.h:372
void vvblockfree(struct VBLOCK *pslock)
Definition: vbmemio.c:81
int ivbkeydelete(const int ihandle, const int ikeynumber)
Definition: vbkeysio.c:777
struct VBTREE * psparent
Definition: isinternal.h:326
struct VBKEY * pskeycurr
Definition: isinternal.h:342
unsigned char iisdictlocked
Definition: isinternal.h:427
off_t trowstart
Definition: isinternal.h:418
off_t tdupnumber
Definition: isinternal.h:417
off_t ttranslast
Definition: isinternal.h:419
off_t tvbdataallocate(const int ihandle)
Definition: vbindexio.c:284
int irefcount
Definition: isinternal.h:457
#define VB_BSWAP_32(val)
Definition: byteswap.h:185
char cvalidation[2]
Definition: isinternal.h:360
struct VBKEY * pskeyfree[32]
Definition: isinternal.h:447
int ivbdatalock(const int ihandle, const int imode, const off_t trownumber)
Definition: vblocking.c:432
off_t tnodenumber
Definition: isinternal.h:343
off_t ttransnumber
Definition: isinternal.h:344
void vvbkeyallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:143
struct VBKEY * pskeycurr[32]
Definition: isinternal.h:448
#define VB_HIDDEN
Definition: isinternal.h:129
struct DICTNODE sdictnode
Definition: isinternal.h:444
char crfulocalindex[36]
Definition: isinternal.h:394
off_t trownode
Definition: isinternal.h:328
int ivbtransuniqueid(const int ihandle, const off_t tuniqueid)
Definition: istrans.c:981
char cnodecount[8]
Definition: isinternal.h:376
void vvbmakekey(const struct keydesc *pskeydesc, char *pcrow_buffer, unsigned char *pckeyvalue)
Definition: vbkeysio.c:212
unsigned char iiseof
Definition: isinternal.h:349
int ivbwriterow(const int ihandle, char *pcrow, const off_t trownumber)
Definition: iswrite.c:85
#define VB_MAX_FILES
Definition: isinternal.h:120
int ivbdataread(const int ihandle, char *pcbuffer, int *pideletedrow, const off_t trownumber)
Definition: vbdataio.c:493
void * pvvbmalloc(const size_t size)
Definition: vbmemio.c:45
int ivbnodesave(const int ihandle, const int ikeynumber, struct VBTREE *pstree, const off_t tnodenumber, const int imode, const int iposn)
Definition: vbnodememio.c:416
int ivbfileopenlock(const int ihandle, const int imode)
Definition: vblocking.c:380
unsigned int ikeysinnode
Definition: isinternal.h:346
char crsvdperkey
Definition: isinternal.h:363
void vvbkeyfree(const int ihandle, const int ikeynumber, struct VBKEY *pskey)
Definition: vbmemio.c:172
struct VBKEY * psprev
Definition: isinternal.h:325
off_t trownumber
Definition: isinternal.h:320
char cmaxrowlength[2]
Definition: isinternal.h:382
char cnodesize[2]
Definition: isinternal.h:365
unsigned char dspare2[2]
Definition: isinternal.h:443
struct DICTINFO * psvbfile[128+1]
Definition: vblowlevel.c:23
#define QUADSIZE
Definition: isinternal.h:108
char coperation[2]
Definition: isinternal.h:487
off_t tvbnodecountgetnext(const int ihandle)
Definition: vbindexio.c:48
int ivbtransbuild(const char *pcfilename, const int iminrowlen, const int imaxrowlen, struct keydesc *pskeydesc, const int imode)
Definition: istrans.c:599
char cnodefree[8]
Definition: isinternal.h:374
char ctransnumber[8]
Definition: isinternal.h:377
int iactivekey
Definition: isinternal.h:401
char cpid[2]
Definition: isinternal.h:488
#define VB_BSWAP_16(val)
Definition: byteswap.h:184
unsigned char iisdatalocked
Definition: isinternal.h:426
off_t tdupnumber
Definition: isinternal.h:329
char cindexcount[2]
Definition: isinternal.h:366
char cvarleng7[8]
Definition: isinternal.h:391
int ivbnodefree(const int ihandle, const off_t tnodenumber)
Definition: vbindexio.c:67
char cvarleng5[8]
Definition: isinternal.h:389
int ivbclose(const int ihandle)
Definition: vblowlevel.c:93
int ivbkeyinsert(const int ihandle, struct VBTREE *pstree, const int ikeynumber, unsigned char *pckeyvalue, off_t trownode, off_t tdupnumber, struct VBTREE *pschild)
Definition: vbkeysio.c:727
char cdatafree[8]
Definition: isinternal.h:373
static int inl_ldlong(void *pclocation)
Definition: isinternal.h:209
int ivbexit(const int ihandle)
Definition: vblocking.c:290
int iopenmode
Definition: isinternal.h:412
int ivbblockwrite(const int ihandle, const int iisindex, const off_t tblocknumber, const char *cbuffer)
Definition: vblowlevel.c:167
char clocalindex
Definition: isinternal.h:371
void vvbtreeallfree(const int ihandle, const int ikeynumber, struct VBTREE *pstree)
Definition: vbmemio.c:105
char cfileversion
Definition: isinternal.h:368
struct VBKEY * pskeylist[512]
Definition: isinternal.h:352
static void inl_stquad(off_t tvalue, void *pclocation)
Definition: isinternal.h:260
ssize_t tvbread(const int ihandle, void *pvbuffer, const size_t tcount)
Definition: vblowlevel.c:117
int ivbforceexit(const int ihandle)
Definition: isopen.c:50
unsigned int ilevel
Definition: isinternal.h:345
struct VBTREE * pstree[32]
Definition: isinternal.h:446
int ivblogfilehandle
Definition: istrans.c:24
char cheaderrsvd
Definition: isinternal.h:361
int ivarlenlength
Definition: isinternal.h:413
char clength[2]
Definition: isinternal.h:486
unsigned char iisdisjoint
Definition: isinternal.h:425
struct VBKEY * pskeyfirst
Definition: isinternal.h:340
struct VBTREE * psparent
Definition: isinternal.h:339
char cvarleng4[8]
Definition: isinternal.h:387
unsigned char iisnew
Definition: isinternal.h:330
struct keydesc * pskeydesc[32]
Definition: isinternal.h:445
dev_t tdevice
Definition: isinternal.h:458
unsigned char iistof
Definition: isinternal.h:348
static off_t inl_ldquad(void *pclocation)
Definition: isinternal.h:238
off_t trownumber
Definition: isinternal.h:416
char ctime[4]
Definition: isinternal.h:490
char cvarleng0[8]
Definition: isinternal.h:383
unsigned char itransyet
Definition: isinternal.h:438
char clastlength[2]
Definition: isinternal.h:493
struct VBKEY * psnext
Definition: isinternal.h:324
int idatahandle
Definition: isinternal.h:405
off_t tvbnodeallocate(const int ihandle)
Definition: vbindexio.c:221
char * ppcrowbuffer
Definition: isinternal.h:423
int ivbtransopen(const int ihandle, const char *pcfilename)
Definition: istrans.c:843
int ivbtranscluster(void)
Definition: istrans.c:691
int inodesize
Definition: isinternal.h:402
void vvbkeyunmalloc(const int ihandle, const int ikeynumber)
Definition: vbmemio.c:196
#define MAXSUBS
Definition: isinternal.h:119
int ivbintrans
Definition: istrans.c:23
int ivbclose2(const int ihandle)
Definition: isopen.c:83
off_t tvblseek(const int ihandle, off_t toffset, const int iwhence)
Definition: vblowlevel.c:107