Subversion Repositories Kolibri OS

Rev

Rev 5011 | 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
 
4920 hidnplayr 8
 
3800 hidnplayr 9
cmd_bye:
10
 
4920 hidnplayr 11
; Send BYE message to the server
4922 ashmew2 12
        mov     dword[buf_cmd], "BYE" + 13 shl 24
13
        mov     byte[buf_cmd+4], 10
5011 hidnplayr 14
        mcall   send, [controlsocket], buf_cmd, 5, 0
4920 hidnplayr 15
 
16
; Close the control connection
5011 hidnplayr 17
        mcall   close, [controlsocket]
6582 nisargshah 18
        ijmp    eax, interface_addr, interface.server_addr
3800 hidnplayr 19
 
4920 hidnplayr 20
 
3794 hidnplayr 21
cmd_pwd:
22
 
4922 ashmew2 23
        mov     dword[buf_cmd], "PWD" + 13 shl 24
24
        mov     byte[buf_cmd+4], 10
5011 hidnplayr 25
        mcall   send, [controlsocket], buf_cmd, 5, 0
3794 hidnplayr 26
 
27
        jmp     wait_for_servercommand
28
 
4920 hidnplayr 29
 
3790 hidnplayr 30
cmd_cwd:
31
 
4922 ashmew2 32
        mov     dword[buf_cmd], "CWD "
3790 hidnplayr 33
 
34
        mov     ecx, 256
35
        xor     al, al
4922 ashmew2 36
        mov     edi, buf_cmd
3790 hidnplayr 37
        repne scasb
4922 ashmew2 38
        lea     esi, [edi - buf_cmd]
3814 hidnplayr 39
        mov     word [edi - 2], 0x0a0d
3790 hidnplayr 40
 
5011 hidnplayr 41
        mcall   send, [controlsocket], buf_cmd, , 0
3790 hidnplayr 42
 
3793 hidnplayr 43
        jmp     wait_for_servercommand
44
 
4920 hidnplayr 45
 
3800 hidnplayr 46
cmd_dele:
3793 hidnplayr 47
 
4922 ashmew2 48
        mov     dword[buf_cmd], "DELE"
6582 nisargshah 49
        mov     byte[buf_cmd+4], " "
3800 hidnplayr 50
 
51
        mov     ecx, 256
52
        xor     al, al
4922 ashmew2 53
        mov     edi, buf_cmd
3800 hidnplayr 54
        repne scasb
4922 ashmew2 55
        lea     esi, [edi - buf_cmd]
3814 hidnplayr 56
        mov     word [edi - 2], 0x0a0d
3800 hidnplayr 57
 
5011 hidnplayr 58
        mcall   send, [controlsocket], buf_cmd, , 0
3800 hidnplayr 59
 
60
        jmp     wait_for_servercommand
61
 
4920 hidnplayr 62
 
3800 hidnplayr 63
cmd_list:
64
        call    open_dataconnection
65
 
66
        mov     [operation], OPERATION_LIST
67
 
4922 ashmew2 68
        mov     dword[buf_cmd], "LIST"
69
        mov     word[buf_cmd+4], 0x0a0d
5011 hidnplayr 70
        mcall   send, [controlsocket], buf_cmd, 6, 0
3800 hidnplayr 71
 
72
        jmp     wait_for_servercommand
73
 
74
 
3793 hidnplayr 75
cmd_retr:
76
        call    open_dataconnection
4920 hidnplayr 77
 
78
; Create/open the file
6582 nisargshah 79
; TODO: check beforehand if the disk has enough free space available to store the file
3793 hidnplayr 80
 
4922 ashmew2 81
        mov     esi, buf_cmd+5
4920 hidnplayr 82
        mov     ecx, 256-5
83
        call    set_filename
3800 hidnplayr 84
 
85
        mov     [filestruct.subfn], 2   ; create/rewrite file
86
        mov     [filestruct.offset], 0
87
        mov     [filestruct.offset+4], 0
88
        mov     [filestruct.size], 0
89
        mov     [filestruct.ptr], 0
90
 
91
        mcall   70, filestruct
6582 nisargshah 92
        test    eax, eax
93
        jz      @f
