Rev 3814 | Rev 4922 | Go to most recent revision | 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 |
12 | mov dword[s], "BYE" + 13 shl 24 |
||
13 | mov byte[s+4], 10 |
||
14 | mcall send, [socketnum], s, 5, 0 |
||
15 | |||
16 | ; Close the control connection |
||
3800 | hidnplayr | 17 | mcall close, [socketnum] |
18 | jmp main |
||
19 | |||
4920 | hidnplayr | 20 | |
3794 | hidnplayr | 21 | cmd_pwd: |
22 | |||
3814 | hidnplayr | 23 | mov dword[s], "PWD" + 13 shl 24 |
24 | mov byte[s+4], 10 |
||
25 | mcall send, [socketnum], s, 5, 0 |
||
3794 | hidnplayr | 26 | |
27 | jmp wait_for_servercommand |
||
28 | |||
4920 | hidnplayr | 29 | |
3790 | hidnplayr | 30 | cmd_cwd: |
31 | |||
32 | mov dword[s], "CWD " |
||
33 | |||
34 | mov ecx, 256 |
||
35 | xor al, al |
||
36 | mov edi, s |
||
37 | repne scasb |
||
3814 | hidnplayr | 38 | lea esi, [edi - s] |
39 | mov word [edi - 2], 0x0a0d |
||
3790 | hidnplayr | 40 | |
41 | mcall send, [socketnum], s, , 0 |
||
42 | |||
3793 | hidnplayr | 43 | jmp wait_for_servercommand |
44 | |||
4920 | hidnplayr | 45 | |
3800 | hidnplayr | 46 | cmd_dele: |
3793 | hidnplayr | 47 | |
3800 | hidnplayr | 48 | mov dword[s], "DELE" |
49 | mov byte[s], " " |
||
50 | |||
51 | mov ecx, 256 |
||
52 | xor al, al |
||
53 | mov edi, s |
||
54 | repne scasb |
||
3814 | hidnplayr | 55 | lea esi, [edi - s] |
56 | mov word [edi - 2], 0x0a0d |
||
3800 | hidnplayr | 57 | |
58 | mcall send, [socketnum], s, , 0 |
||
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 | |||
68 | mov dword[s], "LIST" |
||
3814 | hidnplayr | 69 | mov word[s+4], 0x0a0d |
4920 | hidnplayr | 70 | mcall send, [socketnum], s, 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 |
||
3793 | hidnplayr | 79 | |
4920 | hidnplayr | 80 | mov esi, s+5 |
81 | mov ecx, 256-5 |
||
82 | call set_filename |
||
3800 | hidnplayr | 83 | |
84 | mov [filestruct.subfn], 2 ; create/rewrite file |
||
85 | mov [filestruct.offset], 0 |
||
86 | mov [filestruct.offset+4], 0 |
||
87 | mov [filestruct.size], 0 |
||
88 | mov [filestruct.ptr], 0 |
||
89 | |||
90 | mcall 70, filestruct |
||
91 | cmp eax, -1 |
||
92 | ; je fileerror |
||
93 | |||
4920 | hidnplayr | 94 | ; Prepare to write to the file |
95 | |||
3800 | hidnplayr | 96 | mov [filestruct.subfn], 3 ; write to file |
4920 | hidnplayr | 97 | mov [operation], OPERATION_RETR |
3800 | hidnplayr | 98 | |
4920 | hidnplayr | 99 | ; Request the file from server |
100 | |||
3793 | hidnplayr | 101 | mov dword[s], "RETR" |
102 | mov byte[s+4], " " |
||
103 | |||
104 | mov ecx, 256 |
||
105 | xor al, al |
||
106 | mov edi, s |
||
107 | repne scasb |
||
3814 | hidnplayr | 108 | lea esi, [edi - s] |
4920 | hidnplayr | 109 | mov dword[edi - 2], 0x0a0d |
3793 | hidnplayr | 110 | mcall send, [socketnum], s, , 0 |
111 | |||
4920 | hidnplayr | 112 | invoke con_write_asciiz, s ; print command |
3793 | hidnplayr | 113 | jmp wait_for_servercommand |
114 | |||
115 | |||
116 | cmd_stor: |
||
117 | |||
118 | call open_dataconnection |
||
119 | |||
3800 | hidnplayr | 120 | mov [operation], OPERATION_STOR |
121 | |||
122 | mov [filestruct.subfn], 0 ; read file |
||
123 | mov [filestruct.offset], 0 |
||
124 | mov [filestruct.offset+4], 0 |
||
125 | mov [filestruct.size], BUFFERSIZE |
||
126 | mov [filestruct.ptr], buffer_ptr2 |
||
127 | |||
4920 | hidnplayr | 128 | mov esi, s+5 |
3800 | hidnplayr | 129 | mov ecx, 256-5 |
130 | call set_filename |
||
131 | |||
3793 | hidnplayr | 132 | mov dword[s], "STOR" |
133 | mov byte[s+4], " " |
||
134 | |||
135 | mov ecx, 256 |
||
136 | xor al, al |
||
137 | mov edi, s |
||
138 | repne scasb |
||
3814 | hidnplayr | 139 | lea esi, [edi - s] |
140 | mov word [edi - 2], 0x0a0d |
||
3793 | hidnplayr | 141 | mcall send, [socketnum], s, , 0 |
142 | |||
3800 | hidnplayr | 143 | jmp wait_for_servercommand |
144 | |||
145 | |||
3802 | hidnplayr | 146 | cmd_lcwd: |
3800 | hidnplayr | 147 | |
3802 | hidnplayr | 148 | mov esi, s+5 |
149 | mov ecx, 256-5 |
||
150 | .loop: |
||
151 | lodsb |
||
152 | cmp al, 10 |
||
153 | je .done |
||
154 | test al, al |
||
155 | je .done |
||
156 | loop .loop |
||
157 | .done: |
||
158 | mov byte[esi-1], 0 |
||
159 | mcall 30, 1, s+5 ; set working directory |
||
160 | mcall 30, 2, s, 256 ; and read it again |
||
161 | |||
162 | invoke con_write_asciiz, str_lcwd |
||
163 | invoke con_write_asciiz, s |
||
3813 | hidnplayr | 164 | invoke con_write_asciiz, str_newline |
3802 | hidnplayr | 165 | |
166 | jmp wait_for_usercommand |
||
167 | |||
4920 | hidnplayr | 168 | |
3804 | hidnplayr | 169 | cmd_cdup: |
3802 | hidnplayr | 170 | |
3804 | hidnplayr | 171 | mov dword[s], "CDUP" |
3814 | hidnplayr | 172 | mov word[s+4], 0x0d0a |
173 | mcall send, [socketnum], s, 6, 0 |
||
3802 | hidnplayr | 174 | |
3804 | hidnplayr | 175 | jmp wait_for_servercommand |
176 | |||
4920 | hidnplayr | 177 | |
3804 | hidnplayr | 178 | cmd_rmd: |
179 | |||
180 | mov dword[s], "RMD " |
||
181 | |||
182 | mov ecx, 256 |
||
183 | xor al, al |
||
184 | mov edi, s |
||
185 | repne scasb |
||
3814 | hidnplayr | 186 | lea esi, [edi - s] |
187 | mov word [edi - 2], 0x0a0d |
||
3804 | hidnplayr | 188 | |
189 | mcall send, [socketnum], s, , 0 |
||
190 | |||
191 | jmp wait_for_servercommand |
||
192 | |||
4920 | hidnplayr | 193 | |
3804 | hidnplayr | 194 | cmd_mkd: |
195 | |||
196 | mov dword[s], "MKD " |
||
197 | |||
198 | mov ecx, 256 |
||
199 | xor al, al |
||
200 | mov edi, s |
||
201 | repne scasb |
||
3814 | hidnplayr | 202 | lea esi, [edi - s] |
203 | mov word [edi - 2], 0x0a0d |
||
3804 | hidnplayr | 204 | |
205 | mcall send, [socketnum], s, , 0 |
||
206 | |||
207 | jmp wait_for_servercommand |
||
208 | |||
209 | |||
3800 | hidnplayr | 210 | ; esi = source ptr |
211 | ; ecx = max length of source buffer |
||
212 | set_filename: |
||
213 | |||
4920 | hidnplayr | 214 | mov edi, filestruct.name |
3800 | hidnplayr | 215 | .loop: |
216 | lodsb |
||
217 | test al, al |
||
218 | jz .done |
||
219 | cmp al, 10 |
||
220 | je .done |
||
221 | stosb |
||
222 | loop .loop |
||
223 | .done: |
||
224 | xor al, al ; append a 0 byte |
||
225 | stosb |
||
226 | |||
4920 | hidnplayr | 227 | ret |