Subversion Repositories Kolibri OS

Rev

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

Rev 4431 Rev 5540
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2009-2013. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2014-2015. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  downloader.asm - HTTP client for KolibriOS                     ;;
6
;;  downloader.asm - HTTP client for KolibriOS                     ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;  Based on HTTPC.asm for menuetos by ville turjanmaa             ;;
-
 
9
;;                                                                 ;;
8
;;      hidnplayr@kolibrios.org                                    ;;
10
;;  Programmers: Barsuk, Clevermouse, Marat Zakiyanov,             ;;
-
 
11
;;      Kirill Lipatov, dunkaist, HidnPlayr                        ;;
-
 
12
;;                                                                 ;;
9
;;                                                                 ;;
13
;;          GNU GENERAL PUBLIC LICENSE                             ;;
10
;;          GNU GENERAL PUBLIC LICENSE                             ;;
14
;;             Version 2, June 1991                                ;;
11
;;             Version 2, June 1991                                ;;
15
;;                                                                 ;;
12
;;                                                                 ;;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 17... Line 14...
17
 
14
 
18
URLMAXLEN       = 1024
-
 
Line 19... Line 15...
19
BUFFERSIZE      = 4096
15
URLMAXLEN       = 65535
20
 
16
 
Line 21... Line -...
21
__DEBUG__       = 1
-
 
Line -... Line 17...
-
 
17
__DEBUG__       = 1
22
__DEBUG_LEVEL__ = 1
18
__DEBUG_LEVEL__ = 1
23
 
19
 
Line 24... Line 20...
24
format binary as ""
20
 
25
 
21
format binary as ""
26
use32
22
use32
27
        org     0x0
23
        org     0x0
28
 
24
 
29
        db      'MENUET01'      ; header
25
        db      'MENUET01'      ; header
30
        dd      0x01            ; header version
26
        dd      0x01            ; header version
31
        dd      START           ; entry point
27
        dd      START           ; entry point
Line -... Line 28...
-
 
28
        dd      IM_END          ; image size
32
        dd      IM_END          ; image size
29
        dd      I_END+0x1000    ; required memory
33
        dd      I_END+0x1000    ; required memory
30
        dd      I_END+0x1000    ; esp
34
        dd      I_END+0x1000    ; esp
-
 
35
        dd      params          ; I_PARAM
-
 
36
        dd      0x0             ; I_Path
31
        dd      url
37
 
32
        dd      0x0             ; I_Path
-
 
33
 
-
 
34
 
-
 
35
include '../../macros.inc'
-
 
36
include '../../proc32.inc'
-
 
37
include '../../dll.inc'
-
 
38
include '../../debug-fdo.inc'
Line 38... Line -...
38
include '../../macros.inc'
-
 
Line -... Line 39...
-
 
39
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
39
include '../../proc32.inc'
40
include '../../develop/libraries/http/http.inc'
Line 40... Line 41...
40
include '../../network.inc'
41
 
41
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
42
virtual at 0
42
include '../../dll.inc'
43
        http_msg http_msg
43
include '../../debug-fdo.inc'
44
end virtual
Line 44... Line 45...
44
 
45
 
45
START:
-
 
46
 
-
 
47
        mcall   68, 11                  ; init heap so we can allocate memory dynamically
46
 
48
 
-
 
49
; load libraries
-
 
50
        stdcall dll.Load, @IMPORT
-
 
Line 51... Line 47...
51
        test    eax, eax
47
START:
52
        jnz     exit
-
 
53
 
48
        mcall   68, 11                  ; init heap so we can allocate memory dynamically
54
; prepare webAddr area
-
 
55
        mov     al, ' '
-
 
56
        mov     edi, webAddr
-
 
57
        mov     ecx, URLMAXLEN
-
 
58
        rep     stosb
-
 
59
        xor     eax, eax
-
 
60
        stosb
-
 
61
 
-
 
62
; prepare document area 
-
 
63
        mov     al, '/'
-
 
64
        mov     edi, document
-
 
65
        stosb
-
 
66
        mov     al, ' '
-
 
67
        mov     ecx, URLMAXLEN-1
-
 
68
        rep     stosb
-
 
69
 
-
 
70
; load proxy settings
-
 
71
        invoke  ini.get_str, inifile, sec_proxy, key_proxy, proxyAddr, 256, proxyAddr
-
 
72
        invoke  ini.get_int, inifile, sec_proxy, key_proxyport, 80
49
 
73
        mov     [proxyPort], eax
-
 
74
        invoke  ini.get_str, inifile, sec_proxy, key_user, proxyUser, 256, proxyUser
-
 
75
        invoke  ini.get_str, inifile, sec_proxy, key_password, proxyPassword, 256, proxyPassword
50
; load libraries
76
 
51
        stdcall dll.Load, @IMPORT
77
; check parameters
-
 
78
        cmp     byte[params], 0         ; no parameters ?
-
 
79
        je      reset_events            ; load the GUI
-
 
80
 
-
 
81
; we have an url, copy untill space or 0
-
 
82
        mov     esi, params
-
 
83
        mov     edi, document_user
-
 
84
        mov     ecx, 1024               ; max parameter size
-
 
85
        mov     [shared_name], 0
-
 
86
  .copy_param:
-
 
87
        lodsb
-
 
88
        test    al, al
-
 
89
        jz      .done
-
 
90
 
-
 
91
        cmp     al, ' '
-
 
92
        jz      .done_with_shared
-
 
93
 
52
        test    eax, eax
-
 
53
        jnz     exit
-
 
54
 
Line -... Line 55...
-
 
55
; wanted events
-
 
56
        mcall   40, EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER
Line 94... Line -...
94
        stosb
-
 
95
        dec     ecx
-
 
96
        jnz     .copy_param
57
 
97
        DEBUGF  2, "Invalid parameters\n"
-
 
98
        jmp     exit
-
 
99
 
-
 
100
  .done_with_shared:
-
 
101
        mov     [shared_name], esi
-
 
102
  .done:
-
 
103
        xor     al, al
-
 
104
        stosb
-
 
105
 
-
 
106
 
-
 
107
download:
-
 
108
 
-
 
109
        DEBUGF  1, "Starting download\n"
-
 
110
 
-
 
111
        call    parse_url
-
 
112
 
-
 
113
        cmp     [server_ip], 0
-
 
114
        je      dns_error
-
 
115
 
-
 
116
        call    open_socket
-
 
117
        call    send_request
-
 
118
 
-
 
