1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
23 #ifndef SDBM_PRIVATE_H
24 #define SDBM_PRIVATE_H
27 #include "apr_pools.h"
28 #include "apr_file_io.h"
29 #include "apr_errno.h" /* for apr_status_t */
32 /* if the block/page size is increased, it breaks perl apr_sdbm_t compatibility */
35 #define PAIRMAX 8008 /* arbitrary on PBLKSIZ-N */
39 #define PAIRMAX 1008 /* arbitrary on PBLKSIZ-N */
41 #define SPLTMAX 10 /* maximum allowed splits */
43 /* for apr_sdbm_t.flags */
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 */
51 apr_file_t *dirf; /* directory file descriptor */
52 apr_file_t *pagf; /* page file descriptor */
53 apr_int32_t flags; /* status/error flags, see below */
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 */
68 #define sdbm_hash apu__sdbm_hash
69 #define sdbm_nullitem apu__sdbm_nullitem
71 extern const apr_sdbm_datum_t sdbm_nullitem;
73 long sdbm_hash(const char *str, int len);
78 #define SDBM_INVALIDATE_CACHE(db, finfo) \
79 do { db->dirbno = (!finfo.size) ? 0 : -1; \
81 db->maxbno = (long)(finfo.size * BYTESIZ); \
84 #endif /* SDBM_PRIVATE_H */