Diff for /Amaya/amaya/AHTURLTools.c between versions 1.66 and 1.67

version 1.66, 1999/06/02 12:43:17 version 1.67, 1999/06/27 16:26:39
Line 23 Line 23
   
 #define MAX_PRINT_URL_LENGTH 50  #define MAX_PRINT_URL_LENGTH 50
 typedef struct _HTURI {  typedef struct _HTURI {
     char * access;              /* Now known as "scheme" */      STRING  access;             /* Now known as "scheme" */
     char * host;      STRING  host;
     char * absolute;      STRING  absolute;
     char * relative;      STRING  relative;
     char * fragment;      STRING  fragment;
 } HTURI;  } HTURI;
   
   
Line 36  typedef struct _HTURI { Line 36  typedef struct _HTURI {
   Converts a string to lowercase.    Converts a string to lowercase.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 void         ConvertToLowerCase (char *string)  void         ConvertToLowerCase (STRING string)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 void         ConvertToLowerCase (string)  void         ConvertToLowerCase (string)
 char                *string;  STRING       string;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
Line 49  char                *string; Line 49  char                *string;
    return;     return;
   
  for (i = 0; string[i] != EOS; i++)   for (i = 0; string[i] != EOS; i++)
    string[i] = tolower (string[i]);     string[i] = utolower (string[i]);
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 90  char              **file; Line 90  char              **file;
       goto finished;        goto finished;
   
    /* go to the end of the URL */     /* go to the end of the URL */
    while ((*curr != 0) && (*curr != SPACE) && (*curr != '\b') &&     while ((*curr != 0) && (*curr != SPACE) && (*curr != TEXT('\b')) &&
           (*curr != '\r') && (*curr != EOL))            (*curr != '\r') && (*curr != EOL))
       curr++;        curr++;
   
Line 143  char              **file; Line 143  char              **file;
    if (curr < url)     if (curr < url)
       goto finished;        goto finished;
   
    if (*curr == ':')     if (*curr == TEXT(':'))
      {       {
         *curr = EOS;          *curr = EOS;
         curr--;          curr--;
Line 202  STRING              aSuffix; Line 202  STRING              aSuffix;
         oldptr = ptr = &aName[0];          oldptr = ptr = &aName[0];
         do          do
           {            {
              ptr = ustrrchr (oldptr, '.');               ptr = ustrrchr (oldptr, TEXT('.'));
              if (ptr)               if (ptr)
                 oldptr = &ptr[1];                  oldptr = &ptr[1];
           }            }
Line 223  STRING              aSuffix; Line 223  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 char *path)  ThotBool             IsHTMLName (const STRING path)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsHTMLName (path)  ThotBool             IsHTMLName (path)
 const char         *path;  const STRING        path;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char                temppath[MAX_LENGTH];     CHAR_T              temppath[MAX_LENGTH];
    char                suffix[MAX_LENGTH];     CHAR_T              suffix[MAX_LENGTH];
    char                nsuffix[MAX_LENGTH];     CHAR_T              nsuffix[MAX_LENGTH];
    int                 i;     int                 i;
   
    if (!path)     if (!path)
       return (FALSE);        return (FALSE);
   
    strcpy (temppath, path);     ustrcpy (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] != EOS && i < MAX_LENGTH -1)
      {       {
        nsuffix[i] = tolower (suffix[i]);         nsuffix[i] = utolower (suffix[i]);
        i++;         i++;
      }       }
    nsuffix[i] = EOS;     nsuffix[i] = EOS;
    if (!strcmp (nsuffix, "html") ||     if (!ustrcmp (nsuffix, TEXT("html")) ||
        !strcmp (nsuffix, "htm") ||         !ustrcmp (nsuffix, TEXT("htm")) ||
        !strcmp (nsuffix, "shtml") ||         !ustrcmp (nsuffix, TEXT("shtml")) ||
        !strcmp (nsuffix, "xht") ||         !ustrcmp (nsuffix, TEXT("xht")) ||
        !strcmp (nsuffix, "xhtm") ||         !ustrcmp (nsuffix, TEXT("xhtm")) ||
        !strcmp (nsuffix, "xhtml"))         !ustrcmp (nsuffix, TEXT("xhtml")))
      return (TRUE);       return (TRUE);
    else if (!strcmp (nsuffix, "gz"))     else if (!ustrcmp (nsuffix, TEXT("gz")))
      {       {
        /* take into account compressed files */         /* take into account compressed files */
        ExtractSuffix (temppath, suffix);                ExtractSuffix (temppath, suffix);       
Line 267  const char         *path; Line 267  const char         *path;
            i++;             i++;
          }           }
        nsuffix[i] = EOS;         nsuffix[i] = EOS;
        if (!strcmp (nsuffix, "html") ||         if (!ustrcmp (nsuffix, TEXT("html")) ||
            !strcmp (nsuffix, "htm") ||             !ustrcmp (nsuffix, TEXT("htm")) ||
            !strcmp (nsuffix, "shtml") ||             !ustrcmp (nsuffix, TEXT("shtml")) ||
            !strcmp (nsuffix, "xht") ||             !ustrcmp (nsuffix, TEXT("xht")) ||
            !strcmp (nsuffix, "xhtm") ||             !ustrcmp (nsuffix, TEXT("xhtm")) ||
            !strcmp (nsuffix, "xhtml"))             !ustrcmp (nsuffix, TEXT("xhtml")))
     
          return (TRUE);           return (TRUE);
        else         else
Line 287  const char         *path; Line 287  const char         *path;
   returns TRUE if path points to an XML resource.    returns TRUE if path points to an XML resource.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            IsXMLName (const char *path)  ThotBool             IsXMLName (const STRING path)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsXMLName (path)  ThotBool             IsXMLName (path)
 const char         *path;  const STRING        path;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char                temppath[MAX_LENGTH];     CHAR_T              temppath[MAX_LENGTH];
    char                suffix[MAX_LENGTH];     CHAR_T              suffix[MAX_LENGTH];
   
    if (!path)     if (!path)
       return (FALSE);        return (FALSE);
   
    strcpy (temppath, path);     ustrcpy (temppath, path);
    ExtractSuffix (temppath, suffix);     ExtractSuffix (temppath, suffix);
   
    if (!strcasecmp (suffix, "xml") ||     if (!ustrcasecmp (suffix, TEXT("xml")) ||
        !strcasecmp (suffix, "xht") ||         !ustrcasecmp (suffix, TEXT("xht")) ||
        !strcmp (suffix, "xhtm") ||         !ustrcmp (suffix, TEXT("xhtm")) ||
        !strcmp (suffix, "xhtml"))         !ustrcmp (suffix, TEXT("xhtml")))
      return (TRUE);       return (TRUE);
    else if (!strcmp (suffix, "gz"))     else if (!ustrcmp (suffix, TEXT("gz")))
      {       {
        /* take into account compressed files */         /* take into account compressed files */
        ExtractSuffix (temppath, suffix);                ExtractSuffix (temppath, suffix);       
        if (!strcasecmp (suffix, "xml") ||         if (!ustrcasecmp (suffix, TEXT("xml")) ||
            !strcasecmp (suffix, "xht") ||             !ustrcasecmp (suffix, TEXT("xht")) ||
            !strcmp (suffix, "xhtm") ||             !ustrcmp (suffix, TEXT("xhtm")) ||
            !strcmp (suffix, "xhtml"))             !ustrcmp (suffix, TEXT("xhtml")))
          return (TRUE);           return (TRUE);
        else         else
          return (FALSE);           return (FALSE);
Line 328  const char         *path; Line 328  const char         *path;
   returns TRUE if path points to an XML resource.    returns TRUE if path points to an XML resource.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            IsCSSName (const char *path)  ThotBool             IsCSSName (const STRING path)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsCSSName (path)  ThotBool             IsCSSName (path)
 const char         *path;  const STRING        path;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char                temppath[MAX_LENGTH];     CHAR_T              temppath[MAX_LENGTH];
    char                suffix[MAX_LENGTH];     CHAR_T              suffix[MAX_LENGTH];
   
    if (!path)     if (!path)
       return (FALSE);        return (FALSE);
   
    strcpy (temppath, path);     ustrcpy (temppath, path);
    ExtractSuffix (temppath, suffix);     ExtractSuffix (temppath, suffix);
   
    if (!strcasecmp (suffix, "css"))     if (!ustrcasecmp (suffix, TEXT("css")))
      return (TRUE);       return (TRUE);
    else if (!strcmp (suffix, "gz"))     else if (!ustrcmp (suffix, TEXT("gz")))
      {       {
        /* take into account compressed files */         /* take into account compressed files */
        ExtractSuffix (temppath, suffix);                ExtractSuffix (temppath, suffix);       
        if (!strcasecmp (suffix, "css"))         if (!ustrcasecmp (suffix, TEXT("css")))
          return (TRUE);           return (TRUE);
        else         else
          return (FALSE);           return (FALSE);
Line 363  const char         *path; Line 363  const char         *path;
   returns TRUE if path points to an image resource.    returns TRUE if path points to an image resource.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            IsImageName (const char *path)  ThotBool             IsImageName (const STRING path)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsImageName (path)  ThotBool             IsImageName (path)
 const char         *path;  const STRING        path;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char                temppath[MAX_LENGTH];     CHAR_T                temppath[MAX_LENGTH];
    char                suffix[MAX_LENGTH];     CHAR_T                suffix[MAX_LENGTH];
    char                nsuffix[MAX_LENGTH];     CHAR_T                nsuffix[MAX_LENGTH];
    int                 i;     int                 i;
   
    if (!path)     if (!path)
       return (FALSE);        return (FALSE);
   
    strcpy (temppath, path);     ustrcpy (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] != EOS && i < MAX_LENGTH -1)
      {       {
        nsuffix[i] = tolower (suffix[i]);         nsuffix[i] = utolower (suffix[i]);
        i++;         i++;
      }       }
    nsuffix[i] = EOS;     nsuffix[i] = EOS;
    if ((!strcmp (nsuffix, "gif")) || (!strcmp (nsuffix, "xbm")) ||     if ((!ustrcmp (nsuffix, TEXT("gif"))) || (!ustrcmp (nsuffix, TEXT("xbm"))) ||
        (!strcmp (nsuffix, "xpm")) || (!strcmp (nsuffix, "jpg")) ||         (!ustrcmp (nsuffix, TEXT("xpm"))) || (!ustrcmp (nsuffix, TEXT("jpg"))) ||
        (!strcmp (nsuffix, "png")) || (!strcmp (nsuffix, "au")))         (!ustrcmp (nsuffix, TEXT("png"))) || (!ustrcmp (nsuffix, TEXT("au"))))
       return (TRUE);        return (TRUE);
    return (FALSE);     return (FALSE);
 }  }
Line 400  const char         *path; Line 400  const char         *path;
   returns TRUE if type points to an image resource.    returns TRUE if type points to an image resource.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            IsImageType (const char *type)  ThotBool             IsImageType (const STRING type)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsImageType (type)  ThotBool             IsImageType (type)
 const char         *type;  const STRING     type;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char                temptype[MAX_LENGTH];     CHAR_T              temptype[MAX_LENGTH];
    int                 i;     int                 i;
   
    if (!type)     if (!type)
       return (FALSE);        return (FALSE);
   
    strcpy (temptype, type);     ustrcpy (temptype, type);
    /* Normalize the type */     /* Normalize the type */
    i = 0;     i = 0;
    while (temptype[i] != EOS)     while (temptype[i] != EOS)
Line 420  const char         *type; Line 420  const char         *type;
        temptype[i] = tolower (temptype[i]);         temptype[i] = tolower (temptype[i]);
        i++;         i++;
      }       }
    if ((!strcmp (temptype, "gif")) || (!strcmp (temptype, "x-xbitmap")) ||     if ((!ustrcmp (temptype, TEXT("gif"))) || (!ustrcmp (temptype, TEXT("x-xbitmap"))) ||
        (!strcmp (temptype, "x-xpixmap")) || (!strcmp (temptype, "jpeg")) ||         (!ustrcmp (temptype, TEXT("x-xpixmap"))) || (!ustrcmp (temptype, TEXT("jpeg"))) ||
        (!strcmp (temptype, "png")))         (!ustrcmp (temptype, TEXT("png"))))
       return (TRUE);        return (TRUE);
    return (FALSE);     return (FALSE);
 }  }