119
        mcall   68, 12, BUFFERSIZE      ; create buffer, we'll resize it later if needed..
-
 
120
        mov     [buf_ptr], eax
58
; prepare filename buffers
121
        mov     [buf_size], 0
59
        mov     edi, fname_buf
122
 
-
 
123
        call    read_incoming_data
-
 
124
 
-
 
125
        mcall   close, [socketnum]
-
 
Line 126... Line -...
126
 
-
 
127
        call    parse_result
-
 
128
        call    save
60
        mov     esi, download_file_path
Line 129... Line 61...
129
 
61
  @@:
130
        mcall   68, 13, [final_buffer]  ; free buffer
62
        lodsb
Line 131... Line 63...
131
 
63
        stosb
132
dns_error:
-
 
133
        cmp     byte [params], 0
-
 
134
        jne     exit
64
        test    al, al
135
 
-
 
136
reset_events:
65
        jnz     @r
137
 
66
 
138
        DEBUGF  1, "resetting events\n"
-
 
139
 
67
; Initialise OpenDialog
140
; Report events
68
        invoke  OpenDialog_Init, OpenDialog_data
141
; defaults + mouse
-
 
142
        mcall   40,EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER
69
 
143
 
70
; If user provided parameters, start download right away!
144
redraw:
-
 
145
        call    draw_window
71
        cmp     byte[url], 0
146
 
72
        jne     download
-
 
73
 
Line 147... Line -...
147
still:
-
 
148
        DEBUGF  1, "waiting for events\n"
-
 
149
 
74
        mov     [OpenDialog_data.draw_window], draw_window
150
        mcall   10      ; wait here for event
75
 
151
 
-
 
152
        cmp     eax, EV_REDRAW
76
redraw:
153
        je      redraw
-
 
154
 
77
        call    draw_window
155
        cmp     eax, EV_KEY
78
 
-
 
79
mainloop:
Line 156... Line -...
156
        je      key
-
 
157
 
-
 
158
        cmp     eax, EV_BUTTON
80
        mcall   10      ; wait here for event
159
        je      button
-
 
160
        
81
        cmp     eax, EV_REDRAW
161
        cmp     eax, EV_MOUSE
-
 
162
        je      mouse
-
 
163
 
-
 
164
        jmp     still
-
 
165
 
-
 
166
key:
-
 
167
        mcall   2       ; read key
82
        je      redraw
168
 
83
        cmp     eax, EV_KEY
Line 169... Line 84...
169
        stdcall [edit_box_key], dword edit1
84
        je      .key
170
 
-
 
171
        cmp     ax, 13 shl 8
-
 
172
        je      download
-
 
173
        
-
 
174
        jmp     still
-
 
175
        
-
 
176
button:
-
 
177
 
-
 
178
        mcall   17      ; get id
-
 
179
 
-
 
180
        cmp     ah, 26
-
 
181
        jne     @f
-
 
182
        call    save_to_file
-
 
183
        jmp     still
-
 
184
  @@:
-
 
185
        cmp     ah, 1   ; button id=1 ?
-
 
186
        je      exit
-
 
187
 
-
 
188
        jmp     download
-
 
189
 
-
 
190
mouse:
-
 
191
        stdcall [edit_box_mouse], edit1
-
 
192
        jmp     still
-
 
193
 
-
 
194
exit:
-
 
195
        DEBUGF  1, "Exiting\n"
-
 
196
        or      eax, -1 ; close this program
-
 
197
        mcall
-
 
198
 
-
 
199
 
-
 
200
save:
-
 
201
        cmp     [shared_name], 0
-
 
202
        je      .use_file
-
 
203
 
-
 
204
        call    save_in_shared
-
 
205
        jmp     .done
-
 
206
 
-
 
207
  .use_file:
-
 
208
 
-
 
209
        call    save_to_file
-
 
210
 
-
 
211
  .done:
-
 
212
 
-
 
213
; if called from command line, then exit
-
 
214
        cmp     byte[params], 0
-
 
215
        jne     exit
-
 
216
 
-
 
217
        mov     ecx, [sc.work_text]
-
 
218
        or      ecx, 0x80000000
-
 
219
        mcall   4, <10, 93>, , download_complete
-
 
220
 
-
 
221
        ret
-
 
222
 
-
 
223
save_in_shared:
-
 
224
 
-
 
225
; open the shared memory area
-
 
226
        mov     esi, 1
-
 
227
        mcall   68, 22, [shared_name], , 1 ; SHM_OPEN+SHM_WRITE
-
 
228
        test    eax, eax
-
 
229
        jz      exit
-
 
230
 
-
 
231
        mov     ecx, [final_size]
-
 
232
; store the size
-
 
233
        mov     [eax], ecx
-
 
234
 
-
 
235
; now copy the data
-
 
236
        lea     edi, [eax+4]
-
 
237
        mov     esi, [final_buffer]
-
 
238
        mov     eax, ecx
-
 
239
        shr     ecx, 2
-
 
240
        rep     movsd
-
 
241
        mov     ecx, eax
-
 
242
        and     ecx, 3
-
 
243
        rep     movsb
-
 
244
 
-
 
245
        ret
-
 
246
 
-
 
247
 
-
 
248
;****************************************************************************
-
 
249
;    Function
-
 
250
;       save_to_file
-
 
251
;
-
 
252
;   Description
-
 
253
;
-
 
254
;
-
 
255
;****************************************************************************
-
 
256
 
-
 
257
save_to_file:
-
 
258
 
-
 
259
        DEBUGF  2, "Saving to file\n"
-
 
260
        mcall   70, fileinfo
-
 
261
 
-
 
262
        ret
-
 
263
 
-
 
264
 
-
 
265
;****************************************************************************
-
 
266
;    Function
-
 
267
;       send_request
-
 
268
;
-
 
269
;   Description
-
 
270
;       Transmits the GET request to the server.
-
 
271
;       This is done as GET then URL then HTTP/1.1', 13, 10, 13, 10 in 3 packets
-
 
272
;
-
 
273
;****************************************************************************
-
 
274
send_request:
85
        cmp     eax, EV_BUTTON
275
 
-
 
276
        DEBUGF  1, "Sending request\n"
-
 
277
 
-
 
278
        mov     esi, string0
-
 
279
        mov     edi, request
-
 
280
        movsd
-
 
281
; If proxy is used, make absolute URI - prepend http://
-
 
282
        cmp     byte[proxyAddr], 0
-
 