94
        call    error_fs
95
        jmp     close_datacon
96
      @@:
4920 hidnplayr 97
; Prepare to write to the file
98
 
3800 hidnplayr 99
        mov     [filestruct.subfn], 3   ; write to file
4920 hidnplayr 100
        mov     [operation], OPERATION_RETR
3800 hidnplayr 101
 
4920 hidnplayr 102
; Request the file from server
4922 ashmew2 103
 
104
        mov     dword[buf_cmd], "RETR"
105
        mov     byte[buf_cmd+4], " "
4920 hidnplayr 106
 
3793 hidnplayr 107
        mov     ecx, 256
108
        xor     al, al
4922 ashmew2 109
        mov     edi, buf_cmd
3793 hidnplayr 110
        repne scasb
4922 ashmew2 111
        lea     esi, [edi - buf_cmd]
4920 hidnplayr 112
        mov     dword[edi - 2], 0x0a0d
5011 hidnplayr 113
        mcall   send, [controlsocket], buf_cmd, , 0
3793 hidnplayr 114
 
6582 nisargshah 115
        icall   eax, interface_addr, interface.print, buf_cmd
3793 hidnplayr 116
        jmp     wait_for_servercommand
117
 
4922 ashmew2 118
cmd_rdir:
3793 hidnplayr 119
 
4922 ashmew2 120
        mov     [operation], OPERATION_RDIR
121
 
122
; Request filename list from the server
123
 
5011 hidnplayr 124
        call    open_dataconnection
125
 
126
        mov     [ptr_fname], 0
127
        mov     [size_fname], 0
4922 ashmew2 128
        mov     dword[buf_cmd], "NLST"
129
        mov     word[buf_cmd+4], 0x0a0d
5011 hidnplayr 130
        mcall   send, [controlsocket], buf_cmd, 6, 0
4922 ashmew2 131
 
5011 hidnplayr 132
        jmp     wait_for_servercommand
133
 
3793 hidnplayr 134
cmd_stor:
135
 
136
        call    open_dataconnection
137
 
3800 hidnplayr 138
        mov     [operation], OPERATION_STOR
139
 
6582 nisargshah 140
        ; get file size
141
        mov     [filestruct.subfn], 5
3800 hidnplayr 142
        mov     [filestruct.offset], 0
143
        mov     [filestruct.offset+4], 0
6582 nisargshah 144
        mov     [filestruct.size], 0
145
        mov     [filestruct.ptr], folder_buf
3800 hidnplayr 146
 
4922 ashmew2 147
        mov     esi, buf_cmd+5
3800 hidnplayr 148
        mov     ecx, 256-5
149
        call    set_filename
150
 
6582 nisargshah 151
        mcall   70, filestruct
152
 
153
        mov     eax, dword[folder_buf+32] ; supports file size upto 4GB
154
        mov     [file_size], eax
155
 
156
        mov     [filestruct.subfn], 0   ; read file
157
        ; mov     [filestruct.offset], 0
158
        ; mov     [filestruct.offset+4], 0
159
        mov     [filestruct.size], BUFFERSIZE
160
        mov     [filestruct.ptr], buf_buffer2
161
 
4922 ashmew2 162
        mov     dword[buf_cmd], "STOR"
163
        mov     byte[buf_cmd+4], " "
3793 hidnplayr 164
 
165
        mov     ecx, 256
166
        xor     al, al
4922 ashmew2 167
        mov     edi, buf_cmd
3793 hidnplayr 168
        repne scasb
4922 ashmew2 169
        lea     esi, [edi - buf_cmd]
3814 hidnplayr 170
        mov     word [edi - 2], 0x0a0d
5011 hidnplayr 171
        mcall   send, [controlsocket], buf_cmd, , 0
3793 hidnplayr 172
 
3800 hidnplayr 173
        jmp     wait_for_servercommand
174
 
175
 
3802 hidnplayr 176
cmd_lcwd:
3800 hidnplayr 177
 
4922 ashmew2 178
        mov     esi, buf_cmd+5
5011 hidnplayr 179
        cmp     byte[esi], 10
180
        je      .print
3802 hidnplayr 181
        mov     ecx, 256-5
