Diff for /Amaya/amaya/AHTURLTools.c between versions 1.52 and 1.53

version 1.52, 1998/03/10 22:24:16 version 1.53, 1998/03/11 15:02:09
Line 560  char      *url; Line 560  char      *url;
    NormalizeURL     NormalizeURL
    normalizes orgName according to a base associated with doc, and     normalizes orgName according to a base associated with doc, and
    following the standard URL format rules.     following the standard URL format rules.
      if doc is 0 and otherPath not NULL, normalizes orgName according to this
      other path.
    The function returns the new complete and normalized URL      The function returns the new complete and normalized URL 
    or file name path (newName) and the name of the document (docName).             or file name path (newName) and the name of the document (docName).        
    N.B. If the function can't find out what's the docName, it assigns     N.B. If the function can't find out what's the docName, it assigns
    the name "noname.html".     the name "noname.html".
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 void                NormalizeURL (char *orgName, Document doc, char *newName, char *docName)  void                NormalizeURL (char *orgName, Document doc, char *newName, char *docName, char *otherPath)
 #else  /* __STDC__ */  #else  /* __STDC__ */
 void                NormalizeURL (orgName, doc, newName, docName)  void                NormalizeURL (orgName, doc, newName, docName, otherPath)
 char               *orgName;  char               *orgName;
 Document            doc;  Document            doc;
 char               *newName;  char               *newName;
 char               *docName;  char               *docName;
   char               *otherPath;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    char               *basename;     char               *basename;