283
        jz      .noproxy
-
 
284
        mov     dword[edi], 'http'
-
 
285
        mov     byte[edi+4], ':'
-
 
286
        mov     word[edi+5], '//'
-
 
287
        add     edi, 7
-
 
288
        mov     esi, webAddr
-
 
289
 
-
 
290
  .copy_host_loop:
-
 
291
        lodsb
-
 
292
        cmp     al, ' '
-
 
293
        jz      .noproxy
-
 
294
        stosb
-
 
295
        jmp     .copy_host_loop
-
 
Line 296... Line -...
296
 
-
 
297
  .noproxy:
-
 
298
        xor     edx, edx ; 0
-
 
299
 
-
 
300
  .next_edx:
86
        je      .button
301
; Determine the length of the url to send in the GET request
87
        cmp     eax, EV_MOUSE
302
        mov     al, [edx+document]
-
 
303
        cmp     al, ' '
-
 
Line 304... Line 88...
304
        jbe     .document_done
88
        je      .mouse
305
        mov     [edi], al
89
        jmp     mainloop
306
        inc     edi
90
 
307
        inc     edx
-
 
-
 
91
  .key:
308
        jmp     .next_edx
92
        mcall   2       ; read key
309
 
93
        invoke  edit_box_key, edit1
310
  .document_done:
-
 
311
        mov     esi, stringh
94
        cmp     ax, 13 shl 8
Line 312... Line 95...
312
        mov     ecx, stringh_end-stringh
95
        je      download
313
        rep     movsb
-
 
314
        xor     edx, edx ; 0
-
 
315
 
-
 
316
  .webaddr_next:
96
        jmp     mainloop
317
        mov     al, [webAddr + edx]
-
 
318
        cmp     al, ' '
97
 
319
        jbe     .webaddr_done
-
 
320
        mov     [edi], al
-
 
321
        inc     edi
-
 
322
        inc     edx
-
 
323
        jmp     .webaddr_next
-
 
324
 
-
 
Line -... Line 98...
-
 
98
  .button:
-
 
99
        mcall   17      ; get id
-
 
100
        cmp     ah, 1   ; button id=1 ?
-
 
101
        je      exit
-
 
102
 
-
 
103
        cmp     [btn_text], sz_download
-
 
104
        je      download
325
  .webaddr_done:
105
 
326
        cmp     byte[proxyUser], 0
-
 
327
        jz      @f
-
 
328
        call    append_proxy_auth_header
-
 
329
    @@:
-
 
330
        mov     esi, connclose
-
 
331
        mov     ecx, connclose_end-connclose
-
 
332
        rep     movsb
-
 
333
 
-
 
334
        pusha   
-
 
335
        mov     eax, 63
-
 
336
        mov     ebx, 1
-
 
337
        mov     edx, request
-
 
338
    @@:
-
 
339
        mov     cl, [edx]
-
 
340
        cmp     edx, edi
-
 
341
        jz      @f
-
 
342
        mcall
-
 
343
        inc     edx
-
 
344
        jmp     @b
-
 
345
    @@:
-
 
346
        popa
-
 
347
 
-
 
348
        mov     esi, edi
-
 
349
        sub     esi, request    ; length
-
 
350
        xor     edi, edi        ; flags
-
 
351
        mcall   send, [socketnum], request  ;' HTTP/1.1 .. '
-
 
352
 
-
 
353
        ret
-
 
354
 
-
 
355
;****************************************************************************
-
 
356
;    Function
-
 
357
;       read_incoming_data
-
 
358
;
-
 
359
;   Description
-
 
360
;       receive the web page from the server, storing it without processing
-
 
361
;
-
 
362
;****************************************************************************
-
 
363
read_incoming_data:
-
 
364
 
-
 
365
        DEBUGF  1, "Reading incoming data\n"
-
 
366
 
-
 
367
        mov     eax, [buf_ptr]
-
 
368
        mov     [pos], eax
-
 
369
  .read:
-
 
370
        mcall   recv, [socketnum], [pos], BUFFERSIZE, 0
-
 
371
        inc     eax             ; -1 = error (socket closed?)
-
 
372
        jz      .error
-
 
373
        dec     eax             ; 0 bytes means the remote end closed the connection
-
 
374
        jz      .no_more_data
-
 
375
 
-
 
376
        DEBUGF  1, "Got chunk of %u bytes\n", eax
-
 
377
 
-
 
378
        add     [buf_size], eax
-
 
379
        add     [pos], eax
-
 
380
        push    eax
-
 
381
        mov     ecx, [buf_size]
-
 
382
        add     ecx, BUFFERSIZE
-
 
383
        mcall   68, 20, , [buf_ptr]     ; reallocate memory block (make bigger)
-
 
384
        ; TODO: parse header and resize buffer only once
-
 
385
        pop     eax
-
 
386
        jmp     .read
-
 
387
 
-
 
388
  .error:
-
 
389
        DEBUGF  1, "Socket error: %u\n", ebx
-
 
390
        
-
 
391
  .no_more_data:
-
 
392
        mov     eax, [buf_ptr]
-
 
393
        sub     [pos], eax
106
        cmp     [btn_text], sz_open
394
 
107
        je      open_file
395
        DEBUGF  1, "No more data\n"
-
 
396
 
-
 
397
        ret
-
 
398
        
108
 
399
 
-
 
400
        
-
 
401
; this function cuts header, and removes chunk sizes if doc is chunked
-
 
402
; in: buf_ptr, pos; out: buf_ptr, pos.
-
 
403
        
-
 
404
parse_result:
-
 
405
 
-
 
406
        mov     edi, [buf_ptr]
-
 
407
        mov     edx, [pos]
-
 
408
;        mov     [buf_size], edx
-
 
409
;       mcall   70, fileinfo_tmp
-
 
410
        DEBUGF  1, "Parsing result (%u bytes)\n", edx
-
 
411
 
-
 
412
; first, find end of headers
-
 
413
  .next_byte:
-
 
414
        cmp     dword[edi], 0x0a0d0a0d
-
 
415
        je      .end_of_headers
-
 
416
        inc     edi
-
 
417
        dec     edx
-
 
418
        ja      .next_byte
-
 
419
        DEBUGF  1, "Uh-oh, there's no end of header!\n"
-
 
420
; no end of headers. it's an error. let client see all those headers.
-
 
421
        ret
-
 
422
 
-
 
423
  .end_of_headers:
-
 
424
; here we look at headers and search content-length or transfer-encoding headers
-
 
