Diff for /Amaya/amaya/AHTURLTools.c between versions 1.89 and 1.90

version 1.89, 2000/03/08 16:19:04 version 1.90, 2000/03/13 10:39:50
Line 655  const CHAR_T*        path; Line 655  const CHAR_T*        path;
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
     IsFilePath                                           
     returns TRUE if path is in fact a URL.
     ----------------------------------------------------------------------*/
   #ifdef __STDC__
   static ThotBool             IsFilePath (const CHAR_T* path)
   #else  /* __STDC__ */
   static ThotBool             IsFilePath (path)
   const CHAR_T*        path;
   #endif /* __STDC__ */
   {
     if (ustrncmp (path, TEXT("file:"), 5))
       return FALSE;
     return TRUE;
   }
   
   /*----------------------------------------------------------------------
   IsValidProtocol                                                        IsValidProtocol                                                    
   returns true if the url protocol is supported by Amaya.    returns true if the url protocol is supported by Amaya.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
Line 884  CHAR_T*      target; Line 900  CHAR_T*      target;
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    ConvertFileURL     RemoveNewLines (text)
    If the URL starts with file: prefix, it removes the protocol so that we     Removes any '\n' chars that are found in text. 
    can use it as a local filename. It also changes the URL_SEP into     Returns TRUE if it did the operation, FALSE otherwise.
    DIR_SEPs if they are not the same character.  
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 void ConvertFileURL (CHAR_T* url)  ThotBool RemoveNewLines (CHAR_T *text)
 #else  #else
 void ConvertFileURL (url)  ThotBool RemoveNewLines (text)
 CHAR_T* url  CHAR_T *text;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
   CHAR_T *src, *dest;    ThotBool change = FALSE;
     CHAR_T *src;
     CHAR_T *dest;
   
     src = text;
     dest = text;
   
     while (*src)
       {
         switch (*src)
           {
           case TEXT('\n'):
             /* don't copy the newline */
             change = 1;
             break;
           default:
             *dest = *src;
             dest++;
             break;
           }
         src++;
       }
     /* copy the last EOS char */
     *dest = *src;
   
     return (change);
   }
   
   /*----------------------------------------------------------------------
      CleanCopyFileURL
      Copies a file url from a src string to destination string.
      It changes the URL_SEP into DIR_SEPs if they are not the same 
      character.
     ----------------------------------------------------------------------*/
   #ifdef __STDC__
   static void CleanCopyFileURL (CHAR_T *dest, CHAR_T *src)
   #else
   static void CleanCopyFileURL (dest, src)
   CHAR_T* dest;
   CHAR_T* src;
   
   if (!ustrncasecmp (url, TEXT("file:"), 5))  #endif /* __STDC__ */
   {
     while (*src)
     {      {
       /* skip the file prefix */        switch (*src)
       dest = url;  
       src = url + 5;  
       while (*src)  
         {          {
 #ifdef _WINDOWS  #ifdef _WINDOWS
           if (*dest == URL_SEP)          case WC_URL_SEP:
             /* make the transformation */            /* make the transformation */
             *dest = DIR_SEP;            *dest = WC_DIR_SEP;
           else            dest++;
             break;
 #endif /* _WINDOWS */  #endif /* _WINDOWS */
             *dest = *src;          default:
           src++;            *dest = *src;
           dest++;            dest++;
             break;
         }          }
       *src = WC_EOS;        src++;
     }      }
     /* copy the EOS char */
     *dest = *src;
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 998  CHAR_T*             otherPath; Line 1056  CHAR_T*             otherPath;
        && (length == 0 || tempOrgName[length-1] != TEXT('.')))         && (length == 0 || tempOrgName[length-1] != TEXT('.')))
          tempOrgName[length] = WC_EOS;           tempOrgName[length] = WC_EOS;
   
    if (IsW3Path (tempOrgName))     if (IsW3Path (tempOrgName) || IsFilePath (tempOrgName))
      {       {
        /* the name is complete, go to the Sixth Step */         /* the name is complete, go to the Sixth Step */
        ustrcpy (newName, tempOrgName);         ustrcpy (newName, tempOrgName);
Line 1755  CHAR_T**     url; Line 1813  CHAR_T**     url;
    Return TRUE if target and src differ.                                Return TRUE if target and src differ.                           
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 ThotBool             NormalizeFile (CHAR_T* src, CHAR_T* target)  ThotBool     NormalizeFile (CHAR_T* src, CHAR_T* target)
 #else  #else
 ThotBool             NormalizeFile (src, target)  ThotBool     NormalizeFile (src, target)
 CHAR_T*              src;  CHAR_T*              src;
 CHAR_T*              target;  CHAR_T*              target;
   
 #endif  #endif
 {  {
    CHAR_T*           s;     CHAR_T            *s;
    ThotBool          change;     ThotBool          change;
      int               i;
      int               start_index; /* the first char that we'll copy */
   
    change = FALSE;     change = FALSE;
      start_index = 0;
   
      if (!src || src[0] == WC_EOS)
        return FALSE;
   
      /* @@ do I need file: or file:/ here? */
    if (ustrncmp (src, TEXT("file:"), 5) == 0)     if (ustrncmp (src, TEXT("file:"), 5) == 0)
      {       {
         /* remove the prefix file: */         /* remove the prefix file: */
         if (src[5] == WC_EOS)         start_index += 5;
            ustrcpy (target, WC_DIR_STR);     
         else if (src[0] == TEXT('~'))         if (ustrncmp (&src[start_index], TEXT("/localhost"), 10) == 0)
           {         /* remove the localhost prefix */
             /* replace ~ */           start_index += 10;
             s = TtaGetEnvString ("HOME");  
             ustrcpy (target, s);         if (src[start_index] == WC_EOS)
             ustrcat (target, &src[5]);         /* if there's nothing afterwards, add a DIR_STR */
           }           ustrcpy (target, WC_DIR_STR);
         else  #ifndef _WINDOWS
            ustrcpy (target, &src[5]);         else if (src[start_index] == TEXT('~'))
         change = TRUE;           {
              /* replace ~ */
              s = TtaGetEnvString ("HOME");
              ustrcpy (target, s);
              start_index++;
              i = ustrlen (target);
              ustrcat (&target[i], &src[start_index]);
            }
   #endif /* _WINDOWS */
          else
            {
              CleanCopyFileURL (target, &src[start_index]);
              change = TRUE;
            }
      }       }
 #  ifndef _WINDOWS  #ifndef _WINDOWS
    else if (src[0] == TEXT('~'))     else if (src[0] == TEXT('~'))
      {       {
         /* replace ~ */          /* replace ~ */
         s = TtaGetEnvString ("HOME");          s = TtaGetEnvString ("HOME");
         ustrcpy (target, s);          ustrcpy (target, s);
   #if 0
         if (src[1] != WC_DIR_SEP)          if (src[1] != WC_DIR_SEP)
           ustrcat (target, WC_DIR_STR);            ustrcat (target, WC_DIR_STR);
         ustrcat (target, &src[1]);  #endif
           i = ustrlen (target);
           CleanCopyFileURL (&target[i], &src[1]);
         change = TRUE;          change = TRUE;
      }       }
 #   endif /* _WINDOWS */  #endif /* _WINDOWS */
   
    else     else
       ustrcpy (target, src);       CleanCopyFileURL (target, src);
   
    /* remove /../ and /./ */     /* remove /../ and /./ */
    SimplifyUrl (&target);     SimplifyUrl (&target);

Removed from v.1.89  
changed lines
  Added in v.1.90


Webmaster