5,19 → 5,13 |
|
jmp wait_for_usercommand |
|
|
cmd_bye: |
|
; Send BYE message to the server |
mov dword[s], "BYE" + 13 shl 24 |
mov byte[s+4], 10 |
mcall send, [socketnum], s, 5, 0 |
mcall close, [socketnum] |
mcall close, [datasocket] |
|
; Close the control connection |
mcall close, [socketnum] |
jmp main |
|
|
cmd_pwd: |
|
mov dword[s], "PWD" + 13 shl 24 |
26,7 → 20,6 |
|
jmp wait_for_servercommand |
|
|
cmd_cwd: |
|
mov dword[s], "CWD " |
42,7 → 35,6 |
|
jmp wait_for_servercommand |
|
|
cmd_dele: |
|
mov dword[s], "DELE" |
59,8 → 51,8 |
|
jmp wait_for_servercommand |
|
cmd_list: |
|
cmd_list: |
call open_dataconnection |
|
mov [operation], OPERATION_LIST |
73,14 → 65,11 |
|
|
cmd_retr: |
|
call open_dataconnection |
|
; Create/open the file |
mov [operation], OPERATION_RETR |
|
mov esi, s+5 |
mov ecx, 256-5 |
call set_filename |
|
mov [filestruct.subfn], 2 ; create/rewrite file |
mov [filestruct.offset], 0 |
mov [filestruct.offset+4], 0 |
87,17 → 76,17 |
mov [filestruct.size], 0 |
mov [filestruct.ptr], 0 |
|
lea esi, [s+5] |
mov edi, filestruct.name |
mov ecx, 256-5 |
call set_filename |
|
mcall 70, filestruct |
cmp eax, -1 |
; je fileerror |
|
; Prepare to write to the file |
|
mov [filestruct.subfn], 3 ; write to file |
mov [operation], OPERATION_RETR |
|
; Request the file from server |
|
mov dword[s], "RETR" |
mov byte[s+4], " " |
|
106,10 → 95,9 |
mov edi, s |
repne scasb |
lea esi, [edi - s] |
mov dword[edi - 2], 0x0a0d |
mov word [edi - 2], 0x0a0d |
mcall send, [socketnum], s, , 0 |
|
invoke con_write_asciiz, s ; print command |
jmp wait_for_servercommand |
|
|
125,7 → 113,8 |
mov [filestruct.size], BUFFERSIZE |
mov [filestruct.ptr], buffer_ptr2 |
|
mov esi, s+5 |
lea esi, [s+5] |
mov edi, filestruct.name |
mov ecx, 256-5 |
call set_filename |
|
165,7 → 154,6 |
|
jmp wait_for_usercommand |
|
|
cmd_cdup: |
|
mov dword[s], "CDUP" |
174,7 → 162,6 |
|
jmp wait_for_servercommand |
|
|
cmd_rmd: |
|
mov dword[s], "RMD " |
190,7 → 177,6 |
|
jmp wait_for_servercommand |
|
|
cmd_mkd: |
|
mov dword[s], "MKD " |
207,15 → 193,18 |
jmp wait_for_servercommand |
|
|
|
; esi = source ptr |
; edi = dest ptr |
; ecx = max length of source buffer |
set_filename: |
|
mov edi, filestruct.name |
.loop: |
lodsb |
test al, al |
jz .done |
cmp al, ' ' |
je .done |
cmp al, 10 |
je .done |
stosb |
224,4 → 213,5 |
xor al, al ; append a 0 byte |
stosb |
|
ret |
ret |
|