425
        DEBUGF  1, "Found end of header\n"
-
 
426
 
-
 
427
        sub     edi, [buf_ptr]
-
 
428
        add     edi, 4
-
 
429
        mov     [body_pos], edi  ; store position where document body starts
109
  .mouse:
430
        mov     [is_chunked], 0
-
 
431
; find content-length in headers
-
 
432
; not good method, but should work for 'Content-Length:'
-
 
433
        mov     esi, [buf_ptr]
-
 
434
        mov     edi, s_contentlength
-
 
435
        mov     ebx, [body_pos]
-
 
436
        xor     edx, edx ; 0
-
 
437
  .cl_next:
-
 
438
        mov     al, [esi]
-
 
439
        cmp     al, [edi + edx]
-
 
440
        jne     .cl_fail
-
 
441
        inc     edx
-
 
442
        cmp     edx, len_contentlength
-
 
443
        je      .cl_found
-
 
444
        jmp     .cl_incr
-
 
445
  .cl_fail:
-
 
446
        xor     edx, edx ; 0
-
 
447
  .cl_incr:
-
 
448
        inc     esi
-
 
449
        dec     ebx
-
 
450
        je      .cl_error
-
 
451
        jmp     .cl_next
-
 
452
  .cl_error:
-
 
453
        DEBUGF  1, "content-length not found\n"
-
 
454
 
-
 
455
; find 'chunked'
-
 
456
; äà, ÿ êîïèðóþ êîä, ýòî óæàñíî, íî ìíå õî÷åòñÿ, ÷òîáû ïîñêîðåå çàðàáîòàëî
-
 
457
; à òàì óæ îòðåôàêòîðþ
-
 
458
        mov     esi, [buf_ptr]
-
 
459
        mov     edi, s_chunked
-
 
460
        mov     ebx, [body_pos]
-
 
461
        xor     edx, edx ; 0
-
 
462
 
-
 
463
  .ch_next:
-
 
464
        mov     al, [esi]
-
 
465
        cmp     al, [edi + edx]
-
 
466
        jne     .ch_fail
-
 
467
        inc     edx
-
 
468
        cmp     edx, len_chunked
-
 
469
        je      .ch_found
-
 
470
        jmp     .ch_incr
-
 
471
 
-
 
472
  .ch_fail:
-
 
473
        xor     edx, edx ; 0
-
 
474
 
-
 
475
  .ch_incr:
-
 
476
        inc     esi
-
 
477
        dec     ebx
-
 
478
        je      .ch_error
-
 
479
        jmp     .ch_next
-
 
480
 
-
 
481
  .ch_error:
-
 
482
; if neither of the 2 headers is found, it's an error
-
 
483
;       DEBUGF  1, "transfer-encoding: chunked not found\n"
-
 
484
        mov     eax, [pos]
-
 
485
        sub     eax, [body_pos]
-
 
486
        jmp     .write_final_size
-
 
487
 
-
 
488
  .ch_found:
-
 
489
        mov     [is_chunked], 1
-
 
490
        mov     eax, [body_pos]
-
 
491
        add     eax, [buf_ptr]
-
 
492
        sub     eax, 2
-
 
493
        mov     [prev_chunk_end], eax
-
 
494
        jmp     parse_chunks
-
 
495
        
-
 
496
  .cl_found:
-
 
497
        call    read_number     ; eax = number from *esi
-
 
498
        DEBUGF  1, "Content length: %u\n", eax
-
 
499
 
-
 
500
  .write_final_size:
-
 
501
        
-
 
502
        mov     ebx, [buf_size]
-
 
503
        sub     ebx, [body_pos]
-
 
504
        cmp     eax, ebx
-
 
505
        jbe     .size_ok
-
 
506
        sub     eax, ebx
-
 
507
        DEBUGF  2, "%u bytes of data are missing!\n", eax
-
 
508
        mov     eax, ebx
-
 
509
  .size_ok:
-
 
510
        mov     [final_size], eax
-
 
511
 
-
 
512
        mov     ebx, [body_pos]
-
 
513
        add     ebx, [buf_ptr]
-
 
514
        mov     [final_buffer], ebx
-
 
515
 
-
 
516
        ret
-
 
517
        
-
 
518
parse_chunks:
-
 
519
        DEBUGF  1, "parse chunks\n"
-
 
520
        ; we have to look through the data and remove sizes of chunks we see
-
 
521
        ; 1. read size of next chunk
-
 
522
        ; 2. if 0, it's end. if not, continue.
-
 
523
        ; 3. make a good buffer and copy a chunk there
-
 
524
        xor     eax, eax
-
 
525
        mov     [final_buffer], eax      ; 0
-
 
526
        mov     [final_size], eax        ; 0
-
 
527
        
-
 
528
.read_size:
-
 
529
        mov     eax, [prev_chunk_end]
-
 
530
        mov     ebx, eax
-
 
531
        sub     ebx, [buf_ptr]
-
 
532
        mov     edx, eax
-
 
533
        DEBUGF  1, "rs "
-
 
534
        cmp     ebx, [pos]
-
 
535
        jae     chunks_end      ; not good
-
 
536
        
-
 
537
        call    read_hex        ; in: eax=pointer to text. out:eax=hex number, ebx=end of text.
-
 
538
        cmp     eax, 0
-
 
539
        jz      chunks_end
-
 
540
 
-
 
541
        add     ebx, 1
-
 
542
        mov     edx, ebx ; edx = size of size of chunk
-
 
543
        
-
 
544
        add     ebx, eax
-
 
545
        mov     [prev_chunk_end], ebx
-
 
546
        
-
 
547
        DEBUGF  1, "sz "
-
 
548
 
-
 
549
; do copying: from buf_ptr+edx to final_buffer+prev_final_size count eax
110
        invoke  edit_box_mouse, edit1
550
; realloc final buffer
-
 
551
        push    eax
-
 
552
        push    edx
-
 
553
        push    dword [final_size]
-
 
554
        add     [final_size], eax
-
 
555
        mcall   68, 20, [final_size], [final_buffer]
-
 
556
        mov     [final_buffer], eax
-
 
557
        DEBUGF  1, "re "
-
 
558
        pop     edi
-
 
559
        pop     esi
-
 
560
        pop     ecx
-
 
561
;       add     [pos], ecx
-
 
562
        add     edi, [final_buffer]
111
        jmp     mainloop
563
        DEBUGF  1, "cp "
-
 
564
 
-
 
