You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by bj...@locus.apache.org on 2000/03/20 02:44:55 UTC
cvs commit: apache-2.0/src/os/os2 os.h util_os2.c
bjh 00/03/19 17:44:55
Modified: src/os/os2 os.h util_os2.c
Log:
Bring ap_os_case_canonical_filename() & ap_os_systemcase_canonical_filename()
implementations for OS/2 forward from 1.3.
Revision Changes Path
1.6 +2 -2 apache-2.0/src/os/os2/os.h
Index: os.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/os/os2/os.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- os.h 2000/01/26 07:51:45 1.5
+++ os.h 2000/03/20 01:44:55 1.6
@@ -32,8 +32,8 @@
#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)
1.8 +56 -3 apache-2.0/src/os/os2/util_os2.c
Index: util_os2.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/os/os2/util_os2.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- util_os2.c 2000/03/04 15:26:31 1.7
+++ util_os2.c 2000/03/20 01:44:55 1.8
@@ -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,14 +36,67 @@
}
}
- strlwr(buf2);
-
/* Switch backslashes to forward */
for (pos=buf2; *pos; pos++)
if (*pos == '\\')
*pos = '/';
return ap_pstrdup(pPool, buf2);
+}
+
+
+
+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;
}