httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken Parzygnat" <kp...@raleigh.ibm.com>
Subject [PATCH] Win32: UNC Directory container
Date Mon, 19 Oct 1998 20:54:37 GMT
Here's the second set of patches in 
the continuing saga of Win32 canonical
filenames.

This patch is a simple massage of get_path_info
and ap_no2slash to help UNC names work.

ap_no2slash should not remove the initial slashes
of a UNC name.  get_path_info should not remove
the trailing slash of a UNC name that has the 
form \\machine\share\

This patch only works in conjunction with the 
canonical overhaul patch discussed in the 
thread "Canonical filename overhaul".

--- util.c.first	Sat Oct 10 01:12:20 1998
+++ util.c	Mon Oct 19 19:13:41 1998
@@ -424,6 +424,13 @@
     char *d, *s;

     s = d = name;
+
+#ifdef WIN32
+    /* Check for UNC names.  Leave leading two slashes. */
+    if (s[0] == '/' && s[1] == '/')
+        *d++ = *s++;
+#endif
+
     while (*s) {
 	if ((*d++ = *s) == '/') {
 	    do {
--- http_request.c.first	Mon Oct 19 19:05:33 1998
+++ http_request.c	Mon Oct 19 20:49:06 1998
@@ -180,6 +180,7 @@
     int rv;
 #ifdef WIN32
     char buf[5];
+    BOOL bStripSlash=TRUE;
 #endif

     if (r->finfo.st_mode) {
@@ -198,12 +199,33 @@
 	path=buf;
 	end=buf+4;
     }
-#endif

-    /* Advance over trailing slashes ... NOT part of filename */
+    /* If UNC name == //machine/share/, do not
+     * advance over the trailing slash.  Any other
+     * UNC name is OK to strip the slash.
+     */
+    cp = end;
+    if (strlen(path) > 2 && path[0] == '/' && path[1] == '/' &&
+        path[2] != '/' && cp[-1] == '/') {
+        char *p;
+        int iCount=0;
+        p = path;
+        while (p = strchr(p,'/')) {
+            p++;
+            iCount++;
+        }
+
+        if (iCount == 4)
+            bStripSlash = FALSE;
+    }

-    for (cp = end; cp > path && cp[-1] == '/'; --cp)
-        continue;
+    if (bStripSlash)
+#endif
+        /* Advance over trailing slashes ... NOT part of filename
+         * if file is not a UNC name (Win32 only).
+         */
+        for (cp = end; cp > path && cp[-1] == '/'; --cp)
+            continue;


     while (cp > path) {

- - - - - - - - - - - - - - - - - -
Ken Parzygnat
email: kparz@raleigh.ibm.com 










--------------------------------------------------------------------------------
Users of the Apache webserver are hereby granted a non-exclusive, irrevocable,
world-wide, royalty-free, non-transferable license to use, execute, prepare
derivative works of, and distribute (internally and externally, and including
derivative works) the code accompanying this license as part of, and
integrated into the Apache webserver.  This code is provided "AS IS" WITHOUT
WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
AND ANY WARRANTY OF NON-INFRINGEMENT.  THE ENTIRE RISK ARISING OUT OF THE USE
OR PERFORMANCE OF THIS CODE REMAINS WITH USERS OF THE APACHE WEBSERVER.  The
owner of this code represents and warrants that it is legally entitled to
grant the above license.

Mime
View raw message