httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: apache-nspr-01.tar.gz
Date Mon, 27 Apr 1998 19:13:46 GMT
Just to give folks a better idea of what I'm doing here, since the above
tarball is a really large delta from current CVS, here is a much smaller
incremental update.  In this one I've finished replacing
opendir/readdir/closedir; and I'm part way through replacing all stat()
calls... I got stuck because to replace stat() I had to walk into the time
functions and I'll need to replace them first... and then I fell asleep. 

This isn't -02 or anything, just a little peek at part of the larger
process. 

I am really impressed with NSPR -- it is a complete abstraction layer that
does not allow you to "cheat".  At least I haven't spent effort to find a
way... for example I almost wanted to just use the various pipe() code for
spawning, but there's no way to take a filedescriptor and put it into an
NSPR PRFileDesc.  You have to do it all the right way.  And nothing
important appears to be missing (well except for docs for prtime.h ;)

Oh and this means we can't use FILE * at all any more... which is why
you'll see I've been increasing the buff.c functionality as I replace FILE
* usage in various places.  You essentially can't call any system calls
except through the NSPR interfaces; if you do call system calls then the
code won't work on unixes that don't have system level threads. 

Folks wondering how we'll deal with 3rd party libraries and this stuff --
here's my thoughts.  On systems where NSPR uses pthreads (and on win32 I
hope) 3rd party libraries will work without effort -- in this case NSPR is
a wrapper around all the unix system calls, and not much more.  On systems
where NSPR uses user level threads packages you would have to port the
library to NSPR before you could use it.  But this isn't a surprise -- on
those systems there are generally no kernel threads and so nothing really
works in a threaded setting unless they all share the same threads
library... but we can make all of these systems work. 

What we need to do is to "port" NSPR to fork().  This should amount to
taking all the NSPR pthreads code and removing threading from it.  In this
case certain operations won't work, but Apache wouldn't be using those
operations.  We'd end up with a server that behaves like the current 1.x
code base... but all the syscalls would be wrapped by NSPR.  This kills
two birds with one stone -- we get the pre-forking model, and we get
compatibility with 3rd party libraries. 

Dean

diff -ru -xCVS -xhttpd.map apache-nspr-01/src/README.NSPR apache-nspr/src/README.NSPR
--- apache-nspr-01/src/README.NSPR	Wed Apr 29 01:07:16 1998
+++ apache-nspr/src/README.NSPR	Wed Apr 29 03:52:25 1998
@@ -12,7 +12,7 @@
 TODO:
 
 - clean up timeouts, all the timeout routines in http_main are
-  commented out
+  commented out; still need to set timeout in BUFF
 - implement ebcdic as a layer ?
 - implement chunking as a layer
 - need ap_slack functionality, probably has to be inside NSPR
@@ -20,6 +20,8 @@
 - mmap/transmitfile
 - clean up the messy hacks that I made for hostname/addr parsing
   and such... should be able to grep for XXX:.*ipv6
+- uhhh... I haven't touched the proxy much at all, it's going to
+  need some serious surgery...
 
 NSPR thoughts/nits/questions:
 
@@ -85,3 +87,15 @@
     PR_Poll()?  Assuming yes.
 
 - what is the correct way to compare two PRNetAddrs for equality?
+
+- folks should test PRStatus results against PR_SUCCESS when at
+    all possible -- because PR_SUCCESS is 0, and such tests are
+    frequently cheaper for the compiler to implement than tests
+    for -1 (PR_FAILURE).  i.e.
+	foo == PR_SUCCESS   is better than  foo != PR_FAILURE
+	foo != PR_SUCCESS   is better than  foo == PR_FAILURE
+    similarly tests >= 0, > 0, < 0 are all cheaper ... and should
+    be used when the function definition permits it.
+
+- Where are the .html docs for PRTime?  (Hmm, I wonder if the
+    .h files or the .html docs are more up to date.)
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/include/alloc.h apache-nspr/src/include/alloc.h
--- apache-nspr-01/src/include/alloc.h	Tue Apr 28 22:24:38 1998
+++ apache-nspr/src/include/alloc.h	Wed Apr 29 01:29:46 1998
@@ -81,11 +81,6 @@
  * alloc.c.  
  */
 
- /* Need declaration of DIR on Win32 */
-#ifdef WIN32
-#include "../os/win32/readdir.h"
-#endif
-
 typedef struct pool pool;
 
 pool * ap_init_alloc(void);		/* Set up everything */
@@ -261,8 +256,8 @@
 API_EXPORT(void) ap_pregfree(pool *p, regex_t * reg);
 
 /* routines to deal with directories */
-API_EXPORT(DIR *) ap_popendir(pool *p, const char *name);
-API_EXPORT(void) ap_pclosedir(pool *p, DIR * d);
+API_EXPORT(PRDir *) ap_popendir(pool *p, const char *name);
+API_EXPORT(PRStatus) ap_pclosedir(pool *p, PRDir *d);
 
 /* ... even child processes (which we may want to wait for,
  * or to kill outright, on unexpected termination).
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/include/httpd.h apache-nspr/src/include/httpd.h
--- apache-nspr-01/src/include/httpd.h	Wed Apr 29 00:51:08 1998
+++ apache-nspr/src/include/httpd.h	Wed Apr 29 03:41:49 1998
@@ -83,6 +83,7 @@
 
 #include <prinrval.h>
 #include <prio.h>
+#include <prtime.h>
 
 /* ----------------------------- config dir ------------------------------ */
 
@@ -685,7 +686,13 @@
     char *filename;
     char *path_info;
     char *args;			/* QUERY_ARGS, if any */
-    struct stat finfo;		/* ST_MODE set to zero if no such file */
+    /* Previously the file exists test was done by checking if
+     * finfo.st_mode != 0... because finfo was a struct stat.
+     * Now this boolean should be tested.  file_exists indicates
+     * that the file exists, and finfo contains valid information.
+     */
+    int file_exists;
+    PRFileInfo finfo;		/* ST_MODE set to zero if no such file */
     uri_components parsed_uri;	/* components of uri, dismantled */
 
     /* Various other config info which may change with .htaccess files
@@ -800,8 +807,11 @@
     /* Transaction handling */
 
     server_addr_rec *addrs;
-    PRIntervalTime pr_timeout;			/* Timeout, in seconds, before we give up */
-    PRIntervalTime pr_keep_alive_timeout;	/* Seconds we'll wait for another request */
+    /* used to be called timeout and keep_alive_timeout, the names were
+     * changed to force compile-time errors with out-of-date modules
+     */
+    PRIntervalTime timeout_interval;	/* Timeout, in seconds, before we give up */
+    PRIntervalTime keep_alive_timeout_interval;	/* Seconds we'll wait for another request
*/
     int keep_alive_max;		/* Maximum requests per connection */
     int keep_alive;		/* Use persistent connections? */
     PRSize send_buffer_size;	/* size of TCP send buffer (in bytes) */
