2016-10-07 20:11:07 +03:00
|
|
|
;;================================================================================================;;
|
|
|
|
parse_args: ;/////////////////////////////////////////////////////////////////////////////////////;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;? parses command line arguments of type ;;
|
|
|
|
;? ftp://user:password@server:port/folder/subfolder type urls and attempts to connect ;;
|
|
|
|
;? automatically ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;> buf_cmd = pointer to command line arguments ;;
|
|
|
|
;;------------------------------------------------------------------------------------------------;;
|
|
|
|
;< none ;;
|
|
|
|
;;================================================================================================;;
|
2016-04-12 15:24:28 +03:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
cmp dword[buf_cmd], 'ftp:'
|
|
|
|
jne @f
|
2016-04-12 15:24:28 +03:00
|
|
|
mov esi, buf_cmd
|
2016-10-07 20:11:07 +03:00
|
|
|
jmp .start
|
2016-04-12 15:24:28 +03:00
|
|
|
@@:
|
2016-10-07 20:11:07 +03:00
|
|
|
mov esi, buf_cmd+5
|
|
|
|
|
|
|
|
.start:
|
|
|
|
; check ftp://
|
|
|
|
cmp dword[esi], 'ftp:'
|
|
|
|
jne .error
|
|
|
|
cmp word[esi+4], '//'
|
|
|
|
jne .error
|
2016-04-12 15:24:28 +03:00
|
|
|
|
|
|
|
; parse user
|
2016-10-07 20:11:07 +03:00
|
|
|
lea edi, [param_user]
|
|
|
|
@@:
|
2016-04-12 15:24:28 +03:00
|
|
|
lodsb
|
2016-10-07 20:11:07 +03:00
|
|
|
test al, al
|
|
|
|
jz .error
|
|
|
|
stosb
|
2016-04-12 15:24:28 +03:00
|
|
|
cmp byte [esi], ':'
|
2016-10-07 20:11:07 +03:00
|
|
|
jne @b
|
|
|
|
mov byte [edi], 0
|
2016-04-12 15:24:28 +03:00
|
|
|
|
|
|
|
; parse password
|
|
|
|
inc esi
|
2016-10-07 20:11:07 +03:00
|
|
|
lea edi, [param_password]
|
|
|
|
@@:
|
2016-04-12 15:24:28 +03:00
|
|
|
lodsb
|
2016-10-07 20:11:07 +03:00
|
|
|
test al, al
|
|
|
|
jz .error
|
|
|
|
stosb
|
2016-04-12 15:24:28 +03:00
|
|
|
cmp byte [esi], '@'
|
2016-10-07 20:11:07 +03:00
|
|
|
jne @b
|
|
|
|
mov byte [edi], 0
|
2016-04-12 15:24:28 +03:00
|
|
|
|
|
|
|
; parse server address
|
|
|
|
inc esi
|
|
|
|
mov edi, param_server_addr
|
2016-10-07 20:11:07 +03:00
|
|
|
@@:
|
2016-04-12 15:24:28 +03:00
|
|
|
lodsb
|
2016-10-07 20:11:07 +03:00
|
|
|
test al, al
|
|
|
|
jz .error
|
|
|
|
stosb
|
2016-04-12 15:24:28 +03:00
|
|
|
cmp byte [esi], ':'
|
2016-10-07 20:11:07 +03:00
|
|
|
jne @b
|
2016-04-12 15:24:28 +03:00
|
|
|
mov byte [edi], 0
|
|
|
|
|
|
|
|
; parse port
|
|
|
|
inc esi
|
2016-10-07 20:11:07 +03:00
|
|
|
lea edi, [param_port]
|
|
|
|
@@:
|
2016-04-12 15:24:28 +03:00
|
|
|
lodsb
|
2016-10-07 20:11:07 +03:00
|
|
|
test al, al
|
|
|
|
jz .error
|
|
|
|
stosb
|
|
|
|
cmp byte [esi], '/'
|
|
|
|
jne @b
|
|
|
|
mov byte [edi], 0
|
2016-04-12 15:24:28 +03:00
|
|
|
|
|
|
|
; parse path
|
2016-10-07 20:11:07 +03:00
|
|
|
inc esi
|
|
|
|
lea edi, [param_path]
|
|
|
|
@@:
|
|
|
|
movsb
|
2016-04-12 15:24:28 +03:00
|
|
|
cmp byte [esi], 0
|
2016-10-07 20:11:07 +03:00
|
|
|
jne @b
|
|
|
|
mov byte [edi], 0
|
2016-04-12 15:24:28 +03:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
; parameters parsed successfully
|
|
|
|
jmp arg_handler.connect
|
2016-04-12 15:24:28 +03:00
|
|
|
|
2016-10-07 20:11:07 +03:00
|
|
|
.error:
|
|
|
|
mov eax, str_err_params
|
|
|
|
jmp error
|