Line 431  const char         *type; Line 431  const char         *type;
   IsTextName                                                             IsTextName                                                         
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            IsTextName (const char *path)  ThotBool             IsTextName (const STRING path)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsTextName (path)  ThotBool             IsTextName (path)
 const char         *path;  const STRING        path;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char                temppath[MAX_LENGTH];     CHAR_T                temppath[MAX_LENGTH];
    char                suffix[MAX_LENGTH];     CHAR_T                suffix[MAX_LENGTH];
    char                nsuffix[MAX_LENGTH];     CHAR_T                nsuffix[MAX_LENGTH];
    int                 i;     int                 i;
   
    if (!path)     if (!path)
      return (FALSE);       return (FALSE);
   
    strcpy (temppath, path);     ustrcpy (temppath, path);
    ExtractSuffix (temppath, suffix);     ExtractSuffix (temppath, suffix);
   
    /* Normalize the suffix */     /* Normalize the suffix */
Line 458  const char         *path; Line 458  const char         *path;
      }       }
    nsuffix[i] = EOS;     nsuffix[i] = EOS;
   
    if ((!strcmp (nsuffix, "txt")) || (!strcmp (nsuffix, "dtd")))     if ((!ustrcmp (nsuffix, TEXT("txt"))) || (!ustrcmp (nsuffix, TEXT("dtd"))))
       return (TRUE);        return (TRUE);
    else if (!strcmp (nsuffix, "gz"))     else if (!ustrcmp (nsuffix, TEXT("gz")))
      {       {
        /* take into account compressed files */         /* take into account compressed files */
        ExtractSuffix (temppath, suffix);                ExtractSuffix (temppath, suffix);       
Line 472  const char         *path; Line 472  const char         *path;
            i++;             i++;
          }           }
        nsuffix[i] = EOS;         nsuffix[i] = EOS;
        if ((!strcmp (nsuffix, "txt")) || (!strcmp (nsuffix, "dtd")))         if ((!ustrcmp (nsuffix, TEXT("txt"))) || (!ustrcmp (nsuffix, TEXT("dtd"))))
          return (TRUE);           return (TRUE);
        else         else
          return (FALSE);           return (FALSE);
Line 486  const char         *path; Line 486  const char         *path;
   returns TRUE if path is in fact an http URL.    returns TRUE if path is in fact an http URL.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            IsHTTPPath (const char *path)  ThotBool             IsHTTPPath (const STRING path)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsHTTPPath (path)  ThotBool             IsHTTPPath (path)
 const char         *path;  const STRING       path;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    if (!path)     if (!path)
       return FALSE;        return FALSE;
   
    if ((!strncmp (path, "http:", 5) != 0)     if ((!ustrncmp (path, TEXT("http:"), 5) != 0)
        || !strncmp (path, "internal:", 9))         || !ustrncmp (path, TEXT("internal:"), 9))
       return TRUE;        return TRUE;
    return FALSE;     return FALSE;
 }  }