@@ -836,7 +846,7 @@
 
 API_EXPORT(struct tm *) ap_get_gmtoff(int *tz, struct tm *);
 API_EXPORT(char *) ap_get_time(char *);
-API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt);
+API_EXPORT(char *) ap_ht_time(pool *p, PRTime t, const char *fmt, int gmt);
 API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t t);
 
 /* String handling. The *_nc variants allow you to use non-const char **s as
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/main/alloc.c apache-nspr/src/main/alloc.c
--- apache-nspr-01/src/main/alloc.c	Tue Apr 28 23:44:48 1998
+++ apache-nspr/src/main/alloc.c	Wed Apr 29 01:25:42 1998
@@ -1516,33 +1516,33 @@
 
 static void dir_cleanup(void *dv)
 {
-    closedir((DIR *) dv);
+    PR_CloseDir(dv);
 }
 
-API_EXPORT(DIR *) ap_popendir(pool *p, const char *name)
+API_EXPORT(PRDir *) ap_popendir(pool *p, const char *name)
 {
-    DIR *d;
-    int save_errno;
+    PRDir *d;
 
     ap_block_alarms();
-    d = opendir(name);
+    d = PR_OpenDir(name);
     if (d == NULL) {
-	save_errno = errno;
 	ap_unblock_alarms();
-	errno = save_errno;
 	return NULL;
     }
-    ap_register_cleanup(p, (void *) d, dir_cleanup, dir_cleanup);
+    ap_register_cleanup(p, d, dir_cleanup, dir_cleanup);
     ap_unblock_alarms();
     return d;
 }
 
-API_EXPORT(void) ap_pclosedir(pool *p, DIR * d)
+API_EXPORT(PRStatus) ap_pclosedir(pool *p, PRDir *d)
 {
+    PRStatus rc;
+
     ap_block_alarms();
-    ap_kill_cleanup(p, (void *) d, dir_cleanup);
-    closedir(d);
+    ap_kill_cleanup(p, d, dir_cleanup);
+    rc = PR_CloseDir(d);
     ap_unblock_alarms();
+    return rc;
 }
 
 /*****************************************************************
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/main/http_config.c apache-nspr/src/main/http_config.c
--- apache-nspr-01/src/main/http_config.c	Wed Apr 29 00:44:20 1998
+++ apache-nspr/src/main/http_config.c	Wed Apr 29 02:53:49 1998
@@ -1086,20 +1086,19 @@
 {
     const char *errmsg;
     cmd_parms parms;
-    struct stat finfo;
 
     fname = ap_server_root_relative(p, fname);
 
     if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
 	!(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) {
-	if (stat(fname, &finfo) == -1)
+	if (PR_Access(fname, PR_ACCESS_READ_OK) != PR_SUCCESS)
 	    return;
     }
 
     /* don't require conf/httpd.conf if we have a -C or -c switch */
     if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
        !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
-	if (stat(fname, &finfo) == -1)
+	if (PR_Access(fname, PR_ACCESS_READ_OK) != PR_SUCCESS)
 	    return;
     }
 
@@ -1227,8 +1226,8 @@
     s->error_fname = NULL;
     s->srm_confname = NULL;
     s->access_confname = NULL;
-    s->pr_timeout = PR_INTERVAL_NO_WAIT;
-    s->pr_keep_alive_timeout = PR_INTERVAL_NO_WAIT;
+    s->timeout_interval = PR_INTERVAL_NO_WAIT;
+    s->keep_alive_timeout_interval = PR_INTERVAL_NO_WAIT;
     s->keep_alive = -1;
     s->keep_alive_max = -1;
     s->error_log = main_server->error_log;
@@ -1274,11 +1273,11 @@
 	if (virt->access_confname == NULL)
 	    virt->access_confname = main_server->access_confname;
 
-	if (virt->pr_timeout == PR_INTERVAL_NO_WAIT)
-	    virt->pr_timeout = main_server->pr_timeout;
+	if (virt->timeout_interval == PR_INTERVAL_NO_WAIT)
+	    virt->timeout_interval = main_server->timeout_interval;
 
-	if (virt->pr_keep_alive_timeout == PR_INTERVAL_NO_WAIT)
-	    virt->pr_keep_alive_timeout = main_server->pr_keep_alive_timeout;
+	if (virt->keep_alive_timeout_interval == PR_INTERVAL_NO_WAIT)
+	    virt->keep_alive_timeout_interval = main_server->keep_alive_timeout_interval;
 
 	if (virt->keep_alive == -1)
 	    virt->keep_alive = main_server->keep_alive;
@@ -1339,8 +1338,8 @@
     s->loglevel = DEFAULT_LOGLEVEL;
     s->srm_confname = RESOURCE_CONFIG_FILE;
     s->access_confname = ACCESS_CONFIG_FILE;
-    s->pr_timeout = PR_SecondsToInterval(DEFAULT_TIMEOUT);
-    s->pr_keep_alive_timeout = PR_SecondsToInterval(DEFAULT_KEEPALIVE_TIMEOUT);
+    s->timeout_interval = PR_SecondsToInterval(DEFAULT_TIMEOUT);
+    s->keep_alive_timeout_interval = PR_SecondsToInterval(DEFAULT_KEEPALIVE_TIMEOUT);
     s->keep_alive_max = DEFAULT_KEEPALIVE;
     s->keep_alive = 1;
     s->next = NULL;
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/main/http_core.c apache-nspr/src/main/http_core.c
--- apache-nspr-01/src/main/http_core.c	Wed Apr 29 00:23:35 1998
+++ apache-nspr/src/main/http_core.c	Wed Apr 29 03:57:44 1998
@@ -1393,7 +1393,7 @@
     const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
     if (err != NULL) return err;
 
-    cmd->server->pr_timeout = PR_SecondsToInterval(atoi(arg));
+    cmd->server->timeout_interval = PR_SecondsToInterval(atoi(arg));
     return NULL;
 }
 
@@ -1403,7 +1403,7 @@
     const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
     if (err != NULL) return err;
 
-    cmd->server->pr_keep_alive_timeout = PR_SecondsToInterval(atoi(arg));
+    cmd->server->keep_alive_timeout_interval = PR_SecondsToInterval(atoi(arg));
     return NULL;
 }
 
