]> granicus.if.org Git - apache/commitdiff
Bring ap_os_case_canonical_filename() & ap_os_systemcase_canonical_filename()
authorBrian Havard <bjh@apache.org>
Mon, 20 Mar 2000 01:44:55 +0000 (01:44 +0000)
committerBrian Havard <bjh@apache.org>
Mon, 20 Mar 2000 01:44:55 +0000 (01:44 +0000)
implementations for OS/2 forward from 1.3.

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

os/os2/os.h
os/os2/util_os2.c

index 20ebcec9f432f4789c57385d786ac8f9f0371a52..11a6655db7be98b07e27c19810806a74750c1b1f 100644 (file)
@@ -32,8 +32,8 @@ extern int ap_os_is_path_absolute(const char *file);
 #endif
 
 char *ap_os_canonical_filename(ap_context_t *p, const char *file);
-#define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f)
-#define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f)
+char *ap_os_case_canonical_filename(ap_context_t *p, const char *szFile);
+char *ap_os_systemcase_filename(ap_context_t *p, const char *szFile);
 /* FIXME: the following should be implemented on this platform */
 #define ap_os_is_filename_valid(f)         (1)
 
index 17bea6647c7addf851eede75e35ada8cfe853076..37f426bb41cfd907c14c375dcefecceb09a8cb9e 100644 (file)
@@ -11,7 +11,7 @@
 #include <string.h>
 
 
-API_EXPORT(char *)ap_os_canonical_filename(ap_context_t *pPool, const char *szFile)
+API_EXPORT(char *)ap_os_case_canonical_filename(ap_context_t *pPool, const char *szFile)
 {
     char buf[HUGE_STRING_LEN];
     char buf2[HUGE_STRING_LEN];
@@ -36,8 +36,6 @@ API_EXPORT(char *)ap_os_canonical_filename(ap_context_t *pPool, const char *szFi
         }
     }
 
-    strlwr(buf2);
-    
 /* Switch backslashes to forward */
     for (pos=buf2; *pos; pos++)
         if (*pos == '\\')
@@ -48,6 +46,61 @@ API_EXPORT(char *)ap_os_canonical_filename(ap_context_t *pPool, const char *szFi
 
 
 
+static void fix_component(char *path, char *lastcomp)
+{
+    FILEFINDBUF3 fb3;
+    HDIR hDir = HDIR_CREATE;
+    ULONG numNames = 1;
+    ULONG rc = DosFindFirst( (UCHAR *)path, &hDir, FILE_NORMAL|FILE_DIRECTORY, &fb3, sizeof(fb3), &numNames, FIL_STANDARD );
+
+    if (rc == 0)
+        strcpy(lastcomp, fb3.achName);
+
+    DosFindClose(hDir);
+}
+
+
+
+char *ap_os_systemcase_canonical_filename(ap_context_t *pPool, const char *szFile)
+{
+    char *szCanonicalFile = ap_os_case_canonical_filename(pPool, szFile);
+    int startslash = 2, slashnum=0;
+    char *pos, *prevslash = NULL;
+
+    if (szCanonicalFile[0] == '/' && szCanonicalFile[1] == '/') /* a UNC name */
+        startslash = 5;
+
+    for (pos = szCanonicalFile; *pos; pos++) {
+        if (*pos == '/') {
+            slashnum++;
+            if (slashnum >= startslash) {
+                *pos = 0;
+                fix_component(szCanonicalFile, prevslash+1);
+                *pos = '/';
+            }
+            prevslash = pos;
+        }
+    }
+
+    if (slashnum >= startslash) {
+        fix_component(szCanonicalFile, prevslash+1);
+    }
+
+    return szCanonicalFile;
+}
+
+
+
+char *ap_os_canonical_filename(ap_context_t *pPool, const char *szFile)
+{
+    char *szCanonicalFile = ap_os_systemcase_canonical_filename(pPool, szFile);
+    strlwr(szCanonicalFile);
+printf("ap_os_canonical_filename(%s) = %s\n", szFile, szCanonicalFile);
+    return szCanonicalFile;
+}
+
+
+
 int ap_os_kill(pid_t pid, int sig)
 {
 /* SIGTERM's don't work too well in OS/2 (only affects other EMX programs).