Subversion Repositories Kolibri OS

Rev

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

Rev 661 Rev 1645
Line 1... Line -...
1
;
-
 
2
;    HTTPC.ASM
1
; wget 0.2 by barsuk
3
;
-
 
4
;    Compile with FASM for Menuet ( v1.40 for DOS )
-
 
5
;
-
 
6
;    This program implements a very simple web browser
-
 
7
;
-
 
8
;    Version 0.4    2nd December 2003 Mike Hibbett
-
 
9
;    Enabled lowercase/uppcase characters in URL
-
 
10
;    Version 0.3    30th November 2003 Mike Hibbett
-
 
11
;    Fixed bug with tcp socket opne - uses unique port
-
 
12
;    Version 0.2    27th November 2003 Mike Hibbett
-
 
13
;    Added user entry of url, and implements url -> IP address
-
 
14
;    resolution through DNS
2
; based on Menuet Httpc
15
;
-
 
16
;    Version 0.1  Ville Mikael Turjanmaa
-
 
17
;    Original version
-
 
Line 18... Line 3...
18
 
3
 
19
 
4
 
20
; Enabling debugging puts stuff to the debug board
5
; Enabling debugging puts stuff to the debug board
21
DEBUGGING_ENABLED           equ     1
6
DEBUGGING_ENABLED           equ     1
Line 22... Line 7...
22
DEBUGGING_DISABLED          equ     0
7
DEBUGGING_DISABLED          equ     0
23
DEBUGGING_STATE             equ     DEBUGGING_DISABLED
8
DEBUGGING_STATE             equ     DEBUGGING_ENABLED
24
 
9
 
25
use32
10
use32
26
 org    0x0
11
 org    0x0
27
 db     'MENUET01'    ; header
12
 db     'MENUET01'    ; header
28
 dd     0x01          ; header version
13
 dd     0x01          ; header version
29
 dd     START         ; entry point
14
 dd     START         ; entry point
-
 
15
 dd     I_END         ; image size
30
 dd     I_END         ; image size
16
 dd     0x100000      ; required memory
Line 31... Line 17...
31
 dd     0x100000      ; required memory
17
 dd     0x100000      ; esp
32
 dd     0x100000      ; esp
18
 dd     params		  ; I_PARAM
33
 dd     0x0 , 0x0     ; I_Param , I_Path
19
 dd		0x0     	  ;I_Path
Line 34... Line 20...
34
 
20
 
-
 
21
include 'lang.inc'
-
 
22
include '../../../macros.inc'
Line 35... Line 23...
35
include 'lang.inc'
23
include "DEBUG.INC"
36
include 'macros.inc'
24
 
37
;include "DEBUG.INC"
-
 
38
 
-
 
Line 39... Line 25...
39
URLMAXLEN       equ     50  ; maximum length of url string
25
URLMAXLEN       equ     256  ; maximum length of url string
Line 40... Line 26...
40
 
26
 
Line 41... Line 27...
41
; Memory usage
27
primary_buffer_size	equ	4096
42
; webpage source file at 0x10000
28
 
43
; decoded text page at   0x20000
29
; Memory usage
Line -... Line 30...
-
 
30
; webpage headers at buf_headers
-
 
31
 
-
 
32
START:                              ; start of execution
-
 
33
 
-
 
34
;dps <"Program started",13,10>
-
 
35
 
-
 
36
    mov     eax,40                          ; Report events
-
 
37
    mov     ebx,10000111b                   ; Stack 8 + defaults
-
 
38
    mcall
-
 
39
	
-
 
40
	mov		eax, 68						; create local heap
-
 
41
	mov		ebx, 11
-
 
42
	mcall
-
 
43
	
-
 
44
	call		load_settings
-
 
45
	
-
 
46
	cmp		byte [params], 0
-
 
47
	jz		red
-
 
48
	
-
 
49
	; we have an url
-
 
50
	
-
 
51
	mov		edi, document_user
-
 
52
	mov		al, ' '
-
 
53
	mov		ecx, URLMAXLEN
-
 
54
	rep		stosb
-
 
55
	
-
 
56
	mov		esi, params
-
 
57
	mov		edi, document_user
-
 
58
.copy_param:
-
 
59
	mov		al, [esi]
-
 
60
	cmp		al, 0
-
 
61
	jz		.done
-
 
62
	cmp		al, ' '
-
 
63
	jz		.done_inc
-
 
64
	mov		[edi], al
-
 
65
	inc		esi
-
 
66
	inc		edi
-
 
67
	jmp		.copy_param
-
 
68
.done_inc:
44
; text attribute         0x30000  (1 = normal, 2 = bold, 128+ = link)
69
	; url is followed by shared memory name.
45
 
70
	inc		esi
Line 46... Line 71...
46
START:                              ; start of execution
71
.done:
47
 
72
	mov		[shared_name], esi
Line 133... Line 158...
133
 
158
 
134
button:                 ; button
159
button:                 ; button
135
;dps <"Button pressed",13,10>
160
;dps <"Button pressed",13,10>
136
    mov     eax,17      ; get id
161
    mov     eax,17      ; get id
-
 
162
    mcall
-
 
163
	cmp		ah,26
137
    mcall
164
	je		save
138
    cmp     ah,1                   ; button id=1 ?
165
    cmp     ah,1                   ; button id=1 ?
Line 139... Line 166...
139
    jne     noclose
166
    jne     noclose
Line 140... Line -...
140
 
-
 
141
;dps "Closing socket before exit... "
167
 
142
 
-
 
143
    mov     eax, 53
-
 
Line 144... Line 168...
144
    mov     ebx, 8
168
;dps "Closing socket before exit... "
145
    mov     ecx, [socket]
169
 
Line 146... Line 170...
146
    mcall
170
close_end_exit:
147
 
171
 
148
;dpd eax
172
;dpd eax
Line -... Line 173...
-
 
173
;dps <13,10>
-
 
174
 
-
 
175
exit:
-
 
176
    or      eax,-1                 ; close this program
-
 
177
    mcall
-
 
178
 
-
 
179
save:
-
 
180
dps "saving"
-
 
181
newline
-
 
182
	mov		eax, 70
149
;dps <13,10>
183
	mov		ebx, fileinfo
150
 
184
	mcall
151
exit:
185
;pregs
152
    or      eax,-1                 ; close this program
186
 
153
    mcall
187
	jmp		still
Line 172... Line 206...
172
 
206
 
173
    mov     [addr],dword document_user
207
    mov     [addr],dword document_user
174
    mov     [ya],dword 38
208
    mov     [ya],dword 38
Line 175... Line 209...
175
    mov     [len],dword URLMAXLEN
209
    mov     [len],dword URLMAXLEN
176
 
210
 
177
    mov     ecx,[len]
211
    mov     ecx,URLMAXLEN
178
    mov     edi,[addr]
212
    mov     edi,[addr]
Line 179... Line 213...
179
    mov     al,' '
213
    mov     al,' '
Line 242... Line 276...
242
;    Function
276
;    Function
243
;       send_request
277
;       send_request
244
;
278
;
245
;   Description
279
;   Description
246
;       Transmits the GET request to the server.
280
;       Transmits the GET request to the server.
247
;       This is done as GET then URL then HTTP/1.0',13,10,13,10 in 3 packets
281
;       This is done as GET then URL then HTTP/1.1',13,10,13,10 in 3 packets
248
;
282
;
249
;****************************************************************************
283
;****************************************************************************
250
send_request:
284
send_request:
251
    pusha
285
    pusha
252
    mov     eax,53     ; 'GET '
-
 
253
    mov     ebx,7
-
 
254
    mov     ecx,[socket]