182
  .loop:
183
        lodsb
184
        cmp     al, 10
6582 nisargshah 185
        je      .check
3802 hidnplayr 186
        test    al, al
6582 nisargshah 187
        je      .check
3802 hidnplayr 188
        loop    .loop
6582 nisargshah 189
 
190
  .check:
3802 hidnplayr 191
        mov     byte[esi-1], 0
6582 nisargshah 192
 
193
        ; check whether entered path is valid (folder exists)
194
        mov     [filestruct2.subfn], 5
195
        mov     [filestruct2.offset], 0
196
        mov     [filestruct2.size], 0
197
        mov     [filestruct2.ptr], folder_buf
198
        mov     [filestruct2.name], buf_cmd+5
199
        mcall   70, filestruct2
200
        test    eax, eax
201
        jz      @f
202
        cmp     eax, 2
203
        je      @f
204
        call    error_fs
205
        jmp     wait_for_usercommand
206
 
207
  @@:
4922 ashmew2 208
        mcall   30, 1, buf_cmd+5              ; set working directory
6582 nisargshah 209
 
5011 hidnplayr 210
  .print:
4922 ashmew2 211
        mcall   30, 2, buf_cmd, 256           ; and read it again
6582 nisargshah 212
        icall   eax, interface_addr, interface.print, str_lcwd, buf_cmd, str_newline
3802 hidnplayr 213
 
214
        jmp     wait_for_usercommand
215
 
4920 hidnplayr 216
 
3804 hidnplayr 217
cmd_cdup:
3802 hidnplayr 218
 
4922 ashmew2 219
        mov     dword[buf_cmd], "CDUP"
6582 nisargshah 220
        mov     word[buf_cmd+4], 0x0a0d
5011 hidnplayr 221
        mcall   send, [controlsocket], buf_cmd, 6, 0
3802 hidnplayr 222
 
3804 hidnplayr 223
        jmp     wait_for_servercommand
224
 
4920 hidnplayr 225
 
3804 hidnplayr 226
cmd_rmd:
227
 
4922 ashmew2 228
        mov     dword[buf_cmd], "RMD "
3804 hidnplayr 229
 
230
        mov     ecx, 256
231
        xor     al, al
4922 ashmew2 232
        mov     edi, buf_cmd
3804 hidnplayr 233
        repne scasb
4922 ashmew2 234
        lea     esi, [edi - buf_cmd]
3814 hidnplayr 235
        mov     word [edi - 2], 0x0a0d
3804 hidnplayr 236
 
5011 hidnplayr 237
        mcall   send, [controlsocket], buf_cmd, , 0
3804 hidnplayr 238
 
239
        jmp     wait_for_servercommand
240
 
4920 hidnplayr 241
 
3804 hidnplayr 242
cmd_mkd:
243
 
4922 ashmew2 244
        mov     dword[buf_cmd], "MKD "
3804 hidnplayr 245
 
246
        mov     ecx, 256
247
        xor     al, al
4922 ashmew2 248
        mov     edi, buf_cmd
3804 hidnplayr 249
        repne scasb
4922 ashmew2 250
        lea     esi, [edi - buf_cmd]
3814 hidnplayr 251
        mov     word [edi - 2], 0x0a0d
3804 hidnplayr 252
 
5011 hidnplayr 253
        mcall   send, [controlsocket], buf_cmd, , 0
3804 hidnplayr 254
 
255
        jmp     wait_for_servercommand
256
 
257
 
6582 nisargshah 258
cmd_abor:
259
 
260
        mcall   close, [datasocket]
261
        jmp     wait_for_servercommand
262
 
263
 
3800 hidnplayr 264
; esi   = source ptr
265
; ecx   = max length of source buffer
266
set_filename:
267
 
4920 hidnplayr 268
        mov     edi, filestruct.name
3800 hidnplayr 269
  .loop:
270
        lodsb
271
        test    al, al
272
        jz      .done
273
        cmp     al, 10
274
        je      .done
275
        stosb
276
        loop    .loop
277
  .done:
278
        xor     al, al          ; append a 0 byte
279
        stosb
280
 
4920 hidnplayr 281
        ret