version 1.109, 2001/03/19 09:29:26
|
version 1.110, 2001/03/27 12:09:01
|
Line 1
|
Line 1
|
/* |
/* |
* |
* |
* (c) COPYRIGHT MIT and INRIA, 1996. |
* (c) COPYRIGHT MIT and INRIA, 1996-2001 |
* Please first read the full copyright statement in file COPYRIGHT. |
* Please first read the full copyright statement in file COPYRIGHT. |
* |
* |
*/ |
*/ |
Line 698 char *GetBaseURL (Document doc)
|
Line 698 char *GetBaseURL (Document doc)
|
|
|
/* @@@ irene */ |
/* @@@ irene */ |
if (!DocumentURLs[doc]) |
if (!DocumentURLs[doc]) |
return NULL; |
return NULL; |
basename = TtaGetMemory (MAX_LENGTH); |
basename = TtaGetMemory (MAX_LENGTH); |
strncpy (basename, DocumentURLs[doc], MAX_LENGTH-1); |
strncpy (basename, DocumentURLs[doc], MAX_LENGTH-1); |
basename[MAX_LENGTH-1] = EOS; |
basename[MAX_LENGTH-1] = EOS; |
length = MAX_LENGTH -1; |
length = MAX_LENGTH -1; |
/* get the root element */ |
/* get the document element */ |
el = TtaGetMainRoot (doc); |
el = TtaGetMainRoot (doc); |
/* search the BASE element */ |
/* search the BASE element */ |
elType.ElSSchema = TtaGetDocumentSSchema (doc); |
elType.ElSSchema = TtaGetDocumentSSchema (doc); |
Line 726 char *GetBaseURL (Document doc)
|
Line 726 char *GetBaseURL (Document doc)
|
TtaGiveTextAttributeValue (attr, basename, &length); |
TtaGiveTextAttributeValue (attr, basename, &length); |
/* base and orgName have to be separated by a DIR_SEP */ |
/* base and orgName have to be separated by a DIR_SEP */ |
length--; |
length--; |
if (basename[0] != EOS && basename[length] != URL_SEP && basename[length] != DIR_SEP) |
if (basename[0] != EOS && basename[length] != URL_SEP && |
|
basename[length] != DIR_SEP) |
/* verify if the base has the form "protocol://server:port" */ |
/* verify if the base has the form "protocol://server:port" */ |
{ |
{ |
ptr = AmayaParseUrl (basename, "", AMAYA_PARSE_ACCESS | |
ptr = AmayaParseUrl (basename, "", AMAYA_PARSE_ACCESS | |
Line 984 void NormalizeURL (char *orgName, Docume
|
Line 985 void NormalizeURL (char *orgName, Docume
|
int length; |
int length; |
ThotBool check; |
ThotBool check; |
|
|
# ifdef _WINDOWS |
#ifdef _WINDOWS |
int ndx; |
int ndx; |
# endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
|
|
if (!newName || !docName) |
if (!newName || !docName) |
return; |
return; |
Line 1041 void NormalizeURL (char *orgName, Docume
|
Line 1042 void NormalizeURL (char *orgName, Docume
|
strcpy (newName, tempOrgName); |
strcpy (newName, tempOrgName); |
SimplifyUrl (&newName); |
SimplifyUrl (&newName); |
/* verify if the URL has the form "protocol://server:port" */ |
/* verify if the URL has the form "protocol://server:port" */ |
ptr = AmayaParseUrl (newName, "", AMAYA_PARSE_ACCESS | AMAYA_PARSE_HOST | AMAYA_PARSE_PUNCTUATION); |
ptr = AmayaParseUrl (newName, "", AMAYA_PARSE_ACCESS | |
if (ptr && !strcmp (ptr, newName)) /* it has this form, we complete it by adding a DIR_STR */ |
AMAYA_PARSE_HOST | |
|
AMAYA_PARSE_PUNCTUATION); |
|
if (ptr && !strcmp (ptr, newName)) |
|
/* it has this form, we complete it by adding a DIR_STR */ |
strcat (newName, URL_STR); |
strcat (newName, URL_STR); |
|
|
if (ptr) |
if (ptr) |
Line 1054 void NormalizeURL (char *orgName, Docume
|
Line 1058 void NormalizeURL (char *orgName, Docume
|
else |
else |
{ |
{ |
/* Calculate the absolute URL, using the base or document URL */ |
/* Calculate the absolute URL, using the base or document URL */ |
# ifdef _WINDOWS |
#ifdef _WINDOWS |
if (!IsW3Path (basename)) |
if (!IsW3Path (basename)) |
{ |
{ |
length = strlen (tempOrgName); |
length = strlen (tempOrgName); |
Line 1062 void NormalizeURL (char *orgName, Docume
|
Line 1066 void NormalizeURL (char *orgName, Docume
|
if (tempOrgName [ndx] == '/') |
if (tempOrgName [ndx] == '/') |
tempOrgName [ndx] = '\\'; |
tempOrgName [ndx] = '\\'; |
} |
} |
# endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
ptr = AmayaParseUrl (tempOrgName, basename, AMAYA_PARSE_ALL); |
ptr = AmayaParseUrl (tempOrgName, basename, AMAYA_PARSE_ALL); |
if (ptr) |
if (ptr) |
{ |
{ |
Line 1115 void NormalizeURL (char *orgName, Docume
|
Line 1119 void NormalizeURL (char *orgName, Docume
|
} |
} |
else |
else |
{ /* docname is comprised inside the URL */ |
{ /* docname is comprised inside the URL */ |
while (length >= 0 && newName[length] != URL_SEP && newName[length] != DIR_SEP) |
while (length >= 0 && newName[length] != URL_SEP && |
|
newName[length] != DIR_SEP) |
length--; |
length--; |
if (length < 0) |
if (length < 0) |
strcpy (docName, newName); |
strcpy (docName, newName); |
Line 1460 char *AmayaParseUrl (const char *aName
|
Line 1465 char *AmayaParseUrl (const char *aName
|
strcat (result, ""); |
strcat (result, ""); |
else |
else |
{ |
{ |
if (wanted & AMAYA_PARSE_PUNCTUATION) |
if (wanted & AMAYA_PARSE_PUNCTUATION) |
strcat (result, "#"); |
strcat (result, "#"); |
strcat (result, given.fragment ? given.fragment : related.fragment); |
strcat (result, given.fragment ? given.fragment : related.fragment); |
} |
} |
} |
} |
len = strlen (result); |
len = strlen (result); |
Line 1497 static char *HTCanon (char **filename,
|
Line 1502 static char *HTCanon (char **filename,
|
else |
else |
used_sep = DIR_SEP; |
used_sep = DIR_SEP; |
|
|
while (access > *filename && *(access - 1) != used_sep) /* Find access method */ |
while (access > *filename && *(access - 1) != used_sep) /* Find access method */ |
access--; |
access--; |
if ((path = strchr (host, used_sep)) == NULL) /* Find path */ |
if ((path = strchr (host, used_sep)) == NULL) /* Find path */ |
path = host + strlen (host); |
path = host + strlen (host); |
if ((strptr = strchr (host, '@')) != NULL && strptr < path) /* UserId */ |
if ((strptr = strchr (host, '@')) != NULL && strptr < path) /* UserId */ |
host = strptr; |
host = strptr; |
if ((port = strchr (host, ':')) != NULL && port > path) /* Port number */ |
if ((port = strchr (host, ':')) != NULL && port > path) /* Port number */ |
port = NULL; |
port = NULL; |
|
|
strptr = host; /* Convert to lower-case */ |
strptr = host; /* Convert to lower-case */ |
Line 1682 void SimplifyUrl (char **url)
|
Line 1687 void SimplifyUrl (char **url)
|
p = path; |
p = path; |
while (p < end) |
while (p < end) |
{ |
{ |
/* if we're pointing to a char, it's safe to reactivate the ../ convertion */ |
/* if we're pointing to a char, it's safe to reactivate the |
|
../ convertion */ |
if (!ddot_simplify && *p != '.' && *p != used_sep) |
if (!ddot_simplify && *p != '.' && *p != used_sep) |
ddot_simplify = TRUE; |
ddot_simplify = TRUE; |
|
|
Line 1746 void SimplifyUrl (char **url)
|
Line 1752 void SimplifyUrl (char **url)
|
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
ThotBool NormalizeFile (char *src, char *target, ConvertionType convertion) |
ThotBool NormalizeFile (char *src, char *target, ConvertionType convertion) |
{ |
{ |
# ifndef _WINDOWS |
#ifndef _WINDOWS |
char *s; |
char *s; |
int i; |
int i; |
# endif /* !_WINDOWS */ |
#endif /* !_WINDOWS */ |
ThotBool change; |
ThotBool change; |
int start_index; /* the first char that we'll copy */ |
int start_index; /* the first char that we'll copy */ |
|
|
Line 1857 char *MakeRelativeURL (char *aName,
|
Line 1863 char *MakeRelativeURL (char *aName,
|
char *after_access; |
char *after_access; |
char *last_slash = NULL; |
char *last_slash = NULL; |
int slashes, levels, len; |
int slashes, levels, len; |
|
#ifdef _WINDOWS |
# ifdef _WINDOWS |
|
int ndx; |
int ndx; |
# endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
|
|
if (aName == NULL || relatedName == NULL) |
if (aName == NULL || relatedName == NULL) |
return (NULL); |
return (NULL); |
Line 1928 char *MakeRelativeURL (char *aName,
|
Line 1933 char *MakeRelativeURL (char *aName,
|
strcpy (return_value, result); |
strcpy (return_value, result); |
|
|
} |
} |
# ifdef _WINDOWS |
#ifdef _WINDOWS |
len = strlen (return_value); |
len = strlen (return_value); |
for (ndx = 0; ndx < len; ndx ++) |
for (ndx = 0; ndx < len; ndx ++) |
if (return_value[ndx] == '\\') |
if (return_value[ndx] == '\\') |
return_value[ndx] = '/' ; |
return_value[ndx] = '/' ; |
# endif /* _WINDOWS */ |
#endif /* _WINDOWS */ |
return (return_value); |
return (return_value); |
} |
} |
|
|