home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / apache_2.2.8-win32-x86-no_ssl.msi / Data1.cab / _BDC42AA43841480B856E9FC571DAA382 < prev    next >
Text File  |  2007-11-01  |  6KB  |  176 lines

  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
  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.
  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.  * status: ex-public domain
  22.  */
  23.  
  24. #ifndef APR_SDBM_H
  25. #define APR_SDBM_H
  26.  
  27. #include "apu.h"
  28. #include "apr_errno.h"
  29. #include "apr_file_io.h"   /* for apr_fileperms_t */
  30.  
  31. /** 
  32.  * @file apr_sdbm.h
  33.  * @brief apr-util SDBM library
  34.  */
  35. /**
  36.  * @defgroup APR_Util_DBM_SDBM SDBM library
  37.  * @ingroup APR_Util_DBM
  38.  * @{
  39.  */
  40.  
  41. /**
  42.  * Structure for referencing an sdbm
  43.  */
  44. typedef struct apr_sdbm_t apr_sdbm_t;
  45.  
  46. /**
  47.  * Structure for referencing the datum record within an sdbm
  48.  */
  49. typedef struct {
  50.     /** pointer to the data stored/retrieved */
  51.     char *dptr;
  52.     /** size of data */
  53.     int dsize;
  54. } apr_sdbm_datum_t;
  55.  
  56. /* The extensions used for the database files */
  57. /** SDBM Directory file extension */
  58. #define APR_SDBM_DIRFEXT    ".dir"
  59. /** SDBM page file extension */
  60. #define APR_SDBM_PAGFEXT    ".pag"
  61.  
  62. /* flags to sdbm_store */
  63. #define APR_SDBM_INSERT     0   /**< Insert */
  64. #define APR_SDBM_REPLACE    1   /**< Replace */
  65. #define APR_SDBM_INSERTDUP  2   /**< Insert with duplicates */
  66.  
  67. /**
  68.  * Open an sdbm database by file name
  69.  * @param db The newly opened database
  70.  * @param name The sdbm file to open
  71.  * @param mode The flag values (APR_READ and APR_BINARY flags are implicit)
  72.  * <PRE>
  73.  *           APR_WRITE          open for read-write access
  74.  *           APR_CREATE         create the sdbm if it does not exist
  75.  *           APR_TRUNCATE       empty the contents of the sdbm
  76.  *           APR_EXCL           fail for APR_CREATE if the file exists
  77.  *           APR_DELONCLOSE     delete the sdbm when closed
  78.  *           APR_SHARELOCK      support locking across process/machines
  79.  * </PRE>
  80.  * @param perms Permissions to apply to if created
  81.  * @param p The pool to use when creating the sdbm
  82.  * @remark The sdbm name is not a true file name, as sdbm appends suffixes 
  83.  * for seperate data and index files.
  84.  */
  85. APU_DECLARE(apr_status_t) apr_sdbm_open(apr_sdbm_t **db, const char *name, 
  86.                                         apr_int32_t mode, 
  87.                                         apr_fileperms_t perms, apr_pool_t *p);
  88.  
  89. /**
  90.  * Close an sdbm file previously opened by apr_sdbm_open
  91.  * @param db The database to close
  92.  */
  93. APU_DECLARE(apr_status_t) apr_sdbm_close(apr_sdbm_t *db);
  94.  
  95. /**
  96.  * Lock an sdbm database for concurency of multiple operations
  97.  * @param db The database to lock
  98.  * @param type The lock type
  99.  * <PRE>
  100.  *           APR_FLOCK_SHARED
  101.  *           APR_FLOCK_EXCLUSIVE
  102.  * </PRE>
  103.  * @remark Calls to apr_sdbm_lock may be nested.  All apr_sdbm functions
  104.  * perform implicit locking.  Since an APR_FLOCK_SHARED lock cannot be 
  105.  * portably promoted to an APR_FLOCK_EXCLUSIVE lock, apr_sdbm_store and 
  106.  * apr_sdbm_delete calls will fail if an APR_FLOCK_SHARED lock is held.
  107.  * The apr_sdbm_lock call requires the database to be opened with the
  108.  * APR_SHARELOCK mode value.
  109.  */
  110. APU_DECLARE(apr_status_t) apr_sdbm_lock(apr_sdbm_t *db, int type);
  111.  
  112. /**
  113.  * Release an sdbm lock previously aquired by apr_sdbm_lock
  114.  * @param db The database to unlock
  115.  */
  116. APU_DECLARE(apr_status_t) apr_sdbm_unlock(apr_sdbm_t *db);
  117.  
  118. /**
  119.  * Fetch an sdbm record value by key
  120.  * @param db The database 
  121.  * @param value The value datum retrieved for this record
  122.  * @param key The key datum to find this record
  123.  */
  124. APU_DECLARE(apr_status_t) apr_sdbm_fetch(apr_sdbm_t *db, 
  125.                                          apr_sdbm_datum_t *value, 
  126.                                          apr_sdbm_datum_t key);
  127.  
  128. /**
  129.  * Store an sdbm record value by key
  130.  * @param db The database 
  131.  * @param key The key datum to store this record by
  132.  * @param value The value datum to store in this record
  133.  * @param opt The method used to store the record
  134.  * <PRE>
  135.  *           APR_SDBM_INSERT     return an error if the record exists
  136.  *           APR_SDBM_REPLACE    overwrite any existing record for key
  137.  * </PRE>
  138.  */
  139. APU_DECLARE(apr_status_t) apr_sdbm_store(apr_sdbm_t *db, apr_sdbm_datum_t key,
  140.                                          apr_sdbm_datum_t value, int opt);
  141.  
  142. /**
  143.  * Delete an sdbm record value by key
  144.  * @param db The database 
  145.  * @param key The key datum of the record to delete
  146.  * @remark It is not an error to delete a non-existent record.
  147.  */
  148. APU_DECLARE(apr_status_t) apr_sdbm_delete(apr_sdbm_t *db, 
  149.                                           const apr_sdbm_datum_t key);
  150.  
  151. /**
  152.  * Retrieve the first record key from a dbm
  153.  * @param db The database 
  154.  * @param key The key datum of the first record
  155.  * @remark The keys returned are not ordered.  To traverse the list of keys
  156.  * for an sdbm opened with APR_SHARELOCK, the caller must use apr_sdbm_lock
  157.  * prior to retrieving the first record, and hold the lock until after the
  158.  * last call to apr_sdbm_nextkey.
  159.  */
  160. APU_DECLARE(apr_status_t) apr_sdbm_firstkey(apr_sdbm_t *db, apr_sdbm_datum_t *key);
  161.  
  162. /**
  163.  * Retrieve the next record key from an sdbm
  164.  * @param db The database 
  165.  * @param key The key datum of the next record
  166.  */
  167. APU_DECLARE(apr_status_t) apr_sdbm_nextkey(apr_sdbm_t *db, apr_sdbm_datum_t *key);
  168.  
  169. /**
  170.  * Returns true if the sdbm database opened for read-only access
  171.  * @param db The database to test
  172.  */
  173. APU_DECLARE(int) apr_sdbm_rdonly(apr_sdbm_t *db);
  174. /** @} */
  175. #endif /* APR_SDBM_H */
  176.