Subversion Repositories Kolibri OS

Rev

Rev 9362 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9362 Rev 9363
Line 1... Line 1...
1
#define MEMSIZE 1024*100
1
#define MEMSIZE 4096*40
Line 2... Line -...
2
 
-
 
3
#include "../lib/kolibri.h"
-
 
4
#include "../lib/collection.h"
2
 
5
#include "../lib/gui.h"
3
#include "../lib/gui.h"
Line 6... Line -...
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
 
-
 
17
int url_id=0;
4
#include "../lib/fs.h"
18
 
5
 
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");
-
 
29
	con_write_asciiz stdcall ("Downloading pages...\n\n");
6
void main()
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 -... Line 7...
-
 
7
{
52
	}
8
	proc_info Form;
53
}
9
 
54
 
10
	@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE);
55
void get_next_url()
11
	loop() switch(WaitEvent())
56
{
-
 
57
	char get_url[2500];
12
	{
58
	dword url;
-
 
59
 
13
		case evMouse:			
60
	url_id++;
14
			mouse.get();
61
	url = links.get(url_id);
-
 
62
 
15
			break;
63
	if (!url) {
16
 
64
		con_write_asciiz stdcall ("Download complete.");
17
		case evKey:
65
		con_exit stdcall (0);
-
 
66
		ExitProcess();
-
 
67
	} else {
-
 
68
		con_write_asciiz stdcall (itoa(url_id));
18
			@GetKeyScancode();
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);
19
			if (AL == SCAN_CODE_ESC) @ExitProcess();
74
		} else if (!strncmp(url,"http:",5)) {
20
			break;
75
			sprintf(#get_url, "%s", url);
-
 
76
		} else {
-
 
-
 
21
 
77
			get_next_url();
22
		case evReDraw:
78
		}
23
			sc.get();
79
 
24
			DefineAndDrawWindow(100, 100, 300, 250, 0x34, sc.work, "Template app", 0);