-
 
255
    mov     edx,4
-
 
-
 
286
	
256
    mov     esi,string0
287
	mov		esi, string0
-
 
288
	mov		edi, request
257
    mcall
289
	movsd
Line -... Line 290...
-
 
290
 
-
 
291
    ; If proxy is used, make absolute URI - prepend http://
-
 
292
	cmp		byte [proxyAddr], 0
-
 
293
	jz		.noproxy
-
 
294
	mov		dword [edi], 'http'
-
 
295
	mov		byte [edi+4], ':'
-
 
296
	mov		word [edi+5], '//'
258
 
297
	add		edi, 7
-
 
298
	mov		esi, webAddr
-
 
299
.copy_host_loop:
-
 
300
	lodsb
-
 
301
	cmp		al, ' '
-
 
302
	jz		.noproxy
-
 
303
	stosb
-
 
304
	jmp		.copy_host_loop
Line -... Line 305...
-
 
305
.noproxy:
259
    mov     edx,0
306
	
260
 
307
	mov		edx, 0
-
 
308
.next_edx:
-
 
309
    ; Determine the length of the url to send in the GET request
-
 
310
	mov		al, [edx+document]
-
 
311
	cmp		al, ' '
-
 
312
    je     	.document_done
261
next_edx:
313
	mov		[edi], al
262
    ; Determine the length of the url to send in the GET request
314
	inc		edi
263
    inc     edx
315
    inc     edx
Line -... Line 316...
-
 
316
	jmp		.next_edx
264
    cmp     [edx+document],byte ' '
317
.document_done:
-
 
318
 
-
 
319
	mov		esi, stringh
265
    jne     next_edx
320
	mov		ecx, stringh_end-stringh
-
 
321
	rep		movsb
266
 
322
 
-
 
323
	mov		edx, 0
-
 
324
.webaddr_next:
267
    mov     eax,53     ; document_user
325
	mov		al, [webAddr + edx]
-
 
326
	cmp		al, ' '
268
    mov     ebx,7
327
	je		.webaddr_done
-
 
328
	mov		[edi], al
-
 
329
	inc		edi
Line -... Line 330...
-
 
330
	inc		edx
-
 
331
	jmp		.webaddr_next
-
 
332
.webaddr_done:
-
 
333
 
-
 
334
	cmp		byte [proxyUser], 0
-
 
335
	jz		@f
-
 
336
	call		append_proxy_auth_header
-
 
337
@@:
-
 
338
 
-
 
339
	mov		esi, connclose
-
 
340
	mov		ecx, connclose_end-connclose
-
 
341
	rep		movsb
-
 
342
 
-
 
343
	pusha	
-
 
344
	mov  eax,63
-
 
345
	mov  ebx,1
-
 
346
	mov  edx, request
-
 
347
@@:
-
 
348
   mov  cl,[edx]
-
 
349
   cmp edx,edi
-
 
350
   jz   @f
-
 
351
   int  40h
-
 
352
   inc  edx
-
 
353
   jmp  @b
-
 
354
@@:
-
 
355
	popa
-
 
356
 
269
    mov     ecx,[socket]
357
    mov     edx, edi
270
    mov     esi,document
358
	sub		edx, request
271
    mcall
359
	
272
 
-
 
273
    mov     eax,53     ; ' HTTP/1.0 .. '
360
	;;;;now write \r\nConnection: Close \r\n\r\n
274
    mov     ebx,7
361
    mov     eax, 53     ; ' HTTP/1.1 .. '
Line 275... Line 362...
275
    mov     ecx,[socket]
362
    mov     ebx, 7
276
    mov     edx,stringh_end-stringh
363
    mov     ecx, [socket]
Line 344... Line 431...
344
    cmp     [onoff],1
431
    cmp     [onoff],1
345
    je      rid
432
    je      rid
346
    ret
433
    ret
Line 347... Line 434...
347
 
434
 
-
 
435
rid:
-
 
436
 
-
 
437
	push	esi
348
rid:
438
	push	edi
-
 
439
dps "rid"
Line 349... Line 440...
349
    mov     ecx,-1
440
newline
-
 
441
 
-
 
442
newbyteread:
-
 
443
 
350
 
444
	;call	print_status
351
newbyteread:
445
 
352
    mov     eax, 53
446
    mov     eax, 53
353
    mov     ebx, 2
447
    mov     ebx, 2
Line 354... Line 448...
354
    mov     ecx, [socket]
448
    mov     ecx, [socket]
355
    mcall
449
    mcall
Line 356... Line -...
356
 
-
 
357
    cmp     eax,0
450
 
358
    je      no_more_data
451
    cmp     eax,0
-
 
452
    je      no_more_data
359
 
453
 
-
 
454
    mov     eax, 53
360
read_more:
455
    mov     ebx, 11
Line -... Line 456...
-
 
456
	mov		edx, primary_buf
-
 
457
    mov     ecx, [socket]
361
    mov     eax, 53
458
	mov		esi, primary_buffer_size
-
 
459
    mcall
362
    mov     ebx, 3
460
	
-
 
461
;dps "part "
-
 
462
;dph eax
-
 
463
;newline
-
 
464
 
-
 
465
	mov		edi, [pos]
-
 
466
 
363
    mov     ecx, [socket]
467
	add		[pos], eax
364
    mcall
468
	push	eax
-
 
469
	
Line -... Line 470...
-
 
470
	mov		eax, 68
-
 
471
	mov		ebx, 20
365
 
472
	mov		ecx, [pos]
-
 
473
	mov		edx, [buf_ptr]
-
 
474
	mcall
-
 
475
	
Line 366... Line 476...
366
yesm:
476
	mov		[buf_ptr], eax
367
    inc     [pos]
-
 
Line 368... Line 477...
368
    mov     ecx,[pos]
477
	add		edi, eax
369
    mov     [0x10000+ecx],bl
478
	mov		esi, primary_buf
-
 
479
	pop		ecx					; number of recently read bytes
370
 
480
	lea		edx, [ecx - 3]
-
 
481
	rep		movsb
-
 
482
	
Line 371... Line 483...
371
    call    print_status
483
no_more_data:
Line -... Line 484...
-
 
484
 
-
 
485
	mov		eax, 53
-
 
486
	mov		ebx, 6
-
 
487
	mov		ecx, [socket]
-
 
488
	mcall
-
 
489
	cmp		eax, 4
-
 
490
	jne		no_more_data.finish
-
 
491
 
-
 
492
	jmp		newbyteread
-
 
493
 
372
 
494
.finish:
-
 
495
 
-
 
496
;dps "finish "
-
 
497
;pregs
-
 
498
 
-
 
499
	call	parse_result
-
 
500
 
-
 
501
	mov		ecx, [shared_name]
-
 
502
	cmp		byte [ecx], 0
-
 
503
	jnz		save_in_shared
-
 
504
	mov		eax, 70
-
 
505
	mov		ebx, fileinfo
-
 
506
	mcall
-
 
507
;dps "saving "
-
 
508
;pregs
373
    cmp     eax,0
509
 
Line -... Line 510...
-
 
510
	;jmp		close_end_exit
-
 
511
	
-
 
512
	pop		edi
-
 
513
	pop		esi
-
 
514
	
-
 
515
	; if called from command line, then exit
-
 
516
	cmp		byte [params], 0
-
 
517
	jnz		exit
-
 
518
	
-
 
519
    ret
-
 
520
	
-
 
521
save_in_shared:
-
 
522
	mov	eax, 68
-
 
523
	mov	ebx, 22
-
 
524
	mov	esi, 1	; SHM_OPEN+SHM_WRITE
-
 
525
	mcall
-
 
