Subversion Repositories Kolibri OS

Rev

Rev 4922 | Rev 6394 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4922 Rev 5011
Line 89... Line 89...
89
        call    ascii_dec
89
        call    ascii_dec
90
        mov     byte[sockaddr2.port+1], bl
90
        mov     byte[sockaddr2.port+1], bl
Line 91... Line 91...
91
 
91
 
92
        invoke  con_write_asciiz, str_open
92
        invoke  con_write_asciiz, str_open
93
        mcall   connect, [datasocket], sockaddr2, 18
93
        mcall   connect, [datasocket], sockaddr2, 18
94
;        cmp     eax, -1
94
        cmp     eax, -1
95
;        je      error_socket
95
        je      error_socket
Line 96... Line 96...
96
        jmp     wait_for_servercommand
96
        jmp     wait_for_servercommand
97
 
97
 
98
  .fail:
98
  .fail:
Line 153... Line 153...
153
        invoke  con_write_asciiz, str_close
153
        invoke  con_write_asciiz, str_close
154
        mcall   close, [datasocket]
154
        mcall   close, [datasocket]
155
        mov     [operation], OPERATION_NONE
155
        mov     [operation], OPERATION_NONE
156
        jmp     wait_for_servercommand
156
        jmp     wait_for_servercommand
Line 157... Line -...
157
 
-
 
158
 
157
 
159
  .rdir:
-
 
160
	cmp	[size_fname], 0
-
 
161
	jne	.realloc
-
 
162
 
-
 
163
  .malloc:					; create a new dynamic block
-
 
164
  	mov 	ecx, eax
-
 
165
	inc 	ecx	
-
 
166
 
-
 
167
	mcall	68,12	      			; eax now points to new buffer	
-
 
168
	
-
 
169
	test 	eax,eax
-
 
170
	je 	error_heap
-
 
171
 
-
 
172
	mov 	[ptr_fname_start], eax
-
 
173
 
-
 
174
	jmp 	.rdir_init
-
 
175
 
158
  .rdir:
176
  .realloc:					; expand block created with .malloc
-
 
177
 
159
        ; alloc/realloc memory block to store filenames
178
  	mov 	ecx, eax			; eax is size of buffer received
160
        mov     ecx, eax                        ; eax is size of buffer received
179
	inc	ecx
-
 
180
 
161
        inc     ecx
181
	add	ecx, [size_fname]		; added old size to form new required size
-
 
182
 
162
        add     ecx, [size_fname]               ; added old size to form new required size
183
	mcall 	68,20,,[ptr_fname_start]
-
 
184
 
163
        mcall   68, 20, , [ptr_fname]           ; realloc
185
    	test	eax, eax
164
        test    eax, eax
-
 
165
        je      error_heap
-
 
166
        mov     [ptr_fname], eax                ; eax contains the new block now
Line 186... Line -...
186
	je	error_heap
-
 
187
 
-
 
188
	mov	[ptr_fname_start], eax		; eax contains the new block now
-
 
189
	add	eax, [size_fname]
167
        mov     [ptr_queue], eax
190
 
-
 
191
  .rdir_init:					; copies filenames into our buffer
168
 
192
 
169
        ; copy filenames into fname buffer
193
	mov	esi, buf_buffer2
-
 
-
 
170
        mov     esi, buf_buffer2
194
	mov	edi, eax
171
        mov     edi, eax
195
	
172
        add     edi, [size_fname]
196
  .copy_buf:
173
  .copy_buf:
197
  	lodsb
174
        lodsb
198
	cmp	al,13				; ignore any \r character
175
        cmp     al, 13                          ; ignore any carriage return character
199
	je 	.copy_buf
-
 
200
	stosb
176
        je      .copy_buf
201
 
177
        stosb
202
	cmp	al, 10
178
        cmp     al, 10                          ; linefeed marks end of filename
203
	jne 	.not_end
-
 
204
	inc 	[queued]
179
        je      @f
205
 
180
        inc     [queued]
206
  .not_end:
181
  @@:
Line 207... Line -...
207
	test	al,al
-
 
208
	jne 	.copy_buf
-
 
209
	
-
 
210
	dec 	edi
182
        test    al, al                          ; 0 marks end of buffer
211
	dec 	edi
183
        jne     .copy_buf
212
 
-
 
213
	mov	eax, [ptr_fname_start]
184
 
214
	mov 	[ptr_queue], eax
185
        ; All received filenames have been copied, calculate new size of fname buffer
215
 
-
 
216
	sub 	edi, eax		; edi contains the current size now
186
        dec     edi                             ; dont count the trailing 0 byte
Line 217... Line -...
217
	mov	[size_fname], edi	
-
 
218
 
-
 
219
	jmp	data_loop
-
 
220
	
-
 
221
 
-
 
222
; files for rdir operation are queued
-
 
223
transfer_queued:
-
 
224
 
-
 
225
	mov	esi, [ptr_queue]		; always pointing to current part of ptr_fname_start
-
 
226
	mov 	edi, buf_cmd+5	   		; always point to filename for retr command
-
 
227
 
-
 
228
  .build_filename:
-
 
229
	lodsb	
-
 
230
	stosb
-
 
231
 
-
 
232
	cmp 	al,10
-
 
233
	je 	.get_file			; filename ends with character 10
-
 
234
	test	al,al
-
 
235
	jz	.null_found			; this should be end of buffer
-
 
236
	jmp	.build_filename
-
 
237
 
-
 
238
  .null_found:					
-
 
239
 
-
 
240
	mov	[queued],0
-
 
241
	jmp 	.free
-
 
242
 
-
 
243
  .get_file:
-
 
244
	dec	[queued]
-
 
245
	jnz	.after_free	
-
 
246
	
-
 
247
  .free:
-
 
248
	mcall	68,13,[ptr_fname_start]		; freeing the buffer
-
 
249
	test	eax,eax
-
 
250
	jz 	error_heap
-
 
251
	jmp	wait_for_usercommand
-
 
252
 
-
 
253
  .after_free:
-
 
254
	xor	al,al				; appending 0 after retr command
-
 
255
	stosb
-
 
256
	mov	eax, esi
187
        sub     edi, [ptr_fname]
257
	mov	[ptr_queue], eax
188
        mov     [size_fname], edi       
258
	
189
        jmp     data_loop
259
	jmp	cmd_retr
190
 
260
		
191
 
261
close_datacon:
192
close_datacon:
Line 262... Line -...
262
        cmp     [operation], OPERATION_NONE
-
 
263
        je      wait_for_usercommand
193
        cmp     [operation], OPERATION_NONE
Line 264... Line 194...
264
        invoke  con_write_asciiz, str_close
194
        je      wait_for_usercommand
265
        mcall   close, [datasocket]
195
        invoke  con_write_asciiz, str_close
266
        jmp     wait_for_usercommand
196
        mcall   close, [datasocket]