Line 531  const char         *url; Line 531  const char         *url;
   returns TRUE if path is in fact a URL.    returns TRUE if path is in fact a URL.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            IsW3Path (const char *path)  ThotBool             IsW3Path (const STRING path)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsW3Path (path)  ThotBool             IsW3Path (path)
 const char               *path;  const STRING        path;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    if ((strncmp (path, "http:", 5)) && (strncmp (path, "ftp:", 4)) &&     if ((ustrncmp (path, TEXT("http:"), 5)) && (ustrncmp (path, TEXT("ftp:"), 4)) &&
        (strncmp (path, "telnet:", 7)) && (strncmp (path, "wais:", 5)) &&         (ustrncmp (path, TEXT("telnet:"), 7)) && (ustrncmp (path, TEXT("wais:"), 5)) &&
        (strncmp (path, "news:", 5)) && (strncmp (path, "gopher:", 7)) &&         (ustrncmp (path, TEXT("news:"), 5)) && (ustrncmp (path, TEXT("gopher:"), 7)) &&
        (strncmp (path, "mailto:", 7)) && (strncmp (path, "archie:", 7)))         (ustrncmp (path, TEXT("mailto:"), 7)) && (ustrncmp (path, TEXT("archie:"), 7)))
       return FALSE;        return FALSE;
    return TRUE;     return TRUE;
 }  }
Line 550  const char               *path; Line 550  const char               *path;
   returns true if the url protocol is supported by Amaya.    returns true if the url protocol is supported by Amaya.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            IsValidProtocol (const char *url)  ThotBool             IsValidProtocol (const STRING url)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsValidProtocol (url)  ThotBool             IsValidProtocol (url)
 const char         *url;  const STRING       url;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    if (!strncmp (url, "http:", 5)     if (!ustrncmp (url, TEXT("http:"), 5)
       || !strncmp (url, "internal:", 9))        || !ustrncmp (url, TEXT("internal:"), 9))
        /* experimental */         /* experimental */
       /***  || !strncmp (url, "ftp:", 4) ***/        /***  || !strncmp (url, "ftp:", 4) ***/
      /*** || !strncmp (path, "news:", 5)***/        /*** || !strncmp (path, "news:", 5)***/ 
Line 576  const char         *url; Line 576  const char         *url;
       - or the document path (without document name).        - or the document path (without document name).
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 char               *GetBaseURL (Document doc)  STRING              GetBaseURL (Document doc)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 char               *GetBaseURL (doc)  STRING              GetBaseURL (doc)
 Document            doc;  Document            doc;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
Line 586  Document            doc; Line 586  Document            doc;
   ElementType         elType;    ElementType         elType;
   AttributeType       attrType;    AttributeType       attrType;
   Attribute           attr;    Attribute           attr;
   char               *ptr, *basename;    STRING              ptr, basename;
   int                 length;    int                 length;
   
   /* @@@ irene */    /* @@@ irene */
   if (!DocumentURLs[doc])    if (!DocumentURLs[doc])
           return NULL;            return NULL;
   basename = TtaGetMemory (MAX_LENGTH);    basename = TtaAllocString (MAX_LENGTH);
   strncpy (basename, DocumentURLs[doc], MAX_LENGTH-1);    ustrncpy (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 root element    */
Line 622  Document            doc; Line 622  Document            doc;
           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, _EMPTYSTR_, AMAYA_PARSE_ACCESS |
                                                  AMAYA_PARSE_HOST |                                                   AMAYA_PARSE_HOST |
                                                  AMAYA_PARSE_PUNCTUATION);                                                   AMAYA_PARSE_PUNCTUATION);
               if (ptr && !strcmp (ptr, basename))                if (ptr && !ustrcmp (ptr, basename))
                 {                  {
                   /* it has this form, we complete it by adding a URL_STR  */                    /* it has this form, we complete it by adding a URL_STR  */
                   if (strchr (basename, DIR_SEP))                    if (ustrchr (basename, DIR_SEP))
                     strcat (basename, DIR_STR);                      ustrcat (basename, DIR_STR);
                   else                    else
                     strcat (basename, URL_STR);                      ustrcat (basename, URL_STR);
                   length++;                    length++;
                 }                  }
               if (ptr)                if (ptr)
Line 645  Document            doc; Line 645  Document            doc;
    * protocol. If found, end the string there. If neither char is found,     * protocol. If found, end the string there. If neither char is found,
    * then discard the whole base element.     * then discard the whole base element.
    */     */
   length = strlen (basename) - 1;    length = ustrlen (basename) - 1;
   /* search for the last DIR_SEP char */    /* search for the last DIR_SEP char */
   while (length >= 0  && basename[length] != URL_SEP && basename[length] != DIR_SEP)    while (length >= 0  && basename[length] != URL_SEP && basename[length] != DIR_SEP)
     length--;      length--;