526
	test	eax, eax
-
 
527
	jz	save_in_shared_done
-
 
528
	sub	edx, 4
-
 
529
	jbe	save_in_shared_done
-
 
530
	mov	ecx, [final_size]
-
 
531
	cmp	ecx, edx
-
 
532
	jb	@f
-
 
533
	mov	ecx, edx
-
 
534
@@:
-
 
535
	mov	[eax], ecx
-
 
536
	lea	edi, [eax+4]
Line 374... Line -...
374
    jne     read_more
-
 
375
 
-
 
376
    mov     eax,5
-
 
377
    mov     ebx,50
-
 
378
    mcall
-
 
379
 
-
 
380
    jmp     newbyteread
537
	mov	esi, [final_buffer]
381
 
-
 
382
no_more_data:
-
 
383
    ret
-
 
384
 
-
 
385
 
-
 
386
;****************************************************************************
-
 
387
;    Function
538
	mov	edx, ecx
Line 388... Line 539...
388
;       draw_page
539
	shr	ecx, 2
389
;
-
 
390
;   Description
-
 
391
;       parses the web page data, storing displayable data at 0x20000
-
 
392
;       and attributes at 0x30000. It then calls display_page to render
-
 
393
;       the data
-
 
394
;
-
 
395
;****************************************************************************
-
 
396
draw_page:
-
 
397
    pusha
-
 
Line 398... Line 540...
398
    mov     esi,0
540
	rep	movsd
399
    mov     [command_on_off],0
-
 
400
 
-
 
401
newlettercheck:
-
 
402
    movzx   eax,byte [esi+0x10000]
541
	mov	ecx, edx
403
    cmp     al,'<'
-
 
404
    jne     no_c_on
542
	and	ecx, 3
405
    mov     [command_on_off],1
543
	rep	movsb
406
 
544
save_in_shared_done:
Line 407... Line 545...
407
no_c_on:
545
	pop	edi
408
    cmp     al,'>'
546
	pop	esi
409
    jne     no_c_off
547
	jmp	exit
-
 
548
	
-
 
549
	; this function cuts header, and removes chunk sizes if doc is chunked
410
    mov     [command_on_off],0
550
	; in: buf_ptr, pos; out: buf_ptr, pos.
-
 
551
	
411
 
552
parse_result:
412
no_c_off:
553
 
413
    cmp     [command_on_off],0
554
	; close socket
-
 
555
    mov     eax, 53
-
 
556
    mov     ebx, 8
414
    je      no_lower_case
557
    mov     ecx, [socket]
415
 
558
    mcall
-
 
559
	
-
 
560
dps "close socket: "
416
    cmp     eax,96
561
dph eax
-
 
562
newline
-
 
563
 
-
 
564
	mov		edi, [buf_ptr]
417
    jg      no_lower_case
565
	mov		edx, [pos]
418
    cmp     eax,65
566
	
-
 
567
	mov		[buf_size], edx
-
 
568
	;mov		eax, 70
-
 
569
	;mov		ebx, fileinfo_tmp
-
 
570
	;mcall
Line 419... Line 571...
419
    jb      no_lower_case
571
 
420
    add     eax,32
572
dps "pos = "
Line 421... Line 573...
421
 
573
dph edx
Line 422... Line -...
422
no_lower_case:
-
 
423
    mov     [esi+0x10000],al
-
 
424
    inc     esi
-
 
425
    cmp     esi,[pos]
-
 
426
    jbe     newlettercheck
-
 
427
    mov     edi,0x30000
-
 
428
    mov     ecx,0x10000
-
 
429
    mov     al,0
-
 
430
    cld
-
 
Line 431... Line -...
431
    rep     stosb
-
 
432
    mov     [text_type],1
574
newline
Line 433... Line 575...
433
    mov     [command_on_off],0
575
 
-
 
576
	; first, find end of headers
Line 434... Line 577...
434
 
577
	
-
 
578
.next_byte:
-
 
579
	cmp		dword [edi], 0x0d0a0d0a		; ìíå ëåíü ÷èòàòü ñòàíäàðò, ïóñòü áóäóò îáà âàðèàíòà
-
 
580
	je		.end_of_headers
Line 435... Line -...
435
    mov     esi,0
-
 
436
    mov     ecx,[pos]
-
 
437
 
-
 
438
    ; search for double lf
-
 
439
 
-
 
440
find_dlf:
581
	cmp		dword [edi], 0x0a0d0a0d
441
    cmp     [0x10000+esi-4],dword 0x0d0a0d0a
-
 
442
    je      found_dlf
-
 
443
    cmp     [0x10000+esi-4],dword 0x0a0d0a0d
-
 
444
    je      found_dlf
-
 
445
    cmp     [0x10000+esi-2],word 0x0d0d
582
	je		.end_of_headers
446
    je      found_dlf
-
 
Line 447... Line 583...
447
    cmp     [0x10000+esi-2],word 0x0a0a
583
	inc		edi
448
    je      found_dlf
584
	dec		edx
449
 
585
	jne		.next_byte
450
    cmp     esi,5500
586
	
-
 
587
	; no end of headers. it's an error. let client see all those headers.
451
    je      found_dlf
588
	ret
452
 
-
 
-
 
589
	
453
    inc     esi
590
.end_of_headers:
-
 
591
 
454
 
592
 
455
    jmp     find_dlf
593
	; here we look at headers and search content-length or transfer-encoding headers
456
 
594
 
-
 
595
;dps "eoh "
457
found_dlf:
596
;newline
-
 
597
 
458
newbyte:
598
	sub		edi, [buf_ptr]
-
 
599
	add		edi, 3
-
 
600
	mov		[body_pos], edi		; store position where document body starts
459
    mov     al,[esi+0x10000]
601
	mov		[is_chunked], 0
-
 
602
 
-
 
603
	; find content-length in headers
-
 
604
	; not good method, but should work for 'Content-Length:'
-
 
605
	
-
 
606
	mov		esi, [buf_ptr]
460
    cmp     al,'<'
607
	mov		edi, s_contentlength
461
    jne     no_command_on
608
	mov		ebx, [body_pos]
-
 
609
	mov		edx, 0
-
 
610
.cl_next:
462
    mov     [command_on_off],1
611
	mov		al, [esi]
-
 
612
	cmp		al, [edi + edx]
463
 
613
	jne		.cl_fail
464
no_command_on:
614
	inc		edx
465
    cmp     al,'>'
615
	cmp		edx, len_contentlength
466
    jne     no_command_off
616
	je		.cl_found
467
    mov     [command_on_off],0
617
	jmp		.cl_incr
468
    jmp     byte_done
618
.cl_fail:
469
 
619
	mov		edx, 0
-
 
620
.cl_incr:
-
 
621
	inc		esi
470
no_command_off:
622
	dec		ebx
-
 
623
	je		.cl_error
-
 
624
	jmp		.cl_next
-
 
625
.cl_error:
471
    mov     eax,[esi+0x10000]    ; 
-
 
478
    cmp     ax,'->'
673
	
Line 479... Line 674...
479
    jne     no_com2_end
674
	call	read_number		; eax = number from *esi
480
    mov     [com2],0
675
	inc		eax				; bugfix :)
-
 
676
	
Line 481... Line 677...
481
    inc     esi
677
.write_final_size:
482
    jmp     byte_done
678
	mov		[final_size], eax		; if this works, i will b very happy...
483
 
679
	
Line 484... Line -...
484
no_com2_end:
-
 
485
    mov     eax,[esi+0x10000]    ; 
-
 
486
    cmp     eax,'
-
 
487
    jne     no_script_start
-
 
488
    mov     [script],1
