- From: Sergey Borisov <barya@speakglobally.com>
- Date: Tue, 14 Nov 2000 16:39:49 +0300
- To: www-lib@w3.org
Hello!
I've made a patch for URL to local file representation in HTWWWStr.c
for MS Windows 2000.
In current version libwww 5.3.1
For URL "file://d:\1.htm" file name translates to //d:\1.htm\
In patched version it translates to d:\1.htm
/* Convert file URLs into a local representation
** ---------------------------------------------
** The URL has already been translated through the rules in get_physical
** in HTAccess.c and all we need to do now is to map the path to a local
** representation, for example if must translate '/' to the ones that
** turn the wrong way ;-)
** Returns:
** OK: local file (that must be freed by caller)
** Error: NULL
*/
PUBLIC char * HTWWWToLocal (const char * url, const char * base,
HTUserProfile * up)
{
if (url) {
char * access = HTParse(url, base, PARSE_ACCESS);
char * host = HTParse(url, base, PARSE_HOST);
char * path = HTParse(url, base, PARSE_PATH+PARSE_PUNCTUATION);
const char * myhost = HTUserProfile_fqdn(up);
/* Find out if this is a reference to the local file system */
if ((*access && strcmp(access, "file") && strcmp(access, "cache")) ||
(*host && strcasecomp(host, "localhost") &&
myhost && strcmp(host, myhost))) {
HTTRACE(CORE_TRACE, "LocalName... Not on local file system\n");
HT_FREE(access);
HT_FREE(host);
HT_FREE(path);
return NULL;
} else {
char *ptr;
if ((ptr = strchr(path, ';')) || (ptr = strchr(path, '?')))
*ptr = '\0';
/*
** Do whatever translation is required here in order to fit your
** platform _before_ the path is unescaped.
*/
#ifdef VMS
HTVMS_checkDecnet(path);
#endif
#ifdef WWW_MSWINDOWS
/* An absolute pathname with logical drive */
if (*path == '/' && path[2] == ':') {
char *orig=path, *dest=path+1;
while((*orig++ = *dest++));
/* A network host */
} else if (*host && strcasecomp(host, "localhost")) {
char * newpath = NULL;
SB> StrAllocMCopy(&newpath, /*"//",*/ host, path, NULL);
HT_FREE(path);
path = newpath;
}
/* Convert '/' to '\' */
{
char *p = path;
while (*p) {
if (*p=='/') *p='\\';
p++;
}
}
SB> /* delete the last '\' */
SB> {
SB> char *p1=&path[strlen(path)-1];
SB> while (p1!=path && *p1=='\\')
SB> *p1--=0;
SB> }
#endif
HTUnEscape(path); /* Take out the escaped characters */
HTTRACE(CORE_TRACE, "Node........ `%s' means path `%s'\n" _ url _ path);
HT_FREE(access);
HT_FREE(host);
return path;
}
}
return NULL;
}
--
Best regards,
Sergey mailto:barya@speakglobally.com
Received on Tuesday, 14 November 2000 08:41:37 UTC