Commit 554b24a5 authored by Brian Havard's avatar Brian Havard
Browse files

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
parent 93261696
Loading
Loading
Loading
Loading
+2 −2
Changes for os/os2/os.h: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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)

+56 −3
Changes for os/os2/util_os2.c: 56 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -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).