version 1.82, 2000/01/28 16:21:31
|
version 1.83, 2000/02/08 16:29:35
|
Line 322 STRING aSuffix;
|
Line 322 STRING aSuffix;
|
returns TRUE if path points to an HTML resource. |
returns TRUE if path points to an HTML resource. |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
ThotBool IsHTMLName (const STRING path) |
ThotBool IsHTMLName (const CharUnit* path) |
#else /* __STDC__ */ |
#else /* __STDC__ */ |
ThotBool IsHTMLName (path) |
ThotBool IsHTMLName (path) |
const STRING path; |
const CharUnit* path; |
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
CHAR_T temppath[MAX_LENGTH]; |
CharUnit temppath[MAX_LENGTH]; |
CHAR_T suffix[MAX_LENGTH]; |
CharUnit suffix[MAX_LENGTH]; |
CHAR_T nsuffix[MAX_LENGTH]; |
CharUnit nsuffix[MAX_LENGTH]; |
int i; |
int i; |
|
|
if (!path) |
if (!path) |
return (FALSE); |
return (FALSE); |
|
|
ustrcpy (temppath, path); |
StringCopy (temppath, path); |
ExtractSuffix (temppath, suffix); |
ExtractSuffix (temppath, suffix); |
|
|
/* Normalize the suffix */ |
/* Normalize the suffix */ |
i = 0; |
i = 0; |
while (suffix[i] != EOS && i < MAX_LENGTH -1) |
while (suffix[i] != CUS_EOS && i < MAX_LENGTH -1) |
{ |
{ |
nsuffix[i] = utolower (suffix[i]); |
nsuffix[i] = ToLower (suffix[i]); |
i++; |
i++; |
} |
} |
nsuffix[i] = EOS; |
nsuffix[i] = EOS; |
if (!ustrcmp (nsuffix, TEXT("html")) || |
if (!StringCompare (nsuffix, CUSTEXT("html")) || |
!ustrcmp (nsuffix, TEXT("htm")) || |
!StringCompare (nsuffix, CUSTEXT("htm")) || |
!ustrcmp (nsuffix, TEXT("shtml")) || |
!StringCompare (nsuffix, CUSTEXT("shtml")) || |
!ustrcmp (nsuffix, TEXT("jsp")) || |
!StringCompare (nsuffix, CUSTEXT("jsp")) || |
!ustrcmp (nsuffix, TEXT("xht")) || |
!StringCompare (nsuffix, CUSTEXT("xht")) || |
!ustrcmp (nsuffix, TEXT("xhtm")) || |
!StringCompare (nsuffix, CUSTEXT("xhtm")) || |
!ustrcmp (nsuffix, TEXT("xhtml"))) |
!StringCompare (nsuffix, CUSTEXT("xhtml"))) |
return (TRUE); |
return (TRUE); |
else if (!ustrcmp (nsuffix, TEXT("gz"))) |
else if (!StringCompare (nsuffix, CUSTEXT("gz"))) |
{ |
{ |
/* take into account compressed files */ |
/* take into account compressed files */ |
ExtractSuffix (temppath, suffix); |
ExtractSuffix (temppath, suffix); |
/* Normalize the suffix */ |
/* Normalize the suffix */ |
i = 0; |
i = 0; |
while (suffix[i] != EOS && i < MAX_LENGTH -1) |
while (suffix[i] != CUS_EOS && i < MAX_LENGTH -1) |
{ |
{ |
nsuffix[i] = tolower (suffix[i]); |
nsuffix[i] = ToLower (suffix[i]); |
i++; |
i++; |
} |
} |
nsuffix[i] = EOS; |
nsuffix[i] = CUS_EOS; |
if (!ustrcmp (nsuffix, TEXT("html")) || |
if (!StringCompare (nsuffix, CUSTEXT("html")) || |
!ustrcmp (nsuffix, TEXT("htm")) || |
!StringCompare (nsuffix, CUSTEXT("htm")) || |
!ustrcmp (nsuffix, TEXT("shtml")) || |
!StringCompare (nsuffix, CUSTEXT("shtml")) || |
!ustrcmp (nsuffix, TEXT("jsp")) || |
!StringCompare (nsuffix, CUSTEXT("jsp")) || |
!ustrcmp (nsuffix, TEXT("xht")) || |
!StringCompare (nsuffix, CUSTEXT("xht")) || |
!ustrcmp (nsuffix, TEXT("xhtm")) || |
!StringCompare (nsuffix, CUSTEXT("xhtm")) || |
!ustrcmp (nsuffix, TEXT("xhtml"))) |
!StringCompare (nsuffix, CUSTEXT("xhtml"))) |
|
|
return (TRUE); |
return (TRUE); |
else |
else |
Line 779 Document doc;
|
Line 779 Document doc;
|
Allocate and return the local document path associated to the url |
Allocate and return the local document path associated to the url |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
#ifdef __STDC__ |
#ifdef __STDC__ |
STRING GetLocalPath (Document doc, STRING url) |
CharUnit* GetLocalPath (Document doc, CharUnit* url) |
#else /* __STDC__ */ |
#else /* __STDC__ */ |
STRING GetLocalPath (doc, url) |
CharUnit* GetLocalPath (doc, url) |
Document doc; |
Document doc; |
STRING url; |
CharUnit* url; |
#endif /* __STDC__ */ |
#endif /* __STDC__ */ |
{ |
{ |
STRING ptr, n; |
CharUnit* ptr; |
STRING documentname; |
CharUnit* n; |
CHAR_T url_sep; |
CharUnit* documentname; |
int len; |
CharUnit url_sep; |
|
int len; |
ThotBool noFile; |
ThotBool noFile; |
|
|
if (url != NULL) |
if (url != NULL) |
{ |
{ |
/* check whether the file name exists */ |
/* check whether the file name exists */ |
len = ustrlen (url) - 1; |
len = StringLength (url) - 1; |
if (IsW3Path (url)) |
if (IsW3Path (url)) |
url_sep = TEXT('/'); |
url_sep = CUSTEXT('/'); |
else |
else |
url_sep = DIR_SEP; |
url_sep = CUS_DIR_SEP; |
noFile = (url[len] == url_sep); |
noFile = (url[len] == url_sep); |
if (noFile) |
if (noFile) |
url[len] = EOS; |
url[len] = CUS_EOS; |
ptr = TtaAllocString (MAX_LENGTH); |
ptr = TtaAllocCUString (MAX_LENGTH); |
documentname = TtaAllocString (MAX_LENGTH); |
documentname = TtaAllocCUString (MAX_LENGTH); |
TtaExtractName (url, ptr, documentname); |
TtaExtractName (url, ptr, documentname); |
usprintf (ptr, TEXT("%s%s%d%s"), TempFileDirectory, DIR_STR, doc, DIR_STR); |
cus_sprintf (ptr, CUSTEXT("%s%s%d%s"), TempFileDirectory, CUS_DIR_STR, doc, CUS_DIR_STR); |
if (!TtaCheckDirectory (ptr)) |
if (!TtaCheckDirectory (ptr)) |
/* directory did not exist */ |
/* directory did not exist */ |
TtaMakeDirectory (ptr); |
TtaMakeDirectory (ptr); |
|
|
/* don't include the query string within document name */ |
/* don't include the query string within document name */ |
n = ustrrchr(documentname, TEXT('?')); |
n = StrRChr (documentname, CUSTEXT('?')); |
if (n != NULL) |
if (n != NULL) |
*n = EOS; |
*n = CUS_EOS; |
/* don't include ':' within document name */ |
/* don't include ':' within document name */ |
n = ustrchr (documentname, TEXT(':')); |
n = StrChr (documentname, CUSTEXT(':')); |
if (n != NULL) |
if (n != NULL) |
*n = EOS; |
*n = CUS_EOS; |
/* if after all this operations document name |
/* if after all this operations document name |
is empty, let's use noname.html instead */ |
is empty, let's use noname.html instead */ |
if (documentname[0] == EOS) |
if (documentname[0] == CUS_EOS) |
ustrcat (ptr, TEXT("noname.html")); |
StringConcat (ptr, CUSTEXT("noname.html")); |
else |
else |
ustrcat (ptr, documentname); |
StringConcat (ptr, documentname); |
TtaFreeMemory (documentname); |
TtaFreeMemory (documentname); |
/* restore the url */ |
/* restore the url */ |
if (noFile) |
if (noFile) |