Subversion Repositories Kolibri OS

Rev

Rev 6021 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. int UrlIsAbsolute(dword in)
  3. {
  4.         if(!strncmp(in,"http:",5)) return true;
  5.         if(!strncmp(in,"https:",6)) return true;
  6.         if(!strncmp(in,"file:",5)) return true;
  7.         if(!strncmp(in,"mailto:",7)) return true;
  8.         if(!strncmp(in,"ftp:",4)) return true;
  9.         if(!strncmp(in,"WebView:",8)) return true;
  10.         if(!strncmp(in,"/sys/",5)) return true;
  11.         if(!strncmp(in,"/hd/",4)) return true;
  12.         if(!strncmp(in,"/fd/",4)) return true;
  13.         if(!strncmp(in,"/rd/",4)) return true;
  14.         if(!strncmp(in,"/tmp/",5)) return true;
  15.         if(!strncmp(in,"/cd/",4)) return true;
  16.         if(!strncmp(in,"/bd/",4)) return true;
  17.         if(!strncmp(in,"/usbhd/",7)) return true;
  18.         if(!strncmp(in,"/kolibrios/",11)) return true;
  19.         return false;
  20. }
  21.  
  22. void GetAbsoluteURL(dword in_URL)
  23. {
  24.         int i;
  25.         dword orig_URL = in_URL;
  26.         char newurl[sizeof(URL)];
  27.  
  28.         while (i=strstr(in_URL, "&"))
  29.         {
  30.                 strcpy(i+1, i+5);
  31.         }
  32.  
  33.         if (UrlIsAbsolute(in_URL)) return;
  34.  
  35.         IF (!strcmpn(in_URL,"//", 2))
  36.         {
  37.                 //strcpy(#newurl, "http:");
  38.                 //strcat(#newurl, in_URL);
  39.                 sprintf(#newurl, "http:%s", in_URL);
  40.                 strcpy(orig_URL, #newurl);
  41.                 return;
  42.         }
  43.        
  44.         IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
  45.         if (!http_transfer)
  46.         {
  47.                 strcpy(#newurl, history.current());
  48.         }
  49.         else
  50.         {
  51.                 strcpy(#newurl, history.items.get(history.active-2));
  52.         }
  53.  
  54.         if (ESBYTE[in_URL] == '/') //remove everything after site domain name
  55.         {
  56.                 i = strchr(#newurl+8, '/');
  57.                 if (i) ESBYTE[i]=0;
  58.                 in_URL+=1;
  59.         }
  60.                
  61.         _CUT_ST_LEVEL_MARK:
  62.                
  63.         if (newurl[strrchr(#newurl, '/')-2]<>'/')
  64.         {
  65.                 newurl[strrchr(#newurl, '/')] = 0x00;
  66.         }
  67.        
  68.         IF (!strncmp(in_URL,"../",3))
  69.         {
  70.                 in_URL+=3;
  71.                 newurl[strrchr(#newurl, '/')-1] = 0x00;
  72.                 goto _CUT_ST_LEVEL_MARK;
  73.         }
  74.        
  75.         if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
  76.        
  77.         strcat(#newurl, in_URL);
  78.         strcpy(orig_URL, #newurl);
  79. }
  80.  
  81.