Subversion Repositories Kolibri OS

Rev

Rev 3813 | Rev 4922 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3701 hidnplayr 1
cmd_help:
2
 
3
        push    str_help
4
        call    [con_write_asciiz]
5
 
3790 hidnplayr 6
        jmp     wait_for_usercommand
7
 
3800 hidnplayr 8
cmd_bye:
9
 
10
        mcall   close, [socketnum]
11
        mcall   close, [datasocket]
12
 
13
        jmp     main
14
 
3794 hidnplayr 15
cmd_pwd:
16
 
3814 hidnplayr 17
        mov     dword[s], "PWD" + 13 shl 24
18
        mov     byte[s+4], 10
19
        mcall   send, [socketnum], s, 5, 0
3794 hidnplayr 20
 
21
        jmp     wait_for_servercommand
22
 
3790 hidnplayr 23
cmd_cwd:
24
 
25
        mov     dword[s], "CWD "
26
 
27
        mov     ecx, 256
28
        xor     al, al
29
        mov     edi, s
30
        repne scasb
3814 hidnplayr 31
        lea     esi, [edi - s]
32
        mov     word [edi - 2], 0x0a0d
3790 hidnplayr 33
 
34
        mcall   send, [socketnum], s, , 0
35
 
3793 hidnplayr 36
        jmp     wait_for_servercommand
37
 
3800 hidnplayr 38
cmd_dele:
3793 hidnplayr 39
 
3800 hidnplayr 40
        mov     dword[s], "DELE"
41
        mov     byte[s], " "
42
 
43
        mov     ecx, 256
44
        xor     al, al
45
        mov     edi, s
46
        repne scasb
3814 hidnplayr 47
        lea     esi, [edi - s]
48
        mov     word [edi - 2], 0x0a0d
3800 hidnplayr 49
 
50
        mcall   send, [socketnum], s, , 0
51
 
52
        jmp     wait_for_servercommand
53
 
54
cmd_list:
55
 
56
        call    open_dataconnection
57
 
58
        mov     [operation], OPERATION_LIST
59
 
60
        mov     dword[s], "LIST"
3814 hidnplayr 61
        mov     word[s+4], 0x0a0d
62
        mcall   send, [socketnum], s, 6, 0
3800 hidnplayr 63
 
64
        jmp     wait_for_servercommand
65
 
66
 
3793 hidnplayr 67
cmd_retr:
68
 
69
        call    open_dataconnection
70
 
3800 hidnplayr 71
        mov     [operation], OPERATION_RETR
72
 
73
        mov     [filestruct.subfn], 2   ; create/rewrite file
74
        mov     [filestruct.offset], 0
75
        mov     [filestruct.offset+4], 0
76
        mov     [filestruct.size], 0
77
        mov     [filestruct.ptr], 0
78
 
79
        lea     esi, [s+5]
80
        mov     edi, filestruct.name
81
        mov     ecx, 256-5
82
        call    set_filename
83
 
84
        mcall   70, filestruct
85
        cmp     eax, -1
86
;        je      fileerror
87
 
88
        mov     [filestruct.subfn], 3   ; write to file
89
 
3793 hidnplayr 90
        mov     dword[s], "RETR"
91
        mov     byte[s+4], " "
92
 
93
        mov     ecx, 256
94
        xor     al, al
95
        mov     edi, s
96
        repne scasb
3814 hidnplayr 97
        lea     esi, [edi - s]
98
        mov     word [edi - 2], 0x0a0d
3793 hidnplayr 99
        mcall   send, [socketnum], s, , 0
100
 
101
        jmp     wait_for_servercommand
102
 
103
 
104
cmd_stor:
105
 
106
        call    open_dataconnection
107
 
3800 hidnplayr 108
        mov     [operation], OPERATION_STOR
109
 
110
        mov     [filestruct.subfn], 0   ; read file
111
        mov     [filestruct.offset], 0
112
        mov     [filestruct.offset+4], 0
113
        mov     [filestruct.size], BUFFERSIZE
114
        mov     [filestruct.ptr], buffer_ptr2
115
 
116
        lea     esi, [s+5]
117
        mov     edi, filestruct.name
118
        mov     ecx, 256-5
119
        call    set_filename
120
 
3793 hidnplayr 121
        mov     dword[s], "STOR"
122
        mov     byte[s+4], " "
123
 
124
        mov     ecx, 256
125
        xor     al, al
126
        mov     edi, s
127
        repne scasb
3814 hidnplayr 128
        lea     esi, [edi - s]
129
        mov     word [edi - 2], 0x0a0d
3793 hidnplayr 130
        mcall   send, [socketnum], s, , 0
131
 
3800 hidnplayr 132
        jmp     wait_for_servercommand
133
 
134
 
3802 hidnplayr 135
cmd_lcwd:
3800 hidnplayr 136
 
3802 hidnplayr 137
        mov     esi, s+5
138
        mov     ecx, 256-5
139
  .loop:
140
        lodsb
141
        cmp     al, 10
142
        je      .done
143
        test    al, al
144
        je      .done
145
        loop    .loop
146
  .done:
147
        mov     byte[esi-1], 0
148
        mcall   30, 1, s+5              ; set working directory
149
        mcall   30, 2, s, 256           ; and read it again
150
 
151
        invoke  con_write_asciiz, str_lcwd
152
        invoke  con_write_asciiz, s
3813 hidnplayr 153
        invoke  con_write_asciiz, str_newline
3802 hidnplayr 154
 
155
        jmp     wait_for_usercommand
156
 
3804 hidnplayr 157
cmd_cdup:
3802 hidnplayr 158
 
3804 hidnplayr 159
        mov     dword[s], "CDUP"
3814 hidnplayr 160
        mov     word[s+4], 0x0d0a
161
        mcall   send, [socketnum], s, 6, 0
3802 hidnplayr 162
 
3804 hidnplayr 163
        jmp     wait_for_servercommand
164
 
165
cmd_rmd:
166
 
167
        mov     dword[s], "RMD "
168
 
169
        mov     ecx, 256
170
        xor     al, al
171
        mov     edi, s
172
        repne scasb
3814 hidnplayr 173
        lea     esi, [edi - s]
174
        mov     word [edi - 2], 0x0a0d
3804 hidnplayr 175
 
176
        mcall   send, [socketnum], s, , 0
177
 
178
        jmp     wait_for_servercommand
179
 
180
cmd_mkd:
181
 
182
        mov     dword[s], "MKD "
183
 
184
        mov     ecx, 256
185
        xor     al, al
186
        mov     edi, s
187
        repne scasb
3814 hidnplayr 188
        lea     esi, [edi - s]
189
        mov     word [edi - 2], 0x0a0d
3804 hidnplayr 190
 
191
        mcall   send, [socketnum], s, , 0
192
 
193
        jmp     wait_for_servercommand
194
 
195
 
196
 
3800 hidnplayr 197
; esi   = source ptr
198
; edi   = dest ptr
199
; ecx   = max length of source buffer
200
set_filename:
201
 
202
  .loop:
203
        lodsb
204
        test    al, al
205
        jz      .done
206
        cmp     al, ' '
207
        je      .done
208
        cmp     al, 10
209
        je      .done
210
        stosb
211
        loop    .loop
212
  .done:
213
        xor     al, al          ; append a 0 byte
214
        stosb
215
 
216
        ret
217