Line 590  char               *docName; Line 593  char               *docName;
       return;        return;
   
    if (doc != 0)     if (doc != 0)
       basename = GetBaseURL (doc);       basename = GetBaseURL (doc);
      else if (otherPath != NULL)
        basename = TtaStrdup (otherPath);
    else     else
        basename = (char *) NULL;       basename = NULL;
   
    /*     /*
     * Clean orgName      * Clean orgName
Line 609  char               *docName; Line 614  char               *docName;
     * If the URL does not include a protocol, then try to calculate      * If the URL does not include a protocol, then try to calculate
     * one using the doc's base element (if it exists),      * one using the doc's base element (if it exists),
     */      */
    if (tempOrgName[0] == EOS) {     if (tempOrgName[0] == EOS)
       newName[0] = EOS;       {
       TtaFreeMemory (basename);         newName[0] = EOS;
       return;         TtaFreeMemory (basename);
    }         return;
        }
   
    /* clean trailing white space */     /* clean trailing white space */
    length = strlen (tempOrgName) - 1;     length = strlen (tempOrgName) - 1;
    while (tempOrgName[length] == SPACE && tempOrgName[length] == EOL) {     while (tempOrgName[length] == SPACE && tempOrgName[length] == EOL)
          tempOrgName[length] = EOS;       {
          length--;         tempOrgName[length] = EOS;
    }         length--;
        }
   
    /* remove extra dot */     /* remove extra dot */
    if (tempOrgName[length] == '.')     if (tempOrgName[length] == '.')
       tempOrgName[length] = EOS;        tempOrgName[length] = EOS;
   
    if (IsW3Path (tempOrgName)) {     if (IsW3Path (tempOrgName))
       /* the name is complete, go to the Sixth Step */       {
       strcpy (newName, tempOrgName);         /* the name is complete, go to the Sixth Step */
       SimplifyUrl (&newName);         strcpy (newName, tempOrgName);
       /* verify if the URL has the form "protocol://server:port" */         SimplifyUrl (&newName);
       ptr = AmayaParseUrl (newName, "", AMAYA_PARSE_ACCESS | AMAYA_PARSE_HOST | AMAYA_PARSE_PUNCTUATION);         /* verify if the URL has the form "protocol://server:port" */
       if (ptr && !strcmp (ptr, newName)) /* it has this form, we complete it by adding a DIR_STR  */         ptr = AmayaParseUrl (newName, "", 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  */
          strcat (newName, URL_STR);           strcat (newName, URL_STR);
   
       if (ptr)         if (ptr)
          TtaFreeMemory (ptr);           TtaFreeMemory (ptr);
    } else if ( doc == 0) /* the name is complete, go to the Sixth Step */       }
      else if ( basename == NULL)
        /* the name is complete, go to the Sixth Step */
      strcpy (newName, tempOrgName);       strcpy (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);           {
               for (ndx = 0; ndx < length; ndx++)             length = strlen (tempOrgName);
                       if (tempOrgName [ndx] == '/')             for (ndx = 0; ndx < length; ndx++)
                          tempOrgName [ndx] = '\\';               if (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)
           SimplifyUrl (&ptr);           {
           strcpy (newName, ptr);             SimplifyUrl (&ptr);
           TtaFreeMemory (ptr);             strcpy (newName, ptr);
        } else             TtaFreeMemory (ptr);
             newName[0] = EOS;           }
    }         else
            newName[0] = EOS;
        }
   
    TtaFreeMemory (basename);     TtaFreeMemory (basename);
    /*     /*
Line 664  char               *docName; Line 678  char               *docName;
     * .amaya directory. If the new URL finishes on DIR_SEP, then use      * .amaya directory. If the new URL finishes on DIR_SEP, then use
     * noname.html as a default ressource name      * noname.html as a default ressource name
    */     */
    if (newName[0] != EOS) {     if (newName[0] != EOS)
       length = strlen (newName) - 1;       {
       if (newName[length] == URL_SEP || newName[length] == DIR_SEP) {         length = strlen (newName) - 1;
          used_sep = newName[length];         if (newName[length] == URL_SEP || newName[length] == DIR_SEP)
          check = TRUE;           {
          while (check) {             used_sep = newName[length];
              check = TRUE;
              while (check)
                {
                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 (!strncmp (&newName[length+1], "..", 2))
                   newName[length+1] = EOS;                   {
                   /* remove also previous directory */                     newName[length+1] = EOS;
                   length--;                     /* remove also previous directory */
                   while (length >= 0 && newName[length] != used_sep)                     length--;
                         length--;                     while (length >= 0 && newName[length] != used_sep)
                   if (strncmp (&newName[length+1], "//", 2)) /* don't remove server name */                       length--;
                      if (strncmp (&newName[length+1], "//", 2))
                        /* don't remove server name */
                      newName[length+1] = EOS;                       newName[length+1] = EOS;
                } else if (!strncmp (&newName[length+1], ".", 1))                   }
                       newName[length+1] = EOS;                 else if (!strncmp (&newName[length+1], ".", 1))
                    newName[length+1] = EOS;
                else                 else
                   check = FALSE;                   check = FALSE;
          }               }
              strcpy (docName, "noname.html");                       strcpy (docName, "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");             strcpy (docName, "noname.html");
       } else { /* docname is comprised inside the URL */           }
          else
            { /* 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);
           else             else
               strcpy (docName, &newName[length+1]);               strcpy (docName, &newName[length+1]);
       }           }
    } else       }
         docName[0] = EOS;     else
        docName[0] = EOS;
 }   } 
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 1341  char               *target; Line 1364  char               *target;
    char               *s;     char               *s;
    boolean             change;     boolean             change;
   
    change = FALSE;     change = TRUE;
 #  ifdef _WINDOWS     if (strncmp (src, "file:", 5) == 0)
    if (src[1] == ':' && src[2] == '\\') {  
       strcpy (target, src);  
       change = TRUE;  
    }  
 #  else  /* !_WINDOWS */  
    if (src[0] == '~')  
      {  
         /* replace ~ */  
         s = (char *) TtaGetEnvString ("HOME");  
         strcpy (target, s);  
         strcat (target, &src[1]);  
         change = TRUE;  
      }  
 #   endif /* _WINDOWS */  
    else if (strncmp (src, "file:", 5) == 0)  
      {       {
         /* remove the prefix file: */          /* remove the prefix file: */
         if (src[5] == EOS)          if (src[5] == EOS)
Line 1371  char               *target; Line 1379  char               *target;
           }            }
         else          else
            strcpy (target, &src[5]);             strcpy (target, &src[5]);
         change = TRUE;  
      }       }
   #  ifndef _WINDOWS
      else if (src[0] == '~')
        {
           /* replace ~ */
           s = (char *) TtaGetEnvString ("HOME");
           strcpy (target, s);
           if (src[1] != DIR_SEP)
             strcat (target, DIR_STR);
           strcat (target, &src[1]);
        }
   #   endif /* _WINDOWS */
    else     else
       strcpy (target, src);        strcpy (target, src);
   

Removed from v.1.52  
changed lines
  Added in v.1.53


Webmaster