Subversion Repositories Kolibri OS

Rev

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

Rev 4207 Rev 4209
Line 85... Line 85...
85
;> eax = pointer to memory allocation routine                                ;;
85
;> eax = pointer to memory allocation routine                                ;;
86
;> ebx = pointer to memory freeing routine                                   ;;
86
;> ebx = pointer to memory freeing routine                                   ;;
87
;> ecx = pointer to memory reallocation routine                              ;;
87
;> ecx = pointer to memory reallocation routine                              ;;
88
;> edx = pointer to library loading routine                                  ;;
88
;> edx = pointer to library loading routine                                  ;;
89
;;---------------------------------------------------------------------------;;
89
;;---------------------------------------------------------------------------;;
90
;< eax = 1 (fail) / 0 (ok) (library initialization result)                   ;;
90
;< eax = 1 (fail) / 0 (ok)                                                   ;;
91
;;===========================================================================;;
91
;;===========================================================================;;
92
        mov     [mem.alloc], eax
92
        mov     [mem.alloc], eax
93
        mov     [mem.free], ebx
93
        mov     [mem.free], ebx
94
        mov     [mem.realloc], ecx
94
        mov     [mem.realloc], ecx
95
        mov     [dll.load], edx
95
        mov     [dll.load], edx
Line 96... Line 96...
96
 
96
 
97
        invoke  dll.load, @IMPORT
97
        invoke  dll.load, @IMPORT
98
        or      eax, eax
98
        test    eax, eax
Line 99... Line 99...
99
        jz      .ok
99
        jnz     .error
100
 
100
 
101
; load proxy settings
101
; load proxy settings
102
        invoke  ini.get_str, inifile, sec_proxy, key_proxy, proxyAddr, 256, proxyAddr
102
        invoke  ini.get_str, inifile, sec_proxy, key_proxy, proxyAddr, 256, proxyAddr
103
        invoke  ini.get_int, inifile, sec_proxy, key_proxyport, 80
103
        invoke  ini.get_int, inifile, sec_proxy, key_proxyport, 80
104
        mov     [proxyPort], eax
104
        mov     [proxyPort], eax
Line 105... Line 105...
105
        invoke  ini.get_str, inifile, sec_proxy, key_user, proxyUser, 256, proxyUser
105
        invoke  ini.get_str, inifile, sec_proxy, key_user, proxyUser, 256, proxyUser
106
        invoke  ini.get_str, inifile, sec_proxy, key_password, proxyPassword, 256, proxyPassword
-
 
107
 
106
        invoke  ini.get_str, inifile, sec_proxy, key_password, proxyPassword, 256, proxyPassword
Line 108... Line 107...
108
        xor     eax, eax
107
 
109
        inc     eax
108
        xor     eax, eax
110
        ret
109
        ret
Line -... Line 110...
-
 
110
 
Line 111... Line 111...
111
 
111
  .error:
Line 419... Line 419...
419
;< eax = -1 (not finished) / 0 finished                                                           ;;
419
;< eax = -1 (not finished) / 0 finished                                                           ;;
420
;;================================================================================================;;
420
;;================================================================================================;;
421
        pusha
421
        pusha
422
        mov     ebp, [identifier]
422
        mov     ebp, [identifier]
Line -... Line 423...
-
 
423
 
423
 
424
; If the connection is closed, return immediately
424
        test    [ebp + http_msg.flags], FLAG_CONNECTED
425
        test    [ebp + http_msg.flags], FLAG_CONNECTED
Line 425... Line 426...
425
        jz      .connection_closed
426
        jz      .connection_closed
426
 
427
 
427
; Receive some data
428
; Receive some data
428
        mcall   recv, [ebp + http_msg.socket], [ebp + http_msg.write_ptr], \
429
        mcall   recv, [ebp + http_msg.socket], [ebp + http_msg.write_ptr], \
429
                      [ebp + http_msg.buffer_length], MSG_DONTWAIT
430
                      [ebp + http_msg.buffer_length], MSG_DONTWAIT
430
        cmp     eax, 0xffffffff
431
        cmp     eax, 0xffffffff
Line -... Line 432...
-
 
432
        je      .check_socket
431
        je      .check_socket
433
        DEBUGF  1, "Received %u bytes\n", eax
