You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Greg Stein <gs...@lyra.org> on 2000/11/27 11:44:12 UTC
Re: cvs commit: apache-2.0/src/modules/dav/main mod_dav.h
damn. missed... dbm.c wasn't supposed to be checked in yet :-)
Ah well. It works, so I've updated dbm.c with the log entry:
toss dbm. use the new apu_dbm interfaces.
Cheers,
-g
On Mon, Nov 27, 2000 at 10:18:46AM -0000, gstein@locus.apache.org wrote:
> gstein 00/11/27 02:18:46
>
> Modified: src/modules/dav/fs dbm.c repos.c
> src/modules/dav/main mod_dav.h
> Log:
> liveprops are handled via hooks, not the dav_provider structure. clear it
> out of there.
>
> Revision Changes Path
> 1.9 +40 -63 apache-2.0/src/modules/dav/fs/dbm.c
>
> Index: dbm.c
> ===================================================================
> RCS file: /home/cvs/apache-2.0/src/modules/dav/fs/dbm.c,v
> retrieving revision 1.8
> retrieving revision 1.9
> diff -u -u -r1.8 -r1.9
> --- dbm.c 2000/08/08 20:03:50 1.8
> +++ dbm.c 2000/11/27 10:18:45 1.9
> @@ -68,17 +68,20 @@
> */
>
> #include "apr_strings.h"
> -#include "sdbm.h"
> +#include "apr_file_io.h"
> +
> +#include "apu_dbm.h"
>
> #include "mod_dav.h"
> #include "repos.h"
>
> struct dav_db {
> apr_pool_t *pool;
> - SDBM *file;
> + apu_dbm_t *file;
> };
>
> -#define D2G(d) (*(sdbm_datum*)&(d))
> +/* ### temp */
> +#include "sdbm.h"
>
>
> void dav_dbm_get_statefiles(apr_pool_t *p, const char *fname,
> @@ -103,21 +106,27 @@
>
> }
>
> -static dav_error * dav_fs_dbm_error(dav_db *db, apr_pool_t *p)
> +static dav_error * dav_fs_dbm_error(dav_db *db, apr_pool_t *p,
> + apr_status_t status)
> {
> int save_errno = errno;
> int errcode;
> const char *errstr;
> dav_error *err;
>
> + if (status == APR_SUCCESS)
> + return NULL;
> +
> p = db ? db->pool : p;
>
> /* There might not be a <db> if we had problems creating it. */
> - errcode = !db || sdbm_error(db->file);
> - if (errcode)
> - errstr = "I/O error occurred.";
> - else
> - errstr = "No error.";
> + if (db == NULL) {
> + errcode = 1;
> + errstr = "Could not open property database.";
> + }
> + else {
> + apu_dbm_geterror(db->file, &errcode, &errstr);
> + }
>
> err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, errcode, errstr);
> err->save_errno = save_errno;
> @@ -142,17 +151,20 @@
> dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, int ro,
> dav_db **pdb)
> {
> - SDBM *file;
> + apr_status_t status;
> + apu_dbm_t *file;
>
> *pdb = NULL;
>
> - /* NOTE: stupid cast to get rid of "const" on the pathname */
> - if (sdbm_open(&file, pathname,
> - APR_READ | (ro ? 0 : (APR_WRITE | APR_CREATE)),
> - APR_OS_DEFAULT, p) != APR_SUCCESS && !ro) {
> + if ((status = apu_dbm_open(pathname, p,
> + ro ? APU_DBM_READONLY : APU_DBM_RWCREATE,
> + &file)) != APR_SUCCESS
> + && !ro) {
> + /* ### do something with 'status' */
> +
> /* we can't continue if we couldn't open the file
> and we need to write */
> - return dav_fs_dbm_error(NULL, p);
> + return dav_fs_dbm_error(NULL, p, status);
> }
>
> /* may be NULL if we tried to open a non-existent db as read-only */
> @@ -198,87 +210,52 @@
>
> static void dav_dbm_close(dav_db *db)
> {
> - sdbm_close(db->file);
> + apu_dbm_close(db->file);
> }
>
> static dav_error * dav_dbm_fetch(dav_db *db, dav_datum key, dav_datum *pvalue)
> {
> - *(sdbm_datum *) pvalue = sdbm_fetch(db->file, D2G(key));
> -
> - /* we don't need the error; we have *pvalue to tell */
> - sdbm_clearerr(db->file);
> + apr_status_t status = apu_dbm_fetch(db->file, key, pvalue);
>
> - return NULL;
> + return dav_fs_dbm_error(db, NULL, status);
> }
>
> static dav_error * dav_dbm_store(dav_db *db, dav_datum key, dav_datum value)
> {
> - apr_status_t status;
> -
> - status = sdbm_store(db->file, D2G(key), D2G(value), SDBM_REPLACE);
> -
> - /* ### fetch more specific error information? */
> -
> - /* we don't need the error; we have rv to tell */
> - sdbm_clearerr(db->file);
> + apr_status_t status = apu_dbm_store(db->file, key, value);
>
> - if (status != APR_SUCCESS) {
> - return dav_fs_dbm_error(db, NULL);
> - }
> - return NULL;
> + return dav_fs_dbm_error(db, NULL, status);
> }
>
> static dav_error * dav_dbm_delete(dav_db *db, dav_datum key)
> {
> - int rv;
> -
> - rv = sdbm_delete(db->file, D2G(key));
> -
> - /* ### fetch more specific error information? */
> + apr_status_t status = apu_dbm_delete(db->file, key);
>
> - /* we don't need the error; we have rv to tell */
> - sdbm_clearerr(db->file);
> -
> - if (rv == -1) {
> - return dav_fs_dbm_error(db, NULL);
> - }
> - return NULL;
> + return dav_fs_dbm_error(db, NULL, status);
> }
>
> static int dav_dbm_exists(dav_db *db, dav_datum key)
> {
> - int exists;
> - sdbm_datum value = sdbm_fetch(db->file, D2G(key));
> -
> - sdbm_clearerr(db->file); /* unneeded */
> - exists = value.dptr != NULL;
> -
> - return exists;
> + return apu_dbm_exists(db->file, key);
> }
>
> static dav_error * dav_dbm_firstkey(dav_db *db, dav_datum *pkey)
> {
> - *(sdbm_datum *) pkey = sdbm_firstkey(db->file);
> -
> - /* we don't need the error; we have *pkey to tell */
> - sdbm_clearerr(db->file);
> + apr_status_t status = apu_dbm_firstkey(db->file, pkey);
>
> - return NULL;
> + return dav_fs_dbm_error(db, NULL, status);
> }
>
> static dav_error * dav_dbm_nextkey(dav_db *db, dav_datum *pkey)
> {
> - *(sdbm_datum *) pkey = sdbm_nextkey(db->file);
> -
> - /* we don't need the error; we have *pkey to tell */
> - sdbm_clearerr(db->file);
> + apr_status_t status = apu_dbm_nextkey(db->file, pkey);
>
> - return NULL;
> + return dav_fs_dbm_error(db, NULL, status);
> }
>
> static void dav_dbm_freedatum(dav_db *db, dav_datum data)
> {
> - /* nothing */
> + apu_dbm_freedatum(db->file, data);
> }
>
> const dav_hooks_db dav_hooks_db_dbm =
>
>
>
> 1.37 +2 -2 apache-2.0/src/modules/dav/fs/repos.c
>
> Index: repos.c
> ===================================================================
> RCS file: /home/cvs/apache-2.0/src/modules/dav/fs/repos.c,v
> retrieving revision 1.36
> retrieving revision 1.37
> diff -u -u -r1.36 -r1.37
> --- repos.c 2000/11/26 04:47:39 1.36
> +++ repos.c 2000/11/27 10:18:45 1.37
> @@ -1986,8 +1986,8 @@
> &dav_hooks_repository_fs,
> &dav_hooks_db_dbm,
> &dav_hooks_locks_fs,
> - &dav_hooks_liveprop_fs,
> - NULL
> + NULL, /* vsn */
> + NULL /* binding */
> };
>
> void dav_fs_gather_propsets(apr_array_header_t *uris)
>
>
>
> 1.32 +11 -10 apache-2.0/src/modules/dav/main/mod_dav.h
>
> Index: mod_dav.h
> ===================================================================
> RCS file: /home/cvs/apache-2.0/src/modules/dav/main/mod_dav.h,v
> retrieving revision 1.31
> retrieving revision 1.32
> diff -u -u -r1.31 -r1.32
> --- mod_dav.h 2000/11/25 23:35:05 1.31
> +++ mod_dav.h 2000/11/27 10:18:46 1.32
> @@ -59,17 +59,18 @@
> #ifndef _MOD_DAV_H_
> #define _MOD_DAV_H_
>
> -#ifdef __cplusplus
> -extern "C" {
> -#endif
> -
> #include "httpd.h"
> #include "util_xml.h"
> #include "ap_hooks.h"
> #include "apr_hash.h"
> +#include "apu_dbm.h"
>
> #include <limits.h> /* for INT_MAX */
>
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
>
> #define DAV_VERSION AP_SERVER_BASEREVISION
>
> @@ -517,12 +518,16 @@
> ** Note that a provider cannot pick and choose portions. There are too many
> ** dependencies between a dav_resource (defined by <repos>) and the other
> ** functionality.
> +**
> +** Live properties are not part of the dav_provider structure because they
> +** are handled through the AP_HOOK interface (to allow for multiple liveprop
> +** providers). The core always provides some properties, and then a given
> +** provider will add more properties.
> */
> typedef struct {
> const dav_hooks_repository *repos;
> const dav_hooks_propdb *propdb;
> const dav_hooks_locks *locks;
> - const dav_hooks_liveprop *liveprop;
> const dav_hooks_vsn *vsn;
> const dav_hooks_binding *binding;
>
> @@ -939,11 +944,7 @@
> */
>
> typedef struct dav_db dav_db;
> -typedef struct
> -{
> - char *dptr;
> - apr_size_t dsize;
> -} dav_datum;
> +typedef apu_datum_t dav_datum;
>
> /* hook functions to enable pluggable databases */
> struct dav_hooks_propdb
>
>
>
--
Greg Stein, http://www.lyra.org/