Rev 8881 | Rev 9363 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8881 | Rev 9362 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #define MEMSIZE 4096*40 |
1 | #define MEMSIZE 1024*100 |
Line -... | Line 2... | ||
- | 2 | ||
- | 3 | #include "../lib/kolibri.h" |
|
2 | 4 | #include "../lib/collection.h" |
|
3 | #include "../lib/gui.h" |
5 | #include "../lib/gui.h" |
Line -... | Line 6... | ||
- | 6 | #include "../lib/fs.h" |
|
- | 7 | ||
- | 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 | ||
4 | #include "../lib/fs.h" |
17 | int url_id=0; |
5 | 18 | ||
- | 19 | void main() |
|
- | 20 | { |
|
- | 21 | char savepath[100]; |
|
- | 22 | load_dll(libHTTP, #http_lib_init,1); |
|
- | 23 | load_dll(libConsole, #con_init, 0); |
|
- | 24 | ||
- | 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"); |
|
6 | void main() |
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)) |
|
- | 35 | { |
|
- | 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 | } |
|
Line 7... | Line -... | ||
7 | { |
- | |
8 | proc_info Form; |
52 | } |
9 | 53 | } |
|
10 | @SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE); |
54 | |
11 | loop() switch(WaitEvent()) |
55 | void get_next_url() |
- | 56 | { |
|
12 | { |
57 | char get_url[2500]; |
- | 58 | dword url; |
|
13 | case evMouse: |
59 | |
14 | mouse.get(); |
60 | url_id++; |
- | 61 | url = links.get(url_id); |
|
15 | break; |
62 | |
16 | 63 | if (!url) { |
|
17 | case evKey: |
64 | con_write_asciiz stdcall ("Download complete."); |
- | 65 | con_exit stdcall (0); |
|
- | 66 | ExitProcess(); |
|
- | 67 | } else { |
|
18 | @GetKeyScancode(); |
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)) { |
|
19 | if (AL == SCAN_CODE_ESC) @ExitProcess(); |
73 | sprintf(#get_url, "http://gate.aspero.pro/?site=%s", url); |
20 | break; |
74 | } else if (!strncmp(url,"http:",5)) { |
21 | - | ||
- | 75 | sprintf(#get_url, "%s", url); |
|
- | 76 | } else { |
|
22 | case evReDraw: |
77 | get_next_url(); |
23 | sc.get(); |
78 | } |
24 | DefineAndDrawWindow(100, 100, 300, 250, 0x34, sc.work, "Template app", 0); |
79 |