432
        DEBUGF  1, "Received %u bytes\n", eax
434
 
433
 
435
; Update timestamp
434
        push    eax
436
        push    eax
Line 886... Line 888...
886
 
888
 
Line -... Line 889...
-
 
889
endp
-
 
890
 
-
 
891
 
-
 
892
 
-
 
893
;;================================================================================================;;
-
 
894
proc URI_escape URI ;/////////////////////////////////////////////////////////////////////////////;;
-
 
895
;;------------------------------------------------------------------------------------------------;;
-
 
896
;?                                                                                                ;;
-
 
897
;;------------------------------------------------------------------------------------------------;;
-
 
898
;> URI = ptr to ASCIIZ URI                                                                        ;;
-
 
899
;;------------------------------------------------------------------------------------------------;;
-
 
900
;< eax = 0 (error) / ptr to ASCIIZ URI                                                            ;;
-
 
901
;;================================================================================================;;
-
 
902
 
-
 
903
        pusha
-
 
904
 
-
 
905
        invoke  mem.alloc, URLMAXLEN
-
 
906
        test    eax, eax
-
 
907
        jz      .error
-
 
908
        mov     [esp + 7 * 4], eax              ; return ptr in eax
-
 
909
        mov     esi, [URI]
-
 
910
        mov     edi, eax
-
 
911
        xor     ebx, ebx
-
 
912
        xor     ecx, ecx
-
 
913
  .loop:
-
 
914
        lodsb
-
 
915
        test    al, al
-
 
916
        jz      .done
-
 
917
 
-
 
918
        mov     cl, al
-
 
919
        and     cl, 0x1f
-
 
920
        mov     bl, al
-
 
921
        shr     bl, 5
-
 
922
        bt      dword[bits_must_escape + ebx], ecx
-
 
923
        jc      .escape
-
 
924
 
-
 
925
        stosb
-
 
926
        jmp     .loop
-
 
927
 
-
 
928
  .escape:
-
 
929
        mov     al, '%'
-
 
930
        stosb
-
 
931
        mov     bl, byte[esi-1]
-
 
932
        shr     bl, 4
-
 
933
        mov     al, byte[str_hex + ebx]
-
 
934
        stosb
-
 
935
        mov     bl, byte[esi-1]
-
 
936
        and     bl, 0x0f
-
 
937
        mov     al, byte[str_hex + ebx]
-
 
938
        stosb
-
 
939
        jmp     .loop
-
 
940
 
-
 
941
 
-
 
942
  .done:
-
 
943
        stosb
-
 
944
 
-
 
945
        popa
-
 
946
        ret
-
 
947
 
-
 
948
  .error:
-
 
949
        popa
-
 
950
        xor     eax, eax
-
 
951
        ret
-
 
952
 
-
 
953
endp
-
 
954
 
-
 
955
 
-
 
956
 
-
 
957
;;================================================================================================;;
-
 
958
proc URI_unescape URI ;///////////////////////////////////////////////////////////////////////////;;
-
 
959
;;------------------------------------------------------------------------------------------------;;
-
 
960
;?                                                                                                ;;
-
 
961
;;------------------------------------------------------------------------------------------------;;
-
 
962
;> URI = ptr to ASCIIZ URI                                                                        ;;
-
 
963
;;------------------------------------------------------------------------------------------------;;
-
 
964
;< eax = 0 (error) / ptr to ASCIIZ URI                                                            ;;
-
 
965
;;================================================================================================;;
-
 
966
 
-
 
967
        pusha
-
 
968
 
-
 
969
        invoke  mem.alloc, URLMAXLEN
-
 
970
        test    eax, eax
-
 
971
        jz      .error
-
 
972
        mov     [esp + 7 * 4], eax              ; return ptr in eax
-
 
973
        mov     esi, [URI]
-
 
974
        mov     edi, eax
-
 
975
  .loop:
-
 
976
        lodsb
-
 
977
        test    al, al
-
 
978
        jz      .done
-
 
979
 
-
 
980
        cmp     al, '%'
-
 
981
        je      .unescape
-
 
982
 
-
 
983
        stosb
-
 
984
        jmp     .loop
-
 
985
 
-
 
986
  .unescape:
-
 
987
        xor     ebx, ebx
