From: Brian Havard Date: Mon, 20 Mar 2000 01:44:55 +0000 (+0000) Subject: Bring ap_os_case_canonical_filename() & ap_os_systemcase_canonical_filename() X-Git-Tag: APACHE_2_0_ALPHA_2~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36b960b282a8b6c0779f113fe4989adea965f414;p=apache Bring ap_os_case_canonical_filename() & ap_os_systemcase_canonical_filename() 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 --- diff --git a/os/os2/os.h b/os/os2/os.h index 20ebcec9f4..11a6655db7 100644 --- a/os/os2/os.h +++ b/os/os2/os.h @@ -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) diff --git a/os/os2/util_os2.c b/os/os2/util_os2.c index 17bea6647c..37f426bb41 100644 --- a/os/os2/util_os2.c +++ b/os/os2/util_os2.c @@ -11,7 +11,7 @@ #include -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).