Main Page | Modules | Namespace List | Data Structures | File List | Data Fields | Globals | Related Pages

/usr/src/rpmbuilder/BUILD/apr-util-APU_0_9_BRANCH/dbm/sdbm/sdbm_private.h

00001 /* Copyright 2000-2004 The Apache Software Foundation
00002  *
00003  * Licensed under the Apache License, Version 2.0 (the "License");
00004  * you may not use this file except in compliance with the License.
00005  * You may obtain a copy of the License at
00006  *
00007  *     http://www.apache.org/licenses/LICENSE-2.0
00008  *
00009  * Unless required by applicable law or agreed to in writing, software
00010  * distributed under the License is distributed on an "AS IS" BASIS,
00011  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012  * See the License for the specific language governing permissions and
00013  * limitations under the License.
00014  */
00015 
00016 /*
00017  * sdbm - ndbm work-alike hashed database library
00018  * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
00019  * author: oz@nexus.yorku.ca
00020  */
00021 
00022 #ifndef SDBM_PRIVATE_H
00023 #define SDBM_PRIVATE_H
00024 
00025 #include "apr.h"
00026 #include "apr_pools.h"
00027 #include "apr_file_io.h"
00028 #include "apr_errno.h" /* for apr_status_t */
00029 
00030 #if 0
00031 /* if the block/page size is increased, it breaks perl apr_sdbm_t compatibility */
00032 #define DBLKSIZ 16384
00033 #define PBLKSIZ 8192
00034 #define PAIRMAX 8008                    /* arbitrary on PBLKSIZ-N */
00035 #else
00036 #define DBLKSIZ 4096
00037 #define PBLKSIZ 1024
00038 #define PAIRMAX 1008                    /* arbitrary on PBLKSIZ-N */
00039 #endif
00040 #define SPLTMAX 10                      /* maximum allowed splits */
00041 
00042 /* for apr_sdbm_t.flags */
00043 #define SDBM_RDONLY             0x1    /* data base open read-only */
00044 #define SDBM_SHARED             0x2    /* data base open for sharing */
00045 #define SDBM_SHARED_LOCK        0x4    /* data base locked for shared read */
00046 #define SDBM_EXCLUSIVE_LOCK     0x8    /* data base locked for write */
00047 
00048 struct apr_sdbm_t {
00049     apr_pool_t *pool;
00050     apr_file_t *dirf;                  /* directory file descriptor */
00051     apr_file_t *pagf;                  /* page file descriptor */
00052     apr_int32_t flags;                 /* status/error flags, see below */
00053     long maxbno;                       /* size of dirfile in bits */
00054     long curbit;                       /* current bit number */
00055     long hmask;                        /* current hash mask */
00056     long blkptr;                       /* current block for nextkey */
00057     int  keyptr;                       /* current key for nextkey */
00058     long blkno;                        /* current page to read/write */
00059     long pagbno;                       /* current page in pagbuf */
00060     char pagbuf[PBLKSIZ];              /* page file block buffer */
00061     long dirbno;                       /* current block in dirbuf */
00062     char dirbuf[DBLKSIZ];              /* directory file block buffer */
00063     int  lckcnt;                       /* number of calls to sdbm_lock */
00064 };
00065 
00066 extern const apr_sdbm_datum_t sdbm_nullitem;
00067 
00068 long sdbm_hash(const char *str, int len);
00069 
00070 /*
00071  * zero the cache
00072  */
00073 #define SDBM_INVALIDATE_CACHE(db, finfo) \
00074     do { db->dirbno = (!finfo.size) ? 0 : -1; \
00075          db->pagbno = -1; \
00076          db->maxbno = (long)(finfo.size * BYTESIZ); \
00077     } while (0);
00078 
00079 #endif /* SDBM_PRIVATE_H */

Generated on Fri Apr 23 07:22:21 2004 for Apache Portable Runtime Utility Library by doxygen 1.3.4