Subversion Repositories Kolibri OS

Rev

Rev 8425 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. enum {
  2.         PAGE=1, IMG
  3. };
  4.  
  5. struct _cache
  6. {
  7.         dword current_buf;
  8.         dword current_size;
  9.         dword current_type;
  10.         dword current_charset;
  11.         collection url;
  12.         collection_int data;
  13.         collection_int size;
  14.         collection_int type;
  15.         collection_int charset;
  16.         void add();
  17.         bool has();
  18.         void clear();
  19. } cache=0;
  20.  
  21. void _cache::add(dword _url, _data, _size, _type, _charset)
  22. {
  23.         dword data_pointer;
  24.         data_pointer = malloc(_size);
  25.         memmov(data_pointer, _data, _size);
  26.         data.add(data_pointer);
  27.  
  28.         url.add(_url);
  29.         size.add(_size);
  30.         type.add(_type);
  31.         charset.add(_charset);
  32.  
  33.         current_buf = data_pointer;
  34.         current_size = _size;
  35. }
  36.  
  37. bool _cache::has(dword _link)
  38. {
  39.         int pos;
  40.         pos = url.get_pos_by_name(_link);
  41.         if (pos != -1) {
  42.                 current_buf = data.get(pos);
  43.                 current_size = size.get(pos);
  44.                 current_type = type.get(pos);
  45.                 current_charset = charset.get(pos);
  46.                 return true;
  47.         }
  48.         return false;
  49. }
  50.  
  51. void _cache::clear()
  52. {
  53.         int i;
  54.         for (i=0; i<data.count; i++) free(data.get(i));
  55.         url.drop();
  56.         data.drop();
  57.         size.drop();
  58.         type.drop();
  59.         current_buf = NULL;
  60.         current_size = NULL;
  61. }