-
 
988
        xor     ecx, ecx
-
 
989
  .unescape_nibble:
-
 
990
        lodsb
-
 
991
        sub     al, '0'
-
 
992
        jb      .fail
-
 
993
        cmp     al, 9
-
 
994
        jbe     .nibble_ok
-
 
995
        sub     al, 'A' - '0' - 10
-
 
996
        jb      .fail
-
 
997
        cmp     al, 15
-
 
998
        jbe     .nibble_ok
-
 
999
        sub     al, 'a' - 'A'
-
 
1000
        cmp     al, 15
-
 
1001
        ja      .fail
-
 
1002
  .nibble_ok:
-
 
1003
        shl     bl, 8
-
 
1004
        or      bl, al
-
 
1005
        dec     ecx
-
 
1006
        jc      .unescape_nibble
-
 
1007
        mov     al, bl
-
 
1008
        stosb
-
 
1009
        jmp     .loop
-
 
1010
 
-
 
1011
  .fail:
-
 
1012
        DEBUGF  1, "ERROR: invalid URI!\n"
-
 
1013
        jmp     .loop
-
 
1014
 
-
 
1015
  .done:
-
 
1016
        stosb
-
 
1017
 
-
 
1018
        popa
-
 
1019
        ret
-
 
1020
 
-
 
1021
  .error:
-
 
1022
        popa
-
 
1023
        xor     eax, eax
-
 
1024
        ret
-
 
1025
 
Line 887... Line 1026...
887
endp
1026
endp
888
 
1027
 
889
 
1028
 
Line 1159... Line 1298...
1159
        HTTP_head               , 'head'                , \
1298
        HTTP_head               , 'head'                , \
1160
        HTTP_post               , 'post'                , \
1299
        HTTP_post               , 'post'                , \
1161
        find_header_field       , 'find_header_field'   , \
1300
        find_header_field       , 'find_header_field'   , \
1162
        HTTP_process            , 'process'             , \
1301
        HTTP_process            , 'process'             , \
1163
        HTTP_free               , 'free'                , \
1302
        HTTP_free               , 'free'                , \
1164
        HTTP_stop               , 'stop'
1303
        HTTP_stop               , 'stop'                , \
-
 
1304
        URI_escape              , 'escape'              , \
-
 
1305
        URI_unescape            , 'unescape'
Line 1165... Line 1306...
1165
 
1306
 
1166
;        HTTP_put                , 'put'                 , \
1307
;        HTTP_put                , 'put'                 , \
1167
;        HTTP_delete             , 'delete'              , \
1308
;        HTTP_delete             , 'delete'              , \
1168
;        HTTP_trace              , 'trace'               , \
1309
;        HTTP_trace              , 'trace'               , \
Line 1199... Line 1340...
1199
str_te          db 'transfer-encoding', 0
1340
str_te          db 'transfer-encoding', 0
1200
str_get         db 'GET ', 0
1341
str_get         db 'GET ', 0
1201
str_head        db 'HEAD ', 0
1342
str_head        db 'HEAD ', 0
1202
str_post        db 'POST ', 0
1343
str_post        db 'POST ', 0
Line -... Line 1344...
-
 
1344
 
-
 
1345
bits_must_escape:
-
 
1346
dd      0xffffffff                                                      ; 00-1F
-
 
1347
dd      1 shl 0 + 1 shl 2 + 1 shl 3 + 1 shl 5 + 1 shl 28 + 1 shl 30     ; "#%<>
-
 
1348
dd      1 shl 27 + 1 shl 28 + 1 shl 29 + 1 shl 30                       ;[\]^
-
 
1349
dd      1 shl 0 + 1 shl 27 + 1 shl 28 + 1 shl 29 + 1 shl 31             ;`{|} DEL
-
 
1350
 
-
 
1351
dd      0xffffffff
-
 
1352
dd      0xffffffff
-
 
1353
dd      0xffffffff
-
 
1354
dd      0xffffffff
-
 
1355
 
-
 
1356
str_hex:
-
 
1357
db '0123456789ABCDEF'
1203
 
1358
 
Line 1204... Line 1359...
1204
include_debug_strings
1359
include_debug_strings
1205
 
1360
 
1206
; uninitialized data
1361
; uninitialized data