#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)
#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];
}
}
- strlwr(buf2);
-
/* Switch backslashes to forward */
for (pos=buf2; *pos; pos++)
if (*pos == '\\')
+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).