GME  13
apr_sdbm.h
Go to the documentation of this file.
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 /*
00018  * sdbm - ndbm work-alike hashed database library
00019  * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
00020  * author: oz@nexus.yorku.ca
00021  * status: ex-public domain
00022  */
00023 
00024 #ifndef APR_SDBM_H
00025 #define APR_SDBM_H
00026 
00027 #include "apu.h"
00028 #include "apr_errno.h"
00029 #include "apr_file_io.h"   /* for apr_fileperms_t */
00030 
00044 typedef struct apr_sdbm_t apr_sdbm_t;
00045 
00049 typedef struct {
00051     char *dptr;
00053     /* apr_ssize_t for release 2.0??? */
00054     int dsize;
00055 } apr_sdbm_datum_t;
00056 
00057 /* The extensions used for the database files */
00059 #define APR_SDBM_DIRFEXT        ".dir"
00060 
00061 #define APR_SDBM_PAGFEXT        ".pag"
00062 
00063 /* flags to sdbm_store */
00064 #define APR_SDBM_INSERT     0   
00065 #define APR_SDBM_REPLACE    1   
00066 #define APR_SDBM_INSERTDUP  2   
00086 APU_DECLARE(apr_status_t) apr_sdbm_open(apr_sdbm_t **db, const char *name, 
00087                                         apr_int32_t mode, 
00088                                         apr_fileperms_t perms, apr_pool_t *p);
00089 
00094 APU_DECLARE(apr_status_t) apr_sdbm_close(apr_sdbm_t *db);
00095 
00111 APU_DECLARE(apr_status_t) apr_sdbm_lock(apr_sdbm_t *db, int type);
00112 
00117 APU_DECLARE(apr_status_t) apr_sdbm_unlock(apr_sdbm_t *db);
00118 
00125 APU_DECLARE(apr_status_t) apr_sdbm_fetch(apr_sdbm_t *db, 
00126                                          apr_sdbm_datum_t *value, 
00127                                          apr_sdbm_datum_t key);
00128 
00140 APU_DECLARE(apr_status_t) apr_sdbm_store(apr_sdbm_t *db, apr_sdbm_datum_t key,
00141                                          apr_sdbm_datum_t value, int opt);
00142 
00149 APU_DECLARE(apr_status_t) apr_sdbm_delete(apr_sdbm_t *db, 
00150                                           const apr_sdbm_datum_t key);
00151 
00161 APU_DECLARE(apr_status_t) apr_sdbm_firstkey(apr_sdbm_t *db, apr_sdbm_datum_t *key);
00162 
00168 APU_DECLARE(apr_status_t) apr_sdbm_nextkey(apr_sdbm_t *db, apr_sdbm_datum_t *key);
00169 
00174 APU_DECLARE(int) apr_sdbm_rdonly(apr_sdbm_t *db);
00176 #endif /* APR_SDBM_H */