Line 655  Document            doc; Line 655  Document            doc;
   else    else
     /* search for the first PATH_STR char */      /* search for the first PATH_STR char */
     {      {
       for (length = 0; basename[length] != ':' &&         for (length = 0; basename[length] != TEXT(':') && 
              basename[length] != EOS; length ++);               basename[length] != EOS; length ++);
       if (basename[length] == ':')        if (basename[length] == TEXT(':'))
         /* found, so end the string there */          /* found, so end the string there */
         basename[length + 1] = EOS;          basename[length + 1] = EOS;
       else        else
Line 673  Document            doc; Line 673  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__
 char      *GetLocalPath (Document doc, char *url)  STRING     GetLocalPath (Document doc, STRING url)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 char      *GetLocalPath (doc, url)  STRING     GetLocalPath (doc, url)
 Document   doc;  Document   doc;
 char      *url;  STRING     url;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   char    *ptr, *n;    STRING   ptr, n;
   char    *documentname;    STRING   documentname;
   char     url_sep;    CHAR_T   url_sep;
   int      len;    int      len;
   ThotBool noFile;    STRING   tmpDir, tmpName;
     ThotBool  noFile;
   
   if (url != NULL)    if (url != NULL)
     {      {
       /* check whether the file name exists */        /* check whether the file name exists */
       len = strlen (url) - 1;        len = ustrlen (url) - 1;
       if (IsW3Path)        if (IsW3Path)
         url_sep = '/';          url_sep = TEXT('/');
       else         else 
         url_sep = DIR_SEP;          url_sep = DIR_SEP;
       noFile = (url[len] == url_sep);        noFile = (url[len] == url_sep);
       if (noFile)        if (noFile)
         url[len] = EOS;          url[len] = EOS;
       ptr = TtaGetMemory (MAX_LENGTH);        /* ptr = TtaAllocString (MAX_LENGTH);
       documentname = TtaGetMemory (MAX_LENGTH);        documentname = TtaAllocString (MAX_LENGTH); */
       TtaExtractName (url, ptr, documentname);            tmpDir = TtaAllocString (MAX_LENGTH );
       sprintf (ptr, "%s%s%d%s", TempFileDirectory, DIR_STR, doc, DIR_STR);            tmpName = TtaAllocString(MAX_LENGTH );
         TtaExtractName (url, tmpDir, tmpName);
             ptr = tmpDir;
         documentname = tmpName;
   
         usprintf (ptr, TEXT("%s%s%d%s"), TempFileDirectory, DIR_STR, doc, DIR_STR);
       if (!TtaCheckDirectory (ptr))        if (!TtaCheckDirectory (ptr))
         /* directory did not exist */          /* directory did not exist */
 #   ifdef _WINDOWS  #   ifdef _WINDOWS
         _mkdir (ptr);          umkdir (ptr);
 #   else  /* !_WINDOWS */  #   else  /* !_WINDOWS */
         mkdir (ptr, S_IRWXU);          umkdir (ptr, S_IRWXU);
 #   endif /* !_WINDOWS */  #   endif /* !_WINDOWS */
   
       /* don't include the query string within document name */        /* don't include the query string within document name */
       n = strrchr(documentname, '?');        n = ustrrchr(documentname, TEXT('?'));
       if (n != NULL)        if (n != NULL)
         *n = EOS;          *n = EOS;
       /* don't include ':' within document name */        /* don't include ':' within document name */
       n = strchr (documentname, ':');        n = ustrchr (documentname, TEXT(':'));
       if (n != NULL)        if (n != NULL)
         *n = EOS;          *n = EOS;
       strcat (ptr, documentname);        ustrcat (ptr, documentname);
       TtaFreeMemory (documentname);        TtaFreeMemory (documentname);
       /* restore the url */        /* restore the url */
       if (noFile)        if (noFile)
Line 741  char      *url; Line 747  char      *url;
    the name "noname.html".     the name "noname.html".
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 void                NormalizeURL (char *orgName, Document doc, char *newName, char *docName, char *otherPath)  void                NormalizeURL (STRING orgName, Document doc, STRING newName, STRING docName, STRING otherPath)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 void                NormalizeURL (orgName, doc, newName, docName, otherPath)  void                NormalizeURL (orgName, doc, newName, docName, otherPath)
 char               *orgName;  STRING              orgName;
 Document            doc;  Document            doc;
 char               *newName;  STRING              newName;
 char               *docName;  STRING              docName;
 char               *otherPath;  STRING              otherPath;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char               *basename;     STRING             basename;
    char                tempOrgName[MAX_LENGTH];     CHAR_T             tempOrgName[MAX_LENGTH];
    char               *ptr;     STRING             ptr;
    char                used_sep;     CHAR_T             used_sep;
    int                 length;     int                length;
    ThotBool            check;     ThotBool            check;
   
 #  ifdef _WINDOWS  #  ifdef _WINDOWS
Line 779  char               *otherPath; Line 785  char               *otherPath;
     */      */
    ptr = orgName;     ptr = orgName;
    /* skip leading white space and new line characters */     /* skip leading white space and new line characters */
    while ((*ptr == ' ' || *ptr == EOL) && *ptr++ != EOS);     while ((*ptr == SPACE || *ptr == EOL) && *ptr++ != EOS);
    strncpy (tempOrgName, ptr, MAX_LENGTH -1);     ustrncpy (tempOrgName, ptr, MAX_LENGTH -1);
    tempOrgName[MAX_LENGTH -1] = EOS;     tempOrgName[MAX_LENGTH -1] = EOS;
    /*     /*
     * Make orgName a complete URL      * Make orgName a complete URL
Line 795  char               *otherPath; Line 801  char               *otherPath;
      }       }
   
    /* clean trailing white space */     /* clean trailing white space */
    length = strlen (tempOrgName) - 1;     length = ustrlen (tempOrgName) - 1;
    while (tempOrgName[length] == SPACE && tempOrgName[length] == EOL)     while (tempOrgName[length] == SPACE && tempOrgName[length] == EOL)
      {       {
        tempOrgName[length] = EOS;         tempOrgName[length] = EOS;
Line 804  char               *otherPath; Line 810  char               *otherPath;
   
    /* remove extra dot (which dot???) */     /* remove extra dot (which dot???) */
    /* ugly, but faster than a strcmp */     /* ugly, but faster than a strcmp */
    if (tempOrgName[length] == '.'     if (tempOrgName[length] == TEXT('.')
        && (length == 0 || tempOrgName[length-1] != '.'))         && (length == 0 || tempOrgName[length-1] != TEXT('.')))
          tempOrgName[length] = EOS;           tempOrgName[length] = EOS;
   
    if (IsW3Path (tempOrgName))     if (IsW3Path (tempOrgName))
      {       {
        /* the name is complete, go to the Sixth Step */         /* the name is complete, go to the Sixth Step */
        strcpy (newName, tempOrgName);         ustrcpy (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, _EMPTYSTR_, AMAYA_PARSE_ACCESS | AMAYA_PARSE_HOST | AMAYA_PARSE_PUNCTUATION);
        if (ptr && !strcmp (ptr, newName)) /* it has this form, we complete it by adding a DIR_STR  */         if (ptr && !ustrcmp (ptr, newName)) /* it has this form, we complete it by adding a DIR_STR  */
          strcat (newName, URL_STR);           ustrcat (newName, URL_STR);
   
        if (ptr)         if (ptr)
          TtaFreeMemory (ptr);           TtaFreeMemory (ptr);
      }       }
    else if ( basename == NULL)     else if ( basename == NULL)
      /* the name is complete, go to the Sixth Step */       /* the name is complete, go to the Sixth Step */
      strcpy (newName, tempOrgName);       ustrcpy (newName, tempOrgName);
    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 = ustrlen (tempOrgName);
            for (ndx = 0; ndx < length; ndx++)             for (ndx = 0; ndx < length; ndx++)
              if (tempOrgName [ndx] == '/')               if (tempOrgName [ndx] == TEXT('/'))
                tempOrgName [ndx] = '\\';                 tempOrgName [ndx] = TEXT('\\');
          }           }
 #      endif /* _WINDOWS */  #      endif /* _WINDOWS */
        ptr = AmayaParseUrl (tempOrgName, basename, AMAYA_PARSE_ALL);         ptr = AmayaParseUrl (tempOrgName, basename, AMAYA_PARSE_ALL);
        if (ptr)         if (ptr)
          {           {
            SimplifyUrl (&ptr);             SimplifyUrl (&ptr);
            strcpy (newName, ptr);             ustrcpy (newName, ptr);
            TtaFreeMemory (ptr);             TtaFreeMemory (ptr);
          }           }
        else         else
Line 855  char               *otherPath; Line 861  char               *otherPath;
    */     */
    if (newName[0] != EOS)     if (newName[0] != EOS)
      {       {
        length = strlen (newName) - 1;         length = ustrlen (newName) - 1;
        if (newName[length] == URL_SEP || newName[length] == DIR_SEP)         if (newName[length] == URL_SEP || newName[length] == DIR_SEP)
          {           {
            used_sep = newName[length];             used_sep = newName[length];
Line 865  char               *otherPath; Line 871  char               *otherPath;
                length--;                 length--;
                while (length >= 0 && newName[length] != used_sep)                 while (length >= 0 && newName[length] != used_sep)
                  length--;                   length--;
                if (!strncmp (&newName[length+1], "..", 2))                 if (!ustrncmp (&newName[length+1], TEXT(".."), 2))
                  {                   {
                    newName[length+1] = EOS;                     newName[length+1] = EOS;
                    /* remove also previous directory */                     /* remove also previous directory */
                    length--;                     length--;
                    while (length >= 0 && newName[length] != used_sep)                     while (length >= 0 && newName[length] != used_sep)
                      length--;                       length--;
                    if (strncmp (&newName[length+1], "//", 2))                     if (ustrncmp (&newName[length+1], TEXT("//"), 2))
                      /* don't remove server name */                       /* don't remove server name */
                      newName[length+1] = EOS;                       newName[length+1] = EOS;
                  }                   }
                else if (!strncmp (&newName[length+1], ".", 1))                 else if (!ustrncmp (&newName[length+1], TEXT("."), 1))
                  newName[length+1] = EOS;                   newName[length+1] = EOS;
                else                 else
                  check = FALSE;                   check = FALSE;
              }               }
            strcpy (docName, "noname.html");                         ustrcpy (docName, TEXT("noname.html"));             
            /* docname was not comprised inside the URL, so let's */             /* docname was not comprised inside the URL, so let's */
            /* assign the default ressource name */             /* assign the default ressource name */
            strcpy (docName, "noname.html");             ustrcpy (docName, TEXT("noname.html"));
          }           }
        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);               ustrcpy (docName, newName);
            else             else
              strcpy (docName, &newName[length+1]);               ustrcpy (docName, &newName[length+1]);
          }           }
      }       }
    else     else
