Subversion Repositories Kolibri OS

Rev

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

Rev 3704 Rev 3789
Line 1... Line 1...
1
server_parser:
1
server_parser:
Line 2... Line 2...
2
 
2
 
3
; Commands are always 3 numbers and followed by a space
3
; Commands are always 3 numbers and followed by a space
4
; If a server decides it needs multiline output,
4
; If a server decides it needs multiline output,
5
; first lines will have a dash instead of space after numbers,
5
; first lines will have a dash instead of space after numbers,
Line 6... Line 6...
6
; thus they are simply ignored.
6
; thus they are simply ignored in this simple command parser.
7
 
7
 
Line 8... Line 8...
8
        cmp     dword[s], "150 "
8
        cmp     dword[s], "150 "
9
        je      data_ok
9
        je      data_ok
Line -... Line 10...
-
 
10
 
-
 
11
        cmp     dword[s], "220 "
-
 
12
        je      welcome
10
 
13
 
11
        cmp     dword[s], "220 "
14
        cmp     dword[s], "226 "
Line 12... Line 15...
12
        je      welcome
15
;        je      list_ok
13
 
16
 
Line 14... Line 17...
14
        cmp     dword[s], "227 "
17
        cmp     dword[s], "227 "
15
        je      pasv_ok
18
        je      pasv_ok
Line -... Line 19...
-
 
19
 
16
 
20
        cmp     dword[s], "230 "
-
 
21
        je      login_ok
-
 
22
 
-
 
23
        cmp     dword[s], "331 "
-
 
24
        je      pass
-
 
25
 
Line 17... Line 26...
17
        cmp     dword[s], "230 "
26
        cmp     dword[s], "421 "
Line 18... Line 27...
18
        je      login_ok
27
;        je      timeout
19
 
28
 
Line 20... Line 29...
20
        cmp     dword[s], "331 "
29
        cmp     dword[s], "530"         ; password incorrect
Line 21... Line 30...
21
        je      pass
30
        je      welcome
22
 
31
 
Line 23... Line 32...
23
        ret
32
        jmp     wait_for_usercommand
Line 24... Line 33...
24
 
33
 
25
 
34
 
Line 26... Line 35...
26
welcome:
35
welcome:
Line 27... Line 36...
27
 
36
 
Line 63... Line 72...
63
        mov     byte[sockaddr2.ip+2], bl
72
        mov     byte[sockaddr2.ip+2], bl
64
        call    ascii_dec
73
        call    ascii_dec
65
        mov     byte[sockaddr2.ip+3], bl
74
        mov     byte[sockaddr2.ip+3], bl
Line 66... Line 75...
66
 
75
 
67
        call    ascii_dec
-
 
68
        mov     byte[sockaddr2.port+1], bl
-
 
69
        call    ascii_dec
76
        call    ascii_dec
-
 
77
        mov     byte[sockaddr2.port+0], bl
-
 
78
        call    ascii_dec
Line 70... Line -...
70
        mov     byte[sockaddr2.port+0], bl
-
 
71
 
79
        mov     byte[sockaddr2.port+1], bl
72
        push    str_open
-
 
73
        call    [con_write_asciiz]
80
 
Line 74... Line 81...
74
 
81
        invoke  con_write_asciiz, str_open
75
        mcall   connect, [datasocket], sockaddr2, 18
82
        mcall   connect, [datasocket], sockaddr2, 18
Line 76... Line 83...
76
 
83
 
Line 77... Line 84...
77
  .fail:
84
  .fail:
78
        ret
85
        jmp     wait_for_servercommand
79
 
86
 
80
 
87
 
81
data_ok:
88
data_ok:
82
 
-
 
83
        mcall   recv, [datasocket], buffer_ptr, BUFFERSIZE, MSG_DONTWAIT   ; fixme: use other buffer
89
 
84
        inc     eax
-
 
-
 
90
        mcall   recv, [datasocket], buffer_ptr, BUFFERSIZE, MSG_DONTWAIT   ; fixme: use other buffer
85
        jz      .fail
91
        inc     eax
Line 86... Line 92...
86
        dec     eax
92
        jz      .fail
87
        jz      .fail
93
        dec     eax
-
 
94
        jz      .fail
Line 88... Line 95...
88
 
95
        mov     byte[buffer_ptr + eax], 0
Line 89... Line 96...
89
        mov     byte[buffer_ptr + eax], 0
96
 
90
        pushd   buffer_ptr
97
        invoke  con_write_asciiz, buffer_ptr
91
        call    [con_write_asciiz]
98
 
92
 
99
  .fail:
93
  .fail:
100
        mcall   close, [datasocket]
94
        ret
101
        jmp     wait_for_servercommand
95
 
102
 
96
 
103
 
97
ascii_dec:
104
ascii_dec:
98
 
105
 
99
        xor     ebx, ebx
106
        xor     ebx, ebx
100
        mov     cl, 3
107
        mov     cl, 4                   ; max length is 3 digits + 1 separator
101
  .loop:
108
  .loop:
Line 102... Line 109...
102
        lodsb
109
        lodsb