Apache Portable Runtime
apr_dbm_private.h
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef APR_DBM_PRIVATE_H
00018 #define APR_DBM_PRIVATE_H
00019 
00020 #include "apr.h"
00021 #include "apr_errno.h"
00022 #include "apr_pools.h"
00023 #include "apr_dbm.h"
00024 #include "apr_file_io.h"
00025 
00026 #include "apu.h"
00027 
00028 /* ### for now, include the DBM selection; this will go away once we start
00029    ### building and linking all of the DBMs at once. */
00030 #include "apu_select_dbm.h"
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 /** @internal */
00037 
00038 /**
00039  * Most DBM libraries take a POSIX mode for creating files.  Don't trust
00040  * the mode_t type, some platforms may not support it, int is safe.
00041  */
00042 APR_DECLARE(int) apr_posix_perms2mode(apr_fileperms_t perm);
00043 
00044 /**
00045  * Structure to describe the operations of the DBM
00046  */
00047 typedef struct {
00048     /** The name of the DBM Type */
00049     const char *name;
00050 
00051     /** Open the DBM */
00052     apr_status_t (*open)(apr_dbm_t **pdb, const char *pathname,
00053                          apr_int32_t mode, apr_fileperms_t perm,
00054                          apr_pool_t *pool);
00055 
00056     /** Close the DBM */
00057     void (*close)(apr_dbm_t *dbm);
00058 
00059     /** Fetch a dbm record value by key */
00060     apr_status_t (*fetch)(apr_dbm_t *dbm, apr_datum_t key,
00061                                    apr_datum_t * pvalue);
00062 
00063     /** Store a dbm record value by key */
00064     apr_status_t (*store)(apr_dbm_t *dbm, apr_datum_t key, apr_datum_t value);
00065 
00066     /** Delete a dbm record value by key */
00067     apr_status_t (*del)(apr_dbm_t *dbm, apr_datum_t key);
00068 
00069     /** Search for a key within the dbm */
00070     int (*exists)(apr_dbm_t *dbm, apr_datum_t key);
00071 
00072     /** Retrieve the first record key from a dbm */
00073     apr_status_t (*firstkey)(apr_dbm_t *dbm, apr_datum_t * pkey);
00074 
00075     /** Retrieve the next record key from a dbm */
00076     apr_status_t (*nextkey)(apr_dbm_t *dbm, apr_datum_t * pkey);
00077 
00078     /** Proactively toss any memory associated with the apr_datum_t. */
00079     void (*freedatum)(apr_dbm_t *dbm, apr_datum_t data);
00080 
00081     /** Get the names that the DBM will use for a given pathname. */
00082     void (*getusednames)(apr_pool_t *pool,
00083                          const char *pathname,
00084                          const char **used1,
00085                          const char **used2);
00086 
00087 } apr_dbm_type_t;
00088 
00089 
00090 /**
00091  * The actual DBM
00092  */
00093 struct apr_dbm_t
00094 { 
00095     /** Associated pool */
00096     apr_pool_t *pool;
00097 
00098     /** pointer to DB Implementation Specific data */
00099     void *file;
00100 
00101     /** Current integer error code */
00102     int errcode;
00103     /** Current string error code */
00104     const char *errmsg;
00105 
00106     /** the type of DBM */
00107     const apr_dbm_type_t *type;
00108 };
00109 
00110 
00111 /* Declare all of the DBM provider tables */
00112 APR_MODULE_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_sdbm;
00113 APR_MODULE_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_gdbm;
00114 APR_MODULE_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_ndbm;
00115 APR_MODULE_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db;
00116 
00117 #ifdef __cplusplus
00118 }
00119 #endif
00120 
00121 #endif /* APR_DBM_PRIVATE_H */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines