Rev 6437 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6582 | nisargshah | 1 | ;;================================================================================================;; |
2 | parse_args: ;/////////////////////////////////////////////////////////////////////////////////////;; |
||
3 | ;;------------------------------------------------------------------------------------------------;; |
||
4 | ;? parses command line arguments of type ;; |
||
5 | ;? ftp://user:password@server:port/folder/subfolder type urls and attempts to connect ;; |
||
6 | ;? automatically ;; |
||
7 | ;;------------------------------------------------------------------------------------------------;; |
||
8 | ;> buf_cmd = pointer to command line arguments ;; |
||
9 | ;;------------------------------------------------------------------------------------------------;; |
||
10 | ;< none ;; |
||
11 | ;;================================================================================================;; |
||
6394 | nisargshah | 12 | |
6582 | nisargshah | 13 | cmp dword[buf_cmd], 'ftp:' |
14 | jne @f |
||
6394 | nisargshah | 15 | mov esi, buf_cmd |
6582 | nisargshah | 16 | jmp .start |
6394 | nisargshah | 17 | @@: |
6582 | nisargshah | 18 | mov esi, buf_cmd+5 |
6394 | nisargshah | 19 | |
6582 | nisargshah | 20 | .start: |
21 | ; check ftp:// |
||
22 | cmp dword[esi], 'ftp:' |
||
23 | jne .error |
||
24 | cmp word[esi+4], '//' |
||
25 | jne .error |
||
26 | |||
6394 | nisargshah | 27 | ; parse user |
6582 | nisargshah | 28 | lea edi, [param_user] |
29 | @@: |
||
6394 | nisargshah | 30 | lodsb |
6582 | nisargshah | 31 | test al, al |
32 | jz .error |
||
33 | stosb |
||
6394 | nisargshah | 34 | cmp byte [esi], ':' |
6582 | nisargshah | 35 | jne @b |
36 | mov byte [edi], 0 |
||
6394 | nisargshah | 37 | |
38 | ; parse password |
||
39 | inc esi |
||
6582 | nisargshah | 40 | lea edi, [param_password] |
41 | @@: |
||
6394 | nisargshah | 42 | lodsb |
6582 | nisargshah | 43 | test al, al |
44 | jz .error |
||
45 | stosb |
||
6394 | nisargshah | 46 | cmp byte [esi], '@' |
6582 | nisargshah | 47 | jne @b |
48 | mov byte [edi], 0 |
||
6394 | nisargshah | 49 | |
50 | ; parse server address |
||
51 | inc esi |
||
52 | mov edi, param_server_addr |
||
6582 | nisargshah | 53 | @@: |
6394 | nisargshah | 54 | lodsb |
6582 | nisargshah | 55 | test al, al |
56 | jz .error |
||
57 | stosb |
||
6394 | nisargshah | 58 | cmp byte [esi], ':' |
6582 | nisargshah | 59 | jne @b |
6394 | nisargshah | 60 | mov byte [edi], 0 |
61 | |||
62 | ; parse port |
||
63 | inc esi |
||
6582 | nisargshah | 64 | lea edi, [param_port] |
65 | @@: |
||
6394 | nisargshah | 66 | lodsb |
6582 | nisargshah | 67 | test al, al |
68 | jz .error |
||
69 | stosb |
||
70 | cmp byte [esi], '/' |
||
71 | jne @b |
||
72 | mov byte [edi], 0 |
||
6394 | nisargshah | 73 | |
74 | ; parse path |
||
6582 | nisargshah | 75 | inc esi |
76 | lea edi, [param_path] |
||
77 | @@: |
||
78 | movsb |
||
6394 | nisargshah | 79 | cmp byte [esi], 0 |
6582 | nisargshah | 80 | jne @b |
81 | mov byte [edi], 0 |
||
6394 | nisargshah | 82 | |
6582 | nisargshah | 83 | ; parameters parsed successfully |
84 | jmp arg_handler.connect |
||
6394 | nisargshah | 85 | |
6582 | nisargshah | 86 | .error: |
87 | mov eax, str_err_params |
||
88 | jmp error> |