Diff for /Amaya/amaya/AHTURLTools.c between versions 1.21 and 1.22

version 1.21, 1997/02/05 15:28:41 version 1.22, 1997/02/05 22:06:44
Line 21 Line 21
 #include "init_f.h"  #include "init_f.h"
 #include "AHTURLTools_f.h"  #include "AHTURLTools_f.h"
   
   /* Private  functions */
   #ifdef __STDC__
   static void         ConvertToLowerCase (char *string);
   #else
   static void         ConvertToLowerCase (/*char *string*/);
   #endif
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
   ExplodeURL     ExplodeURL 
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
Line 172  char               *path; Line 179  char               *path;
        (strcmp (nsuffix, "htm")) &&         (strcmp (nsuffix, "htm")) &&
        (strcmp (nsuffix, "shtml")))         (strcmp (nsuffix, "shtml")))
      return (FALSE);       return (FALSE);
    else if ((!strcmp (nsuffix, "gz")) ||     else if (!strcmp (nsuffix, "gz"))
             (!strcmp (nsuffix, "z")))  
      {       {
        /* take in account compressed files */         /* take in account compressed files */
        ExtractSuffix (temppath, suffix);                ExtractSuffix (temppath, suffix);       
Line 267  char               *path; Line 273  char               *path;
    if ((strcmp (nsuffix, "gif")) && (strcmp (nsuffix, "xbm")) &&     if ((strcmp (nsuffix, "gif")) && (strcmp (nsuffix, "xbm")) &&
        (strcmp (nsuffix, "xpm")) && (strcmp (nsuffix, "jpg")) &&         (strcmp (nsuffix, "xpm")) && (strcmp (nsuffix, "jpg")) &&
        (strcmp (nsuffix, "pdf")) && (strcmp (nsuffix, "png")) &&         (strcmp (nsuffix, "pdf")) && (strcmp (nsuffix, "png")) &&
        (strcmp (nsuffix, "tgz")) && (strcmp (nsuffix, "xpg")) &&         (strcmp (nsuffix, "tgz")) && (strcmp (nsuffix, "tar")) &&
        (strcmp (nsuffix, "xpd")) && (strcmp (nsuffix, "ps")) &&         (strcmp (nsuffix, "xpg")) && (strcmp (nsuffix, "xpd")) &&
        (strcmp (nsuffix, "au")))         (strcmp (nsuffix, "ps"))  && (strcmp (nsuffix, "au")))
       return (TRUE);        return (TRUE);
    else if ((!strcmp (nsuffix, "gz")) || (!strcmp (nsuffix, "z")))     else if (!strcmp (nsuffix, "gz"))
      {       {
        /* take in account compressed files */         /* take in account compressed files */
        ExtractSuffix (temppath, suffix);                ExtractSuffix (temppath, suffix);       
Line 368  boolean             IsValidProtocol (url Line 374  boolean             IsValidProtocol (url
 char               *url;  char               *url;
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
    if (!strncmp (url, "http:", 5)     if (!strncmp (url, "http:", 5))
       /***|| !strncmp (path, "ftp:", 4)         /* experimental */
       || !strncmp (path, "news:", 5)***/ )       /***|| !strncmp (path, "ftp:", 4)
          || !strncmp (path, "news:", 5)***/ 
       return (TRUE);        return (TRUE);
    else     else
       return (FALSE);        return (FALSE);
Line 448  char               *docName; Line 455  char               *docName;
          {           {
            /* it has this form, we complete it by adding a "/"  */             /* it has this form, we complete it by adding a "/"  */
            strcat (newName, "/");             strcat (newName, "/");
            length++;  
          }           }
        if (ptr)         if (ptr)
          HT_FREE (ptr);           HT_FREE (ptr);
Line 459  char               *docName; Line 465  char               *docName;
    else     else
      {       {
        /* take into account the BASE element. */         /* take into account the BASE element. */
        length = MAX_LENGTH;         length = MAX_LENGTH -1;
        /* get the root element    */         /* get the root element    */
        el = TtaGetMainRoot (doc);         el = TtaGetMainRoot (doc);
                         
Line 526  char               *docName; Line 532  char               *docName;
            else             else
              basename[0] = EOS;               basename[0] = EOS;
          }           }
        
        /*         /*
        ** Fourth Step:          ** Fourth Step: 
        ** If there's no base element, and if we're following         ** If there's no base element, and if we're following
Line 562  char               *docName; Line 568  char               *docName;
            else             else
                basename[0] = EOS;                 basename[0] = EOS;
          }           }
          
        /*         /*
        ** Fifth Step, calculate the absolute URL, using the base         ** Fifth Step, calculate the absolute URL, using the base
        */         */
Line 685  char                base_url; Line 691  char                base_url;
   
    return (result);     return (result);
 }  }
   /*----------------------------------------------------------------------
     HasKnownFileSuffix
     returns TRUE if path points to a file ending with a suffix.
     ----------------------------------------------------------------------*/
   #ifdef __STDC__
   boolean             HasKnownFileSuffix (char *path)
   #else  /* __STDC__ */
   boolean             HasKnownFileSuffix (path)
   char               *path;
   #endif /* __STDC__ */
   {
      char                *root;
      char                temppath[MAX_LENGTH];
      char                suffix[MAX_LENGTH];
   
      if (!path || path[0] == EOS)
        return (FALSE);
   
      root = HTParse(path, (char *) NULL, PARSE_PATH | PARSE_PUNCTUATION);
   
      if (root) 
        {
          strcpy (temppath, root);
          HT_FREE (root);
          /* Get the suffix */
          ExtractSuffix (temppath, suffix); 
   
          if( suffix[0] == EOS)
            /* no suffix */
            return (FALSE);
   
          /* Normalize the suffix */
          ConvertToLowerCase (suffix);
   
          if ((!strcmp (suffix, "gz")) ||
              (!strcmp (suffix, "z")))
            /* skip the compressed suffix */
            {
            ExtractSuffix (temppath, suffix);
            if(suffix[0] == EOS)
              /* no suffix */
              return (FALSE);
            /* Normalize the suffix */
            ConvertToLowerCase (suffix);
            }
   
          if ((strcmp (suffix, "gif")) && (strcmp (suffix, "xbm")) &&
              (strcmp (suffix, "xpm")) && (strcmp (suffix, "jpg")) &&
              (strcmp (suffix, "pdf")) && (strcmp (suffix, "png")) &&
              (strcmp (suffix, "tgz")) && (strcmp (suffix, "xpg")) &&
              (strcmp (suffix, "xpd")) && (strcmp (suffix, "ps")) &&
              (strcmp (suffix, "au"))  && (strcmp (suffix, "html")) &&
              (strcmp (suffix, "htm")) && (strcmp (suffix, "shtml")) &&
              (strcmp (suffix, "txt")) && (strcmp (suffix, "css")) &&
              (strcmp (suffix, "eps")))
            return (FALSE);
          else
            return (TRUE);
        }
      else
        return (FALSE);
   }
   
   
   /*----------------------------------------------------------------------
     ConvertToLowerCase
     Converts a string to lowercase.
     ----------------------------------------------------------------------*/
   #ifdef __STDC__
   static void         ConvertToLowerCase (char *string)
   #else  /* __STDC__ */
   static void         ConvertToLowerCase (string)
   char                *string;
   
   #endif /* __STDC__ */
   {
    int i;
   
    if (!string)
      return;
   
    for (i = 0; string[i] != EOS; i++)
      string[i] = TOLOWER (string[i]);
   }
   
   
   
   
   
   

Removed from v.1.21  
changed lines
  Added in v.1.22


Webmaster