Line 904  char               *otherPath; Line 910  char               *otherPath;
   IsSameHost                                                             IsSameHost                                                         
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            IsSameHost (const char *url1, const char *url2)  ThotBool             IsSameHost (const STRING url1, const STRING url2)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            IsSameHost (url1, url2)  ThotBool             IsSameHost (url1, url2)
 const char         *url1;  const STRING       url1;
 const char         *url2;  const STRING       url2;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char            *basename_ptr1, *basename_ptr2;     STRING           basename_ptr1, basename_ptr2;
    ThotBool         result;     ThotBool          result;
   
    basename_ptr1 = AmayaParseUrl (url1, "", AMAYA_PARSE_ACCESS | AMAYA_PARSE_HOST | AMAYA_PARSE_PUNCTUATION);     basename_ptr1 = AmayaParseUrl (url1, _EMPTYSTR_, AMAYA_PARSE_ACCESS | AMAYA_PARSE_HOST | AMAYA_PARSE_PUNCTUATION);
    basename_ptr2 = AmayaParseUrl (url2, "", AMAYA_PARSE_ACCESS | AMAYA_PARSE_HOST | AMAYA_PARSE_PUNCTUATION);     basename_ptr2 = AmayaParseUrl (url2, _EMPTYSTR_, AMAYA_PARSE_ACCESS | AMAYA_PARSE_HOST | AMAYA_PARSE_PUNCTUATION);
   
    if (strcmp (basename_ptr1, basename_ptr2))     if (ustrcmp (basename_ptr1, basename_ptr2))
       result = FALSE;        result = FALSE;
    else     else
       result = TRUE;        result = TRUE;
