diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-21 04:06:28 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2008-11-21 04:06:28 +0000 |
commit | a5d7c7c8cb94d70c2d39cf3ae51c440ce26a7564 (patch) | |
tree | 7c9e4a4bf80cbdb313c34f041992f5a7b5ab245a | |
parent | e12819aeacd2547daf41100b67a0e0de676105c3 (diff) | |
download | libapr-util-a5d7c7c8cb94d70c2d39cf3ae51c440ce26a7564.tar.gz |
Now, revert r719466. Must quit using commit -m ""
git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/trunk@719468 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | Makefile.in | 3 | ||||
-rw-r--r-- | build.conf | 21 | ||||
-rw-r--r-- | build/dbm.m4 | 24 | ||||
-rw-r--r-- | build/dso.m4 | 1 | ||||
-rw-r--r-- | dbm/apr_dbm.c | 197 | ||||
-rw-r--r-- | dbm/apr_dbm_berkeleydb.c | 2 | ||||
-rw-r--r-- | dbm/apr_dbm_gdbm.c | 2 | ||||
-rw-r--r-- | dbm/apr_dbm_ndbm.c | 2 | ||||
-rw-r--r-- | include/apr_dbm.h | 13 | ||||
-rw-r--r-- | include/apu.hw | 3 | ||||
-rw-r--r-- | include/private/apr_dbm_private.h | 6 |
11 files changed, 85 insertions, 189 deletions
diff --git a/Makefile.in b/Makefile.in index 963feada..305d3302 100644 --- a/Makefile.in +++ b/Makefile.in @@ -37,9 +37,6 @@ LDADD_dbd_sqlite3 = @LDADD_dbd_sqlite3@ LDADD_dbd_mysql = @LDADD_dbd_mysql@ LDADD_dbd_freetds = @LDADD_dbd_freetds@ LDADD_dbd_odbc = @LDADD_dbd_odbc@ -LDADD_dbm_db = @LDADD_dbm_db@ -LDADD_dbm_gdbm = @LDADD_dbm_gdbm@ -LDADD_dbm_ndbm = @LDADD_dbm_ndbm@ LDADD_ldap = @LDADD_ldap@ LDADD_crypto_openssl = @LDADD_crypto_openssl@ LDADD_crypto_nss = @LDADD_crypto_nss@ @@ -13,8 +13,7 @@ paths = crypto/apr_sha1.c crypto/getuuid.c crypto/uuid.c - dbm/apr_dbm_sdbm.c - dbm/apr_dbm.c + dbm/*.c dbm/sdbm/*.c encoding/*.c hooks/*.c @@ -34,10 +33,7 @@ platform_dirs = # the public headers headers = include/*.h include/private/*.h -modules = - ldap crypto_openssl crypto_nss dbd_pgsql - dbd_sqlite2 dbd_sqlite3 dbd_oracle dbd_mysql dbd_freetds dbd_odbc - dbm_db dbm_gdbm dbm_ndbm +modules = crypto_openssl crypto_nss ldap dbd_pgsql dbd_sqlite2 dbd_sqlite3 dbd_oracle dbd_mysql dbd_freetds dbd_odbc # gen_uri_delim.c @@ -80,21 +76,8 @@ target = dbd/apr_dbd_freetds.la paths = dbd/apr_dbd_odbc.c target = dbd/apr_dbd_odbc.la -[dbm_db] -paths = dbm/apr_dbm_berkeleydb.c -target = dbm/apr_dbm_db.la - -[dbm_gdbm] -paths = dbm/apr_dbm_gdbm.c -target = dbm/apr_dbm_gdbm.la - -[dbm_ndbm] -paths = dbm/apr_dbm_ndbm.c -target = dbm/apr_dbm_ndbm.la - [ldap] paths = ldap/apr_ldap_init.c \ ldap/apr_ldap_option.c \ ldap/apr_ldap_rebind.c target = ldap/apr_ldap.la - diff --git a/build/dbm.m4 b/build/dbm.m4 index c4c8afb9..6998eee3 100644 --- a/build/dbm.m4 +++ b/build/dbm.m4 @@ -911,25 +911,25 @@ AC_DEFUN([APU_CHECK_DBM], [ AC_SUBST(apu_db_header) AC_SUBST(apu_db_version) - if test "$apu_have_db" = "1"; then - LDADD_dbm_db="-l$apu_db_lib" - if test -n "apu_db_xtra_libs"; then - LDADD_dbm_db="$LDADD_dbm_db $apu_db_xtra_libs" - fi - fi - dnl Since we have already done the AC_CHECK_LIB tests, if we have it, dnl we know the library is there. if test "$apu_have_gdbm" = "1"; then - LDADD_dbm_gdbm="-lgdbm" + APR_ADDTO(APRUTIL_EXPORT_LIBS,[-lgdbm]) + APR_ADDTO(APRUTIL_LIBS,[-lgdbm]) fi if test "$apu_have_ndbm" = "1"; then - LDADD_dbm_ndbm="-l$apu_ndbm_lib" + APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_ndbm_lib]) + APR_ADDTO(APRUTIL_LIBS,[-l$apu_ndbm_lib]) fi - AC_SUBST(LDADD_dbm_db) - AC_SUBST(LDADD_dbm_gdbm) - AC_SUBST(LDADD_dbm_ndbm) + if test "$apu_have_db" = "1"; then + APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l$apu_db_lib]) + APR_ADDTO(APRUTIL_LIBS,[-l$apu_db_lib]) + if test -n "apu_db_xtra_libs"; then + APR_ADDTO(APRUTIL_EXPORT_LIBS,[$apu_db_xtra_libs]) + APR_ADDTO(APRUTIL_LIBS,[$apu_db_xtra_libs]) + fi + fi ]) diff --git a/build/dso.m4 b/build/dso.m4 index 90bf49ae..701ee855 100644 --- a/build/dso.m4 +++ b/build/dso.m4 @@ -28,7 +28,6 @@ AC_DEFUN([APU_CHECK_UTIL_DSO], [ aprdso=`awk '/^#define APR_HAS_DSO/ { print @S|@3; }' $apr_h` if test "$enable_util_dso" = "no" || "$aprdso" = "0"; then - # Statically link the DBD drivers: objs= test $apu_have_openssl = 1 && objs="$objs crypto/apr_crypto_openssl.lo" diff --git a/dbm/apr_dbm.c b/dbm/apr_dbm.c index 3126b84b..d4fed7b1 100644 --- a/dbm/apr_dbm.c +++ b/dbm/apr_dbm.c @@ -34,165 +34,56 @@ ### API entirely? Oh, what to do. We need an APU_DEFAULT_DBM #define. ### Sounds like a job for autoconf. */ -#if APU_USE_DB -#define DBM_VTABLE apr_dbm_type_db -#define DBM_NAME "db" +#if APU_USE_SDBM +#define DBM_VTABLE apr_dbm_type_sdbm #elif APU_USE_GDBM #define DBM_VTABLE apr_dbm_type_gdbm -#define DBM_NAME "gdbm" +#elif APU_USE_DB +#define DBM_VTABLE apr_dbm_type_db #elif APU_USE_NDBM #define DBM_VTABLE apr_dbm_type_ndbm -#define DBM_NAME "ndbm" -#elif APU_USE_SDBM -#define DBM_VTABLE apr_dbm_type_sdbm -#define DBM_NAME "sdbm" #else /* Not in the USE_xDBM list above */ #error a DBM implementation was not specified #endif -#ifdef APU_DSO_BUILD - -static apr_hash_t *drivers = NULL; - -static apr_status_t apr_dbd_term(void *ptr) -{ - /* set drivers to NULL so init can work again */ - drivers = NULL; - - /* Everything else we need is handled by cleanups registered - * when we created mutexes and loaded DSOs - */ - return APR_SUCCESS; -} - -#endif /* APU_DSO_BUILD */ - -static apr_status_t dbm_open_type(apr_dbm_type_t const* * vtable, - const char *type, - apr_pool_t *pool) +APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **pdb, const char*type, + const char *pathname, + apr_int32_t mode, apr_fileperms_t perm, + apr_pool_t *pool) { -#ifndef APU_DSO_BUILD - - *vtable = NULL; - if (!strcasecmp(type, "default")) *vtable = &DBM_VTABLE; -#if APU_HAVE_DB - else if (!strcasecmp(type, "db")) *vtable = &apr_dbm_type_db; -#endif - else if (*type && !strcasecmp(type + 1, "dbm")) { #if APU_HAVE_GDBM - if (*type == 'G' && *type == 'g') *vtable = &apr_dbm_type_gdbm; -#endif -#if APU_HAVE_NDBM - if (*type == 'N' && *type == 'n') *vtable = &apr_dbm_type_ndbm; + if (!strcasecmp(type, "GDBM")) { + return (*apr_dbm_type_gdbm.open)(pdb, pathname, mode, perm, pool); + } #endif #if APU_HAVE_SDBM - if (*type == 'S' && *type == 's') *vtable = &apr_dbm_type_sdbm; -#endif - /* avoid empty block */ ; - } - if (*vtable) - return APR_SUCCESS; - return APR_ENOTIMPL; - -#else /* APU_DSO_BUILD */ - - char modname[32]; - char symname[34]; - apr_dso_handle_sym_t symbol; - apr_status_t rv; - int usertype = 0; - - if (!strcasecmp(type, "default")) type = DBM_NAME; - else if (!strcasecmp(type, "db")) type = "db"; - else if (*type && !strcasecmp(type + 1, "dbm")) { - if (type == 'G' || type == 'g') type = "gdbm"; - else if (type == 'N' || type == 'n') type = "ndbm"; - else if (type == 'S' || type == 's') type = "sdbm"; + if (!strcasecmp(type, "SDBM")) { + return (*apr_dbm_type_sdbm.open)(pdb, pathname, mode, perm, pool); } - else usertype = 1; - - if (!drivers) - { - apr_pool_t *ppool = pool; - apr_pool_t *parent; - - /* Top level pool scope, need process-scope lifetime */ - for (parent = pool; parent; parent = apr_pool_parent_get(ppool)) - ppool = parent; - - /* deprecate in 2.0 - permit implicit initialization */ - apu_dso_init(ppool); - - drivers = apr_hash_make(ppool); - apr_hash_set(drivers, "sdbm", APR_HASH_KEY_STRING, &apr_dbm_type_sdbm); - - apr_pool_cleanup_register(ppool, NULL, dbm_term, - apr_pool_cleanup_null); - } - - rv = apu_dso_mutex_lock(); - if (rv) { - *vtable = NULL - return rv; +#endif +#if APU_HAVE_DB + if (!strcasecmp(type, "DB")) { + return (*apr_dbm_type_db.open)(pdb, pathname, mode, perm, pool); } - - *vtable = apr_hash_get(drivers, type, APR_HASH_KEY_STRING); - if (*vtable) { - apu_dso_mutex_unlock(); - return APR_SUCCESS; +#endif +#if APU_HAVE_NDBM + if (!strcasecmp(type, "NDBM")) { + return (*apr_dbm_type_ndbm.open)(pdb, pathname, mode, perm, pool); } - - /* The driver DSO must have exactly the same lifetime as the - * drivers hash table; ignore the passed-in pool */ - pool = apr_hash_pool_get(drivers); - -#if defined(NETWARE) - apr_snprintf(modname, sizeof(modname), "dbm%s.nlm", type); -#elif defined(WIN32) - apr_snprintf(modname, sizeof(modname), - "apr_dbm_%s-" APU_STRINGIFY(APU_MAJOR_VERSION) ".dll", type); -#else - apr_snprintf(modname, sizeof(modname), - "apr_dbm_%s-" APU_STRINGIFY(APU_MAJOR_VERSION) ".so", type); #endif - apr_snprintf(symname, sizeof(symname), "apr_dbm_type_%s", type); - rv = apu_dso_load(&symbol, modname, symname, pool); - if (rv != APR_SUCCESS || rv == APR_EINIT) { /* previously loaded?!? */ - *vtable = symbol; - if (usertype) - type = apr_pstrdup(pool, type); - apr_hash_set(drivers, type, APR_HASH_KEY_STRING, *vtable); + if (!strcasecmp(type, "default")) { + return (*DBM_VTABLE.open)(pdb, pathname, mode, perm, pool); } - else - *vtable = NULL; - - apu_dso_mutex_unlock(); - return rv; -#endif /* APU_DSO_BUILD */ -} - -APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **pdb, const char *type, - const char *pathname, - apr_int32_t mode, - apr_fileperms_t perm, - apr_pool_t *pool) -{ - apr_dbm_type_t const* vtable = NULL; - apr_status_t rv = dbm_open_type(&vtable, type, pool); - - if (rv == APR_SUCCESS) { - rv = (vtable->open)(pdb, pathname, mode, perm, pool); - } - return rv; + return APR_ENOTIMPL; } APU_DECLARE(apr_status_t) apr_dbm_open(apr_dbm_t **pdb, const char *pathname, apr_int32_t mode, apr_fileperms_t perm, apr_pool_t *pool) { - return apr_dbm_open_ex(pdb, DBM_NAME, pathname, mode, perm, pool); + return (*DBM_VTABLE.open)(pdb, pathname, mode, perm, pool); } APU_DECLARE(void) apr_dbm_close(apr_dbm_t *dbm) @@ -258,14 +149,37 @@ APU_DECLARE(apr_status_t) apr_dbm_get_usednames_ex(apr_pool_t *p, const char **used1, const char **used2) { - apr_dbm_type_t const* vtable; - apr_status_t rv = dbm_open_type(&vtable, type, p); +#if APU_HAVE_GDBM + if (!strcasecmp(type, "GDBM")) { + (*apr_dbm_type_gdbm.getusednames)(p,pathname,used1,used2); + return APR_SUCCESS; + } +#endif +#if APU_HAVE_SDBM + if (!strcasecmp(type, "SDBM")) { + (*apr_dbm_type_sdbm.getusednames)(p,pathname,used1,used2); + return APR_SUCCESS; + } +#endif +#if APU_HAVE_DB + if (!strcasecmp(type, "DB")) { + (*apr_dbm_type_db.getusednames)(p,pathname,used1,used2); + return APR_SUCCESS; + } +#endif +#if APU_HAVE_NDBM + if (!strcasecmp(type, "NDBM")) { + (*apr_dbm_type_ndbm.getusednames)(p,pathname,used1,used2); + return APR_SUCCESS; + } +#endif - if (rv == APR_SUCCESS) { - (vtable->getusednames)(p, pathname, used1, used2); + if (!strcasecmp(type, "default")) { + (*DBM_VTABLE.getusednames)(p, pathname, used1, used2); return APR_SUCCESS; } - return rv; + + return APR_ENOTIMPL; } APU_DECLARE(void) apr_dbm_get_usednames(apr_pool_t *p, @@ -273,7 +187,10 @@ APU_DECLARE(void) apr_dbm_get_usednames(apr_pool_t *p, const char **used1, const char **used2) { - apr_dbm_get_usednames_ex(p, DBM_NAME, pathname, used1, used2); + /* ### one day, a DBM type name will be passed and we'll need to look it + ### up. for now, it is constant. */ + + (*DBM_VTABLE.getusednames)(p, pathname, used1, used2); } /* Most DBM libraries take a POSIX mode for creating files. Don't trust diff --git a/dbm/apr_dbm_berkeleydb.c b/dbm/apr_dbm_berkeleydb.c index 00b47467..06277421 100644 --- a/dbm/apr_dbm_berkeleydb.c +++ b/dbm/apr_dbm_berkeleydb.c @@ -385,7 +385,7 @@ static void vt_db_usednames(apr_pool_t *pool, const char *pathname, } -APU_MODULE_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_db = { +APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_db = { "db", vt_db_open, diff --git a/dbm/apr_dbm_gdbm.c b/dbm/apr_dbm_gdbm.c index 87c0ac72..e5462c47 100644 --- a/dbm/apr_dbm_gdbm.c +++ b/dbm/apr_dbm_gdbm.c @@ -237,7 +237,7 @@ static void vt_gdbm_usednames(apr_pool_t *pool, const char *pathname, *used2 = NULL; } -APU_MODULE_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_gdbm = { +APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_gdbm = { "gdbm", vt_gdbm_open, vt_gdbm_close, diff --git a/dbm/apr_dbm_ndbm.c b/dbm/apr_dbm_ndbm.c index db6eec1f..42ddbed3 100644 --- a/dbm/apr_dbm_ndbm.c +++ b/dbm/apr_dbm_ndbm.c @@ -220,7 +220,7 @@ static void vt_ndbm_usednames(apr_pool_t *pool, const char *pathname, *used2 = NULL; } -APU_MODULE_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_ndbm = { +APU_DECLARE_DATA const apr_dbm_type_t apr_dbm_type_ndbm = { "ndbm", vt_ndbm_open, vt_ndbm_close, diff --git a/include/apr_dbm.h b/include/apr_dbm.h index ad1b4f39..9f6e8b47 100644 --- a/include/apr_dbm.h +++ b/include/apr_dbm.h @@ -63,10 +63,10 @@ typedef struct * @param dbm The newly opened database * @param type The type of the DBM (not all may be available at run time) * <pre> - * db for Berkeley DB files - * gdbm for GDBM files - * ndbm for NDBM files - * sdbm for SDBM files (always available) + * GDBM for GDBM files + * SDBM for SDBM files + * DB for berkeley DB files + * NDBM for NDBM files * default for the default DBM type * </pre> * @param name The dbm file name to open @@ -81,9 +81,6 @@ typedef struct * @param cntxt The pool to use when creating the dbm * @remark The dbm name may not be a true file name, as many dbm packages * append suffixes for seperate data and index files. - * @bug In apr-util 0.9 and 1.x, the type arg was case insensitive. This - * was highly inefficient, and as of 2.x the dbm name must be provided in - * the correct case (lower case for all bundled providers) */ APU_DECLARE(apr_status_t) apr_dbm_open_ex(apr_dbm_t **dbm, const char* type, @@ -187,7 +184,7 @@ APU_DECLARE(char *) apr_dbm_geterror(apr_dbm_t *dbm, int *errcode, * actual file/path names which would be (created and) used. At most, two * files may be used; used2 may be NULL if only one file is used. * @param pool The pool for allocating used1 and used2. - * @param type The type of DBM you require info on @see apr_dbm_open_ex + * @param type The type of DBM you require info on * @param pathname The path name to generate used-names from. * @param used1 The first pathname used by the apr_dbm implementation. * @param used2 The second pathname used by apr_dbm. If only one file is diff --git a/include/apu.hw b/include/apu.hw index cdc3fb8a..b0b0b3ca 100644 --- a/include/apu.hw +++ b/include/apu.hw @@ -108,13 +108,14 @@ #define APU_HAVE_DB_VERSION 0 #endif +#ifndef APU_DBD_DSO_BUILD #define APU_HAVE_PGSQL 0 #define APU_HAVE_MYSQL 0 #define APU_HAVE_SQLITE3 0 #define APU_HAVE_SQLITE2 0 #define APU_HAVE_ORACLE 0 #define APU_HAVE_FREETDS 0 - +#endif /* Windows always has ODBC */ #define APU_HAVE_ODBC 1 diff --git a/include/private/apr_dbm_private.h b/include/private/apr_dbm_private.h index f92cce77..c598752f 100644 --- a/include/private/apr_dbm_private.h +++ b/include/private/apr_dbm_private.h @@ -110,11 +110,13 @@ struct apr_dbm_t /* Declare all of the builtin DBM providers */ APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_sdbm; -#ifndef DSO_BUILD APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_gdbm; APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_ndbm; +APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db1; +APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db2; +APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db3; +APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db4; APU_DECLARE_DATA extern const apr_dbm_type_t apr_dbm_type_db; -#endif #ifdef __cplusplus } |