Rev 8016 | Rev 8339 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8016 | leency | 1 | enum { |
2 | PAGE=1, IMG |
||
3 | }; |
||
7764 | leency | 4 | |
8016 | leency | 5 | struct _cache |
7764 | leency | 6 | { |
8016 | leency | 7 | dword current_buf; |
8 | dword current_size; |
||
8336 | leency | 9 | dword current_type; |
7764 | leency | 10 | collection url; |
7972 | leency | 11 | collection_int data; |
12 | collection_int size; |
||
8016 | leency | 13 | collection_int type; |
7764 | leency | 14 | void add(); |
15 | bool has(); |
||
7770 | leency | 16 | void clear(); |
8016 | leency | 17 | } cache=0; |
7764 | leency | 18 | |
8016 | leency | 19 | void _cache::add(dword _url, _data, _size, _type) |
7764 | leency | 20 | { |
21 | dword data_pointer; |
||
22 | data_pointer = malloc(_size); |
||
23 | memmov(data_pointer, _data, _size); |
||
7972 | leency | 24 | data.add(data_pointer); |
7764 | leency | 25 | |
26 | url.add(_url); |
||
7972 | leency | 27 | size.add(_size); |
8016 | leency | 28 | type.add(_type); |
7764 | leency | 29 | } |
30 | |||
8016 | leency | 31 | bool _cache::has(dword _link) |
7764 | leency | 32 | { |
33 | int pos; |
||
34 | pos = url.get_pos_by_name(_link); |
||
35 | if (pos != -1) { |
||
8016 | leency | 36 | current_buf = data.get(pos); |
37 | current_size = size.get(pos); |
||
8336 | leency | 38 | current_type = type.get(pos); |
7764 | leency | 39 | return true; |
40 | } |
||
41 | return false; |
||
7770 | leency | 42 | } |
43 | |||
8016 | leency | 44 | void _cache::clear() |
7770 | leency | 45 | { |
46 | url.drop(); |
||
47 | data.drop(); |
||
48 | size.drop(); |
||
8016 | leency | 49 | current_buf = NULL; |
50 | current_size = NULL; |
||
7764 | leency | 51 | } |