Rev 8881 | Rev 9363 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9362 | leency | 1 | #define MEMSIZE 1024*100 |
8881 | leency | 2 | |
9362 | leency | 3 | #include "../lib/kolibri.h" |
4 | #include "../lib/collection.h" |
||
8881 | leency | 5 | #include "../lib/gui.h" |
6 | #include "../lib/fs.h" |
||
7 | |||
9362 | leency | 8 | #include "../lib/obj/http.h" |
9 | #include "../lib/obj/console.h" |
||
10 | |||
11 | collection links; |
||
12 | #include "urls.h" |
||
13 | |||
14 | _http http; |
||
15 | char accept_language[]= "Accept-Language: en\n"; |
||
16 | |||
17 | int url_id=0; |
||
18 | |||
8881 | leency | 19 | void main() |
20 | { |
||
9362 | leency | 21 | char savepath[100]; |
22 | load_dll(libHTTP, #http_lib_init,1); |
||
23 | load_dll(libConsole, #con_init, 0); |
||
8881 | leency | 24 | |
9362 | leency | 25 | con_init stdcall (70, 40, 70, 1020, "Web stability test"); |
26 | urls_add(); |
||
27 | con_write_asciiz stdcall ("Redirect is not handled yet.\n"); |
||
28 | con_write_asciiz stdcall ("All pages are saved into /tmp0/1\n\n"); |
||
29 | con_write_asciiz stdcall ("Downloading pages...\n\n"); |
||
30 | pause(100); |
||
31 | get_next_url(); |
||
32 | |||
33 | @SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
||
34 | loop() switch(@WaitEventTimeout(200)) |
||
8881 | leency | 35 | { |
9362 | leency | 36 | case evNetwork: |
37 | if (!http.receive_result) { |
||
38 | sprintf(#savepath, "/tmp0/1/%s.htm", links.get(url_id)+7); |
||
39 | CreateFile(http.content_received, http.content_pointer, #savepath); |
||
40 | free(http.content_pointer); |
||
41 | http_free stdcall (http.transfer); |
||
42 | http.transfer=0; |
||
43 | con_write_asciiz stdcall ("\n"); |
||
44 | get_next_url(); |
||
45 | } |
||
46 | if (http.transfer) { |
||
47 | http.receive(); |
||
48 | } else { |
||
49 | con_write_asciiz stdcall (" => FAILED\n"); |
||
50 | get_next_url(); |
||
51 | } |
||
52 | } |
||
53 | } |
||
8881 | leency | 54 | |
9362 | leency | 55 | void get_next_url() |
56 | { |
||
57 | char get_url[2500]; |
||
58 | dword url; |
||
8881 | leency | 59 | |
9362 | leency | 60 | url_id++; |
61 | url = links.get(url_id); |
||
62 | |||
63 | if (!url) { |
||
64 | con_write_asciiz stdcall ("Download complete."); |
||
65 | con_exit stdcall (0); |
||
66 | ExitProcess(); |
||
67 | } else { |
||
68 | con_write_asciiz stdcall (itoa(url_id)); |
||
69 | con_write_asciiz stdcall (". "); |
||
70 | con_write_asciiz stdcall (links.get(url_id)); |
||
71 | |||
72 | if (!strncmp(url,"https:",6)) { |
||
73 | sprintf(#get_url, "http://gate.aspero.pro/?site=%s", url); |
||
74 | } else if (!strncmp(url,"http:",5)) { |
||
75 | sprintf(#get_url, "%s", url); |
||
76 | } else { |
||
77 | get_next_url(); |
||
78 | } |
||
79 | |||
80 | http.get(#get_url); |
||
8881 | leency | 81 | } |
82 | } |