]> granicus.if.org Git - apache/commitdiff
The feature macro may appear a bit odd. I'm open to any better suggest.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 8 Dec 2000 18:27:53 +0000 (18:27 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 8 Dec 2000 18:27:53 +0000 (18:27 +0000)
  Define AP_AUTH_DBM_USE_APR for apr dbm access, and apply the symbol to
  the win32 build.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87265 13f79535-47bb-0310-9956-ffa450edef68

modules/aaa/mod_auth_dbm.c
modules/aaa/mod_auth_dbm.dsp

index c00cc699a883d86748731ea2f600ee8c79fb85b8..faf2eff8f4a5a7d94afc32b1b2520732763d1e3a 100644 (file)
 #include "http_protocol.h"
 #include "http_request.h"   /* for ap_hook_(check_user_id | auth_checker)*/
 
-#if defined(WIN32) /* XXX: A better feature test is needed here */
-#include "sdbm.h"
-#define DBM SDBM
-#define datum sdbm_datum
-#define dbm_open sdbm_open
-#define dbm_fetch sdbm_fetch
-#define dbm_close sdbm_close
+#if defined(AP_AUTH_DBM_USE_APR)
+#include "apr_dbm.h"
+#define DBM apr_dbm_t
+#define datum apr_datum_t
+#define dbm_open apr_dbm_open
+#define dbm_fetch apr_dbm_fetch
+#define dbm_close apr_dbm_close
 #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
     && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
 #include <db1/ndbm.h>
@@ -160,7 +160,7 @@ static char *get_dbm_pw(request_rec *r, char *user, char *auth_dbmpwfile)
     DBM *f;
     datum d, q;
     char *pw = NULL;
-#ifdef WIN32 /* this is only used on Windows, so only define it on Windows */
+#ifdef AP_AUTH_DBM_USE_APR
     apr_status_t retval;
 #endif
     q.dptr = user;
@@ -170,20 +170,27 @@ static char *get_dbm_pw(request_rec *r, char *user, char *auth_dbmpwfile)
     q.dsize = strlen(q.dptr) + 1;
 #endif
 
-#ifdef WIN32 /* XXX: Same bad symbol here - need feature macro */
-    if (!(retval = dbm_open(&f, auth_dbmpwfile, O_RDONLY, 0664, r->pool))) {
+#ifdef AP_AUTH_DBM_USE_APR
+    if (!(retval = dbm_open(&f, auth_dbmpwfile, APR_DBM_READONLY, r->pool))) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, retval, r,
                    "could not open sdbm auth file: %s", auth_dbmpwfile);
+       return NULL;
+    }
+    if (dbm_fetch(f, q, &d) == APR_SUCCESS)
+        /* sorry for the obscurity ... falls through to the 
+         * if (d.dptr) {  block ...
+         */
+
 #else
     if (!(f = dbm_open(auth_dbmpwfile, O_RDONLY, 0664))) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
                    "could not open dbm auth file: %s", auth_dbmpwfile);
-#endif
        return NULL;
     }
-
     d = dbm_fetch(f, q);
 
+#endif
+
     if (d.dptr) {
        pw = apr_palloc(r->pool, d.dsize + 1);
        strncpy(pw, d.dptr, d.dsize);
index 89fec9a039ed5ddb84fb15076ead3371d4bd02b7..498115e90262aa0e3767b277d1213c73ee14fcf2 100644 (file)
@@ -43,7 +43,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /I "..\..\srclib\sdbm" /I "..\..\os\win32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /I "..\..\srclib\sdbm" /I "..\..\os\win32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "AP_AUTH_DBM_USE_APR" /FD /c
 # ADD BASE MTL /nologo /D "NDEBUG" /win32
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
 # ADD BASE RSC /l 0x809 /d "NDEBUG"
@@ -69,7 +69,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /I "..\..\srclib\sdbm" /I "..\..\os\win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /I "..\..\srclib\sdbm" /I "..\..\os\win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "AP_AUTH_DBM_USE_APR" /FD /c
 # ADD BASE MTL /nologo /D "_DEBUG" /win32
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
 # ADD BASE RSC /l 0x809 /d "_DEBUG"