-
 
489
 
-
 
490
no_script_start:
-
 
491
    mov     eax,[esi+0x10000]    ; /script>
-
 
492
    cmp     eax,'
-
 
493
    jne     no_script_end
-
 
494
    mov     [script],0
-
 
495
    inc     esi
-
 
496
    jmp     byte_done
-
 
497
 
-
 
498
no_script_end:
-
 
499
    cmp     [command_on_off],0
-
 
500
    jne     no_print
-
 
501
 
-
 
502
    cmp     [com2],0
-
 
503
    jne     no_print
-
 
504
 
-
 
505
    cmp     [script],0
-
 
506
    jne     no_print
-
 
507
 
-
 
508
    mov     al,[esi+0x10000] ; &
-
 
509
    cmp     al,'&'
680
	mov		ebx, [pos]	; we well check if it is right
510
    jne     no_nbsp
681
	sub		ebx, [body_pos]
511
 
-
 
512
newsps:
-
 
Line 513... Line 682...
513
    inc     esi
682
 
514
    mov     al,[esi+0x10000] ;
-
 
515
    cmp     al,';'
-
 
516
    jne     newsps
-
 
517
    jmp     byte_done
-
 
518
 
-
 
519
no_nbsp:
-
 
520
    cmp     al,13
-
 
521
    jne     no_lb
-
 
522
    jmp     byte_done
-
 
523
 
-
 
524
no_lb:
-
 
525
    cmp     al,10
-
 
526
    jne     no_lf
-
 
Line -... Line 683...
-
 
683
;dps "check cl eax==ebx "	
-
 
684
;pregs
527
    jmp     byte_done
685
 
Line 528... Line 686...
528
 
686
	; everything is ok, so we return
529
no_lf:
-
 
Line 530... Line -...
530
    mov     ebx,[pagey]
-
 
531
    imul    ebx,[pagexs]
-
 
532
    add     ebx,[pagex]
-
 
533
    add     ebx,0x20000
-
 
534
    and     eax,0xff
-
 
535
    cmp     eax,31
687
	
536
    jbe     byte_done
-
 
537
    cmp     [lastletter],al
-
 
538
    jne     letter_ok
-
 
539
    cmp     al,' '
-
 
540
    je      byte_done
688
	mov		eax, [body_pos]
Line 541... Line -...
541
 
-
 
542
letter_ok:
-
 
543
    mov     [ebx],al
689
	mov		ebx, [buf_ptr]
544
    mov     dl,[text_type]
690
	add		ebx, eax
545
    mov     [ebx+0x10000],dl
-
 
546
    mov     [pageyinc],0
-
 
Line 547... Line -...
547
    mov     [lastletter],al
-
 
548
 
691
	mov		[final_buffer], ebx
549
    inc     [pagex]
692
	;mov		ebx, [pos]
550
 
-
 
551
    mov     ebx,[pagex]
-
 
552
    cmp     ebx,[pagexs]
-
 
553
    jb      byte_done
-
 
554
    mov     [pagex],0
693
	;sub		ebx, eax
555
    inc     [pagey]
-
 
556
 
-
 
557
    jmp     byte_done
-
 
558
 
-
 
559
no_print:
-
 
Line -... Line 694...
-
 
694
	;mov		[final_size], ebx
-
 
695
	
-
 
696
	ret
-
 
697
	
-
 
698
parse_chunks:
-
 
699
 
-
 
700
;dps "parse chunks"
560
    ; HTML -COMMAND
701
;newline
-
 
702
	; we have to look through the data and remove sizes of chunks we see
-
 
703
	
-
 
704
	; 1. read size of next chunk
-
 
705
	; 2. if 0, it's end. if not, continue.
-
 
706
	; 3. make a good buffer and copy a chunk there
-
 
707
	
-
 
708
	mov		[final_buffer], 0
561
 
709
	mov		[final_size], 0
-
 
710
	
-
 
711
.read_size:
-
 
712
	
562
    mov     ax,[esi+0x10000]    ; b> bold
713
	mov		eax, [prev_chunk_end]
-
 
714
	mov		ebx, eax
563
    cmp     ax,'b>'
715
	sub		ebx, [buf_ptr]
564
    jne     no_bold_start
716
 
-
 
717
	mov		edx, eax
-
 
718
	
-
 
719
;dps "rs "
-
 
720
;pregs
-
 
721
 
-
 
722
	cmp		ebx, [pos]
-
 
723
	jae		chunks_end			; not good
-
 
724
	
-
 
725
	call	read_hex			; in: eax=pointer to text. out:eax=hex number,ebx=end of text.
565
    mov     [text_type],2
726
	cmp		eax, 0
-
 
727
	jz		chunks_end
-
 
728
 
-
 
729
	add		ebx, 1
-
 
730
	mov		edx, ebx			; edx = size of size of chunk
-
 
731
	
-
 
732
	add		ebx, eax
-
 
733
	mov		[prev_chunk_end], ebx
Line 566... Line -...
566
 
-
 
567
no_bold_start:
-
 
568
    mov     eax,[esi+0x10000]    ; /b bold end
-
 
569
    cmp     eax,''
-
 
570
    jne     no_bold_end
-
 
571
    mov     [text_type],1
734
	
Line -... Line 735...
-
 
735
;dps "sz "
-
 
736
;pregs
-
 
737
 
-
 
738
	; do copying: from buf_ptr+edx to final_buffer+prev_final_size count eax
-
 
739
	
-
 
740
	; realloc final buffer
-
 
741
	
-
 
742
	push	eax
-
 
743
	push	edx
-
 
744
	push	dword [final_size]
-
 
745
	
-
 
746
	add		[final_size], eax
-
 
747
	
-
 
748
	mov		eax, 68
-
 
749
	mov		ebx, 20
-
 
750
	mov		ecx, [final_size]
-
 
751
	mov		edx, [final_buffer]
-
 
752
	mcall
-
 
753
	mov		[final_buffer], eax
-
 
754
;dps "re "
-
 
755
;pregs
-
 
756
	
-
 
757
	pop		edi
-
 
758
	pop		esi
-
 
759
	pop		ecx
-
 
760
 
-
 
761
	;add		[pos], ecx
-
 
762
	
-
 
763
	add		edi, [final_buffer]
-
 
764
 
-
 
765
;dps "cp "
-
 
766
;pregs
-
 
767
	
572
    add     esi,2
768
	rep		movsb
-
 
769
	
573
 
770
	jmp		.read_size
574
no_bold_end:
771
	
575
    mov     ax,[esi+0x10000]    ; 
772
chunks_end:
-
 
773
	; free old buffer
-
 
774
dps "chunks end"
-
 
775
newline
576
    cmp     ax,'a '
776
	
-
 
777
	mov		eax, 68
Line 577... Line -...
577
    jne     no_link_start
-
 
578
    mov     [text_type],128
778
	mov		ebx, 13
Line -... Line 779...
-
 
779
	mov		ecx, [buf_ptr]
-
 
780
	mcall
-
 
781
	
-
 
782
	; done!
-
 
783
	
-
 
784
	ret
-
 
785
	
-
 
786
	
-
 
787
	
-
 
788
; reads content-length from [edi+ecx], result in eax
-
 
789
read_number:
-
 
790
 
-
 
791
	push	ebx
-
 
792
	xor		eax, eax
579
    add     esi,2
793
	xor		ebx, ebx
-
 
794
.next:
-
 
795
	mov		bl, [esi]
-
 
796
;dph ebx
-
 
797
	cmp		bl, '0'
-
 
798
	jb		.not_number
-
 
799
	cmp		bl, '9'
-
 
800
	ja		.not_number
-
 
