Annotation of parser3/src/lib/sdbm/sdbm_private.h, revision 1.6
1.5 moko 1: /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
2: * applicable.
1.1 paf 3: *
1.5 moko 4: * Licensed under the Apache License, Version 2.0 (the "License");
5: * you may not use this file except in compliance with the License.
6: * You may obtain a copy of the License at
7: *
8: * http://www.apache.org/licenses/LICENSE-2.0
9: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
1.1 paf 15: */
16:
17: /*
18: * sdbm - ndbm work-alike hashed database library
19: * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
20: * author: oz@nexus.yorku.ca
21: */
22:
23: #ifndef SDBM_PRIVATE_H
24: #define SDBM_PRIVATE_H
25:
1.4 moko 26: #include "pa_apr.h"
27: #include "pa_file_io.h"
28: #include "pa_errno.h" /* for pa_status_t */
1.1 paf 29:
1.2 paf 30: #if 1
1.4 moko 31: /* if the block/page size is increased, it breaks perl pa_sdbm_t compatibility */
1.1 paf 32: #define DBLKSIZ 16384
33: #define PBLKSIZ 8192
1.3 misha 34: // !see PAIRMAX definition in pa_vhashfile.C. values should be the same
1.1 paf 35: #define PAIRMAX 8008 /* arbitrary on PBLKSIZ-N */
36: #else
37: #define DBLKSIZ 4096
38: #define PBLKSIZ 1024
39: #define PAIRMAX 1008 /* arbitrary on PBLKSIZ-N */
40: #endif
41: #define SPLTMAX 10 /* maximum allowed splits */
42:
1.4 moko 43: /* for pa_sdbm_t.flags */
1.1 paf 44: #define SDBM_RDONLY 0x1 /* data base open read-only */
45: #define SDBM_SHARED 0x2 /* data base open for sharing */
46: #define SDBM_SHARED_LOCK 0x4 /* data base locked for shared read */
47: #define SDBM_EXCLUSIVE_LOCK 0x8 /* data base locked for write */
48:
1.4 moko 49: struct pa_sdbm_t {
50: pa_pool_t *pool;
51: pa_file_t *dirf; /* directory file descriptor */
52: pa_file_t *pagf; /* page file descriptor */
53: pa_int32_t flags; /* status/error flags, see below */
1.1 paf 54: long maxbno; /* size of dirfile in bits */
55: long curbit; /* current bit number */
56: long hmask; /* current hash mask */
57: long blkptr; /* current block for nextkey */
58: int keyptr; /* current key for nextkey */
59: long blkno; /* current page to read/write */
60: long pagbno; /* current page in pagbuf */
61: char pagbuf[PBLKSIZ]; /* page file block buffer */
62: long dirbno; /* current block in dirbuf */
63: char dirbuf[DBLKSIZ]; /* directory file block buffer */
64: int lckcnt; /* number of calls to sdbm_lock */
65: };
66:
1.6 ! moko 67: #define sdbm_hash pa_sdbm_hash
! 68: #define sdbm_nullitem pa_sdbm_nullitem
! 69:
1.4 moko 70: extern const pa_sdbm_datum_t sdbm_nullitem;
1.1 paf 71:
72: long sdbm_hash(const char *str, int len);
73:
74: /*
75: * zero the cache
76: */
77: #define SDBM_INVALIDATE_CACHE(db, finfo) \
78: do { db->dirbno = (!finfo.size) ? 0 : -1; \
79: db->pagbno = -1; \
80: db->maxbno = (long)(finfo.size * BYTESIZ); \
81: } while (0);
82:
83: #endif /* SDBM_PRIVATE_H */
E-mail: