2013-06-24 23:33:16 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2018-02-26 19:21:06 +03:00
|
|
|
;; Copyright (C) KolibriOS team 2013-2018. All rights reserved. ;;
|
2013-06-24 23:33:16 +04:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;; ftpc.asm - FTP client for KolibriOS ;;
|
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
2016-10-07 20:11:07 +03:00
|
|
|
;; Modified by nisargshah323@gmail.com (2016) ;;
|
2013-06-24 23:33:16 +04:00
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
format binary as ""
|
|
|
|
|
2014-05-07 11:31:49 +04:00
|
|
|
TIMEOUT = 3 ; seconds
|
|
|
|
|
2013-07-10 13:37:01 +04:00
|
|
|
BUFFERSIZE = 4096
|
2013-06-24 23:33:16 +04:00
|
|
|
|
|
|
|
STATUS_CONNECTING = 0
|
|
|
|
STATUS_CONNECTED = 1
|
|
|
|
STATUS_NEEDPASSWORD = 2
|
|
|
|
STATUS_LOGGED_IN = 3
|
|
|
|
|
2013-07-13 12:50:07 +04:00
|
|
|
OPERATION_NONE = 0
|
|
|
|
OPERATION_LIST = 1
|
|
|
|
OPERATION_RETR = 2
|
|
|
|
OPERATION_STOR = 3
|
2014-07-27 00:36:31 +04:00
|
|
|
OPERATION_RDIR = 4
|
|
|
|
|
2013-06-24 23:33:16 +04:00
|
|
|
use32
|
|
|
|
; standard header
|
|
|
|
db 'MENUET01' ; signature
|
|
|
|
dd 1 ; header version
|
|
|
|
dd start ; entry point
|
|
|
|
dd i_end ; initialized size
|
|
|
|
dd mem+0x1000 ; required memory
|
|
|
|
dd mem+0x1000 ; stack pointer
|
2014-05-12 03:42:10 +04:00
|
|
|
dd buf_cmd ; parameters
|
2014-07-27 00:36:31 +04:00
|
|
|
dd path ; path
|
2013-06-24 23:33:16 +04:00
|
|
|
|
|
|
|
include '../../macros.inc'
|
2016-10-07 20:11:07 +03:00
|
|
|
macro ijmp reg, addr, method
|
|
|
|
{
|
|
|
|
mov reg, [addr]
|
|
|
|
add reg, [method]
|
|
|
|
jmp dword[reg]
|
|
|
|
}
|
|
|
|
macro icall reg, addr, method, [arg]
|
|
|
|
{
|
|
|
|
mov reg, [addr]
|
|
|
|
add reg, [method]
|
|
|
|
if ~ arg eq
|
|
|
|
pushd arg
|
|
|
|
end if
|
|
|
|
call dword[reg]
|
|
|
|
}
|
|
|
|
|
2013-06-24 23:33:16 +04:00
|
|
|
purge mov,add,sub
|
2016-10-07 20:11:07 +03:00
|
|
|
|
2013-06-24 23:33:16 +04:00
|
|
|
include '../../proc32.inc'
|
|
|
|
include '../../network.inc'
|
2018-02-26 19:21:06 +03:00
|
|
|
include '../../KOSfuncs.inc'
|
2016-10-07 20:11:07 +03:00
|
|
|
|
|
|
|
include 'console.inc'
|
|
|
|
include 'gui.inc'
|
|
|
|
include 'login_gui.inc'
|
2013-06-24 23:33:16 +04:00
|
|
|
include 'usercommands.inc'
|
|
|
|
include 'servercommands.inc'
|
2016-04-12 15:24:28 +03:00
|
|
|
include 'parser.inc'
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
; TODO: Add Pasta support to FTPC
|
|
|
|
|
|
|
|
;;================================================================================================;;
|
|
|
|
start: ;//////////////////////////////////////////////////////////////////////////////////////////;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;? Program entry point - initialize heap, load libraries and settings ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;> ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;< none ;;
|
|
|
|
;;================================================================================================;;
|
2014-05-12 03:42:10 +04:00
|
|
|
; initialize heap for using dynamic blocks
|
2017-01-19 20:48:18 +03:00
|
|
|
mcall 68, 11
|
|
|
|
test eax, eax
|
2014-07-27 00:36:31 +04:00
|
|
|
je exit2
|
|
|
|
|
2014-05-07 11:31:49 +04:00
|
|
|
; disable all events except network event
|
|
|
|
mcall 40, EV_STACK
|
2013-06-24 23:33:16 +04:00
|
|
|
; load libraries
|
|
|
|
stdcall dll.Load, @IMPORT
|
|
|
|
test eax, eax
|
|
|
|
jnz exit
|
2014-07-27 00:36:31 +04:00
|
|
|
; find path to main settings file (ftpc.ini)
|
|
|
|
mov edi, path ; Calculate the length of zero-terminated string
|
|
|
|
xor al, al
|
|
|
|
mov ecx, 1024
|
|
|
|
repne scasb
|
|
|
|
dec edi
|
|
|
|
mov esi, str_ini ; append it with '.ini', 0
|
|
|
|
movsd
|
|
|
|
movsb
|
|
|
|
; get settings from ini
|
|
|
|
invoke ini.get_str, path, str_active, str_ip, str_active_ip, 16, 0
|
|
|
|
mov esi, str_active_ip
|
|
|
|
.ip_loop:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .ip_ok
|
|
|
|
cmp al, ' '
|
|
|
|
je .ip_ok
|
|
|
|
cmp al, '.'
|
|
|
|
jne .ip_loop
|
|
|
|
mov byte[esi-1], ','
|
|
|
|
jmp .ip_loop
|
|
|
|
.ip_ok:
|
|
|
|
mov byte[esi-1], 0
|
|
|
|
|
|
|
|
invoke ini.get_int, path, str_active, str_port_start, 64000
|
|
|
|
mov [acti_port_start], ax
|
|
|
|
|
|
|
|
invoke ini.get_int, path, str_active, str_port_stop, 65000
|
|
|
|
mov [acti_port_stop], ax
|
|
|
|
|
|
|
|
invoke ini.get_str, path, str_general, str_dir, buf_buffer1, BUFFERSIZE, 0
|
|
|
|
mcall 30, 1, buf_buffer1 ; set working directory
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
; initialize log file
|
|
|
|
invoke ini.get_str, path, str_general, str_logfile, log_file, 512, 0
|
|
|
|
mov [filestruct2.subfn], 2
|
|
|
|
mov [filestruct2.offset], 0
|
|
|
|
mov [filestruct2.size], 0
|
|
|
|
mov [filestruct2.ptr], 0
|
|
|
|
mov [filestruct2.name], log_file
|
|
|
|
mcall 70, filestruct2
|
|
|
|
|
|
|
|
; Usage: ftpc [-cli] [ftp://username:password@server:port/path]
|
|
|
|
|
|
|
|
; mov dword[buf_cmd], '-cli' ;;;; to test CLI ;;;;;
|
|
|
|
|
|
|
|
cmp byte[buf_cmd], 0
|
|
|
|
jne @f
|
|
|
|
mov [interface_addr], gui
|
|
|
|
jmp .args_ok
|
|
|
|
@@: cmp dword[buf_cmd], '-cli'
|
|
|
|
jne .error
|
|
|
|
mov [interface_addr], console
|
|
|
|
jmp .args_ok
|
|
|
|
|
|
|
|
.args_ok:
|
|
|
|
|
|
|
|
icall eax, interface_addr, interface.init
|
|
|
|
; check for ftp://username:pass@server:port/path urls
|
|
|
|
cmp dword[buf_cmd], 'ftp:'
|
|
|
|
je parse_args
|
|
|
|
cmp dword[buf_cmd+5], 'ftp:'
|
|
|
|
je parse_args
|
|
|
|
ijmp eax, interface_addr, interface.server_addr
|
|
|
|
|
|
|
|
.error:
|
|
|
|
call console.init
|
|
|
|
invoke con_write_asciiz, str_args_err
|
|
|
|
invoke con_getch2
|
|
|
|
call console.exit
|
|
|
|
jmp exit
|
|
|
|
|
|
|
|
;;================================================================================================;;
|
|
|
|
arg_handler: ;////////////////////////////////////////////////////////////////////////////////////;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;? Passes initial connection info from console/GUI to FTP core and the other way around ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;> esp+4 = pointer to the argument passed to the function ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;< none ;;
|
|
|
|
;;================================================================================================;;
|
|
|
|
|
|
|
|
.get_username:
|
|
|
|
; request username
|
|
|
|
ijmp eax, interface_addr, interface.get_username
|
|
|
|
|
|
|
|
.copy_user:
|
|
|
|
mov dword[buf_cmd], "USER"
|
|
|
|
mov byte[buf_cmd+4], " "
|
|
|
|
; copy user name to buf_cmd (for command line args)
|
|
|
|
mov edi, buf_cmd+5
|
|
|
|
mov esi, param_user
|
|
|
|
@@:
|
|
|
|
movsb
|
|
|
|
cmp byte [esi-1], 0
|
|
|
|
jne @b
|
|
|
|
mov word[edi-1], 0x0a0d
|
|
|
|
|
|
|
|
lea esi, [edi+1-buf_cmd]
|
|
|
|
jmp server_connect.send
|
|
|
|
|
|
|
|
.get_pass:
|
|
|
|
mov dword[buf_cmd], "PASS"
|
|
|
|
mov byte[buf_cmd+4], " "
|
|
|
|
; copy password to buf_cmd (for command line args)
|
|
|
|
mov edi, buf_cmd+5
|
|
|
|
mov esi, param_password
|
|
|
|
@@:
|
|
|
|
movsb
|
|
|
|
cmp byte[esi-1], 0
|
|
|
|
jne @b
|
|
|
|
mov word[edi-1], 0x0a0d
|
|
|
|
|
|
|
|
lea esi, [edi+1-buf_cmd]
|
|
|
|
jmp server_connect.send
|
2014-07-27 00:36:31 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
.get_path:
|
|
|
|
; copy path from param_path to buf_cmd
|
|
|
|
mov dword[buf_cmd], "CWD "
|
|
|
|
mov edi, buf_cmd+4
|
|
|
|
mov esi, param_path
|
2013-06-24 23:33:16 +04:00
|
|
|
@@:
|
|
|
|
lodsb
|
2016-10-07 20:11:07 +03:00
|
|
|
stosb
|
|
|
|
cmp al, 0x20
|
|
|
|
ja @b
|
|
|
|
mov word[edi-1], 0x0a0d
|
|
|
|
|
|
|
|
lea esi, [edi+1-buf_cmd]
|
|
|
|
jmp server_connect.send
|
|
|
|
|
|
|
|
.connect:
|
|
|
|
; copy server address to buf_cmd
|
|
|
|
mov esi, param_server_addr
|
|
|
|
mov edi, buf_cmd
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
stosb
|
2013-06-24 23:33:16 +04:00
|
|
|
cmp al, 0x20
|
|
|
|
ja @r
|
2016-10-07 20:11:07 +03:00
|
|
|
mov byte[edi-1], 0 ; delete terminating '\n'
|
|
|
|
|
|
|
|
cmp [param_port], 0x20
|
|
|
|
jbe server_connect.default_port
|
|
|
|
mov esi, param_port
|
|
|
|
jmp server_connect.do_port
|
|
|
|
|
|
|
|
|
|
|
|
;;================================================================================================;;
|
|
|
|
server_connect: ;/////////////////////////////////////////////////////////////////////////////////;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;? Establishes a connection to the FTP server (common block for all interfaces) ;;
|
|
|
|
;? .do_port - Port is specified by the user and needs to be converted from ASCII ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;> esi = pointer to port no. ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;< none ;;
|
|
|
|
;;================================================================================================;;
|
|
|
|
|
|
|
|
.send:
|
|
|
|
; send username/password/path to the server
|
|
|
|
mcall send, [controlsocket], buf_cmd, , 0
|
|
|
|
icall eax, interface_addr, interface.print, str_newline
|
|
|
|
icall eax, interface_addr, interface.set_flags, 0x07 ; reset color
|
|
|
|
|
|
|
|
jmp wait_for_servercommand
|
2014-07-27 00:36:31 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
; resolve port if specified
|
2014-07-27 00:36:31 +04:00
|
|
|
.do_port:
|
|
|
|
xor eax, eax
|
|
|
|
xor ebx, ebx
|
|
|
|
.portloop:
|
|
|
|
lodsb
|
|
|
|
cmp al, 0x20
|
|
|
|
jbe .port_done
|
|
|
|
sub al, '0'
|
2016-05-28 13:13:18 +03:00
|
|
|
jnb @f
|
|
|
|
mov eax, str_err_host
|
|
|
|
jmp error
|
|
|
|
@@: cmp al, 9
|
|
|
|
jna @f
|
|
|
|
mov eax, str_err_host
|
|
|
|
jmp error
|
|
|
|
@@: lea ebx, [ebx*4 + ebx]
|
2014-07-27 00:36:31 +04:00
|
|
|
shl ebx, 1
|
|
|
|
add ebx, eax
|
|
|
|
jmp .portloop
|
|
|
|
|
|
|
|
.port_done:
|
|
|
|
xchg bl, bh
|
|
|
|
mov [sockaddr1.port], bx
|
2016-10-07 20:11:07 +03:00
|
|
|
jmp .done
|
|
|
|
|
|
|
|
.default_port:
|
|
|
|
mov [sockaddr1.port], 21 shl 8
|
2014-07-27 00:36:31 +04:00
|
|
|
|
|
|
|
.done:
|
2013-07-12 12:59:34 +04:00
|
|
|
; Say to the user that we're resolving
|
2016-10-07 20:11:07 +03:00
|
|
|
icall eax, interface_addr, interface.set_flags, 0x07 ; reset color
|
|
|
|
icall eax, interface_addr, interface.print, str_resolve, buf_cmd
|
2013-06-24 23:33:16 +04:00
|
|
|
; resolve name
|
|
|
|
push esp ; reserve stack place
|
2014-05-12 03:42:10 +04:00
|
|
|
invoke getaddrinfo, buf_cmd, 0, 0, esp
|
2013-06-24 23:33:16 +04:00
|
|
|
pop esi
|
|
|
|
; test for error
|
|
|
|
test eax, eax
|
2016-05-28 13:13:18 +03:00
|
|
|
jz @f
|
|
|
|
mov eax, str_err_resolve
|
|
|
|
jmp error
|
|
|
|
@@:
|
2013-06-24 23:33:16 +04:00
|
|
|
; write results
|
2016-10-07 20:11:07 +03:00
|
|
|
icall eax, interface_addr, interface.print, str8 ; ' (',0
|
2013-07-10 13:37:01 +04:00
|
|
|
mov eax, [esi+addrinfo.ai_addr] ; convert IP address to decimal notation
|
|
|
|
mov eax, [eax+sockaddr_in.sin_addr] ;
|
|
|
|
mov [sockaddr1.ip], eax ;
|
|
|
|
invoke inet_ntoa, eax ;
|
2016-10-07 20:11:07 +03:00
|
|
|
icall ebx, interface_addr, interface.print, eax, str9 ; <ip>,')',10,0
|
2013-07-10 13:37:01 +04:00
|
|
|
invoke freeaddrinfo, esi ; free allocated memory
|
|
|
|
; open the socket
|
2013-06-24 23:33:16 +04:00
|
|
|
mcall socket, AF_INET4, SOCK_STREAM, 0
|
|
|
|
cmp eax, -1
|
2016-05-28 13:13:18 +03:00
|
|
|
jne @f
|
|
|
|
mov eax, str_err_socket
|
|
|
|
jmp error
|
|
|
|
@@: mov [controlsocket], eax
|
2013-07-10 13:37:01 +04:00
|
|
|
; connect to the server
|
2016-10-07 20:11:07 +03:00
|
|
|
icall eax, interface_addr, interface.print, str_connect
|
2014-07-27 00:36:31 +04:00
|
|
|
mcall connect, [controlsocket], sockaddr1, 18
|
2014-05-07 11:31:49 +04:00
|
|
|
cmp eax, -1
|
2016-05-28 13:13:18 +03:00
|
|
|
jne @f
|
|
|
|
mov eax, str_err_connect
|
|
|
|
jmp error
|
|
|
|
@@: mov [status], STATUS_CONNECTING
|
2013-07-12 12:59:34 +04:00
|
|
|
; Tell the user we're waiting for the server now.
|
2016-10-07 20:11:07 +03:00
|
|
|
icall eax, interface_addr, interface.print, str_waiting
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2013-07-12 12:59:34 +04:00
|
|
|
; Reset 'offset' variable, it's used by the data receiver
|
2013-07-10 00:55:18 +04:00
|
|
|
mov [offset], 0
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
|
|
|
|
;;================================================================================================;;
|
|
|
|
wait_for_servercommand: ;/////////////////////////////////////////////////////////////////////////;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;? Checks if any data received from the server is present in buffer. ;;
|
|
|
|
;? If not, receives and processes it ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;> ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;< none ;;
|
|
|
|
;;================================================================================================;;
|
2013-07-12 12:59:34 +04:00
|
|
|
; Any commands still in our buffer?
|
2013-07-10 00:55:18 +04:00
|
|
|
cmp [offset], 0
|
2013-07-12 12:59:34 +04:00
|
|
|
je .receive ; nope, receive some more
|
2013-07-10 00:55:18 +04:00
|
|
|
mov esi, [offset]
|
2014-05-12 03:42:10 +04:00
|
|
|
mov edi, buf_cmd
|
2013-07-10 00:55:18 +04:00
|
|
|
mov ecx, [size]
|
|
|
|
add ecx, esi
|
|
|
|
jmp .byteloop
|
2013-06-24 23:33:16 +04:00
|
|
|
|
|
|
|
; receive socket data
|
2013-07-10 00:55:18 +04:00
|
|
|
.receive:
|
2014-05-07 11:31:49 +04:00
|
|
|
mcall 26, 9
|
|
|
|
add eax, TIMEOUT*100
|
|
|
|
mov [timeout], eax
|
|
|
|
.receive_loop:
|
|
|
|
mcall 23, 50 ; Wait for event with timeout
|
|
|
|
mcall 26, 9
|
|
|
|
cmp eax, [timeout]
|
2016-05-28 13:13:18 +03:00
|
|
|
jl @f
|
|
|
|
mov eax, str_err_timeout
|
|
|
|
jmp error
|
|
|
|
@@: mcall recv, [controlsocket], buf_buffer1, BUFFERSIZE, MSG_DONTWAIT
|
2014-05-07 11:31:49 +04:00
|
|
|
test eax, eax
|
|
|
|
jnz .got_data
|
|
|
|
cmp ebx, EWOULDBLOCK
|
2016-05-28 13:13:18 +03:00
|
|
|
je @f
|
|
|
|
mov eax, str_err_recv
|
|
|
|
jmp error
|
|
|
|
@@: jmp .receive_loop
|
2013-07-10 00:19:08 +04:00
|
|
|
|
2014-05-07 11:31:49 +04:00
|
|
|
.got_data:
|
2013-07-10 00:55:18 +04:00
|
|
|
mov [offset], 0
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
; extract commands, copy them to "buf_cmd" buffer
|
|
|
|
lea ecx, [eax + buf_buffer1] ; ecx = end pointer
|
|
|
|
mov esi, buf_buffer1 ; esi = current pointer
|
|
|
|
mov edi, buf_cmd
|
2013-06-24 23:33:16 +04:00
|
|
|
.byteloop:
|
2013-07-10 00:19:08 +04:00
|
|
|
cmp esi, ecx
|
|
|
|
jae wait_for_servercommand
|
2013-06-24 23:33:16 +04:00
|
|
|
lodsb
|
|
|
|
cmp al, 10 ; excellent, we might have a command
|
|
|
|
je .got_command
|
2013-07-10 00:19:08 +04:00
|
|
|
cmp al, 13 ; just ignore this byte
|
2013-06-24 23:33:16 +04:00
|
|
|
je .byteloop
|
|
|
|
stosb
|
|
|
|
jmp .byteloop
|
2013-07-10 00:19:08 +04:00
|
|
|
.got_command: ; we have a newline check if its a command
|
2013-07-10 00:55:18 +04:00
|
|
|
cmp esi, ecx
|
|
|
|
je .no_more_data
|
|
|
|
mov [offset], esi
|
|
|
|
sub ecx, esi
|
|
|
|
mov [size], ecx
|
|
|
|
jmp .go_cmd
|
|
|
|
.no_more_data:
|
|
|
|
mov [offset], 0
|
|
|
|
.go_cmd:
|
2014-05-12 03:42:10 +04:00
|
|
|
lea ecx, [edi - buf_cmd] ; length of command
|
2013-06-24 23:33:16 +04:00
|
|
|
xor al, al
|
|
|
|
stosb
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
icall eax, interface_addr, interface.set_flags, 0x03 ; change color
|
|
|
|
icall eax, interface_addr, interface.print, buf_cmd, str_newline
|
|
|
|
icall eax, interface_addr, interface.set_flags, 0x07 ; reset color
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2013-07-10 00:19:08 +04:00
|
|
|
jmp server_parser ; parse command
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2013-07-12 12:59:34 +04:00
|
|
|
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
;;================================================================================================;;
|
|
|
|
wait_for_usercommand: ;///////////////////////////////////////////////////////////////////////////;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;? Reads the FTP command entered by the user and compares it with valid FTP commands. ;;
|
|
|
|
;? Jumps to appropriate handling routine in usercommands.inc ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;> status = socket connection status ;;
|
|
|
|
;> buf_cmd = command entered by the user ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;< none ;;
|
|
|
|
;;================================================================================================;;
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
; Are there any files in the transfer queue?
|
|
|
|
|
2014-07-27 00:36:31 +04:00
|
|
|
cmp [queued], 0
|
2014-05-12 03:42:10 +04:00
|
|
|
ja transfer_queued ; Yes, transfer those first.
|
2016-10-07 20:11:07 +03:00
|
|
|
|
2013-07-12 12:59:34 +04:00
|
|
|
; change color to green for user input
|
2016-10-07 20:11:07 +03:00
|
|
|
icall eax, interface_addr, interface.set_flags, 0x0a
|
2013-07-10 00:19:08 +04:00
|
|
|
|
2013-07-12 12:59:34 +04:00
|
|
|
; If we are not yet connected, request username/password
|
2016-10-07 20:11:07 +03:00
|
|
|
|
2013-06-24 23:33:16 +04:00
|
|
|
cmp [status], STATUS_CONNECTED
|
2016-10-07 20:11:07 +03:00
|
|
|
je arg_handler.get_username
|
2013-06-24 23:33:16 +04:00
|
|
|
|
|
|
|
cmp [status], STATUS_NEEDPASSWORD
|
2016-10-07 20:11:07 +03:00
|
|
|
je arg_handler.get_pass
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
ijmp eax, interface_addr, interface.get_cmd
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
.parse_cmd:
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "cwd "
|
2013-07-10 00:55:18 +04:00
|
|
|
je cmd_cwd
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "mkd "
|
2013-07-12 12:59:34 +04:00
|
|
|
je cmd_mkd
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "rmd "
|
2013-07-12 12:59:34 +04:00
|
|
|
je cmd_rmd
|
2013-07-10 01:31:47 +04:00
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "pwd" + 10 shl 24
|
2013-07-10 01:59:02 +04:00
|
|
|
je cmd_pwd
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "bye" + 10 shl 24
|
2013-07-12 12:59:34 +04:00
|
|
|
je cmd_bye
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "rdir"
|
2014-07-27 00:36:31 +04:00
|
|
|
je cmd_rdir
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp byte[buf_cmd+4], " "
|
2013-07-12 12:59:34 +04:00
|
|
|
jne @f
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "lcwd"
|
2013-07-12 12:59:34 +04:00
|
|
|
je cmd_lcwd
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "retr"
|
2013-07-12 12:59:34 +04:00
|
|
|
je cmd_retr
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "stor"
|
2013-07-10 13:37:01 +04:00
|
|
|
je cmd_stor
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "dele"
|
2013-07-10 13:37:01 +04:00
|
|
|
je cmd_dele
|
|
|
|
|
2013-07-12 12:59:34 +04:00
|
|
|
@@:
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp byte[buf_cmd+4], 10
|
2013-07-12 12:59:34 +04:00
|
|
|
jne @f
|
2013-07-10 14:17:07 +04:00
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "list"
|
2013-07-12 12:59:34 +04:00
|
|
|
je cmd_list
|
2013-07-10 15:19:18 +04:00
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "help"
|
2013-07-12 12:59:34 +04:00
|
|
|
je cmd_help
|
2013-07-10 15:19:18 +04:00
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
cmp dword[buf_cmd], "cdup"
|
2013-07-10 15:19:18 +04:00
|
|
|
je cmd_cdup
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
cmp dword[buf_cmd], "abor"
|
|
|
|
je cmd_abor
|
|
|
|
|
2013-07-12 12:59:34 +04:00
|
|
|
@@:
|
|
|
|
; Uh oh.. unknown command, tell the user and wait for new input
|
2016-10-07 20:11:07 +03:00
|
|
|
icall eax, interface_addr, interface.print, str_unknown
|
2013-06-24 23:33:16 +04:00
|
|
|
jmp wait_for_usercommand
|
|
|
|
|
|
|
|
|
2014-07-27 00:36:31 +04:00
|
|
|
; files for rdir operation are queued
|
|
|
|
transfer_queued:
|
|
|
|
|
|
|
|
mov esi, [ptr_queue] ; always pointing to current part of ptr_fname_start
|
|
|
|
mov edi, buf_cmd+5 ; always point to filename for retr command
|
|
|
|
.build_filename:
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
cmp al, 10
|
|
|
|
je .get_file ; filename ends with character 10
|
|
|
|
test al, al
|
|
|
|
jnz .build_filename
|
|
|
|
|
|
|
|
; Error occured, we reached the end of the buffer before [queued] reached 0
|
|
|
|
mov [queued], 0
|
|
|
|
mcall 68, 13, [ptr_fname] ; free buffer
|
|
|
|
test eax, eax
|
|
|
|
jz error_heap
|
|
|
|
jmp wait_for_usercommand
|
|
|
|
|
|
|
|
.get_file:
|
|
|
|
mov byte[edi], 0 ; end filename with 0 byte
|
|
|
|
mov [ptr_queue], esi
|
|
|
|
dec [queued]
|
|
|
|
jnz cmd_retr
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2014-07-27 00:36:31 +04:00
|
|
|
mcall 68, 13, [ptr_fname] ; free buffer
|
|
|
|
test eax, eax
|
|
|
|
jz error_heap
|
|
|
|
jmp cmd_retr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
open_dataconnection:
|
|
|
|
|
|
|
|
test [mode], 1
|
|
|
|
jnz .active
|
|
|
|
|
|
|
|
mcall send, [controlsocket], str_PASV, str_PASV.length, 0
|
2013-06-24 23:33:16 +04:00
|
|
|
ret
|
|
|
|
|
2014-07-27 00:36:31 +04:00
|
|
|
.active:
|
|
|
|
mcall socket, AF_INET4, SOCK_STREAM, 0
|
|
|
|
cmp eax, -1
|
2016-05-28 13:13:18 +03:00
|
|
|
jne @f
|
|
|
|
mov eax, str_err_socket
|
|
|
|
jmp error
|
|
|
|
@@: mov [datasocket], eax
|
2014-07-27 00:36:31 +04:00
|
|
|
|
|
|
|
mov ax, [acti_port_start]
|
|
|
|
xchg al, ah
|
|
|
|
mov [sockaddr2.port], ax
|
|
|
|
|
|
|
|
mcall bind, [datasocket], sockaddr2, 18
|
|
|
|
cmp eax, -1
|
2016-05-28 13:13:18 +03:00
|
|
|
jne @f
|
|
|
|
mov eax, str_err_bind
|
|
|
|
jmp error
|
|
|
|
@@:
|
2014-07-27 00:36:31 +04:00
|
|
|
|
|
|
|
mcall listen, [datasocket], 1
|
|
|
|
cmp eax, -1
|
2016-05-28 13:13:18 +03:00
|
|
|
jne @f
|
|
|
|
mov eax, str_err_listen
|
|
|
|
jmp error
|
|
|
|
@@:
|
2014-07-27 00:36:31 +04:00
|
|
|
|
|
|
|
mov dword[buf_buffer1], 'PORT'
|
|
|
|
mov byte[buf_buffer1+4], ' '
|
|
|
|
mov edi, buf_buffer1+5
|
|
|
|
mov esi, str_active_ip
|
|
|
|
.loop:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .ip_ok
|
|
|
|
stosb
|
|
|
|
jmp .loop
|
|
|
|
.ip_ok:
|
|
|
|
mov al, ','
|
|
|
|
stosb
|
|
|
|
movzx eax, byte[sockaddr2.port+0]
|
|
|
|
call dword_ascii
|
|
|
|
mov al, ','
|
|
|
|
stosb
|
|
|
|
movzx eax, byte[sockaddr2.port+1]
|
|
|
|
call dword_ascii
|
|
|
|
mov ax, 0x0a0d
|
|
|
|
stosw
|
|
|
|
lea esi, [edi - buf_buffer1]
|
|
|
|
mcall send, [controlsocket], buf_buffer1, , 0
|
|
|
|
|
|
|
|
mcall accept, [datasocket], sockaddr2, 18 ; time to accept the awaiting connection..
|
|
|
|
cmp eax, -1
|
2016-05-28 13:13:18 +03:00
|
|
|
jne @f
|
|
|
|
mov eax, str_err_accept
|
|
|
|
jmp error
|
|
|
|
@@: push eax
|
2014-07-27 00:36:31 +04:00
|
|
|
mcall close, [datasocket]
|
|
|
|
pop [datasocket]
|
|
|
|
|
|
|
|
mcall recv, [controlsocket], buf_buffer1, BUFFERSIZE, 0
|
|
|
|
|
2013-06-24 23:33:16 +04:00
|
|
|
ret
|
|
|
|
|
2014-07-27 00:36:31 +04:00
|
|
|
; eax = input
|
|
|
|
; edi = ptr where to write
|
|
|
|
dword_ascii:
|
|
|
|
|
|
|
|
push edx ebx ecx
|
|
|
|
mov ebx, 10
|
|
|
|
xor ecx, ecx
|
|
|
|
|
|
|
|
@@:
|
|
|
|
xor edx, edx
|
|
|
|
div ebx
|
|
|
|
add edx, '0'
|
|
|
|
push dx
|
|
|
|
inc ecx
|
|
|
|
test eax, eax
|
|
|
|
jnz @r
|
|
|
|
|
|
|
|
@@:
|
|
|
|
pop ax
|
|
|
|
stosb
|
|
|
|
dec ecx
|
|
|
|
jnz @r
|
|
|
|
|
|
|
|
pop ecx ebx edx
|
|
|
|
ret
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
|
|
|
|
;;================================================================================================;;
|
|
|
|
write_to_file: ;//////////////////////////////////////////////////////////////////////////////////;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;? Writes input buffer to log file ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;> eax = pointer to buffer ;;
|
|
|
|
;> ecx = size of buffer ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;< eax = status of SF 70.3 ;;
|
|
|
|
;;================================================================================================;;
|
2018-03-21 19:10:11 +03:00
|
|
|
cmp [logfile_offset], -1 ; if offset == -1 => logging disabled
|
|
|
|
jne @f
|
|
|
|
mov eax, 0
|
|
|
|
ret
|
|
|
|
@@:
|
2016-10-07 20:11:07 +03:00
|
|
|
mov [filestruct2.subfn], 3
|
|
|
|
m2m [filestruct2.offset], [logfile_offset]
|
|
|
|
mov [filestruct2.size], ecx
|
|
|
|
mov [filestruct2.ptr], eax
|
|
|
|
mov [filestruct2.name], log_file
|
|
|
|
mcall 70, filestruct2
|
|
|
|
test eax, eax
|
|
|
|
jz @f
|
|
|
|
mov [logfile_offset], -1 ; disable logging
|
|
|
|
call error_fs
|
|
|
|
icall ebx, interface_addr, interface.print, str_no_logging
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
mov eax, [logfile_offset]
|
|
|
|
add eax, ecx
|
|
|
|
mov [logfile_offset], eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
;;================================================================================================;;
|
|
|
|
error: ;//////////////////////////////////////////////////////////////////////////////////////////;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;? Generic error routine. Prints the error string passed to it. ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;> eax = pointer to the error string ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;< none ;;
|
|
|
|
;;================================================================================================;;
|
2016-05-28 13:13:18 +03:00
|
|
|
push eax
|
2016-10-07 20:11:07 +03:00
|
|
|
icall ebx, interface_addr, interface.set_flags, 0x0c ; print errors in red
|
2016-05-28 13:13:18 +03:00
|
|
|
pop eax
|
2016-10-07 20:11:07 +03:00
|
|
|
icall ebx, interface_addr, interface.print, eax
|
2014-07-27 00:36:31 +04:00
|
|
|
jmp wait_for_keypress
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
|
|
|
|
; Error handling block for filesystem errors
|
|
|
|
error_fs:
|
|
|
|
|
|
|
|
cmp eax, 12
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_12
|
|
|
|
@@:
|
|
|
|
cmp eax, 11
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_11
|
|
|
|
@@:
|
|
|
|
cmp eax, 10
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_10
|
|
|
|
@@:
|
|
|
|
cmp eax, 9
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_9
|
|
|
|
@@:
|
|
|
|
cmp eax, 8
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_8
|
|
|
|
@@:
|
|
|
|
cmp eax, 7
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_7
|
|
|
|
@@:
|
|
|
|
cmp eax, 6
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_6
|
|
|
|
@@:
|
|
|
|
cmp eax, 5
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_5
|
|
|
|
@@:
|
|
|
|
cmp eax, 3
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_3
|
|
|
|
@@:
|
|
|
|
cmp eax, 2
|
|
|
|
jne @f
|
|
|
|
mov ebx, str_fs_err_2
|
|
|
|
@@:
|
|
|
|
mov edi, fs_error_code
|
|
|
|
call dword_ascii ; convert error code in eax to ascii
|
|
|
|
icall eax, interface_addr, interface.set_flags, 0x0c ; print errors in red
|
|
|
|
icall eax, interface_addr, interface.print, str_err_fs, fs_error_code, ebx
|
|
|
|
mov word[fs_error_code], ' ' ; clear error code for next time
|
|
|
|
icall eax, interface_addr, interface.set_flags, 0x0a
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
error_heap:
|
2016-10-07 20:11:07 +03:00
|
|
|
icall eax, interface_addr, interface.set_flags, 0x0c ; print errors in red
|
|
|
|
icall eax, interface_addr, interface.print, str_err_heap
|
2014-07-27 00:36:31 +04:00
|
|
|
|
2013-07-12 12:59:34 +04:00
|
|
|
wait_for_keypress:
|
2014-07-27 00:36:31 +04:00
|
|
|
mcall close, [controlsocket]
|
2016-10-07 20:11:07 +03:00
|
|
|
icall eax, interface_addr, interface.set_flags, 0x07 ; reset color to grey
|
|
|
|
icall eax, interface_addr, interface.print, str_push
|
|
|
|
ijmp eax, interface_addr, interface.error
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2013-07-10 00:19:08 +04:00
|
|
|
exit:
|
2014-07-27 00:36:31 +04:00
|
|
|
mcall close, [controlsocket]
|
|
|
|
exit2:
|
2013-06-24 23:33:16 +04:00
|
|
|
mcall -1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; data
|
2018-10-14 21:05:52 +03:00
|
|
|
str_title db 'FTP client for KolibriOS',0
|
2018-10-30 18:09:41 +03:00
|
|
|
str_welcome db 'FTP client for KolibriOS v0.15b',10
|
2016-10-07 20:11:07 +03:00
|
|
|
db 10,0
|
|
|
|
str_srv_addr db 'Please enter ftp server address.',10,0
|
2016-04-12 15:24:28 +03:00
|
|
|
|
2013-07-12 12:59:34 +04:00
|
|
|
str_prompt db '> ',0
|
|
|
|
str_resolve db 'Resolving ',0
|
|
|
|
str_newline db 10,0
|
|
|
|
str_err_resolve db 10,'Name resolution failed.',10,0
|
2016-05-28 13:13:18 +03:00
|
|
|
str_err_socket db 10,'[75,0 socket]: Error creating a socket',10,0
|
|
|
|
str_err_bind db 10,'[75,2 bind]: Error binding to socket',10,0
|
|
|
|
str_err_listen db 10,'[75,3 listen]: Cannot accept incoming connections',10,0
|
|
|
|
str_err_accept db 10,'[75,5 accept]: Error accepting a connection',10,0
|
|
|
|
str_err_recv db 10,'[75,7 recv]: Error receiving data from server',10,0
|
2014-07-27 00:36:31 +04:00
|
|
|
str_err_heap db 10,'Cannot allocate memory from heap.',10,0
|
2014-05-07 11:31:49 +04:00
|
|
|
str_err_timeout db 10,'Timeout - no response from server.',10,0
|
2016-05-28 13:13:18 +03:00
|
|
|
str_err_connect db 10,'[75,4 connect]: Cannot connect to the server.',10,0
|
2014-07-27 00:36:31 +04:00
|
|
|
str_err_host db 10,'Invalid hostname.',10,0
|
2016-05-28 13:13:18 +03:00
|
|
|
str_err_params db 10,'Invalid parameters',10,0
|
2016-10-07 20:11:07 +03:00
|
|
|
str_err_fs db 10,'File system error: code ',0
|
|
|
|
fs_error_code db ' ',0 ; file system error code
|
|
|
|
str_fs_err_2 db ' [Function is not supported for the given file system]',10,0
|
|
|
|
str_fs_err_3 db ' [Unknown file system]',10,0
|
|
|
|
str_fs_err_5 db ' [File/Folder not found]',10,0
|
|
|
|
str_fs_err_6 db ' [End of file, EOF]',10,0
|
|
|
|
str_fs_err_7 db ' [Pointer lies outside of application memory]',10,0
|
|
|
|
str_fs_err_8 db ' [Disk is full]',10,0
|
|
|
|
str_fs_err_9 db ' [File system error]',10,0
|
|
|
|
str_fs_err_10 db ' [Access denied]',10,0
|
|
|
|
str_fs_err_11 db ' [Device error]',10,0
|
|
|
|
str_fs_err_12 db ' [File system requires more memory]',10,0
|
2013-07-12 12:59:34 +04:00
|
|
|
str8 db ' (',0
|
|
|
|
str9 db ')',10,0
|
|
|
|
str_push db 'Push any key to continue.',0
|
|
|
|
str_connect db 'Connecting...',10,0
|
|
|
|
str_waiting db 'Waiting for welcome message.',10,0
|
|
|
|
str_user db "username: ",0
|
|
|
|
str_pass db "password: ",0
|
2016-10-07 20:11:07 +03:00
|
|
|
str_port db "port (default 21): ",0
|
|
|
|
str_path db "path (optional): ",0
|
2013-07-12 12:59:34 +04:00
|
|
|
str_unknown db "Unknown command or insufficient parameters - type help for more information.",10,0
|
|
|
|
str_lcwd db "Local working directory is now: ",0
|
2016-10-07 20:11:07 +03:00
|
|
|
str_bytes_done db ' ',0
|
|
|
|
str_downloaded db 'Downloaded ',0
|
|
|
|
str_bytes db ' bytes',13,0
|
|
|
|
str_args_err db 'Invalid arguments. USAGE: ftpc [-cli] [ftp://username:password@server:port/path]',10,0
|
2013-07-12 12:59:34 +04:00
|
|
|
|
|
|
|
str_open db "opening data socket",10,0
|
2014-05-12 03:42:10 +04:00
|
|
|
str_close db 10,"closing data socket",10,0
|
|
|
|
str_dot db '.',0
|
2013-07-12 12:59:34 +04:00
|
|
|
|
|
|
|
str_help db "available commands:",10
|
|
|
|
db 10
|
|
|
|
db "bye - close the connection",10
|
|
|
|
db "cdup - change to parent of current directory on the server",10
|
|
|
|
db "cwd <directory> - change working directoy on the server",10
|
|
|
|
db "dele <file> - delete file from the server",10
|
|
|
|
db "list - list files and folders in current server directory",10
|
|
|
|
db "lcwd <path> - change local working directory",10
|
|
|
|
db "mkd <directory> - make directory on the server",10
|
|
|
|
db "pwd - print server working directory",10
|
|
|
|
db "retr <file> - retreive file from the server",10
|
|
|
|
db "rmd <directory> - remove directory from the server",10
|
|
|
|
db "stor <file> - store file on the server",10
|
2016-10-07 20:11:07 +03:00
|
|
|
db "rdir - retreive all files from current server dir",10
|
2013-07-12 12:59:34 +04:00
|
|
|
db 10,0
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2014-07-27 00:36:31 +04:00
|
|
|
str_ini db '.ini', 0
|
|
|
|
str_active db 'active', 0
|
|
|
|
str_port_start db 'port_start', 0
|
|
|
|
str_port_stop db 'port_stop', 0
|
|
|
|
str_ip db 'ip', 0
|
|
|
|
str_dir db 'dir', 0
|
|
|
|
str_general db 'general', 0
|
2016-10-07 20:11:07 +03:00
|
|
|
str_logfile db 'logfile',0
|
|
|
|
str_no_logging db 'Error writing to log file. Logging disabled',0
|
2014-07-27 00:36:31 +04:00
|
|
|
|
|
|
|
queued dd 0
|
|
|
|
mode db 0 ; passive = 0, active = 1
|
2013-07-13 12:50:07 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
|
2013-07-13 12:50:07 +04:00
|
|
|
; FTP strings
|
|
|
|
|
|
|
|
str_PASV db 'PASV',13,10
|
|
|
|
.length = $ - str_PASV
|
|
|
|
|
2013-06-24 23:33:16 +04:00
|
|
|
sockaddr1:
|
|
|
|
dw AF_INET4
|
2014-07-27 00:36:31 +04:00
|
|
|
.port dw ?
|
|
|
|
.ip dd ?
|
2013-06-24 23:33:16 +04:00
|
|
|
rb 10
|
|
|
|
|
|
|
|
sockaddr2:
|
|
|
|
dw AF_INET4
|
2014-07-27 00:36:31 +04:00
|
|
|
.port dw ?
|
|
|
|
.ip dd ?
|
2013-06-24 23:33:16 +04:00
|
|
|
rb 10
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
struc interface
|
|
|
|
{
|
|
|
|
.init dd 0
|
|
|
|
.server_addr dd 4
|
|
|
|
.get_username dd 8
|
|
|
|
.get_cmd dd 12
|
|
|
|
.print dd 16
|
|
|
|
.set_flags dd 20
|
|
|
|
.list dd 24
|
|
|
|
.progress dd 28
|
|
|
|
.error dd 32
|
|
|
|
}
|
|
|
|
interface interface
|
|
|
|
|
2013-06-24 23:33:16 +04:00
|
|
|
; import
|
|
|
|
align 4
|
|
|
|
@IMPORT:
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
library network, 'network.obj', libini, 'libini.obj'
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
import network, \
|
|
|
|
getaddrinfo, 'getaddrinfo', \
|
2013-06-24 23:33:16 +04:00
|
|
|
freeaddrinfo, 'freeaddrinfo', \
|
|
|
|
inet_ntoa, 'inet_ntoa'
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
import libini, \
|
|
|
|
ini.get_str, 'ini_get_str', \
|
2014-07-27 00:36:31 +04:00
|
|
|
ini.get_int, 'ini_get_int'
|
|
|
|
|
2013-06-24 23:33:16 +04:00
|
|
|
|
|
|
|
i_end:
|
|
|
|
|
2013-07-12 12:59:34 +04:00
|
|
|
; uninitialised data
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
interface_addr rd 1
|
|
|
|
|
2013-07-10 01:59:02 +04:00
|
|
|
status db ?
|
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
file_size dd ?
|
|
|
|
|
2014-07-27 00:36:31 +04:00
|
|
|
controlsocket dd ?
|
2013-06-24 23:33:16 +04:00
|
|
|
datasocket dd ?
|
2013-07-10 00:55:18 +04:00
|
|
|
offset dd ?
|
|
|
|
size dd ?
|
2013-07-10 13:37:01 +04:00
|
|
|
operation dd ?
|
2014-05-07 11:31:49 +04:00
|
|
|
timeout dd ?
|
2014-07-27 00:36:31 +04:00
|
|
|
|
|
|
|
ptr_fname dd ?
|
|
|
|
size_fname dd ?
|
|
|
|
ptr_queue dd ?
|
|
|
|
|
|
|
|
acti_port_start dw ?
|
|
|
|
acti_port_stop dw ?
|
|
|
|
acti_port dw ?
|
|
|
|
|
|
|
|
str_active_ip rb 16
|
2014-05-07 11:31:49 +04:00
|
|
|
|
2013-07-10 13:37:01 +04:00
|
|
|
filestruct:
|
2014-07-27 00:36:31 +04:00
|
|
|
.subfn dd ?
|
|
|
|
.offset dd ?
|
|
|
|
dd ?
|
|
|
|
.size dd ?
|
|
|
|
.ptr dd ?
|
|
|
|
.name rb 1024
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
filestruct2:
|
|
|
|
.subfn dd ?
|
|
|
|
.offset dd ?
|
|
|
|
dd 0
|
|
|
|
.size dd ?
|
|
|
|
.ptr dd ?
|
|
|
|
db 0
|
|
|
|
.name dd ?
|
|
|
|
|
|
|
|
folder_buf rb 40
|
|
|
|
|
|
|
|
|
2014-05-12 03:42:10 +04:00
|
|
|
buf_buffer1 rb BUFFERSIZE+1
|
|
|
|
buf_buffer2 rb BUFFERSIZE+1
|
2014-07-27 00:36:31 +04:00
|
|
|
buf_cmd rb 1024 ; buffer for holding command string
|
2016-10-07 20:11:07 +03:00
|
|
|
log_file rb 512 ; holds log file path
|
|
|
|
logfile_offset rd 1
|
2014-07-27 00:36:31 +04:00
|
|
|
|
|
|
|
path rb 1024
|
2013-06-24 23:33:16 +04:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
initial_login rb 1
|
2016-04-12 15:24:28 +03:00
|
|
|
param_user rb 1024
|
|
|
|
param_password rb 1024
|
|
|
|
param_server_addr rb 1024
|
|
|
|
param_path rb 1024
|
2016-10-07 20:11:07 +03:00
|
|
|
param_port rb 6
|
|
|
|
|
|
|
|
sc system_colors
|
|
|
|
rb 1024
|
2016-04-12 15:24:28 +03:00
|
|
|
|
2013-06-24 23:33:16 +04:00
|
|
|
mem:
|