Line 933  const char         *url2; Line 939  const char         *url2;
   returns TRUE if path points to a file ending with a suffix.    returns TRUE if path points to a file ending with a suffix.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            HasKnownFileSuffix (const char *path)  ThotBool             HasKnownFileSuffix (const STRING path)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 ThotBool            HasKnownFileSuffix (path)  ThotBool             HasKnownFileSuffix (path)
 const char         *path;  const STRING    path;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char            *root;     STRING      root;
    char             temppath[MAX_LENGTH];     CHAR_T      temppath[MAX_LENGTH];
    char             suffix[MAX_LENGTH];     CHAR_T      suffix[MAX_LENGTH];
   
    if (!path || path[0] == EOS || path[strlen(path)] == DIR_SEP)     if (!path || path[0] == EOS || path[ustrlen(path)] == DIR_SEP)
      return (FALSE);       return (FALSE);
   
    root = AmayaParseUrl(path, "", AMAYA_PARSE_PATH | AMAYA_PARSE_PUNCTUATION);     root = AmayaParseUrl(path, _EMPTYSTR_, AMAYA_PARSE_PATH | AMAYA_PARSE_PUNCTUATION);
   
    if (root)      if (root) 
      {       {
        strcpy (temppath, root);         ustrcpy (temppath, root);
        TtaFreeMemory (root);         TtaFreeMemory (root);
        /* Get the suffix */         /* Get the suffix */
        ExtractSuffix (temppath, suffix);          ExtractSuffix (temppath, suffix); 
Line 962  const char         *path; Line 968  const char         *path;
        /* Normalize the suffix */         /* Normalize the suffix */
        ConvertToLowerCase (suffix);         ConvertToLowerCase (suffix);
   
        if (!strcmp (suffix, "gz"))         if (!ustrcmp (suffix, TEXT("gz")))
          /* skip the compressed suffix */           /* skip the compressed suffix */
          {           {
          ExtractSuffix (temppath, suffix);           ExtractSuffix (temppath, suffix);
Line 973  const char         *path; Line 979  const char         *path;
          ConvertToLowerCase (suffix);           ConvertToLowerCase (suffix);
          }           }
   
        if (strcmp (suffix, "gif") &&         if (ustrcmp (suffix, TEXT("gif")) &&
            strcmp (suffix, "xbm") &&             ustrcmp (suffix, TEXT("xbm")) &&
            strcmp (suffix, "xpm") &&             ustrcmp (suffix, TEXT("xpm")) &&
            strcmp (suffix, "jpg") &&             ustrcmp (suffix, TEXT("jpg")) &&
            strcmp (suffix, "pdf") &&             ustrcmp (suffix, TEXT("pdf")) &&
            strcmp (suffix, "png") &&             ustrcmp (suffix, TEXT("png")) &&
            strcmp (suffix, "tgz") &&             ustrcmp (suffix, TEXT("tgz")) &&
            strcmp (suffix, "xpg") &&             ustrcmp (suffix, TEXT("xpg")) &&
            strcmp (suffix, "xpd") &&             ustrcmp (suffix, TEXT("xpd")) &&
            strcmp (suffix, "ps") &&             ustrcmp (suffix, TEXT("ps")) &&
            strcmp (suffix, "au") &&             ustrcmp (suffix, TEXT("au")) &&
            strcmp (suffix, "html") &&             ustrcmp (suffix, TEXT("html")) &&
            strcmp (suffix, "htm") &&             ustrcmp (suffix, TEXT("htm")) &&
            strcmp (suffix, "shtml") &&             ustrcmp (suffix, TEXT("shtml")) &&
            strcmp (suffix, "xht") &&             ustrcmp (suffix, TEXT("xht")) &&
            strcmp (suffix, "xhtm") &&             ustrcmp (suffix, TEXT("xhtm")) &&
            strcmp (suffix, "xhtml") &&             ustrcmp (suffix, TEXT("xhtml")) &&
            strcmp (suffix, "txt") &&             ustrcmp (suffix, TEXT("txt")) &&
            strcmp (suffix, "css") &&             ustrcmp (suffix, TEXT("css")) &&
            strcmp (suffix, "eps"))             ustrcmp (suffix, TEXT("eps")))
          return (FALSE);           return (FALSE);
        else         else
          return (TRUE);           return (TRUE);
Line 1051  const char *inputURL; Line 1057  const char *inputURL;
         Any which are nonzero point to zero terminated strings.          Any which are nonzero point to zero terminated strings.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 static void scan (char * name, HTURI * parts)  static void scan (STRING name, HTURI * parts)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 static void scan (name, parts)  static void scan (name, parts)
 char                *name;  STRING      name;
 HTURI               *parts;  HTURI       *parts;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   char      *p;    STRING    p;
   char      *after_access = name;    STRING    after_access = name;
   
   memset (parts, '\0', sizeof (HTURI));    memset (parts, '\0', sizeof (HTURI));
   /* Look for fragment identifier */    /* Look for fragment identifier */
   if ((p = strchr(name, '#')) != NULL)    if ((p = ustrchr(name, TEXT('#'))) != NULL)
     {      {
       *p++ = '\0';        *p++ = TEXT('\0');
       parts->fragment = p;        parts->fragment = p;
     }      }
           
   for (p=name; *p; p++)    for (p=name; *p; p++)
     {      {
       if (*p == URL_SEP || *p == DIR_SEP || *p=='#' || *p=='?')        if (*p == URL_SEP || *p == DIR_SEP || *p == TEXT('#') || *p == TEXT('?'))
         break;          break;
       if (*p==':')        if (*p == TEXT(':'))
         {          {
           *p = 0;            *p = 0;
           parts->access = after_access; /* Scheme has been specified */            parts->access = after_access; /* Scheme has been specified */
Line 1087  HTURI               *parts; Line 1093  HTURI               *parts;
           /*            while (*after_access == 0)*/            /*            while (*after_access == 0)*/
           /*                after_access++;*/            /*                after_access++;*/
           after_access = p+1;            after_access = p+1;
           if (!strcasecmp("URL", parts->access))            if (!ustrcasecmp(TEXT("URL"), parts->access))
             /* Ignore IETF's URL: pre-prefix */              /* Ignore IETF's URL: pre-prefix */
             parts->access = NULL;              parts->access = NULL;
           else            else
Line 1103  HTURI               *parts; Line 1109  HTURI               *parts;
             parts->host = p+2;          /* host has been specified      */              parts->host = p+2;          /* host has been specified      */
             *p = 0;                     /* Terminate access             */              *p = 0;                     /* Terminate access             */
             /* look for end of host name if any */              /* look for end of host name if any */
             p = strchr (parts->host, URL_SEP);              p = ustrchr (parts->host, URL_SEP);
             if (p)              if (p)
               {                {
                 *p = EOS;                       /* Terminate host */                  *p = EOS;                       /* Terminate host */
Line 1137  HTURI               *parts; Line 1143  HTURI               *parts;
         returns         A pointer to a malloc'd string which MUST BE FREED          returns         A pointer to a malloc'd string which MUST BE FREED
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 char          *AmayaParseUrl (const char *aName, char *relatedName, int wanted)  STRING        AmayaParseUrl (const STRING aName, STRING relatedName, int wanted)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 char          *AmayaParseUrl (aName, relatedName, wanted)  STRING        AmayaParseUrl (aName, relatedName, wanted)
 const char    *aName;  const STRING  aName;
 char          *relatedName;  STRING        relatedName;
 int            wanted;  int            wanted;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   char      *return_value;    STRING     return_value;
   char       result[MAX_LENGTH];    CHAR_T     result[MAX_LENGTH];
   char       name[MAX_LENGTH];    CHAR_T     name[MAX_LENGTH];
   char       rel[MAX_LENGTH];    CHAR_T     rel[MAX_LENGTH];
   char      *p, *access;    STRING     p, access;
   HTURI      given, related;    HTURI      given, related;
   int        len;    int        len;
   char       used_sep;    CHAR_T     used_sep;
   char      *used_str;    STRING     used_str;
   
   if (strchr (aName, DIR_SEP) || strchr (relatedName, DIR_SEP))    if (ustrchr (aName, DIR_SEP) || ustrchr (relatedName, DIR_SEP))
     {      {
       used_str = DIR_STR;        used_str = DIR_STR;
       used_sep = DIR_SEP;        used_sep = DIR_SEP;
Line 1170  int            wanted; Line 1176  int            wanted;
   /* Make working copies of input strings to cut up: */    /* Make working copies of input strings to cut up: */
   return_value = NULL;    return_value = NULL;
   result[0] = 0;                /* Clear string  */    result[0] = 0;                /* Clear string  */
   strcpy (name, aName);    ustrcpy (name, aName);
   if (relatedName != NULL)      if (relatedName != NULL)  
     strcpy (rel, relatedName);      ustrcpy (rel, relatedName);
   else    else
     relatedName[0] = EOS;      relatedName[0] = EOS;
       
Line 1182  int            wanted; Line 1188  int            wanted;
   if (wanted & AMAYA_PARSE_ACCESS)    if (wanted & AMAYA_PARSE_ACCESS)
     if (access)      if (access)
       {        {
         strcat (result, access);          ustrcat (result, access);
         if(wanted & AMAYA_PARSE_PUNCTUATION)          if(wanted & AMAYA_PARSE_PUNCTUATION)
                 strcat (result, ":");                  ustrcat (result, TEXT(":"));
       }        }
       
   if (given.access && related.access)    if (given.access && related.access)
     /* If different, inherit nothing. */      /* If different, inherit nothing. */
     if (strcmp (given.access, related.access) != 0)      if (ustrcmp (given.access, related.access) != 0)
       {        {
         related.host = 0;          related.host = 0;
         related.absolute = 0;          related.absolute = 0;
Line 1201  int            wanted; Line 1207  int            wanted;
     if(given.host || related.host)      if(given.host || related.host)
       {        {
         if(wanted & AMAYA_PARSE_PUNCTUATION)          if(wanted & AMAYA_PARSE_PUNCTUATION)
           strcat (result, "//");            ustrcat (result, TEXT("//"));
         strcat (result, given.host ? given.host : related.host);          ustrcat (result, given.host ? given.host : related.host);
       }        }
       
   if (given.host && related.host)    if (given.host && related.host)
     /* If different hosts, inherit no path. */      /* If different hosts, inherit no path. */
     if (strcmp(given.host, related.host) != 0)      if (ustrcmp (given.host, related.host) != 0)
       {        {
         related.absolute = 0;          related.absolute = 0;
         related.relative = 0;          related.relative = 0;
Line 1220  int            wanted; Line 1226  int            wanted;
         {          {
           /* All is given */            /* All is given */
           if (wanted & AMAYA_PARSE_PUNCTUATION)            if (wanted & AMAYA_PARSE_PUNCTUATION)
             strcat (result, used_str);              ustrcat (result, used_str);
           strcat (result, given.absolute);            ustrcat (result, given.absolute);
         }          }
       else if (related.absolute)        else if (related.absolute)
         {          {
           /* Adopt path not name */            /* Adopt path not name */
           strcat (result, used_str);            ustrcat (result, used_str);
           strcat (result, related.absolute);            ustrcat (result, related.absolute);
           if (given.relative)            if (given.relative)
             {              {
               /* Search part? */                /* Search part? */
               p = strchr (result, '?');                p = ustrchr (result, TEXT('?'));
               if (!p)                if (!p)
                 p=result+strlen(result)-1;                  p=result+ustrlen(result)-1;
               for (; *p!=used_sep; p--);        /* last / */                for (; *p!=used_sep; p--);        /* last / */
               /* Remove filename */                /* Remove filename */
               p[1]=0;                p[1]=0;
               /* Add given one */                /* Add given one */
               strcat (result, given.relative);                ustrcat (result, given.relative);
             }              }
         }          }
       else if (given.relative)        else if (given.relative)
         /* what we've got */          /* what we've got */
         strcat (result, given.relative);          ustrcat (result, given.relative);
       else if (related.relative)        else if (related.relative)
         strcat (result, related.relative);          ustrcat (result, related.relative);
       else        else
         /* No inheritance */          /* No inheritance */
         strcat (result, used_str);          ustrcat (result, used_str);
     }      }
       
   if (wanted & AMAYA_PARSE_ANCHOR)    if (wanted & AMAYA_PARSE_ANCHOR)
Line 1258  int            wanted; Line 1264  int            wanted;
           {            {
             /*Fixes for relURLs...*/              /*Fixes for relURLs...*/
             if (wanted & AMAYA_PARSE_PUNCTUATION)              if (wanted & AMAYA_PARSE_PUNCTUATION)
               strcat (result, "#");                ustrcat (result, TEXT("#"));
             strcat (result, given.fragment);               ustrcat (result, given.fragment); 
           }            }
         else if (!(given.absolute) && !(given.fragment))          else if (!(given.absolute) && !(given.fragment))
           strcat (result, "");            ustrcat (result, _EMPTYSTR_);
         else          else
           {            {
             if (wanted & AMAYA_PARSE_PUNCTUATION)              if (wanted & AMAYA_PARSE_PUNCTUATION)
               strcat (result, "#");                ustrcat (result, TEXT("#"));
             strcat (result, given.fragment ? given.fragment : related.fragment);               ustrcat (result, given.fragment ? given.fragment : related.fragment); 
           }            }
       }        }
   len = strlen (result);    len = ustrlen (result);
   if ((return_value = (char *) TtaGetMemory (len + 1)) != NULL)    if ((return_value = TtaAllocString (len + 1)) != NULL)
     strcpy (return_value, result);      ustrcpy (return_value, result);
   return (return_value);                /* exactly the right length */    return (return_value);                /* exactly the right length */
 }  }
   
Line 1289  int            wanted; Line 1295  int            wanted;
       
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 static char *HTCanon (char ** filename, char * host)  static STRING HTCanon (STRING* filename, STRING host)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 static char *HTCanon (filename, host)  static STRING HTCanon (filename, host)
 char       **filename;  STRING      *filename;
 char        *host;  STRING      host;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
     char *newname = NULL;      STRING  newname = NULL;
     char *port;      STRING  port;
     char *strptr;      STRING  strptr;
     char *path;      STRING  path;
     char *access = host-3;      STRING  access = host-3;
     char       used_sep;      CHAR_T  used_sep;
   
       
      if (*filename && strchr (*filename, URL_SEP))       if (*filename && ustrchr (*filename, URL_SEP))
        {         {
          used_sep = URL_SEP;           used_sep = URL_SEP;
        }         }
Line 1315  char        *host; Line 1321  char        *host;
       
     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 = ustrchr(host, used_sep)) == NULL)                       /* Find path */
         path = host + strlen(host);          path = host + ustrlen(host);
     if ((strptr = strchr(host, '@')) != NULL && strptr<path)       /* UserId */      if ((strptr = ustrchr(host, TEXT('@'))) != NULL && strptr<path)        /* UserId */
         host = strptr;          host = strptr;
     if ((port = strchr(host, ':')) != NULL && port>path)      /* Port number */      if ((port = ustrchr(host, TEXT(':'))) != NULL && port>path)      /* Port number */
         port = NULL;          port = NULL;
   
     strptr = host;                                  /* Convert to lower-case */      strptr = host;                                  /* Convert to lower-case */
Line 1333  char        *host; Line 1339  char        *host;
        numerical host name. The domain name is already made lower-case         numerical host name. The domain name is already made lower-case
        and without a trailing dot. */         and without a trailing dot. */
     {      {
       char *dot = port ? port : path;        STRING dot = port ? port : path;
       if (dot > *filename && *--dot=='.')        if (dot > *filename && *--dot == TEXT('.'))
         {          {
           char *orig=dot, *dest=dot+1;            STRING orig=dot, dest=dot+1;
           while((*orig++ = *dest++));            while((*orig++ = *dest++));
           if (port) port--;            if (port) port--;
           path--;            path--;
Line 1349  char        *host; Line 1355  char        *host;
           {            {
             if (!newname)              if (!newname)
               {                {
                 char *orig=port, *dest=port+1;                  STRING orig=port, dest=port+1;
                 while((*orig++ = *dest++));                  while((*orig++ = *dest++));
               }                }
           }            }
         else if ((!strncmp(access, "http", 4) &&          else if ((!ustrncmp(access, TEXT("http"), 4) &&
                   (*(port+1)=='8'&&*(port+2)=='0'&&(*(port+3)==used_sep||!*(port+3)))) ||                    (*(port+1) == TEXT('8') && *(port+2) == TEXT('0') && (*(port+3) == used_sep || !*(port + 3)))) ||
                  (!strncmp(access, "gopher", 6) &&                   (!ustrncmp (access, TEXT("gopher"), 6) &&
                   (*(port+1)=='7'&&*(port+2)=='0'&&(*(port+3)==used_sep||!*(port+3)))) ||                    (*(port+1) == TEXT('7') && *(port+2) == TEXT('0') && (*(port+3) == used_sep || !*(port+3)))) ||
                  (!strncmp(access, "ftp", 3) &&                   (!ustrncmp(access, TEXT("ftp"), 3) &&
                   (*(port+1)=='2'&&*(port+2)=='1'&&(*(port+3)==used_sep||!*(port+3))))) {                    (*(port+1) == TEXT('2') && *(port + 2) == TEXT('1') && (*(port+3) == used_sep || !*(port+3))))) {
           if (!newname)            if (!newname)
             {              {
               char *orig=port, *dest=port+3;                STRING orig=port, dest=port+3;
               while((*orig++ = *dest++));                while((*orig++ = *dest++));
               /* Update path position, Henry Minsky */                /* Update path position, Henry Minsky */
               path -= 3;                path -= 3;
             }              }
         }          }
         else if (newname)          else if (newname)
           strncat(newname, port, (int) (path-port));            ustrncat(newname, port, (int) (path-port));
       }        }
   
     if (newname)      if (newname)
       {        {
         char *newpath = newname+strlen(newname);          STRING newpath = newname + ustrlen (newname);
         strcat(newname, path);          ustrcat(newname, path);
         path = newpath;          path = newpath;
         /* Free old copy */          /* Free old copy */
         TtaFreeMemory(*filename);          TtaFreeMemory(*filename);
Line 1410  char        *host; Line 1416  char        *host;
   Returns: A string which might be the old one or a new one.    Returns: A string which might be the old one or a new one.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 void         SimplifyUrl (char ** url)  void         SimplifyUrl (STRING* url)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 void         SimplifyUrl (url)  void         SimplifyUrl (url)
 char        **url;  STRING       *url;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   char *path, *p;    STRING   path, p;
   char *newptr, *access;    STRING   newptr, access;
   char *orig, *dest, *end;    STRING   orig, dest, end;
   
   char       used_sep;    CHAR_T   used_sep;
   
   
   if (!url || !*url)    if (!url || !*url)
     return;      return;
   
   if (strchr (*url, URL_SEP))    if (ustrchr (*url, URL_SEP))
     {      {
       used_sep = URL_SEP;        used_sep = URL_SEP;
     }      }
Line 1436  char        **url; Line 1442  char        **url;
     }      }
   
   /* Find any scheme name */    /* Find any scheme name */
   if ((path = strstr(*url, "://")) != NULL)    if ((path = ustrstr(*url, TEXT("://"))) != NULL)
     {      {
       /* Find host name */        /* Find host name */
       access = *url;        access = *url;
       while (access<path && (*access=tolower(*access)))        while (access<path && (*access=tolower(*access)))
         access++;          access++;
       path += 3;        path += 3;
       while ((newptr = strstr(path, "://")) != NULL)        while ((newptr = ustrstr(path, TEXT("://"))) != NULL)
         /* For proxies */          /* For proxies */
         path = newptr+3;          path = newptr+3;
       /* We have a host name */        /* We have a host name */
       path = HTCanon(url, path);        path = HTCanon(url, path);
     }      }
   else if ((path = strstr(*url, ":/")) != NULL)    else if ((path = ustrstr(*url, TEXT(":/"))) != NULL)
     path += 2;      path += 2;
   else    else
     path = *url;      path = *url;
Line 1457  char        **url; Line 1463  char        **url;
   if (*path == used_sep && *(path+1)==used_sep)    if (*path == used_sep && *(path+1)==used_sep)
     /* Some URLs start //<foo> */      /* Some URLs start //<foo> */
     path += 1;      path += 1;
   else if (!strncmp(path, "news:", 5))    else if (!ustrncmp(path, TEXT("news:"), 5))
     {      {
       newptr = strchr(path+5, '@');        newptr = ustrchr(path+5, TEXT('@'));
       if (!newptr)        if (!newptr)
         newptr = path + 5;          newptr = path + 5;
       while (*newptr)        while (*newptr)
Line 1474  char        **url; Line 1480  char        **url;
   
   if ((p = path))    if ((p = path))
     {      {
       if (!((end = strchr (path, ';')) || (end = strchr (path, '?')) ||        if (!((end = ustrchr (path, TEXT(';'))) || (end = ustrchr (path, TEXT('?'))) ||
             (end = strchr (path, '#'))))              (end = ustrchr (path, TEXT('#')))))
         end = path + strlen (path);          end = path + ustrlen (path);
               
       /* Parse string second time to simplify */        /* Parse string second time to simplify */
       p = path;        p = path;
Line 1484  char        **url; Line 1490  char        **url;
         {          {
           if (*p==used_sep)            if (*p==used_sep)
             {              {
               if (p > *url && *(p+1) == '.' && (*(p+2) == used_sep || !*(p+2)))                if (p > *url && *(p+1) == TEXT('.') && (*(p+2) == used_sep || !*(p+2)))
                 {                  {
                   orig = p + 1;                    orig = p + 1;
                   dest = (*(p+2)!=used_sep) ? p+2 : p+3;                    dest = (*(p+2)!=used_sep) ? p+2 : p+3;
                   while ((*orig++ = *dest++)); /* Remove a used_sep and a dot*/                    while ((*orig++ = *dest++)); /* Remove a used_sep and a dot*/
                   end = orig - 1;                    end = orig - 1;
                 }                  }
               else if (*(p+1)=='.' && *(p+2)=='.' && (*(p+3)==used_sep || !*(p+3)))                else if (*(p+1) == TEXT('.') && *(p+2) == TEXT('.') && (*(p+3) == used_sep || !*(p+3)))
                 {                  {
                   newptr = p;                    newptr = p;
                   while (newptr>path && *--newptr!=used_sep); /* prev used_sep */                    while (newptr>path && *--newptr!=used_sep); /* prev used_sep */
Line 1527  char        **url; Line 1533  char        **url;
     /*      /*
     **  Check for host/../.. kind of things      **  Check for host/../.. kind of things
     */      */
     if (*path==used_sep && *(path+1)=='.' && *(path+2)=='.' && (!*(path+3) || *(path+3)==used_sep))      if (*path == used_sep && *(path+1) == TEXT('.') && *(path+2) == TEXT('.') && (!*(path+3) || *(path+3) == used_sep))
         *(path+1) = EOS;          *(path+1) = EOS;
   
   return;    return;
Line 1539  char        **url; Line 1545  char        **url;
    Return TRUE if target and src differ.                                Return TRUE if target and src differ.                           
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool            NormalizeFile (char *src, char *target)  ThotBool             NormalizeFile (STRING src, STRING target)
 #else  #else
 ThotBool            NormalizeFile (src, target)  ThotBool             NormalizeFile (src, target)
 char               *src;  STRING              src;
 char               *target;  STRING              target;
   
 #endif  #endif
 {  {
    char               *s;     STRING             s;
    ThotBool            change;     ThotBool            change;
   
    change = FALSE;     change = FALSE;
    if (strncmp (src, "file:", 5) == 0)     if (ustrncmp (src, TEXT("file:"), 5) == 0)
      {       {
         /* remove the prefix file: */          /* remove the prefix file: */
         if (src[5] == EOS)          if (src[5] == EOS)
            strcpy (target, DIR_STR);             ustrcpy (target, DIR_STR);
         else if (src[0] == '~')          else if (src[0] == TEXT('~'))
           {            {
             /* replace ~ */              /* replace ~ */
             s = (char *) TtaGetEnvString ("HOME");              s = TtaGetEnvString (TEXT("HOME"));
             strcpy (target, s);              ustrcpy (target, s);
             strcat (target, &src[5]);              ustrcat (target, &src[5]);
           }            }
         else          else
            strcpy (target, &src[5]);             ustrcpy (target, &src[5]);
         change = TRUE;          change = TRUE;
      }       }
 #  ifndef _WINDOWS  #  ifndef _WINDOWS
    else if (src[0] == '~')     else if (src[0] == TEXT('~'))
      {       {
         /* replace ~ */          /* replace ~ */
         s = (char *) TtaGetEnvString ("HOME");          s = (char *) TtaGetEnvString ("HOME");
Line 1580  char               *target; Line 1586  char               *target;
      }       }
 #   endif /* _WINDOWS */  #   endif /* _WINDOWS */
    else     else
       strcpy (target, src);        ustrcpy (target, src);
   
    /* remove /../ and /./ */     /* remove /../ and /./ */
    SimplifyUrl (&target);     SimplifyUrl (&target);
    if (!change)     if (!change)
      change = strcmp (src, target);       change = ustrcmp (src, target);
    return (change);     return (change);
 }  }
   
Line 1607  char               *target; Line 1613  char               *target;
         The caller is responsible for freeing the resulting name later.          The caller is responsible for freeing the resulting name later.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 char            *MakeRelativeURL (char *aName, char *relatedName)  STRING           MakeRelativeURL (STRING aName, STRING relatedName)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 char            *MakeRelativeURL (aName, relatedName)  STRING           MakeRelativeURL (aName, relatedName)
 char            *aName;  STRING           aName;
 char            *relatedName;  STRING           relatedName;
 #endif  /* __STDC__ */  #endif  /* __STDC__ */
 {  {
   char          *return_value;    STRING         return_value;
   char           result[MAX_LENGTH];    CHAR_T         result[MAX_LENGTH];
   char          *p;    STRING         p;
   char          *q;    STRING         q;
   char          *after_access;    STRING         after_access;
   char          *last_slash = NULL;    STRING         last_slash = NULL;
   int            slashes, levels, len;    int            slashes, levels, len;
   
 # ifdef _WINDOWS  # ifdef _WINDOWS
Line 1636  char            *relatedName; Line 1642  char            *relatedName;
   for (; *p && (*p == *q); p++, q++)    for (; *p && (*p == *q); p++, q++)
     {      {
       /* Find extent of match */        /* Find extent of match */
       if (*p == ':')        if (*p == TEXT(':'))
         after_access = p + 1;          after_access = p + 1;
       if (*p == DIR_SEP)        if (*p == DIR_SEP)
         {          {
Line 1651  char            *relatedName; Line 1657  char            *relatedName;
     {      {
       /* New name is a subset of the related name */        /* New name is a subset of the related name */
       /* exactly the right length */        /* exactly the right length */
       len = strlen (p);        len = ustrlen (p);
       if ((return_value = (char *) TtaGetMemory (len + 1)) != NULL)        if ((return_value = TtaAllocString (len + 1)) != NULL)
         strcpy (return_value, p);          ustrcpy (return_value, p);
     }      }
   else if ((slashes < 2 && after_access == NULL)    else if ((slashes < 2 && after_access == NULL)
       || (slashes < 3 && after_access != NULL))        || (slashes < 3 && after_access != NULL))
     {      {
       /* Two names whitout common path */        /* Two names whitout common path */
       /* exactly the right length */        /* exactly the right length */
       len = strlen (aName);        len = ustrlen (aName);
       if ((return_value = (char *) TtaGetMemory (len + 1)) != NULL)        if ((return_value = TtaAllocString (len + 1)) != NULL)
         strcpy (return_value, aName);          ustrcpy (return_value, aName);
     }      }
   else    else
     {      {
       /* Some path in common */        /* Some path in common */
       if (slashes == 3 && strncmp (aName, "http:", 5) == 0)        if (slashes == 3 && ustrncmp (aName, TEXT("http:"), 5) == 0)
         /* just the same server */          /* just the same server */
         strcpy (result, last_slash);          ustrcpy (result, last_slash);
       else        else
         {          {
           levels= 0;             levels= 0; 
           for (; *q && *q != '#' && *q!=';' && *q!='?'; q++)            for (; *q && *q != TEXT('#') && *q != TEXT(';') && *q != TEXT('?'); q++)
             if (*q == DIR_SEP)              if (*q == DIR_SEP)
               levels++;                levels++;
                       
           result[0] = EOS;            result[0] = EOS;
           for (;levels; levels--)            for (;levels; levels--)
             strcat (result, "../");              ustrcat (result, TEXT("../"));
           strcat (result, last_slash+1);            ustrcat (result, last_slash+1);
         }           } 
   
       if (!*result)        if (!*result)
         strcat (result, "./");          ustrcat (result, TEXT("./"));
   
       /* exactly the right length */        /* exactly the right length */
       len = strlen (result);        len = ustrlen (result);
       if ((return_value = (char *) TtaGetMemory (len + 1)) != NULL)        if ((return_value = TtaAllocString (len + 1)) != NULL)
         strcpy (return_value, result);          ustrcpy (return_value, result);
   
     }      }
 # ifdef _WINDOWS  # ifdef _WINDOWS
   len = strlen (return_value);    len = ustrlen (return_value);
   for (ndx = 0; ndx < len; ndx ++)    for (ndx = 0; ndx < len; ndx ++)
           if (return_value[ndx] == '\\')            if (return_value[ndx] == TEXT('\\'))
              return_value[ndx] = '/' ;               return_value[ndx] = TEXT('/') ;
 # endif /* _WINDOWS */  # endif /* _WINDOWS */
   return (return_value);    return (return_value);
 }  }

Removed from v.1.66  
changed lines
  Added in v.1.67


Webmaster