801
	sub		bl, '0'
-
 
802
	shl		eax, 1
-
 
803
	lea		eax,[eax + eax * 4]		; eax *= 10
-
 
804
	add		eax, ebx
-
 
805
.not_number:
-
 
806
	cmp		bl, 13
-
 
807
	jz		.done
-
 
808
	inc		esi
-
 
809
	jmp		.next
-
 
810
.done:
-
 
811
	pop		ebx
-
 
812
;newline
-
 
813
;dps "strtoint eax "
-
 
814
;pregs
-
 
815
 
-
 
816
	ret
-
 
817
	
-
 
818
	
-
 
819
; reads hex from eax, result in eax, end of text in ebx
-
 
820
read_hex:
-
 
821
 
-
 
822
	add		eax, 2
-
 
823
	mov		ebx, eax
-
 
824
	
-
 
825
	mov		eax, [ebx]
580
 
826
	mov		[deba], eax
Line -... Line 827...
-
 
827
	
-
 
828
;	pushf
-
 
829
;   pushad
-
 
830
;   mov  edx,deba
-
 
831
;   call debug_outstr
-
 
832
;   popad
-
 
833
;   popf
-
 
834
	
-
 
835
	xor		eax, eax
-
 
836
	xor		ecx, ecx
-
 
837
.next:
-
 
838
	mov		cl, [ebx]
-
 
839
	inc		ebx
-
 
840
	
-
 
841
	cmp		cl, 0x0d
581
no_link_start:
842
	jz		.done
582
    mov     ax,[esi+0x10000]    ; /a
843
;dph ebx
583
    cmp     ax,'/a'
844
	or		cl, 0x20
584
    jne     no_link_end2
845
	sub		cl, '0'
585
    mov     [text_type],1
846
	jb		.bad
586
    add     esi,0
847
	cmp		cl, 0x9
587
 
848
	jbe		.adding
588
no_link_end2:
849
	sub		cl, 'a'-'0'-10
589
    mov     ax,[esi+0x10000]
850
	cmp		cl, 0x0a
590
    cmp     ax,'br'
-
 
591
    jne     no_br
-
 
Line 592... Line -...
592
    call    linefeed
-
 
593
    inc     esi
-
 
594
 
-
 
595
no_br:
-
 
596
    mov     ax,[esi+0x10000]
-
 
597
    cmp     ax,'td'
851
	jb		.bad
Line 598... Line -...
598
    jne     no_td
-
 
599
    call    linefeed
-
 
600
    inc     esi
852
	cmp		cl, 0x0f
601
 
853
	ja		.bad
602
no_td:
854
.adding:
603
    mov     eax,[esi+0x10000]
855
	shl		eax, 4
604
    cmp     eax,'tabl'
856
	or		eax, ecx
605
    jne     no_table
857
;	jmp		.not_number
606
    call    linefeed
858
;.bad:
607
    add     esi,3
859
.bad:
608
 
860
	jmp		.next
609
no_table:
-
 
610
byte_done:
-
 
611
    inc     esi
-
 
612
    cmp     esi,[pos]
-
 
613
    jbe     newbyte
-
 
614
 
-
 
615
    mov     [display_from],0
-
 
616
    call    display_page
-
 
617
 
-
 
618
    popa
-
 
619
    ret
-
 
620
 
-
 
621
 
-
 
622
 
-
 
623
;****************************************************************************
-
 
624
;    Function
-
 
625
;       linefeed
-
 
626
;
-
 
627
;   Description
-
 
628
;
-
 
629
;
-
 
630
;****************************************************************************
-
 
631
linefeed:
-
 
632
    cmp     [pageyinc],2
-
 
633
    jge     nolf
-
 
634
 
-
 
635
    mov     [pagex],0
-
 
636
    inc     [pagey]
-
 
637
    inc     [pageyinc]
-
 
638
 
-
 
639
nolf:
-
 
640
    ret
-
 
641
 
-
 
642
 
-
 
643
 
-
 
644
;****************************************************************************
-
 
645
;    Function
-
 
646
;       display_page
-
 
647
;
-
 
648
;   Description
-
 
649
;       Renders the text decoded by draw_page
-
 
650
;
-
 
651
;****************************************************************************
-
 
652
display_page:
-
 
653
    pusha
-
 
654
 
-
 
655
    mov     eax,0
-
 
656
    mov     ebx,0
-
 
657
 
-
 
658
newpxy:
-
 
659
    push    eax
-
 
660
    push    ebx
-
 
661
 
-
 
662
    mov     eax,13       ; background for letter
-
 
663
    mov     ebx,[esp+4]
-
 
664
    imul    ebx,6
-
 
665
    add     ebx,[dpx]
-
 
666
    shl     ebx,16
-
 
667
    add     ebx,6
-
 
668
    mov     ecx,[esp+0]
-
 
669
    imul    ecx,10
-
 
670
    add     ecx,[dpy]
-
 
671
    shl     ecx,16
-
 
672
    add     ecx,10
-
 
673
    mov     edx,0xffffff
-
 
674
    mcall
-
 
675
 
-
 
676
    mov     eax,4
-
 
677
    mov     ebx,[esp+4]
-
 
678
    imul    ebx,6
-
 
679
    add     ebx,[dpx]
-
 
680
    shl     ebx,16
-
 
681
 
-
 
682
    mov     bx,[esp+0]
-
 
683
    imul    bx,10
-
 
684
    add     bx,word [dpy]
861
.done:
Line 685... Line -...
685
 
-
 
686
    mov     esi,[esp]
-
 
687
    imul    esi,[pagexs]
-
 
688
    add     esi,[esp+4]
862
;newline
689
 
863
;dps "hextoint eax "
690
    mov     edx,[display_from]
864
;pregs
691
    imul    edx,[pagexs]
865
	ret
692
    add     edx,0x20000
866
 
Line 740... Line 914...
740
;****************************************************************************
914
;****************************************************************************
741
socket_commands:
915
socket_commands:
742
    cmp     ah,22       ; open socket
916
    cmp     ah,22       ; open socket
743
    jnz     tst3
917
    jnz     tst3
Line -... Line 918...
-
 
918
 
-
 
919
	dps "opening socket"
744
 
920
	newline
-
 
921
    ; Clear all page memory
745
    ; Clear all page memory
922
	
-
 
923
	mov		[prev_chunk_end], 0
746
    mov     edi,0x10000
924
	
-
 
925
	cmp		[buf_ptr], 0
-
 
926
	jz		no_free
747
    mov     ecx,0x30000
927
	mov		eax, 68		; free buffer
-
 
928
	mov		ebx, 13
748
    mov     al,0
929
	mov		ecx, [buf_ptr]
-
 
930
	mcall
749
    cld
931
no_free:
Line 750... Line 932...
750
    rep     stosb
932
	mov		[buf_size], 0
751
 
933
 
Line 752... Line 934...
752
    ; Parse the entered url
934
    ; Parse the entered url
Line 765... Line 947...
765
        jz              getlp1              ; yes - so try next
947
        jz              getlp1              ; yes - so try next
Line 766... Line 948...
766
 
948
 
767
    mov     eax,53
949
    mov     eax,53
768
    mov     ebx,5
950
    mov     ebx,5
-
 
951
    mov     edx,80
-
 
952
    cmp     [proxyAddr], 0
-
 
953
    jz      sc000
-
 
954
    mov     edx,[proxyPort]
769
    mov     edx,80
955
sc000:
770
    mov     esi,dword [server_ip]
956
    mov     esi,dword [server_ip]
771
    mov     edi,1
957
    mov     edi,1
772
    mcall
958
    mcall
Line 776... Line 962...
776
    mov     [pagex],0
962
    mov     [pagex],0
777
    mov     [pagey],0
963
    mov     [pagey],0
778
    mov     [pagexs],80
964
    mov     [pagexs],80
779
    mov     [command_on_off],0
965
    mov     [command_on_off],0
Line -... Line 966...
-
 
966
	
-
 
967
	mov		[is_body], 0
780
 
968
 
Line 781... Line 969...
781
    ret
969
    ret
782
 
970
 
783
tst3:
971
tst3:
Line 827... Line 1015...
827
    mov     ecx,URLMAXLEN
1015
    mov     ecx,URLMAXLEN
828
    rep     stosb
1016
    rep     stosb
829
    mov     edi, webAddr
1017
    mov     edi, webAddr
830
    mov     ecx,URLMAXLEN
1018
    mov     ecx,URLMAXLEN
831
    rep     stosb
1019
    rep     stosb
-
 
1020
 
832
    mov     al, '/'
1021
    mov     al, '/'
833
    mov     [document], al
1022
    mov     [document], al
Line 834... Line 1023...
834
 
1023
 
835
    mov     esi, document_user
1024
    mov     esi, document_user
Line 868... Line 1057...
868
 
1057
 
869
pu_005:
1058
pu_005:
870
    ; copy page to document address
1059
    ; copy page to document address
871
    ; esi = delimiter
1060
    ; esi = delimiter
872
    push    esi
-
 
873
    inc     esi
1061
    push    esi
874
    mov     ecx, edi            ; end of document_user
1062
    mov     ecx, edi            ; end of document_user
875
    mov     edi, document
1063
    mov     edi, document
Line 876... Line 1064...
876
    cld
1064
    cld
Line 911... Line 1099...
911
    mov     esi, document
1099
    mov     esi, document
912
    call    debug_print_string
1100
    call    debug_print_string
913
end if
1101
end if
Line 914... Line 1102...
914
 
1102
 
-
 
1103
    ; Look up the ip address, or was it specified?
-
 
1104
    mov     al, [proxyAddr]
-
 
1105
    cmp     al, 0
915
    ; Look up the ip address, or was it specified?
1106
    jnz     pu_015
-
 
1107
    mov     al, [webAddr]
916
    mov     al, [webAddr]
1108
pu_015:
917
    cmp     al, '0'
1109
    cmp     al, '0'
918
    jb      pu_010              ; Resolve address
1110
    jb      pu_010              ; Resolve address
919
    cmp     al, '9'
1111
    cmp     al, '9'
Line 924... Line 1116...
924
    mov     esi, str2       ; print gotip
1116
    mov     esi, str2       ; print gotip
925
    call    debug_print_string
1117
    call    debug_print_string
926
end if
1118
end if
Line 927... Line 1119...
927
 
1119
 
-
 
1120
    ; Convert address
-
 
1121
    ; If proxy is given, get proxy address instead of server
-
 
1122
    mov     esi,proxyAddr-1
-
 
1123
    cmp     byte [esi+1], 0
928
    ; Convert address
1124
    jnz     pu_020
-
 
1125
    mov     esi,webAddr-1
-
 
1126
pu_020:
929
    mov     esi,webAddr-1
1127
 
930
    mov     edi,server_ip
1128
    mov     edi,server_ip
931
    xor     eax,eax
1129
    xor     eax,eax
932
ip1:
1130
ip1:
933
    inc     esi
1131
    inc     esi
Line 999... Line 1197...
999
    mov     [dnsMsg+8], eax
1197
    mov     [dnsMsg+8], eax
Line 1000... Line 1198...
1000
 
1198
 
1001
    ; domain name goes in at dnsMsg+12
1199
    ; domain name goes in at dnsMsg+12
1002
    mov     esi, dnsMsg + 12        ; location of label length
1200
    mov     esi, dnsMsg + 12        ; location of label length
-
 
1201
    mov     edi, dnsMsg + 13        ; label start
-
 
1202
    mov     edx, proxyAddr
-
 
1203
    cmp     byte [edx], 0
1003
    mov     edi, dnsMsg + 13        ; label start
1204
    jnz     td000
-
 
1205
    mov     edx, webAddr
1004
    mov     edx, webAddr
1206
td000:
Line 1005... Line 1207...
1005
    mov     ecx, 12                  ; total string length so far
1207
    mov     ecx, 12                  ; total string length so far
1006
 
1208
 
1007
td002:
1209
td002:
Line 1008... Line 1210...
1008
    mov     [esi], byte 0
1210
    mov     [esi], byte 0
1009
    inc     ecx
1211
    inc     ecx
1010
 
1212
 
1011
td0021:
1213
td0021:
-
 
1214
    mov     al, [edx]
-
 
1215
    cmp     al, ' '
1012
    mov     al, [edx]
1216
    je      td001                   ; we have finished the string translation
1013
    cmp     al, ' '
1217
    cmp     al, 0
Line 1014... Line 1218...
1014
    je      td001                   ; we have finished the string translation
1218
    je      td001
1015
    cmp     al, '.'                 ; we have finished the label
1219
    cmp     al, '.'                 ; we have finished the label
Line 1067... Line 1271...
1067
        mcall
1271
        mcall
1068
        pop         ecx
1272
        pop         ecx
1069
        cmp         eax, 0                      ; is this local port in use?
1273
        cmp         eax, 0                      ; is this local port in use?
1070
        jz              getlp               ; yes - so try next
1274
        jz              getlp               ; yes - so try next
Line -... Line 1275...
-
 
1275
 
-
 
1276
    ; Get DNS IP
-
 
1277
    mov     eax, 52
-
 
1278
    mov     ebx, 13
-
 
1279
    mcall
1071
 
1280
    mov     esi, eax
1072
    ; First, open socket
1281
    ; First, open socket
1073
    mov     eax, 53
1282
    mov     eax, 53
1074
    mov     ebx, 0
1283
    mov     ebx, 0
1075
    mov     edx, 53    ; remote port - dns
1284
    mov     edx, 53    ; remote port - dns
1076
    mov     esi, dword [dns_ip]
1285
;    mov     esi, dword [dns_ip]
Line 1077... Line 1286...
1077
    mcall
1286
    mcall
Line 1078... Line 1287...
1078
 
1287
 
Line 1289... Line 1498...
1289
 
1498
 
1290
sn_exit:
1499
sn_exit:
1291
    inc     esi
1500
    inc     esi
Line -... Line 1501...
-
 
1501
    ret
-
 
1502
 
-
 
1503
;***************************************************************************
-
 
1504
;   Function
-
 
1505
;       load_settings
-
 
1506
;
-
 
1507
;   Description
-
 
1508
;       Load settings from configuration file network.ini
-
 
1509
;
-
 
1510
;***************************************************************************
-
 
1511
include "proc32.inc"
-
 
1512
include "dll.inc"
-
 
1513
load_settings:
-
 
1514
    stdcall dll.Load, @IMPORT
-
 
1515
    test    eax, eax
-
 
1516
    jnz     ls001
-
 
1517
    invoke  ini.get_str, inifile, sec_proxy, key_proxy, proxyAddr, 256, proxyAddr
-
 
1518
    invoke  ini.get_int, inifile, sec_proxy, key_proxyport, 80
-
 
1519
    mov     [proxyPort], eax
-
 
1520
    invoke  ini.get_str, inifile, sec_proxy, key_user, proxyUser, 256, proxyUser
-
 
1521
    invoke  ini.get_str, inifile, sec_proxy, key_password, proxyPassword, 256, proxyPassword
Line -... Line 1522...
-
 
1522
ls001:
-
 
1523
    ret
-
 
