Diff for /Amaya/amaya/AHTURLTools.c between versions 1.49 and 1.50

version 1.49, 1998/02/20 17:28:32 version 1.50, 1998/03/10 14:28:33
Line 590  char               *docName; Line 590  char               *docName;
       return;        return;
   
    if (doc != 0)     if (doc != 0)
      basename = GetBaseURL (doc);        basename = GetBaseURL (doc);
    else     else
      basename = (char *) NULL;         basename = (char *) NULL;
   
    /*     /*
     * Clean orgName      * Clean orgName
Line 609  char               *docName; Line 609  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;
        newName[0] = EOS;        TtaFreeMemory (basename);
        TtaFreeMemory (basename);        return;
        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;
        tempOrgName[length] = EOS;           length--;
        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 */
        /* the name is complete, go to the Sixth Step */        strcpy (newName, tempOrgName);
        strcpy (newName, tempOrgName);        /* verify if the URL has the form "protocol://server:port" */
        /* verify if the URL has the form "protocol://server:port" */        ptr = AmayaParseUrl (newName, "", AMAYA_PARSE_ACCESS | AMAYA_PARSE_HOST | AMAYA_PARSE_PUNCTUATION);
        ptr = AmayaParseUrl (newName, "", AMAYA_PARSE_ACCESS | AMAYA_PARSE_HOST |        if (ptr && !strcmp (ptr, newName)) /* it has this form, we complete it by adding a DIR_STR  */
                       AMAYA_PARSE_PUNCTUATION);           strcat (newName, URL_STR);
        if (ptr && !strcmp (ptr, newName))  
          /* it has this form, we complete it by adding a DIR_STR  */        if (ptr)
          strcat (newName, URL_STR);           TtaFreeMemory (ptr);
      } else if ( doc == 0) /* the name is complete, go to the Sixth Step */
        if (ptr)  
          TtaFreeMemory (ptr);  
      }  
    else if ( doc == 0)  
      /* 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)) {
Line 656  char               *docName; Line 649  char               *docName;
            }             }
 #      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);
            strcpy (newName, ptr);            TtaFreeMemory (ptr);
            TtaFreeMemory (ptr);         } else
          }              newName[0] = EOS;
        else     }
            newName[0] = EOS;  
      }  
   
    TtaFreeMemory (basename);     TtaFreeMemory (basename);
    /*     /*
Line 672  char               *docName; Line 663  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;
        length = strlen (newName) - 1;        if (newName[length] == URL_SEP || newName[length] == DIR_SEP) {
        if (newName[length] == URL_SEP || newName[length] == DIR_SEP)           used_sep = newName[length];
          {           check = TRUE;
            used_sep = newName[length];           while (check) {
            check = TRUE;                 length--;
            while (check)                 while (length >= 0 && newName[length] != used_sep)
              {                       length--;
                length--;                 if (!strncmp (&newName[length+1], "..", 2)) {
                while (length >= 0 && newName[length] != used_sep)                    newName[length+1] = EOS;
                  length--;                    /* remove also previous directory */
                if (!strncmp (&newName[length+1], "..", 2))                    length--;
                  {                    while (length >= 0 && newName[length] != used_sep)
                    newName[length+1] = EOS;                          length--;
                    /* remove also previous directory */                    if (strncmp (&newName[length+1], "//", 2)) /* don't remove server name */
                    length--;                       newName[length+1] = EOS;
                    while (length >= 0 && newName[length] != used_sep)                 } else if (!strncmp (&newName[length+1], ".", 1))
                      length--;                        newName[length+1] = EOS;
                    if (strncmp (&newName[length+1], "//", 2))                 else
                      /* don't remove server name */                    check = FALSE;
                      newName[length+1] = EOS;           }
                  }  
                else if (!strncmp (&newName[length+1], ".", 1))  
                  newName[length+1] = EOS;  
                else  
                  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             while (length >= 0 && newName[length] != URL_SEP && newName[length] != DIR_SEP)
          {                   length--;
            /* docname is comprised inside the URL */            if (length < 0)
            while (length >= 0 && newName[length] != URL_SEP && newName[length] != DIR_SEP)               strcpy (docName, newName);
              length--;            else
            if (length < 0)                strcpy (docName, &newName[length+1]);
              strcpy (docName, newName);        }
            else     } else
                strcpy (docName, &newName[length+1]);          docName[0] = EOS;
          }  
      }  
    else  
      docName[0] = EOS;  
 }   } 
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------

Removed from v.1.49  
changed lines
  Added in v.1.50


Webmaster