565
        rep     movsb
-
 
566
        jmp     .read_size
-
 
567
        
-
 
568
chunks_end:
-
 
569
        DEBUGF  1, "chunks end\n"
-
 
570
        mcall   68, 13, [buf_ptr]       ; free old buffer
-
 
571
 
112
 
572
        ret
-
 
573
 
-
 
574
; reads content-length from [edi+ecx], result in eax
-
 
575
read_number:
-
 
576
        push    ebx
-
 
577
        xor     eax, eax
-
 
578
        xor     ebx, ebx
-
 
579
 
-
 
580
  .next:
-
 
581
        mov     bl, [esi]
-
 
582
 
-
 
583
        cmp     bl, '0'
-
 
584
        jb      .not_number
-
 
585
        cmp     bl, '9'
-
 
586
        ja      .not_number
113
open_file:
587
        sub     bl, '0'
-
 
588
        shl     eax, 1
-
 
589
        lea     eax, [eax + eax * 4]     ; eax *= 10
-
 
590
        add     eax, ebx
-
 
591
 
-
 
592
  .not_number:
-
 
593
        cmp     bl, 13
114
;        mcall   70, ...
594
        je      .done
-
 
595
        inc     esi
-
 
596
        jmp     .next
-
 
597
 
-
 
598
  .done:
-
 
599
        pop     ebx
-
 
600
        ret
-
 
601
        
-
 
602
; reads hex from eax, result in eax, end of text in ebx
-
 
603
read_hex:
-
 
604
        add     eax, 2
-
 
605
        mov     ebx, eax
-
 
606
        mov     eax, [ebx]
-
 
607
        mov     [deba], eax
-
 
608
 
-
 
609
        xor     eax, eax
-
 
610
        xor     ecx, ecx
-
 
611
  .next:
-
 
612
        mov     cl, [ebx]
-
 
613
        inc     ebx
-
 
614
        
115
        jmp     mainloop
615
        cmp     cl, 0x0d
-
 
616
        jz      .done
116
 
617
 
-
 
618
        or      cl, 0x20
-
 
619
        sub     cl, '0'
-
 
620
        jb      .bad
-
 
621
 
-
 
622
        cmp     cl, 0x9
-
 
623
        jbe     .adding
-
 
624
 
-
 
625
        sub     cl, 'a'-'0'-10
-
 
626
        cmp     cl, 0x0a
-
 
627
        jb      .bad
-
 
628
 
-
 
629
        cmp     cl, 0x0f
-
 
630
        ja      .bad
117
exit:
631
 
-
 
632
  .adding:
-
 
633
        shl     eax, 4
-
 
634
        or      eax, ecx
-
 
635
  .bad:
-
 
636
        jmp     .next
-
 
637
  .done:
-
 
638
 
-
 
639
        ret
-
 
640
 
-
 
641
;****************************************************************************
-
 
642
;    Function
-
 
643
;       open_socket
-
 
644
;
-
 
645
;   Description
-
 
646
;       opens the socket
-
 
647
;
-
 
648
;****************************************************************************
-
 
649
open_socket:
-
 
650
 
-
 
651
        DEBUGF  1, "opening socket\n"
-
 
652
 
-
 
653
        mov     edx, 80
-
 
654
        cmp     byte [proxyAddr], 0
-
 
655
        jz      @f
-
 
656
        mov     eax, [proxyPort]
-
 
657
        xchg    al, ah
-
 
658
        mov     [server_port], ax
-
 
659
    @@:
-
 
660
 
-
 
661
        mcall   socket, AF_INET4, SOCK_STREAM, 0
-
 
662
        mov     [socketnum], eax
-
 
663
        mcall   connect, [socketnum], sockaddr1, 18
-
 
664
 
-
 
665
        ret
-
 
666
 
-
 
667
 
-
 
668
;****************************************************************************
-
 
669
;    Function
-
 
670
;       parse_url
-
 
671
;
-
 
672
;   Description
-
 
673
;       parses the full url typed in by the user into a web address ( that
-
 
674
;       can be turned into an IP address by DNS ) and the page to display
-
 
675
;       DNS will be used to translate the web address into an IP address, if
-
 
676
;       needed.
-
 
677
;       url is at document_user and will be space terminated.
-
 
678
;       web address goes to webAddr and is space terminated.
-
 
679
;       ip address goes to server_ip
-
 
680
;       page goes to document and is space terminated.
-
 
681
;
-
 
682
;       Supported formats:
118
error:
683
;       address
-
 
684
;        is optional, removed and ignored - only http supported
-
 
685
;       
is required. It can be an ip address or web address
-
 
686
;        is optional and must start with a leading / character
-
 
687
;
-
 
688
;****************************************************************************
-
 
689
parse_url:
119
        mcall   -1      ; exit
690
; First, reset destination variables
-
 
691
        mov     al, ' '
-
 
692
        mov     edi, document
-
 
693
        mov     ecx, URLMAXLEN
-
 
694
        rep     stosb
-
 
695
        mov     edi, webAddr
-
 
696
        mov     ecx, URLMAXLEN
-
 
697
        rep     stosb
-
 
698
 
-
 
699
        mov     al, '/'
-
 
700
        mov     [document], al
-
 
701
 
-
 
702
        mov     esi, document_user
-
 
703
; remove any leading protocol text
-
 
704
        mov     ecx, URLMAXLEN
-
 
705
        mov     ax, '//'
-
 
706
 
-
 
707
pu_000:
-
 
708
        cmp     [esi], byte ' '         ; end of text?
120
 
-
 
121
download:
709
        je      pu_002                  ; yep, so not found
122
;        int 3
Line 710... Line -...
710
        cmp     [esi], ax
-
 
711
        je      pu_001                  ; Found it, so esi+2 is start
-
 
712
        inc     esi
123
; Extract the filename from URL
713
        loop    pu_000
-
 
714
 
-
 
715
pu_002:
-
 
716
; not found, so reset esi to start
-
 
717
        mov     esi, document_user-2
-
 
718
 
-
 
719
pu_001:
-
 
720
        add     esi, 2
-
 
721
        mov     ebx, esi ; save address of start of web address
124
        mov     edi, url
722
        mov     edi, document_user + URLMAXLEN   ; end of string
-
 
723
; look for page delimiter - it's a '/' character
-
 
724
pu_003:
-
 
725
        cmp     [esi], byte ' '  ; end of text?
-
 
726
        je      pu_004          ; yep, so none found
-
 
727
        cmp     esi, edi         ; end of string?
125
        xor     al, al
728
        je      pu_004          ; yep, so none found
-
 
729
        cmp     [esi], byte '/'  ; delimiter?
-
 
730
        je      pu_005          ; yep - process it
-
 
731
        inc     esi
-
 
732
        jmp     pu_003
-
 
733
 
-
 
734
pu_005:
126
        mov     ecx, URLMAXLEN
735
; copy page to document address
-
 
736
; esi = delimiter
-
 
737
        push    esi
-
 
738
        mov     ecx, edi         ; end of document_user
-
 
739
        mov     edi, document
-
 
740
 
-
 
741
pu_006:
-
 
742
        movsb
-
 
743
        cmp     esi, ecx
-
 
744
        je      pu_007          ; end of string?
-
 
745
        cmp     [esi], byte ' '  ; end of text
-
 
746
;       je      pu_007          ; äçåí-àññåìáëåð
-
 
747
;       jmp     pu_006          ; íå íàäî ïëîäèòü ñóùíîñòè ïî íàïðàñíó
-
 
748
        jne     pu_006
-
 
749
 
-
 
750
pu_007:
-
 
751
        pop     esi     ; point esi to '/' delimiter
-
 
752
 
-
 
753
pu_004:
-
 
754
; copy web address to webAddr
-
 
755
; start in ebx, end in esi-1
-
 
756
        mov     ecx, esi
-
 
757
        mov     esi, ebx
-
 
758
        mov     edi, webAddr
-
 
759
  @@:
-
 
760
        movsb
-
 
761
        cmp     esi, ecx
-
 
762
        jne     @r
-
 
763
        mov     byte [edi], 0
-
 
Line 764... Line 127...
764
 
127
        repne scasb
765
pu_009:
128
        mov     esi, edi
766
; For debugging, display resulting strings
129
        dec     esi
-
 
130
        dec     esi
-
 
131
        std
-
 
132
  .loop:
-
 
133
        lodsb
-
 
134
        cmp     al, '/'
-
 
135
        je      .done
Line 767... Line -...
767
        DEBUGF  2, "Downloadng %s\n", document_user
-
 
768
 
-
 
769
; Look up the ip address, or was it specified?
-
 
770
        mov     al, [proxyAddr]
136
        test    al, al
771
        cmp     al, 0
137
        jnz     .loop
772
        jnz     pu_015
-
 
773
        mov     al, [webAddr]
138
  .done:
774
pu_015:
139
        cld
775
        cmp     al, '0'
-
 
776
        jb      pu_010  ; Resolve address
-
 
777
        cmp     al, '9'
-
 
778
        ja      pu_010  ; Resolve address
-
 
779
 
-
 
780
        DEBUGF  1, "GotIP\n"
140
        mov     ecx, edi
781
 
141
        sub     ecx, esi
782
; Convert address
-
 
783
; If proxy is given, get proxy address instead of server
142
        inc     esi
784
        mov     esi, proxyAddr-1
-
 
Line -... Line 143...
-
 
143
        inc     esi
785
        cmp     byte[esi+1], 0
144
        mov     edi, filename_area
Line 786... Line 145...
786
        jne     pu_020
145
        rep movsb
-
 
146
 
787
        mov     esi, webAddr-1
147
; invoke OpenDialog
-
 
148
        invoke  OpenDialog_Start, OpenDialog_data
-
 
149
        mcall   40, EVM_REDRAW + EVM_BUTTON + EVM_STACK
-
 
150
        call    draw_window
Line 788... Line -...
788
 
-
 
789
pu_020:
151
 
790
        mov     edi, server_ip
-
 
791
        xor     eax, eax
-
 
792
 
-
 
793
ip1:
-
 
794
        inc     esi
-
 
795
        cmp     [esi], byte '0'
-
 
796
        jb      ip2
152
; Create the file
797
        cmp     [esi], byte '9'
153
        mov     [fileinfo], 2           ; create/write to file
Line 798... Line -...
798
        ja      ip2
-
 
799
        imul    eax, 10
154
        xor     eax, eax
800
        movzx   ebx, byte [esi]
155
        mov     [fileinfo.offset], eax
801
        sub     ebx, 48
156
        mov     [fileinfo.offset+4], eax
802
        add     eax, ebx
-
 
803
        jmp     ip1
-
 
804
 
157
        mov     [fileinfo.size], eax
805
ip2:
158
        mcall   70, fileinfo
806
        mov     [edi], al
-
 
807
        xor     eax, eax
-
 
808
        inc     edi
-
 
809
        cmp     edi, server_ip+3
-
 
Line 810... Line -...
810
        jbe     ip1
-
 
811
 
159
        test    eax, eax
812
        ret
160
        jnz     error                   ; TODO: print error message
Line 813... Line 161...
813
 
161
 
-
 
162
; And start the download
-
 
163
        invoke  HTTP_get, url, 0, FLAG_STREAM or FLAG_REUSE_BUFFER, 0
Line 814... Line -...
814
pu_010:
-
 
815
        DEBUGF  1, "Resolving %s\n", webAddr
164
        test    eax, eax
816
 
-
 
817
; resolve name
-
 
818
        push    esp     ; reserve stack place
-
 
819
        push    esp     ; fourth parameter
-
 
820
        push    0       ; third parameter
-
 
821
        push    0       ; second parameter
-
 
822
        push    webAddr
-
 
823
        call    [getaddrinfo]
-
 
824
        pop     esi
-
 
825
        test    eax, eax
165
        jz      error                   ; TODO: print error message
826
        jnz     .fail_dns
-
 
827
 
-
 
Line 828... Line 166...
828
; fill in ip
166
        mov     [identifier], eax
829
        mov     eax, [esi + addrinfo.ai_addr]
-
 
830
        mov     eax, [eax + sockaddr_in.sin_addr]
-
 
831
        mov     [server_ip], eax
167
        mov     [offset], 0
832
 
168
        mov     [btn_text], sz_cancel
833
; free allocated memory
169
 
834
        push    esi
170
        or      [edit1.flags], ed_figure_only
835
        call    [freeaddrinfo]
171
        call    draw_window
836
 
172
 
-
 
173
download_loop:
-
 
174
        mcall   10
837
        DEBUGF  1, "Resolved to %u.%u.%u.%u\n", [server_ip]:1, [server_ip + 1]:1, [server_ip + 2]:1, [server_ip + 3]:1
175
        cmp     eax, EV_REDRAW
-
 
176
        je      .redraw
838
 
177
        cmp     eax, EV_BUTTON
Line -... Line 178...
-
 
178
        je      .button
839
        ret
179
 
-
 
180
        invoke  HTTP_receive, [identifier]
840
 
181
        test    eax, eax
841
  .fail_dns:
182
        jz      save_chunk
-
 
183
 
-
 
184
        mov     eax, [identifier]
842
        DEBUGF  1, "DNS resolution failed\n"
185
        push    [eax + http_msg.content_length]
843
        mov     [server_ip], 0
186
        pop     [pb.max]
-
 
187
        push    [eax + http_msg.content_received]
844
 
188
        pop     [pb.value]
Line 845... Line -...
845
        ret
-
 
846
 
189
 
847
;***************************************************************************
190
        invoke  progressbar_draw, pb
Line 848... Line -...
848
;   Function
-
 
849
;       append_proxy_auth_header
-
 
850
;
191
        jmp     download_loop
851
;   Description
192
 
852
;       Append header to HTTP request for proxy authentification
-
 
853
;
-
 
854
;***************************************************************************
-
 
Line 855... Line -...
855
append_proxy_auth_header:
-
 
856
        mov     esi, proxy_auth_basic
193
  .redraw:
857
        mov     ecx, proxy_auth_basic_end - proxy_auth_basic
-
 
Line 858... Line 194...
858
        rep     movsb
194
        call    draw_window
859
; base64-encode string :
195
        jmp     download_loop
860
        mov     esi, proxyUser
-
 
861
 
-
 
862
apah000:
196
 
863
        lodsb
-
 
864
        test    al, al
197
  .button:
865
        jz      apah001
-
 
Line 866... Line -...
866
        call    encode_base64_byte
-
 
867
        jmp     apah000
198
        jmp     http_free
868
 
199
 
869
apah001:
200
save_chunk:
870
        mov     al, ':'
201
        mov     ebp, [identifier]
871
        call    encode_base64_byte
-
 
872
        mov     esi, proxyPassword
202
        test    [ebp + http_msg.flags], 0xffff0000      ; error?
873
 
-
 
874
apah002:
-
 
Line 875... Line -...
875
        lodsb
-
 
876
        test    al, al
203
        jnz     http_free
Line -... Line 204...
-
 
204
 
877
        jz      apah003
205
        cmp     [fileinfo], 3
878
        call    encode_base64_byte
206
        je      @f
Line 879... Line -...
879
        jmp     apah002
-
 
880
 
-
 
881
apah003:
-
 
Line 882... Line -...
882
        call    encode_base64_final
-
 
Line -... Line 207...
-
 
207
        DEBUGF  1, "new file size=%u\n", [ebp + http_msg.content_length]
883
        ret
208
        mov     [fileinfo], 4                           ; set end of file
Line -... Line 209...
-
 
209
        mov     eax, [ebp + http_msg.content_length]
884
 
210
        mov     [fileinfo.offset], eax                  ; new file size
Line -... Line 211...
-
 
211
        mcall   70, fileinfo
885
encode_base64_byte:
212
 
886
        inc     ecx
213
        mov     [fileinfo], 3                           ; write to existing file
887
        shl     edx, 8
214
  @@:
Line 888... Line -...
888
        mov     dl, al
-
 
889
        cmp     ecx, 3
215
        mov     ecx, [ebp + http_msg.content_received]
890
        je      ebb001
216
        sub     ecx, [offset]
891
        ret
-
 
892
 
-
 
893
ebb001:
-
 
Line 894... Line -...
894
        shl     edx, 8
-
 
895
        inc     ecx
-
 
896
 
-
 
897
ebb002:
-
 
898
        rol     edx, 6
-
 
899
        xor     eax, eax
-
 
900
        xchg    al, dl
217
        mov     [fileinfo.size], ecx
901
        mov     al, [base64_table+eax]
218
        mov     eax, [ebp + http_msg.content_ptr]
902
        stosb
219
        mov     [fileinfo.buffer], eax
903
        loop    ebb002
220
        mov     ebx, [offset]
Line -... Line 221...
-
 
221
        mov     [fileinfo.offset], ebx
-
 
222
        DEBUGF  1, "Writing to disk: size=%u offset=%u\n", ecx, ebx
904
        ret
223
        mcall   70, fileinfo
Line -... Line 224...
-
 
224
 
-
 
225
        mov     eax, [ebp + http_msg.content_received]
-
 
226
        mov     [offset], eax
-
 
227
 
-
 
228
        test    [ebp + http_msg.flags], FLAG_GOT_ALL_DATA
-
 
229
        jz      download_loop
905
 
230
 
Line -... Line 231...
-
 
231
        mov     [pb.progress_color], 0x0000c800         ; green
-
 
232
 
-
 
233
http_free:
-
 
234
        mcall   40, EVM_REDRAW + EVM_BUTTON
906
encode_base64_final:
235
        push    [ebp + http_msg.content_received]
907
        mov     al, 0
236
        pop     [pb.value]
908
        test    ecx, ecx
237
 
909
        jz      ebf000
238
        mov     ecx, [ebp + http_msg.content_ptr]
910
        call    encode_base64_byte
239
        test    ecx, ecx
Line 911... Line 240...
911
        test    ecx, ecx
240
        jz      @f
912
        jz      ebf001
241
        mcall   68, 13                                  ; free the buffer
913
        call    encode_base64_byte
242
  @@:
Line 914... Line 243...
914
        mov     byte [edi-2], '='
243
 
915
 
244
        invoke  HTTP_free, [identifier]                 ; free headers and connection
916
ebf001:
245
 
-
 
246
        mov     [btn_text], sz_open
Line 917... Line 247...
917
        mov     byte [edi-1], '='
247
        call    draw_window
918
 
248
        jmp     mainloop
919
ebf000:
249
 
920
        ret
250
 
-
 
251
 
-
 
252
draw_window:
-
 
253
        mcall   12, 1   ; start window draw
-
 
254
 
-
 
255
; get system colors
-
 
256
        mcall   48, 3, sc, 40
Line 921... Line -...
921
 
-
 
922
;   *********************************************
-
 
923
;   *******  WINDOW DEFINITIONS AND DRAW ********
-
 
924
;   *********************************************
-
 
925
 
-
 
926
draw_window:
-
 
927
 
-
 
928
        mcall   12, 1
-
 
929
 
-
 
930
        mcall   48, 3, sc, 40 ;get system colors
-
 
931
 
-
 
932
        mov     edx, [sc.work]
-
 
933
        or      edx, 0x34000000
-
 
934
        mcall   0, <50, 370>, <350, 140>, , 0, title   ;draw window
-
 
Line -... Line 257...
-
 
257
 
-
 
258
; draw window
935
        
259
        mov     edx, [sc.work]
-
 
260
        or      edx, 0x34000000
936
        mov     ecx, [sc.work_text]
261
        mcall   0, <50, 320>, <350, 110>, , 0, title
-
 
262
 
Line 937... Line -...
937
        or      ecx, 80000000h
-
 
938
        mcall   4, <14, 14>, , type_pls ;"URL:"
-
 
939
 
-
 
940
        edit_boxes_set_sys_color edit1, editboxes_end, sc
263
; draw button
941
        stdcall [edit_box_draw], edit1
264
        mcall   8, <229,75>, <60,16>, 22, [sc.work_button]      ; download
Line 942... Line -...
942
 
-
 
943
; RELOAD
-
 
944
        mcall   8, <90, 68>, <54, 16>, 22, [sc.work_button]
265
 
945
; STOP
-
 
946
        mcall   , <166, 50>, <54, 16>, 24
266
; draw button text
947
; SAVE
-
 
948
        mcall   , <224, 54>, , 26
267
        mov     ecx, [sc.work_button_text]
949
; BUTTON TEXT
268
        or      ecx, 80000000h
950
        mov     ecx, [sc.work_button_text]
269
        mcall   4, <240,65>, , [btn_text]
951
        or      ecx, 80000000h
270
 
Line -... Line 271...
-
 
271
; draw editbox
-
 
272
        edit_boxes_set_sys_color edit1, editboxes_end, sc
-
 
273
        invoke  edit_box_draw, edit1
-
 
274
 
-
 
275
        cmp     [identifier], 0
-
 
276
        je     @f
952
        mcall   4, <102, 59>, , button_text
277
; draw progressbar
-
 
278
        invoke  progressbar_draw, pb
-
 
279
  @@:
-
 
280
        mcall   12, 2   ; end window draw
953
 
281
        ret
-
 
282
 
954
        mcall   12, 2 ; end window redraw
283
 
955
 
284
dont_draw:
956
        ret
285
 
-
 
286
        ret
-
 
287
 
957
 
288
;---------------------------------------------------------------------
-
 
289
; Data area
958
 
290
;-----------------------------------------------------------------------------
-
 
291
align   4
-
 
292
@IMPORT:
959
;-----------------------------------------------------------------------------
293
 
Line 960... Line -...
960
; Data area
-
 
961
;-----------------------------------------------------------------------------
294
library lib_http,       'http.obj', \
962
align   4
-
 
963
@IMPORT:
-
 
964
 
-
 
965
library libini, 'libini.obj', \
-
 
966
        box_lib, 'box_lib.obj', \
-
 
967
        network, 'network.obj'
-
 
968
 
-
 
969
import  libini, \
-
 
970
        ini.get_str, 'ini_get_str', \
-
 
971
        ini.get_int, 'ini_get_int'
-
 
972
 
295
        box_lib,        'box_lib.obj', \
973
import  box_lib, \
-
 
974
        edit_box_draw, 'edit_box', \
-
 
975
        edit_box_key, 'edit_box_key', \
296
        proc_lib,       'proc_lib.obj'
976
        edit_box_mouse, 'edit_box_mouse'
-
 
Line 977... Line 297...
977
 
297
 
-
 
298
import  lib_http, \
978
import  network,\
299
        HTTP_get,       'get', \
979
        getaddrinfo,    'getaddrinfo',\
300
        HTTP_receive,   'receive', \
-
 
301
        HTTP_free,      'free'
-
 
302
 
-
 
303
import  box_lib, \
980
        freeaddrinfo,   'freeaddrinfo',\
304
        edit_box_draw,    'edit_box', \
981
        inet_ntoa,      'inet_ntoa'
305
        edit_box_key,     'edit_box_key', \
-
 
306
        edit_box_mouse,   'edit_box_mouse', \
-
 
307
        progressbar_draw, 'progressbar_draw', \
-
 
308
        progressbar_prog, 'progressbar_progress'
-
 
309
 
Line 982... Line 310...
982
 
310
import  proc_lib, \
Line 983... Line 311...
983
;---------------------------------------------------------------------
311
        OpenDialog_Init,  'OpenDialog_init', \
Line 984... Line -...
984
fileinfo        dd 2, 0, 0
-
 
985
final_size      dd 0
-
 
986
final_buffer    dd 0
-
 
987
                db '/rd/1/.download', 0
312
        OpenDialog_Start, 'OpenDialog_start'
988
        
-
 
989
body_pos        dd 0
-
 
990
buf_size        dd 0
-
 
991
buf_ptr         dd 0
-
 
992
 
-
 
993
deba            dd 0
-
 
994
                db 0
-
 
995
 
-
 
996
;---------------------------------------------------------------------
-
 
997
 
-
 
998
mouse_dd        dd 0
-
 
999
edit1           edit_box 295, 48, 10, 0xffffff, 0xff, 0x80ff, 0, 0x8000, URLMAXLEN, document_user, mouse_dd, ed_focus+ed_always_focus, 7, 7
-
 
1000
editboxes_end:
-
 
1001
 
-
 
1002
;---------------------------------------------------------------------
-
 
1003
 
-
 
1004
include_debug_strings
-
 
Line 1005... Line 313...
1005
 
313
 
1006
;---------------------------------------------------------------------
-
 
-
 
314
 
1007
 
315
fileinfo        dd 2
-
 
316
  .offset       dd 0, 0
Line -... Line 317...
-
 
317
  .size         dd 0
-
 
318
  .buffer       dd 0
1008
type_pls        db 'URL:', 0
319
                db 0
1009
button_text     db 'DOWNLOAD     STOP     RESAVE', 0
320
                dd fname_buf
1010
download_complete db 'File saved as /rd/1/.download', 0
321
 
Line 1011... Line 322...
1011
title           db 'HTTP Downloader', 0
322
edit1           edit_box 299, 5, 10, 0xffffff, 0x0000ff, 0x0080ff, 0x000000, 0x8000, URLMAXLEN, url, mouse_dd, ed_focus+ed_always_focus, 0, 0
1012
 
-
 
1013
;---------------------------------------------------------------------
-
 
1014
s_contentlength db 'Content-Length:'
-