1524
 
-
 
1525
;***************************************************************************
-
 
1526
;   Function
-
 
1527
;       append_proxy_auth_header
-
 
1528
;
-
 
1529
;   Description
-
 
1530
;       Append header to HTTP request for proxy authentification
-
 
1531
;
-
 
1532
;***************************************************************************
-
 
1533
append_proxy_auth_header:
-
 
1534
    mov     esi, proxy_auth_basic
-
 
1535
    mov     ecx, proxy_auth_basic_end - proxy_auth_basic
-
 
1536
    rep     movsb
-
 
1537
    ; base64-encode string :
-
 
1538
    mov     esi, proxyUser
-
 
1539
apah000:
-
 
1540
    lodsb
-
 
1541
    test    al, al
-
 
1542
    jz      apah001
-
 
1543
    call    encode_base64_byte
-
 
1544
    jmp     apah000
-
 
1545
apah001:
-
 
1546
    mov     al, ':'
-
 
1547
    call    encode_base64_byte
-
 
1548
    mov     esi, proxyPassword
-
 
1549
apah002:
-
 
1550
    lodsb
-
 
1551
    test    al, al
-
 
1552
    jz      apah003
-
 
1553
    call    encode_base64_byte
-
 
1554
    jmp     apah002
-
 
1555
apah003:
-
 
1556
    call    encode_base64_final
-
 
1557
    ret
-
 
1558
 
-
 
1559
encode_base64_byte:
-
 
1560
    inc     ecx
-
 
1561
    shl     edx, 8
-
 
1562
    mov     dl, al
-
 
1563
    cmp     ecx, 3
-
 
1564
    je      ebb001
-
 
1565
    ret
-
 
1566
ebb001:
-
 
1567
    shl     edx, 8
-
 
1568
    inc     ecx
-
 
1569
ebb002:
-
 
1570
    rol     edx, 6
-
 
1571
    xor     eax, eax
-
 
1572
    xchg    al, dl
-
 
1573
    mov     al, [base64_table+eax]
-
 
1574
    stosb
-
 
1575
    loop    ebb002
-
 
1576
    ret
-
 
1577
 
-
 
1578
encode_base64_final:
-
 
1579
    mov     al, 0
-
 
1580
    test    ecx, ecx
-
 
1581
    jz      ebf000
-
 
1582
    call    encode_base64_byte
-
 
1583
    test    ecx, ecx
-
 
1584
    jz      ebf001
-
 
1585
    call    encode_base64_byte
-
 
1586
    mov     byte [edi-2], '='
-
 
1587
ebf001:
Line 1292... Line 1588...
1292
    ret
1588
    mov     byte [edi-1], '='
Line 1293... Line 1589...
1293
 
1589
ebf000:
1294
 
1590
    ret
Line 1382... Line 1678...
1382
;   *********************************************
1678
;   *********************************************
1383
;   *******  WINDOW DEFINITIONS AND DRAW ********
1679
;   *******  WINDOW DEFINITIONS AND DRAW ********
1384
;   *********************************************
1680
;   *********************************************
Line 1385... Line 1681...
1385
 
1681
 
-
 
1682
draw_window:
-
 
1683
 
-
 
1684
	cmp		byte [params], 0
-
 
1685
	jz		.noret
-
 
1686
 
-
 
1687
    mov     eax,12                    ; function 12:tell os about windowdraw
-
 
1688
    mov     ebx,1                     ; 1, start of draw
-
 
1689
    mcall
-
 
1690
 
-
 
1691
	; ýòî íåñêîëüêî çàãàäî÷íî, íî åñëè íå ðèñîâàòü îêîøêî ñîâñåì, ïðîãà íå ïàøåò.
-
 
1692
	
-
 
1693
    mov     eax,0                     ; function 0 : define and draw window
-
 
1694
    mov     ebx,0          ; [x start] *65536 + [x size]
-
 
1695
    mov     ecx,0          ; [y start] *65536 + [y size]
-
 
1696
    mov     edx,0x14ffffff            ; color of work area RRGGBB,8->color gl
-
 
1697
    mov     edi,title                 ; WINDOW LABEL
-
 
1698
    mcall
-
 
1699
 
-
 
1700
    mov     eax,12                    ; function 12:tell os about windowdraw
-
 
1701
    mov     ebx,2                     ; 2, end of draw
-
 
1702
    mcall
-
 
1703
 
-
 
1704
	ret
-
 
1705
	
1386
draw_window:
1706
.noret:
1387
    mov     eax,12                    ; function 12:tell os about windowdraw
1707
    mov     eax,12                    ; function 12:tell os about windowdraw
1388
    mov     ebx,1                     ; 1, start of draw
1708
    mov     ebx,1                     ; 1, start of draw
Line 1389... Line 1709...
1389
    mcall
1709
    mcall
1390
 
1710
 
1391
                                   ; DRAW WINDOW
1711
                                   ; DRAW WINDOW
1392
    mov     eax,0                     ; function 0 : define and draw window
1712
    mov     eax,0                     ; function 0 : define and draw window
1393
    mov     ebx,50*65536+550          ; [x start] *65536 + [x size]
1713
    mov     ebx,50*65536+600          ; [x start] *65536 + [x size]
1394
    mov     ecx,50*65536+400          ; [y start] *65536 + [y size]
1714
    mov     ecx,350*65536+200          ; [y start] *65536 + [y size]
1395
    mov     edx,0x14ffffff            ; color of work area RRGGBB,8->color gl
1715
    mov     edx,0x14ffffff            ; color of work area RRGGBB,8->color gl
Line 1402... Line 1722...
1402
    mov     ebx,30*65536+38           ; [x start] *65536 + [y start]
1722
    mov     ebx,30*65536+38           ; [x start] *65536 + [y start]
1403
    mov     ecx,0x000000              ; color of text RRGGBB
1723
    mov     ecx,0x000000              ; color of text RRGGBB
1404
    mov     edx,document_user         ; pointer to text beginning
1724
    mov     edx,document_user         ; pointer to text beginning
1405
    mcall
1725
    mcall
Line 1406... Line 1726...
1406
 
1726
 
1407
    mov     eax,38
1727
    ; mov     eax,38
1408
    mov     ebx,5*65536+545
1728
    ; mov     ebx,5*65536+545
1409
    mov     ecx,60*65536+60
1729
    ; mov     ecx,60*65536+60
1410
    mov     edx,0x000000
1730
    ; mov     edx,0x000000
Line 1411... Line 1731...
1411
    mcall
1731
    ; mcall
1412
 
1732
 
1413
    ;mov     eax,38
1733
    ;mov     eax,38
1414
    ;mov     ebx,5*65536+545
1734
    ;mov     ebx,5*65536+545
1415
    mov     ecx,[winys]
1735
    ; mov     ecx,[winys]
1416
    shl     ecx,16
1736
    ; shl     ecx,16
1417
    add     ecx,[winys]
1737
    ; add     ecx,[winys]
1418
    sub     ecx,26*65536+26
1738
    ; sub     ecx,26*65536+26
1419
    ;mov     edx,0x000000
1739
    ;mov     edx,0x000000
1420
    mcall
1740
    ;mcall
1421
                                   ; RELOAD
1741
                                   ; RELOAD
1422
    mov     eax,8                     ; function 8 : define and draw button
1742
    mov     eax,8                     ; function 8 : define and draw button
1423
    mov     ebx,388*65536+50          ; [x start] *65536 + [x size]
1743
    mov     ebx,388*65536+50          ; [x start] *65536 + [x size]
Line 1440... Line 1760...
1440
    mov     ecx,34*65536+14           ; [y start] *65536 + [y size]