@@ -1758,12 +1758,13 @@
 
 static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg) 
 {
-    struct stat finfo;
+    PRFileInfo finfo;
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
     if (err != NULL) return err;
 
     arg = ap_server_root_relative(cmd->pool, arg);
-    if ((stat(arg, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
+    if (PR_GetFileInfo(arg, &finfo) != PR_SUCCESS
+	|| finfo.type != PR_FILE_DIRECTORY) {
 	return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", arg, 
 	    " does not exist or is not a directory", NULL);
     }
@@ -2052,7 +2053,7 @@
     if (r->method_number == M_OPTIONS) return ap_send_http_options(r);
     if (r->method_number == M_PUT) return METHOD_NOT_ALLOWED;
 
-    if (r->finfo.st_mode == 0 || (r->path_info && *r->path_info)) {
+    if (r->file_exists == 0 || (r->path_info && *r->path_info)) {
 	ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r->server, 
                     "File does not exist: %s", r->path_info ? 
                     ap_pstrcat(r->pool, r->filename, r->path_info, NULL)
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/main/http_main.c apache-nspr/src/main/http_main.c
--- apache-nspr-01/src/main/http_main.c	Tue Apr 28 17:34:36 1998
+++ apache-nspr/src/main/http_main.c	Wed Apr 29 02:55:40 1998
@@ -2555,6 +2555,7 @@
 #ifndef WIN32
     struct stat wrapper;
 
+    /* XXX: how to do this in NSPR? */
     if ((stat(SUEXEC_BIN, &wrapper)) != 0)
 	return (ap_suexec_enabled);
 
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/main/http_protocol.c apache-nspr/src/main/http_protocol.c
--- apache-nspr-01/src/main/http_protocol.c	Tue Apr 28 22:09:01 1998
+++ apache-nspr/src/main/http_protocol.c	Wed Apr 29 01:18:51 1998
@@ -302,7 +302,7 @@
                          "chunked") ||
          ((r->proto_num >= HTTP_VERSION(1,1)) && (r->chunked = 1))) &&
         r->server->keep_alive &&
-        (r->server->pr_keep_alive_timeout != PR_INTERVAL_NO_WAIT) &&
+        (r->server->keep_alive_timeout_interval != PR_INTERVAL_NO_WAIT) &&
         ((r->server->keep_alive_max == 0) ||
          (r->server->keep_alive_max > r->connection->keepalives)) &&
         !status_drops_connection(r->status) &&
@@ -323,12 +323,12 @@
             if (r->server->keep_alive_max)
 		ap_table_setn(r->headers_out, "Keep-Alive",
 		    ap_psprintf(r->pool, "timeout=%d, max=%d",
-			PR_IntervalToSeconds(r->server->pr_keep_alive_timeout),
+			PR_IntervalToSeconds(r->server->keep_alive_timeout_interval),
 			left));
             else
 		ap_table_setn(r->headers_out, "Keep-Alive",
 		    ap_psprintf(r->pool, "timeout=%d",
-			PR_IntervalToSeconds(r->server->pr_keep_alive_timeout)
+			PR_IntervalToSeconds(r->server->keep_alive_timeout_interval)
 			));
             ap_table_mergen(r->headers_out, "Connection", "Keep-Alive");
         }
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/main/http_request.c apache-nspr/src/main/http_request.c
--- apache-nspr-01/src/main/http_request.c	Mon Apr 20 12:01:55 1998
+++ apache-nspr/src/main/http_request.c	Wed Apr 29 03:17:51 1998
@@ -76,6 +76,8 @@
 #include "scoreboard.h"
 #include "fnmatch.h"
 
+#include <prerror.h>
+
 /*****************************************************************
  *
  * Getting and checking directory configuration.  Also checks the
@@ -112,7 +114,8 @@
 
 static int check_symlinks(char *d, int opts)
 {
-#if defined(__EMX__) || defined(WIN32)
+    /* XXX: figure out how to do symlink stuff on NSPR */
+#if defined(__EMX__) || defined(WIN32) || defined(NSPR)
     /* OS/2 doesn't have symlinks */
     return OK;
 #else
@@ -176,10 +179,11 @@
     char *path = r->filename;
     char *end = &path[strlen(path)];
     char *last_cp = NULL;
-    int rv;
+    PRStatus rv;
+    PRErrorCode ec;
 
-    if (r->finfo.st_mode) {
-	/* assume path_info already set */
+    if (r->file_exists) {
+	/* assume path_info, and finfo already set */
 	return OK;
     }
 
@@ -194,13 +198,12 @@
 
         *cp = '\0';
 
-        errno = 0;
-        rv = stat(path, &r->finfo);
+	rv = PR_GetFileInfo(path, &r->finfo);
 
         if (cp != end)
             *cp = '/';
 
-        if (!rv) {
+        if (rv == PR_SUCCESS) {
 
             /*
              * Aha!  Found something.  If it was a directory, we will search
@@ -208,17 +211,19 @@
              * argument starts with the component after that.
              */
 
-            if (S_ISDIR(r->finfo.st_mode) && last_cp) {
-                r->finfo.st_mode = 0;   /* No such file... */
+	    if (r->finfo.type == PR_FILE_DIRECTORY && last_cp) {
                 cp = last_cp;
             }
+	    else {
+		r->file_exists = 1;
+	    }
 
             r->path_info = ap_pstrdup(r->pool, cp);
             *cp = '\0';
             return OK;
         }
-#if defined(ENOENT) && defined(ENOTDIR)
-        else if (errno == ENOENT || errno == ENOTDIR) {
+	ec = PR_GetError();
+	if (ec == PR_FILE_NOT_FOUND_ERROR || ec == PR_NOT_DIRECTORY_ERROR) {
             last_cp = cp;
 
             while (--cp > path && *cp != '/')
@@ -228,41 +233,14 @@
                 --cp;
         }
         else {
-#if defined(EACCES)
-            if (errno != EACCES)
-#endif
+	    /* XXX: this is bogus, the error code is trashed by the ap_get_remote_host call */
+	    if (ec != PR_NO_ACCESS_RIGHTS_ERROR)
                 ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
                             "access to %s failed for %s", r->uri,
                             ap_get_remote_host(r->connection, r->per_dir_config,
                                             REMOTE_NOLOOKUP));
             return HTTP_FORBIDDEN;
         }
-#else
-#error ENOENT || ENOTDIR not defined; please see the
-#error comments at this line in the source for a workaround.
-        /*
-         * If ENOENT || ENOTDIR is not defined in one of the your OS's
-         * include files, Apache does not know how to check to see why the
-         * stat() of the index file failed; there are cases where it can fail
-         * even though the file exists.  This means that it is possible for
-         * someone to get a directory listing of a directory even though
-         * there is an index (eg. index.html) file in it.  If you do not have
-         * a problem with this, delete the above #error lines and start the
-         * compile again.  If you need to do this, please submit a bug report
-         * from http://www.apache.org/bug_report.html letting us know that
-         * you needed to do this.  Please be sure to include the operating
-         * system you are using.
-         */
-        else {
-            last_cp = cp;
-
-            while (--cp > path && *cp != '/')
-                continue;
-
-            while (cp > path && cp[-1] == '/')
-                --cp;
-        }
-#endif  /* ENOENT && ENOTDIR */
     }
     return OK;
 }
@@ -300,8 +278,8 @@
      * do so.  Where a .htaccess file has permission to override anything,
      * try to find one.  If either of these things fails, we could poke
      * around, see why, and adjust the lookup_rec accordingly --- this might
-     * save us a call to get_path_info (with the attendant stat()s); however,
-     * for the moment, that's not worth the trouble.
+     * save us a call to get_path_info (with the attendant PR_GetFileInfo()s);
+     * however, for the moment, that's not worth the trouble.
      *
      * Fake filenames (i.e. proxy:) only match Directory sections.
      */
@@ -759,9 +737,8 @@
         rnew->uri = ap_make_full_path(rnew->pool, udir, new_file);
         rnew->filename = ap_make_full_path(rnew->pool, fdir, new_file);
 	ap_parse_uri(rnew, rnew->uri);    /* fill in parsed_uri values */
-        if (stat(rnew->filename, &rnew->finfo) < 0) {
-            rnew->finfo.st_mode = 0;
-        }
+	rnew->file_exists =
+	    PR_GetFileInfo(rnew->filename, &rnew->finfo) == PR_SUCCESS;
 
         if ((res = check_safe_file(rnew))) {
             rnew->status = res;
@@ -774,7 +751,7 @@
          * no matter what, if it's a subdirectory, we need to re-run
          * directory_walk
          */
-        if (S_ISDIR(rnew->finfo.st_mode)) {
+	if (rnew->finfo.type == PR_FILE_DIRECTORY) {
             res = directory_walk(rnew);
             if (!res) {
                 res = file_walk(rnew);
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/main/util.c apache-nspr/src/main/util.c
--- apache-nspr-01/src/main/util.c	Wed Apr 29 00:51:40 1998
+++ apache-nspr/src/main/util.c	Wed Apr 29 03:41:24 1998
@@ -123,17 +123,20 @@
     return (time_string);
 }
 
-API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt)
+/* XXX: no way to return error to caller */
+API_EXPORT(char *) ap_ht_time(pool *p, PRTime t, const char *fmt, int gmt)
 {
     char ts[MAX_STRING_LEN];
-    struct tm *tms;
+    PRExplodedTime xt;
     char *res;
-    struct tm tmstore;
 
-    tms = (gmt ? gmtime_r(&t, &tmstore) : localtime_r(&t, &tmstore));
+    if (PR_ExplodeTime(t, gmt ? PR_GMTParameters : PR_LocalTimeParameters,
+	    &xt) != PR_SUCCESS) {
+	return ap_pstrdup(p, "bogus time");
+    }
 
-    /* check return code? */
-    strftime(ts, MAX_STRING_LEN, fmt, tms);
+    /* XXX: This is a deprecated function.  Sigh. */
+    PR_FormatTime(ts, MAX_STRING_LEN, &xt);
     ts[MAX_STRING_LEN - 1] = '\0';
     res = ap_pstrdup(p, ts);
     return res;
@@ -1227,12 +1230,10 @@
 
 API_EXPORT(int) ap_is_directory(const char *path)
 {
-    struct stat finfo;
-
-    if (stat(path, &finfo) == -1)
-	return 0;		/* in error condition, just return no */
+    PRFileInfo finfo;
 
-    return (S_ISDIR(finfo.st_mode));
+    return PR_GetFileInfo(path, &finfo) == PR_SUCCESS
+	    && finfo.type == PR_FILE_DIRECTORY;
 }
 
 API_EXPORT(char *) ap_make_full_path(pool *a, const char *src1,
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/experimental/mod_mmap_static.c apache-nspr/src/modules/experimental/mod_mmap_static.c
--- apache-nspr-01/src/modules/experimental/mod_mmap_static.c	Sat Apr 18 21:28:54 1998
+++ apache-nspr/src/modules/experimental/mod_mmap_static.c	Wed Apr 29 03:19:43 1998
@@ -71,6 +71,8 @@
  * v0.04: work around mod_rewrite, which sets r->filename to the uri first
  */
 
+#error doesn't work with NSPR yet
+
 /*
     Documentation:
 
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/standard/mod_autoindex.c apache-nspr/src/modules/standard/mod_autoindex.c
--- apache-nspr-01/src/modules/standard/mod_autoindex.c	Tue Apr 28 22:03:20 1998
+++ apache-nspr/src/modules/standard/mod_autoindex.c	Wed Apr 29 03:21:37 1998
@@ -531,7 +531,6 @@
 			 int whichend, request_rec *r)
 {
     char *fn;
-    struct stat finfo;
     int plaintext = 0;
     request_rec *rr;
     autoindex_config_rec *cfg =
@@ -546,10 +545,10 @@
     /* XXX: this is a load of crap, it needs to do a full sub_req_lookup_uri */
     fn = ap_make_full_path(r->pool, name, readme_fname);
     fn = ap_pstrcat(r->pool, fn, ".html", NULL);
-    if (stat(fn, &finfo) == -1) {
+    if (PR_Access(fn, PR_ACCESS_READ_OK) != PR_SUCCESS) {
 	/* A brief fake multiviews search for README.html */
 	fn[strlen(fn) - 5] = '\0';
-	if (stat(fn, &finfo) == -1)
+	if (PR_Access(fn, PR_ACCESS_READ_OK) != PR_SUCCESS)
 	    return 0;
 	plaintext = 1;
 	if (hrule)
@@ -655,7 +654,7 @@
     return NULL;
 }
 
-static struct ent *make_autoindex_entry(char *name, int autoindex_opts,
+static struct ent *make_autoindex_entry(const char *name, int autoindex_opts,
 					autoindex_config_rec * d,
 					request_rec *r, char keyid,
 					char direction)
@@ -1012,9 +1011,8 @@
     char *title_name = ap_escape_html(r->pool, r->uri);
     char *title_endp;
     char *name = r->filename;
-
-    DIR *d;
-    struct DIR_TYPE *dstruct;
+    PRDir *d;
+    PRDirEntry *dstruct;
     int num_ent = 0, x;
     struct ent *head, *p;
     struct ent **ar = NULL;
@@ -1089,8 +1087,8 @@
      * linked list and then arrayificate them so qsort can use them. 
      */
     head = NULL;
-    while ((dstruct = readdir(d))) {
-	p = make_autoindex_entry(dstruct->d_name, autoindex_opts,
+    while ((dstruct = PR_ReadDir(d, PR_SKIP_NONE))) {
+	p = make_autoindex_entry(dstruct->name, autoindex_opts,
 				 autoindex_conf, r, keyid, direction);
 	if (p != NULL) {
 	    p->next = head;
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/standard/mod_cgi.c apache-nspr/src/modules/standard/mod_cgi.c
--- apache-nspr-01/src/modules/standard/mod_cgi.c	Tue Apr 28 15:52:31 1998
+++ apache-nspr/src/modules/standard/mod_cgi.c	Wed Apr 29 03:24:24 1998
@@ -167,15 +167,15 @@
 			   int show_errno, char *error)
 {
     FILE *f;
-    struct stat finfo;
+    PRFileInfo finfo;
     char timebuf[MAX_STRING_LEN];
 
     ap_log_error(APLOG_MARK, show_errno|APLOG_ERR, r->server, 
 		"%s, reason: %s", error, r->filename);
 
     if (!conf->logname ||
-	((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0)
-	 &&   (finfo.st_size > conf->logbytes)) ||
+	((PR_GetFileInfo(ap_server_root_relative(r->pool, conf->logname), &finfo) == PR_SUCCESS)
+	 &&   (finfo.size > conf->logbytes)) ||
          ((f = ap_pfopen(r->pool, ap_server_root_relative(r->pool, conf->logname),
 		      "a")) == NULL)) {
 	return ret;
@@ -201,11 +201,11 @@
     char argsbuffer[HUGE_STRING_LEN];
     FILE *f;
     int i;
-    struct stat finfo;
+    PRFileInfo finfo;
 
     if (!conf->logname ||
-	((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0)
-	 &&   (finfo.st_size > conf->logbytes)) ||
+	((PR_GetFileInfo(ap_server_root_relative(r->pool, conf->logname), &finfo) == PR_SUCCESS)
+	 &&   (finfo.size > conf->logbytes)) ||
          ((f = ap_pfopen(r->pool, ap_server_root_relative(r->pool, conf->logname),
 		      "a")) == NULL)) {
 	/* Soak up script output */
@@ -382,6 +382,7 @@
 			       "attempt to include NPH CGI script");
 
 #if defined(__EMX__) || defined(WIN32)
+#error need some NSPR tweaking here
     /* Allow for cgi files without the .EXE extension on them under OS/2 */
     if (r->finfo.st_mode == 0) {
 	struct stat statbuf;
@@ -394,7 +395,7 @@
 	}
     }
 #else
-    if (r->finfo.st_mode == 0)
+    if (r->file_exists == 0)
 	return log_scripterror(r, conf, NOT_FOUND, APLOG_NOERRNO,
 			       "script not found or unable to stat");
 #endif
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/standard/mod_include.c apache-nspr/src/modules/standard/mod_include.c
--- apache-nspr-01/src/modules/standard/mod_include.c	Tue Apr 28 22:19:23 1998
+++ apache-nspr/src/modules/standard/mod_include.c	Wed Apr 29 03:42:45 1998
@@ -1023,14 +1023,14 @@
 
 
 static int find_file(request_rec *r, const char *directive, const char *tag,
-                     char *tag_val, struct stat *finfo, const char *error)
+                     char *tag_val, PRFileInfo *finfo, const char *error)
 {
     char *to_send;
 
     if (!strcmp(tag, "file")) {
         ap_getparents(tag_val);    /* get rid of any nasties */
         to_send = ap_make_full_path(r->pool, "./", tag_val);
-        if (stat(to_send, finfo) == -1) {
+	if (PR_GetFileInfo(to_send, finfo) != PR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
                         "unable to get information about \"%s\" "
                         "in parsed file %s",
@@ -1073,7 +1073,7 @@
 {
     char tag[MAX_STRING_LEN];
     char *tag_val;
-    struct stat finfo;
+    PRFileInfo finfo;
     char parsed_string[MAX_STRING_LEN];
 
     while (1) {
@@ -1087,17 +1087,11 @@
             parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
             if (!find_file(r, "fsize", tag, parsed_string, &finfo, error)) {
                 if (sizefmt == SIZEFMT_KMG) {
-                    ap_send_size(finfo.st_size, r);
+                    ap_send_size(finfo.size, r);
                 }
                 else {
                     int l, x;
-#if defined(BSD) && BSD > 199305
-                    /* ap_snprintf can't handle %qd */
-                    sprintf(tag, "%qd", finfo.st_size);
-#else
-                    ap_snprintf(tag, sizeof(tag), "%ld", finfo.st_size);
-#endif
-                    l = strlen(tag);    /* grrr */
+                    l = ap_snprintf(tag, sizeof(tag), "%lu", finfo.size);
                     for (x = 0; x < l; x++) {
                         if (x && (!((l - x) % 3))) {
                             ap_rputc(',', r);
@@ -1114,7 +1108,7 @@
 {
     char tag[MAX_STRING_LEN];
     char *tag_val;
-    struct stat finfo;
+    PRFileInfo finfo;
     char parsed_string[MAX_STRING_LEN];
 
     while (1) {
@@ -1127,7 +1121,7 @@
         else {
             parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
             if (!find_file(r, "flastmod", tag, parsed_string, &finfo, error)) {
-                ap_rputs(ap_ht_time(r->pool, finfo.st_mtime,
+                ap_rputs(ap_ht_time(r->pool, finfo.modifyTime,
 		    ap_table_get(r->subprocess_env, INCLUDE_TIME_FORMAT), 0), r);
             }
         }
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/standard/mod_mime_magic.c apache-nspr/src/modules/standard/mod_mime_magic.c
--- apache-nspr-01/src/modules/standard/mod_mime_magic.c	Sat Apr 18 21:29:04 1998
+++ apache-nspr/src/modules/standard/mod_mime_magic.c	Wed Apr 29 03:44:42 1998
@@ -1445,63 +1445,19 @@
  */
 static int fsmagic(request_rec *r, const char *fn)
 {
-    switch (r->finfo.st_mode & S_IFMT) {
-    case S_IFDIR:
+    switch (r->finfo.type) {
+    case PR_FILE_DIRECTORY:
 	magic_rsl_puts(r, DIR_MAGIC_TYPE);
 	return DONE;
-    case S_IFCHR:
-	/*
-	 * (void) magic_rsl_printf(r,"character special (%d/%d)",
-	 * major(sb->st_rdev), minor(sb->st_rdev));
-	 */
+    case PR_FILE_OTHER:
 	(void) magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
 	return DONE;
-#ifdef S_IFBLK
-    case S_IFBLK:
-	/*
-	 * (void) magic_rsl_printf(r,"block special (%d/%d)",
-	 * major(sb->st_rdev), minor(sb->st_rdev));
-	 */
-	(void) magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
-	return DONE;
-	/* TODO add code to handle V7 MUX and Blit MUX files */
-#endif
-#ifdef    S_IFIFO
-    case S_IFIFO:
-	/*
-	 * magic_rsl_puts(r,"fifo (named pipe)");
-	 */
-	(void) magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
-	return DONE;
-#endif
-#ifdef    S_IFLNK
-    case S_IFLNK:
-	/* We used stat(), the only possible reason for this is that the
-	 * symlink is broken.
-	 */
-	ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server,
-		    MODNAME ": broken symlink (%s)", fn);
-	return HTTP_INTERNAL_SERVER_ERROR;
-#endif
-#ifdef    S_IFSOCK
-#ifndef __COHERENT__
-    case S_IFSOCK:
-	magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
-	return DONE;
-#endif
-#endif
-    case S_IFREG:
-	break;
-    default:
-	ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, r->server,
-		    MODNAME ": invalid mode 0%o.", (unsigned int)r->finfo.st_mode);
-	return HTTP_INTERNAL_SERVER_ERROR;
     }
 
     /*
      * regular file, check next possibility
      */
-    if (r->finfo.st_size == 0) {
+    if (r->finfo.size == 0) {
 	magic_rsl_puts(r, MIME_TEXT_UNKNOWN);
 	return DONE;
     }
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/standard/mod_negotiation.c apache-nspr/src/modules/standard/mod_negotiation.c
--- apache-nspr-01/src/modules/standard/mod_negotiation.c	Tue Apr 28 21:52:24 1998
+++ apache-nspr/src/modules/standard/mod_negotiation.c	Wed Apr 29 03:45:38 1998
@@ -784,8 +784,8 @@
 
     char *filp;
     int prefix_len;
-    DIR *dirp;
-    struct DIR_TYPE *dir_entry;
+    PRDir *dirp;
+    PRDirEntry *dir_entry;
     struct var_rec mime_info;
     struct accept_rec accept_info;
     void *new_var;
@@ -811,15 +811,15 @@
         return HTTP_FORBIDDEN;
     }
 
-    while ((dir_entry = readdir(dirp))) {
+    while ((dir_entry = PR_ReadDir(dirp, PR_SKIP_NONE))) {
         request_rec *sub_req;
 
         /* Do we have a match? */
 
-        if (strncmp(dir_entry->d_name, filp, prefix_len)) {
+        if (strncmp(dir_entry->name, filp, prefix_len)) {
             continue;
         }
-        if (dir_entry->d_name[prefix_len] != '.') {
+        if (dir_entry->name[prefix_len] != '.') {
             continue;
         }
 
@@ -828,7 +828,7 @@
          * which we'll be slapping default_type on later).
          */
 
-        sub_req = ap_sub_req_lookup_file(dir_entry->d_name, r);
+        sub_req = ap_sub_req_lookup_file(dir_entry->name, r);
 
         /* If it has a handler, we'll pretend it's a CGI script,
          * since that's a good indication of the sort of thing it
@@ -861,7 +861,7 @@
          */
 
         mime_info.sub_req = sub_req;
-        mime_info.file_name = ap_pstrdup(neg->pool, dir_entry->d_name);
+        mime_info.file_name = ap_pstrdup(neg->pool, dir_entry->name);
         if (sub_req->content_encoding) {
             mime_info.content_encoding = sub_req->content_encoding;
         }
@@ -1279,24 +1279,24 @@
 }
 
 /* Determining the content length --- if the map didn't tell us,
- * we have to do a stat() and remember for next time.
+ * we have to do a PR_GetFileInfo() and remember for next time.
  *
  * Grump.  For Apache, even the first stat here may well be
- * redundant (for multiviews) with a stat() done by the sub_req
+ * redundant (for multiviews) with a PR_GetFileInfo() done by the sub_req
  * machinery.  At some point, that ought to be fixed.
  */
 
 static float find_content_length(negotiation_state *neg, var_rec *variant)
 {
-    struct stat statb;
+    PRFileInfo statb;
 
     if (variant->bytes == 0) {
         char *fullname = ap_make_full_path(neg->pool, neg->dir_name,
                                         variant->file_name);
 
-        if (stat(fullname, &statb) >= 0) {
+        if (PR_GetFileInfo(fullname, &statb) == PR_SUCCESS) {
             /* Note, precision may be lost */
-            variant->bytes = (float) statb.st_size;
+            variant->bytes = (float) statb.size;
         }
     }
 
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/standard/mod_rewrite.c apache-nspr/src/modules/standard/mod_rewrite.c
--- apache-nspr-01/src/modules/standard/mod_rewrite.c	Sat Apr 18 22:55:22 1998
+++ apache-nspr/src/modules/standard/mod_rewrite.c	Wed Apr 29 03:55:12 1998
@@ -441,7 +441,6 @@
 {
     rewrite_server_conf *sconf;
     rewritemap_entry *new;
-    struct stat st;
 
     sconf = (rewrite_server_conf *)
             ap_get_module_config(cmd->server->module_config, &rewrite_module);
@@ -496,7 +495,8 @@
     new->fpout = -1;
 
     if (new->checkfile && (sconf->state == ENGINE_ENABLED)
-                       && (stat(new->checkfile, &st) == -1))
+                       && (PR_Access(new->checkfile, PR_ACCESS_READ_OK)
+			    != PR_SUCCESS))
         return ap_pstrcat(cmd->pool, "RewriteMap: map file or program not found:",
                        new->checkfile, NULL);
 
@@ -947,7 +947,6 @@
     char buf[512];
     char docroot[512];
     char *cp, *cp2;
-    struct stat finfo;
     int n;
     int l;
 
@@ -1155,7 +1154,7 @@
              * because we only do stat() on the first directory
              * and this gets cached by the kernel for along time!
              */
-            n = prefix_stat(r->filename, &finfo);
+            n = prefix_stat(r->filename);
             if (n == 0) {
                 if ((cp = ap_document_root(r)) != NULL) {
                     l = ap_cpystrn(docroot, cp, sizeof(docroot)) - docroot;
@@ -1974,7 +1973,7 @@
                               backrefinfo *briRC)
 {
     char input[MAX_STRING_LEN];
-    struct stat sb;
+    PRFileInfo sb;
     request_rec *rsub;
     regmatch_t regmatch[MAX_NMATCH];
     int rc;
@@ -2000,25 +1999,26 @@
 
     rc = 0;
     if (strcmp(p->pattern, "-f") == 0) {
-        if (stat(input, &sb) == 0)
-            if (S_ISREG(sb.st_mode))
+        if (PR_GetFileInfo(input, &sb) == PR_STATUS)
+            if (sb.type == PR_FILE_FILE)
                 rc = 1;
     }
     else if (strcmp(p->pattern, "-s") == 0) {
-        if (stat(input, &sb) == 0)
-            if (S_ISREG(sb.st_mode) && sb.st_size > 0)
+        if (PR_GetFileInfo(input, &sb) == PR_STATUS)
+            if (sb.type == PR_FILE_FILE && sb.size > 0)
                 rc = 1;
     }
     else if (strcmp(p->pattern, "-l") == 0) {
-#if !defined(__EMX__) && !defined(WIN32)
+	/* XXX: how do we do lstat in NSPR? */
+#if !defined(__EMX__) && !defined(WIN32) && !defined(NSPR)
         if (lstat(input, &sb) == 0)
             if (S_ISLNK(sb.st_mode))
                 rc = 1;
 #endif
     }
     else if (strcmp(p->pattern, "-d") == 0) {
-        if (stat(input, &sb) == 0)
-            if (S_ISDIR(sb.st_mode))
+        if (PR_GetFileInfo(input, &sb) == PR_STATUS)
+            if (sb.type == PR_FILE_DIRECTORY)
                 rc = 1;
     }
     else if (strcmp(p->pattern, "-U") == 0) {
@@ -2062,7 +2062,7 @@
             /* file exists for any result up to 2xx, no redirects */
             if (rsub->status < 300 &&
                 /* double-check that file exists since default result is 200 */
-                stat(rsub->filename, &sb) == 0)
+                PR_GetFileInfo(rsub->filename, &sb) == PR_SUCCESS)
                 rc = 1;
 
             /* log it */
@@ -2485,7 +2485,7 @@
     rewritemap_entry *entries;
     rewritemap_entry *s;
     char *value;
-    struct stat st;
+    PRFileInfo st;
     int i;
 
     /* get map configuration */
@@ -2498,7 +2498,7 @@
         s = &entries[i];
         if (strcmp(s->name, name) == 0) {
             if (s->type == MAPTYPE_TXT) {
-                if (stat(s->checkfile, &st) == -1) {
+                if (PR_GetFileInfo(s->checkfile, &st) != PR_SUCCESS) {
                     ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
                                 "mod_rewrite: can't access text RewriteMap "
                                 "file %s", s->checkfile);
@@ -2507,7 +2507,7 @@
                     return NULL;
                 }
                 value = get_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key);
+                                         st.modifyTime, key);
                 if (value == NULL) {
                     rewritelog(r, 6, "cache lookup FAILED, forcing new "
                                "map lookup");
@@ -2516,7 +2516,7 @@
                         rewritelog(r, 5, "map lookup OK: map=%s key=%s[txt] "
                                    "-> val=%s", s->name, key, value);
                         set_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key, value);
+                                         st.modifyTime, key, value);
                         return value;
                     }
                     else {
@@ -2533,7 +2533,7 @@
             }
             else if (s->type == MAPTYPE_DBM) {
 #ifndef NO_DBM_REWRITEMAP
-                if (stat(s->checkfile, &st) == -1) {
+                if (PR_GetFileInfo(s->checkfile, &st) != PR_SUCCESS) {
                     ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
                                 "mod_rewrite: can't access DBM RewriteMap "
                                 "file %s", s->checkfile);
@@ -2542,7 +2542,7 @@
                     return NULL;
                 }
                 value = get_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key);
+                                         st.modifyTime, key);
                 if (value == NULL) {
                     rewritelog(r, 6,
                                "cache lookup FAILED, forcing new map lookup");
@@ -2551,7 +2551,7 @@
                         rewritelog(r, 5, "map lookup OK: map=%s[dbm] key=%s "
                                    "-> val=%s", s->name, key, value);
                         set_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key, value);
+                                         st.modifyTime, key, value);
                         return value;
                     }
                     else {
@@ -2593,7 +2593,7 @@
                 }
             }
             else if (s->type == MAPTYPE_RND) {
-                if (stat(s->checkfile, &st) == -1) {
+                if (PR_GetFileInfo(s->checkfile, &st) != PR_SUCCESS) {
                     ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
                                 "mod_rewrite: can't access text RewriteMap "
                                 "file %s", s->checkfile);
@@ -2602,7 +2602,7 @@
                     return NULL;
                 }
                 value = get_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key);
+                                         st.modifyTime, key);
                 if (value == NULL) {
                     rewritelog(r, 6, "cache lookup FAILED, forcing new "
                                "map lookup");
@@ -2611,7 +2611,7 @@
                         rewritelog(r, 5, "map lookup OK: map=%s key=%s[txt] "
                                    "-> val=%s", s->name, key, value);
                         set_cache_string(cachep, s->name, CACHEMODE_TS,
-                                         st.st_mtime, key, value);
+                                         st.modifyTime, key, value);
                     }
                     else {
                         rewritelog(r, 5, "map lookup FAILED: map=%s[txt] "
@@ -3240,7 +3240,8 @@
     time_t tc;
     struct tm *tm;
     request_rec *rsub;
-#ifndef WIN32
+/* XXX: how to do this with NSPR? */
+#if !defined(WIN32) && !defined(NSPR)
     struct passwd *pw;
     struct group *gr;
     struct stat finfo;
@@ -3430,7 +3431,7 @@
         LOOKAHEAD(ap_sub_req_lookup_file)
     }
 
-#ifndef WIN32
+#if !defined(WIN32) && !defined(NSPR)
     /* Win32 has a rather different view of file ownerships.
        For now, just forget it */
 
@@ -3769,7 +3770,7 @@
 **
 */
 
-static int prefix_stat(const char *path, struct stat *sb)
+static int prefix_stat(const char *path)
 {
     char curpath[LONG_STRING_LEN];
     char *cp;
@@ -3779,7 +3780,7 @@
         return 0;
     if ((cp = strchr(curpath+1, '/')) != NULL)
         *cp = '\0';
-    if (stat(curpath, sb) == 0)
+    if (PR_Access(curpath, PR_ACCESS_READ_OK) == PR_SUCCESS)
         return 1;
     else
         return 0;
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/standard/mod_rewrite.h apache-nspr/src/modules/standard/mod_rewrite.h
--- apache-nspr-01/src/modules/standard/mod_rewrite.h	Sat Apr 18 21:29:08 1998
+++ apache-nspr/src/modules/standard/mod_rewrite.h	Wed Apr 29 03:53:23 1998
@@ -310,7 +310,7 @@
     /* the cache structures */
 
 typedef struct cacheentry {
-    time_t time;
+    PRTime time;
     char  *key;
     char  *value;
 } cacheentry;
@@ -448,9 +448,9 @@
 
     /* caching functions */
 static cache *init_cache(pool *p);
-static char  *get_cache_string(cache *c, char *res, int mode, time_t mtime,
+static char  *get_cache_string(cache *c, char *res, int mode, PRTime mtime,
                                char *key);
-static void   set_cache_string(cache *c, char *res, int mode, time_t mtime,
+static void   set_cache_string(cache *c, char *res, int mode, PRTime mtime,
                                char *key, char *value);
 static cacheentry *retrieve_cache_string(cache *c, char *res, char *key);
 static void   store_cache_string(cache *c, char *res, cacheentry *ce);
@@ -459,7 +459,7 @@
 static char  *subst_prefix_path(request_rec *r, char *input, char *match,
                                 char *subst);
 static int    parseargline(char *str, char **a1, char **a2, char **a3);
-static int    prefix_stat(const char *path, struct stat *sb);
+static int    prefix_stat(const char *path);
 static void   add_env_variable(request_rec *r, char *s);
 
     /* File locking */
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/standard/mod_speling.c apache-nspr/src/modules/standard/mod_speling.c
--- apache-nspr-01/src/modules/standard/mod_speling.c	Sat Apr 18 21:29:09 1998
+++ apache-nspr/src/modules/standard/mod_speling.c	Wed Apr 29 01:29:24 1998
@@ -186,8 +186,8 @@
     void *server_conf = r->server->module_config;
     char *good, *bad, *postgood, *url;
     int filoc, dotloc, urlen, pglen;
-    DIR *dirp;
-    struct DIR_TYPE *dir_entry;
+    PRDir *dirp;
+    PRDirEntry *dir_entry;
     array_header *candidates = NULL;
 
     if (!ap_get_module_config(server_conf, &speling_module))
@@ -246,7 +246,7 @@
     if (dotloc == -1)
         dotloc = strlen(bad);
 
-    while ((dir_entry = readdir(dirp)) != NULL) {
+    while ((dir_entry = PR_ReadDir(dirp, PR_SKIP_NONE)) != NULL) {
         sp_reason q;
 
         /*
@@ -254,7 +254,7 @@
          * requested one, we must have found a broken symlink or some such.
          * Do _not_ try to redirect this, it causes a loop!
          */
-        if (strcmp(bad, dir_entry->d_name) == 0) {
+        if (strcmp(bad, dir_entry->name) == 0) {
             ap_pclosedir(r->pool, dirp);
             return OK;
         }
@@ -262,18 +262,18 @@
          * miscapitalization errors are checked first (like, e.g., lower case
          * file, upper case request)
          */
-        else if (strcasecmp(bad, dir_entry->d_name) == 0) {
+        else if (strcasecmp(bad, dir_entry->name) == 0) {
             misspelled_file *sp_new = (misspelled_file *) ap_push_array(candidates);
-            sp_new->name = ap_pstrdup(r->pool, dir_entry->d_name);
+            sp_new->name = ap_pstrdup(r->pool, dir_entry->name);
             sp_new->quality = SP_MISCAPITALIZED;
         }
         /*
          * simple typing errors are checked next (like, e.g.,
          * missing/extra/transposed char)
          */
-        else if ((q = spdist(bad, dir_entry->d_name)) != SP_VERYDIFFERENT) {
+        else if ((q = spdist(bad, dir_entry->name)) != SP_VERYDIFFERENT) {
             misspelled_file *sp_new = (misspelled_file *) ap_push_array(candidates);
-            sp_new->name = ap_pstrdup(r->pool, dir_entry->d_name);
+            sp_new->name = ap_pstrdup(r->pool, dir_entry->name);
             sp_new->quality = q;
         }
         /* The spdist() should have found the majority of the misspelled requests.
@@ -305,14 +305,14 @@
              * (e.g. foo.gif and foo.html) This code will pick the first one
              * it finds. Better than a Not Found, though.
              */
-            int entloc = ap_ind(dir_entry->d_name, '.');
+            int entloc = ap_ind(dir_entry->name, '.');
             if (entloc == -1)
-                entloc = strlen(dir_entry->d_name);
+                entloc = strlen(dir_entry->name);
 
             if ((dotloc == entloc)
-                && !strncasecmp(bad, dir_entry->d_name, dotloc)) {
+                && !strncasecmp(bad, dir_entry->name, dotloc)) {
                 misspelled_file *sp_new = (misspelled_file *) ap_push_array(candidates);
-                sp_new->name = ap_pstrdup(r->pool, dir_entry->d_name);
+                sp_new->name = ap_pstrdup(r->pool, dir_entry->name);
                 sp_new->quality = SP_VERYDIFFERENT;
             }
 #endif
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/modules/standard/mod_userdir.c apache-nspr/src/modules/standard/mod_userdir.c
--- apache-nspr-01/src/modules/standard/mod_userdir.c	Sat Apr 18 21:29:11 1998
+++ apache-nspr/src/modules/standard/mod_userdir.c	Wed Apr 29 03:56:15 1998
@@ -198,7 +198,7 @@
     const char *w, *dname;
     char *redirect;
     char *x = NULL;
-    struct stat statbuf;
+    PRFileInfo statbuf;
 
     /*
      * If the URI doesn't match our basic pattern, we've nothing to do with
@@ -312,13 +312,15 @@
          * anyway, in the hope that some handler might handle it. This can be
          * used, for example, to run a CGI script for the user.
          */
-        if (filename && (!*userdirs || stat(filename, &statbuf) != -1)) {
+        if (filename && (!*userdirs || PR_GetFileInfo(filename, &statbuf) ==
PR_SUCCESS)) {
             r->filename = ap_pstrcat(r->pool, filename, dname, NULL);
 	    /* when statbuf contains info on r->filename we can save a syscall
 	     * by copying it to r->finfo
 	     */
-	    if (*userdirs && dname[0] == 0)
+	    if (*userdirs && dname[0] == 0) {
 		r->finfo = statbuf;
+		r->file_exists = 1;
+	    }
             return OK;
         }
     }
diff -ru -xCVS -xhttpd.map apache-nspr-01/src/os/nspr/http_main.c apache-nspr/src/os/nspr/http_main.c
--- apache-nspr-01/src/os/nspr/http_main.c	Wed Apr 29 00:11:34 1998
+++ apache-nspr/src/os/nspr/http_main.c	Wed Apr 29 03:56:38 1998
@@ -1488,6 +1488,7 @@
 {
     struct stat wrapper;
 
+/* XXX: how do we do this with NSPR? */
     if ((stat(SUEXEC_BIN, &wrapper)) != 0)
 	return (ap_suexec_enabled);
 



Mime
View raw message