1760
    mov     ecx,34*65536+14           ; [y start] *65536 + [y size]
1441
    mov     edx,24                    ; button id
1761
    mov     edx,24                    ; button id
1442
    ;mov     esi,0x5588dd              ; button color RRGGBB
1762
    ;mov     esi,0x5588dd              ; button color RRGGBB
1443
    mcall
1763
    mcall
Line -... Line 1764...
-
 
1764
 
-
 
1765
									; SAVE
-
 
1766
    mov     ebx,(443+55)*65536+50          ; [x start] *65536 + [x size]
-
 
1767
    mov     ecx,34*65536+14           ; [y start] *65536 + [y size]
-
 
1768
    mov     edx,26                    ; button id
-
 
1769
    ;mov     esi,0x5588dd              ; button color RRGGBB
-
 
1770
    mcall
1444
 
1771
	
1445
                                   ; BUTTON TEXT
1772
                                   ; BUTTON TEXT
1446
    mov     eax,4                     ; function 4 : write text to window
1773
    mov     eax,4                     ; function 4 : write text to window
1447
    mov     ebx,390*65536+38          ; [x start] *65536 + [y start]
1774
    mov     ebx,390*65536+38          ; [x start] *65536 + [y start]
1448
    mov     ecx,0xffffff              ; color of text RRGGBB
1775
    mov     ecx,0xffffff              ; color of text RRGGBB
1449
    mov     edx,button_text           ; pointer to text beginning
1776
    mov     edx,button_text           ; pointer to text beginning
1450
    mov     esi,20                    ; text length
1777
    mov     esi,30                    ; text length
Line 1451... Line 1778...
1451
    mcall
1778
    mcall
Line 1452... Line 1779...
1452
 
1779
 
1453
    call    display_page
1780
    call    display_page
1454
 
1781
 
Line 1455... Line 1782...
1455
    mov     eax,12                    ; function 12:tell os about windowdraw
1782
    mov     eax,12                    ; function 12:tell os about windowdraw
Line -... Line 1783...
-
 
1783
    mov     ebx,2                     ; 2, end of draw
-
 
1784
    mcall
-
 
1785
 
-
 
1786
    ret
-
 
1787
 
-
 
1788
align 4
-
 
1789
@IMPORT:
-
 
1790
 
-
 
1791
library	libini, 'libini.obj'
-
 
1792
 
-
 
1793
import	libini, \
-
 
1794
	ini.get_str, 'ini_get_str',	\
-
 
1795
	ini.get_int, 'ini_get_int'
-
 
1796
 
-
 
1797
 
-
 
1798
fileinfo		dd	2, 0, 0
-
 
1799
final_size		dd		0
-
 
1800
final_buffer	dd		0
-
 
1801
				db	'/rd/1/.download',0
-
 
1802
				
-
 
1803
body_pos		dd		0
-
 
1804
 
-
 
1805
;fileinfo_tmp	dd	2, 0, 0
-
 
1806
buf_size		dd		0
-
 
1807
buf_ptr			dd		0
Line 1456... Line 1808...
1456
    mov     ebx,2                     ; 2, end of draw
1808
				;db	'/rd/1/1',0
1457
    mcall
1809
 
1458
 
1810
deba			dd		0
1459
    ret
1811
				db		0
1460
 
1812
 
1461
 
1813
 
Line -... Line 1814...
-
 
1814
if DEBUGGING_STATE = DEBUGGING_ENABLED
-
 
1815
str1:       db  "Resolving...",0
1462
if DEBUGGING_STATE = DEBUGGING_ENABLED
1816
str3:       db  "Resolved",0
1463
str1:       db  "Resolving...",0
1817
str2:       db  "GotIP",0
1464
str3:       db  "Resolved",0
1818
str4:       db  "GotResponse",0
1465
str2:       db  "GotIP",0
1819
end if
1466
str4:       db  "GotResponse",0
1820
 
1467
end if
1821
params		db	1024 dup(0)
Line 1484... Line 1838...
1484
 
1838
 
1485
addr            dd  0x0
1839
addr            dd  0x0
1486
ya              dd  0x0
1840
ya              dd  0x0
Line 1487... Line 1841...
1487
len             dd  0x00
1841
len             dd  0x00
Line 1488... Line 1842...
1488
 
1842
 
1489
title         db      'HTTPC - PgUp/PgDown',0
1843
title         db      'Downloader',0
1490
 
1844
 
-
 
1845
server_ip:      db      207,44,212,20
1491
server_ip:      db      207,44,212,20
1846
;dns_ip:         db      194,145,128,1
1492
dns_ip:         db      194,145,128,1
1847
webAddr:        times URLMAXLEN db ' '
1493
webAddr:        times 128 db ' '
1848
db 0
1494
document_user:  db      'Click on the button to the left to enter a URL',0
1849
document_user:  db      'Click on the button to the left to enter a URL',0
-
 
1850
times URLMAXLEN+document_user-$ db 0
-
 
1851
document:       db      '/'
-
 
1852
times URLMAXLEN-1       db      ' '
-
 
1853
 
-
 
1854
s_contentlength		db	'Content-Length:'
-
 
1855
len_contentlength	=	15
-
 
1856
 
-
 
1857
s_chunked			db	'Transfer-Encoding: chunked'
-
 
1858
len_chunked			= $ - s_chunked
-
 
1859
 
-
 
1860
is_body			dd		0 ; 0 if headers, 1 if content
Line 1495... Line 1861...
1495
times  100      db      0x0
1861
is_chunked		dd		0
Line 1496... Line 1862...
1496
document:       db      '/'
1862
prev_chunk_end	dd		0
1497
times  100      db      ' '
1863
cur_chunk_size	dd		0
-
 
1864
 
-
 
1865
string0:        db      'GET '
-
 
1866
 
-
 
1867
stringh:        db      ' HTTP/1.1',13,10,'Host: '
-
 
1868
stringh_end:
-
 
1869
proxy_auth_basic: db      13,10,'Proxy-Authorization: Basic '
-
 
1870
proxy_auth_basic_end:
-
 
1871
connclose:		db		13,10,'User-Agent: Kolibrios Downloader',13,10,'Connection: Close',13,10,13,10
-
 
1872
connclose_end:
-
 
1873
 
-
 
1874
base64_table	db	'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
-
 
1875
		db	'0123456789+/'
-
 
1876
 
-
 
1877
inifile		db	'/sys/network/zeroconf.ini',0
-
 
1878
 
-
 
1879
sec_proxy:
-
 
1880
key_proxy		db		'proxy',0
-
 
1881
key_proxyport		db		'port',0
-
 
1882
key_user		db		'user',0
-
 
1883
key_password		db		'password',0
-
 
1884
 
-
 
1885
request			db		256 dup(0)
-
 
1886
 
-
 
1887
proxyAddr		db		256 dup(0)
-
 
1888
proxyUser		db		256 dup(0)
-
 
1889
proxyPassword	db		256 dup(0)
-
 
1890
proxyPort		dd		80
Line 1498... Line 1891...
1498
 
1891
 
1499
string0:        db      'GET '
1892
shared_name		dd		0
Line 1500... Line 1893...
1500
 
1893
 
Line 1501... Line 1894...
1501
stringh:        db      ' HTTP/1.0',13,10,13,10
1894
;yandex:			db		'menuetos.net'
1502
stringh_end:
1895
;yandex_end:
Line -... Line 1896...
-
 
1896
 
-
 
1897
status          dd      0x0
1503
 
1898
prev_status     dd      0x0
1504
status          dd      0x0
1899
 
1505
prev_status     dd      0x0
1900
onoff           dd      0x0
1506
 
1901