Subversion Repositories Kolibri OS

Rev

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

Rev 2562 Rev 2563
Line 47... Line 47...
47
        db 'PASV'
47
        db 'PASV'
48
        dd cmdPASV
48
        dd cmdPASV
49
        db 'PWD', 0     ; Print Working Directory
49
        db 'PWD', 0
50
        dd cmdPWD
50
        dd cmdPWD
51
        db 'PORT'
51
        db 'PORT'
52
        dd cmdPORT
52
        dd cmdPORT
53
        db 'QUIT'
53
        db 'QUIT'
54
        dd cmdQUIT
54
        dd cmdQUIT
55
        db 'RETR'
55
        db 'RETR'
56
        dd cmdRETR
56
        dd cmdRETR
57
        db 'STOR'
57
        db 'STOR'
Line 74... Line 74...
74
 
74
 
Line 75... Line 75...
75
align 4
75
align 4
Line 76... Line 76...
76
cmdCWD:
76
cmdCWD:                 ; Change Working Directory
-
 
77
 
-
 
78
        sub     ecx, 4
-
 
79
        jb      .err
-
 
80
        add     esi, 4
-
 
81
        mov     edi, work_dir + 1
-
 
82
 
-
 
83
        cmp     byte [esi], '/'
-
 
84
        jne     @f
-
 
85
        inc     esi
-
 
86
        dec     ecx
-
 
87
        jz      .done
-
 
88
       @@:
-
 
89
 
-
 
90
  .loop:
-
 
91
        lodsb
-
 
92
        cmp     al, 0x20
-
 
93
        jb      .done
-
 
94
        stosb
-
 
95
        loop    .loop
-
 
96
  .done:
77
 
97
        cmp     byte [edi-1], '/'
-
 
98
        je      @f
-
 
99
        mov     byte [edi], '/'
-
 
100
        inc     edi
-
 
101
       @@:
-
 
102
        mov     byte [edi], 0
-
 
103
 
-
 
104
        mcall   send, [socketnum2], str250, str250.length, 0
-
 
105
 
-
 
106
        ret
-
 
107
 
-
 
108
  .err:
-
 
109
 
Line 78... Line 110...
78
        ret
110
        ret
Line 79... Line 111...
79
 
111
 
80
align 4
112
align 4
Line 86... Line 118...
86
cmdLIST:
118
cmdLIST:
Line 87... Line 119...
87
 
119
 
88
        cmp     [mode], MODE_ACTIVE
120
; If we are in active mode, it's time to open a data socket..
Line -... Line 121...
-
 
121
        cmp     [mode], MODE_ACTIVE
89
        jne     @f
122
        jne     @f
90
        mcall   connect, [datasocketnum], datasock, datasock.length
123
        mcall   connect, [datasocketnum], datasock, datasock.length
91
        cmp     eax, -1
124
        cmp     eax, -1
92
        je      .err
125
        je      .err
93
  @@:
126
  @@:
94
 
127
 
Line -... Line 128...
-
 
128
; Warn the client we're about to send the data
95
        mcall   send, [socketnum2], str150, str150.length, 0    ; here it comes..
129
        mcall   send, [socketnum2], str150, str150.length, 0    ; here it comes..
Line -... Line 130...
-
 
130
 
-
 
131
; Create fpath from home_dir and work_dir
-
 
132
        call    create_path
-
 
133
 
96
 
134
; Start the search
97
        push    FA_READONLY + FA_FOLDER
135
        push    FA_READONLY + FA_FOLDER
98
        push    str_mask
136
        push    str_mask
99
        push    home_dir
137
        push    fpath
Line 100... Line 138...
100
        call    [file.find.first]
138
        call    [file.find.first]
101
 
-
 
102
        mov     edi, buffer
-
 
103
        jmp     .parse_file
-
 
104
 
-
 
105
  .checknextfile:
-
 
106
        push    edx
-
 
107
        call    [file.find.next]
139
 
108
 
140
        mov     edi, buffer
109
  .parse_file:
141
  .parse_file:
Line 110... Line 142...
110
        test    eax, eax
142
        test    eax, eax        ; did we find a file?
Line 111... Line 143...
111
        jz      .done
143
        jz      .done
112
 
144
 
113
        mov     edx, eax
145
        mov     edx, eax        ; yes, save the descripter
Line 114... Line 146...
114
 
146
 
115
; first, convert the attributes
147
; first, convert the attributes
Line 116... Line 148...
116
        test    [eax + FileInfoA.Attributes], FA_FOLDER
148
        test    [edx + FileInfoA.Attributes], FA_FOLDER
117
        jnz     .folder
149
        jnz     .folder
118
 
150
 
Line 119... Line 151...
119
        test    [eax + FileInfoA.Attributes], FA_READONLY
151
        test    [edx + FileInfoA.Attributes], FA_READONLY
120
        jnz     .readonly
152
        jnz     .readonly
121
 
153
 
122
        mov     eax, '-rw-'
154
        mov     eax, '-rw-'
Line 123... Line 155...
123
        stosd
155
        stosd
124
        jmp     .attr
156
        jmp     .attr
125
 
157
 
Line 151... Line 183...
151
 
183
 
152
; now the filesize in ascii
184
; now the filesize in ascii
153
        mov     ebx, dword [edx + FileInfoA.FileSize]
185
        mov     ebx, [edx + FileInfoA.FileSizeLow]
Line 154... Line 186...
154
        call    dword_to_ascii
186
        call    dword_to_ascii
155
 
187
 
156
        mov     al, ' '
188
        mov     al, ' '
Line 157... Line 189...
157
        stosb
189
        stosb
158
 
190
 
Line 184... Line 216...
184
        loop    .nameloop
216
        loop    .nameloop
185
 
217
 
186
  .namedone:
218
; insert a cr lf
187
        mov     ax, 0x0d0a
219
  .namedone:
Line -... Line 220...
-
 
220
        mov     ax, 0x0d0a
188
        stosw
221
        stosw
189
        jmp     .checknextfile
222
 
190
 
223
; check next file
191
  .done:
-
 
Line -... Line 224...
-
 
224
        push    edx
-
 
225
        call    [file.find.next]
-
 
226
        jmp     .parse_file
-
 
227
 
-
 
228
; close file desc
-
 
229
  .done:
192
        push    edx
230
        push    edx
193
        call    [file.find.close]
231
        call    [file.find.close]
194
 
232
 
Line -... Line 233...
-
 
233
; append the string with a 0
195
        xor     al, al
234
        xor     al, al
196
        stosb
235
        stosb
Line -... Line 236...
-
 
236
 
197
 
237
; print everything on the console
198
        push    buffer
238
        push    buffer
Line -... Line 239...
-
 
239
        call    [con_write_asciiz]
199
        call    [con_write_asciiz]
240
 
200
 
241
; and send it to the client
Line -... Line 242...
-
 
242
        lea     esi, [edi - buffer]
201
        lea     esi, [edi - buffer]
243
        mcall   send, [datasocketnum], buffer, , 0
Line 202... Line 244...
202
        mcall   send, [datasocketnum], buffer, , 0
244
 
203
 
245
; close the data socket..
204
        mcall   close, [datasocketnum]
246
        mcall   close, [datasocketnum]
205
 
247
 
Line -... Line 248...
-
 
248
        cmp     [mode], MODE_PASSIVE_OK
206
        cmp     [mode], MODE_PASSIVE_OK
249
        jne     @f
Line 207... Line 250...
207
        jne     @f
250
        mov     [mode], MODE_PASSIVE_WAIT
Line 208... Line 251...
208
        mov     [mode], MODE_PASSIVE_WAIT
251
      @@:
209
      @@:
252
 
Line 294... Line 337...
294
 
337
 
Line 295... Line 338...
295
align 4
338
align 4
Line 296... Line 339...
296
cmdPWD:
339
cmdPWD:         ; Print Working Directory
297
 
340
 
Line 298... Line 341...
298
        mov     dword[buffer], '257 '
341
        mov     dword[buffer], '257 '
299
        mov     byte[buffer+4], '"'
342
        mov     byte[buffer+4], '"'
Line 300... Line 343...
300
 
343
 
Line 381... Line 424...
381
cmdRETR:
424
cmdRETR:
Line 382... Line 425...
382
 
425
 
383
;        mcall   connect, [datasocketnum], datasock, datasock.length
426
        cmp     [mode], MODE_ACTIVE
Line -... Line 427...
-
 
427
        jne     @f
-
 
428
        mcall   connect, [datasocketnum], datasock, datasock.length
384
;        cmp     eax, -1
429
;        cmp     eax, -1
385
;        je      .err
430
;        je      .err
386
 
431
  @@:
-
 
432
 
-
 
433
        mcall   send, [socketnum2], str150, str150.length, 0    ; here it comes..
-
 
434
 
Line 387... Line 435...
387
;        push    O_READ
435
        push    O_READ
388
;        push    home_dir
436
        push    home_dir
389
;        call    [file.open]
437
        call    [file.open]
390
;        test    eax, eax
438
;        test    eax, eax
391
;        jz      .cannot_open
439
;        jz      .cannot_open
-
 
440
 
-
 
441
        mov     ebx, eax
392
;
442
 
-
 
443
  .read_more:
393
;        push    BUFFERSIZE
444
        push    BUFFERSIZE
394
;        push    buffer
445
        push    buffer
395
;        push    eax
446
        push    ebx
396
;        call    [file.read]
447
        call    [file.read]
397
;        cmp     eax, -1
448
;        cmp     eax, -1
398
;        jz      .cannot_open
449
;        je      .cannot_open
-
 
450
 
-
 
451
        push    eax
-
 
452
        push    ebx
-
 
453
        mov     esi, eax
-
 
454
        mcall   send, [datasocketnum], buffer, , 0
-
 
455
        pop     ebx
-
 
456
        pop     ecx
-
 
457
;        cmp     eax, -1
-
 
458
;        je      .socketerr
-
 
459
 
-
 
460
        cmp     ecx, BUFFERSIZE
-
 
461
        je      .read_more
-
 
462
 
-
 
463
        mcall   close, [datasocketnum]
-
 
464
 
-
 
465
        cmp     [mode], MODE_PASSIVE_OK
-
 
466
        jne     @f
-
 
467
        mov     [mode], MODE_PASSIVE_WAIT
-
 
468
      @@:
-
 
469
 
-
 
470
        mcall   send, [socketnum2], str226, str226.length, 0    ; transfer ok
Line 399... Line 471...
399
 
471
 
Line 400... Line 472...
400
        ret
472
        ret
401
 
473
 
Line 540... Line 612...
540
        ret
612
        ret
541
 
613
 
Line 542... Line 614...
542
 
614
align 4
Line -... Line 615...
-
 
615
create_path:            ; combine home_dir and work_dir strings into fpath
-
 
616
        mov     edi, fpath
-
 
617
        mov     esi, home_dir
-
 
618
        mov     ecx, 1024
-
 
619
 
-
 
620
  .loop1:
-
 
621
        lodsb
-
 
622
        or      al, al
-
 
623
        jz      .next
-
 
624
        stosb
-
 
625
        loop    .loop1
-
 
626
  .next:
-
 
627
 
-
 
628
        cmp     byte[edi-1], '/'
-
 
629
        jne     @f
-
 
630
        dec     edi
-
 
631
       @@:
-
 
632
 
-
 
633
        mov     esi, work_dir
-
 
634
        mov     ecx, 1024
-
 
635
 
-
 
636
  .loop2:
-
 
637
        lodsb
-
 
638
        or      al, al
-
 
639
        jz      .done
-
 
640
        stosb
-
 
641
        loop    .loop2
-
 
642
 
-
 
643
  .done:
-
 
644
        stosb
-
 
645
 
-
 
646
        ret
-
 
647
 
-
 
648
 
-
 
649
 
Line 543... Line 650...
543
 
650
 
Line 561... Line 668...
561
.length = $ - str230
668
.length = $ - str230
562
str250  db '250 command successful', 13, 10
669
str250  db '250 command successful', 13, 10
563
;str257  db '257 "'
670
.length = $ - str250
564
;.length = $ - str257
671
str331  db '331 Please specify the password.', 13, 10
565
;str257b db '"', 13, 10
672
.length = $ - str331
566
;.length = $ - str257b
-
 
567
str331  db '331 Please specify the password.', 13, 10
673
str421  db '421 Timeout!', 13, 10
568
.length = $ - str331
-
 
569
str421  db '421 Timeout!', 13, 10
-
 
570
.length = $ - str421
674
.length = $ - str421
571
str425  db '425 Cant open data connection.', 13, 10
675
str425  db '425 Cant open data connection.', 13, 10
572
.length = $ - str425
676
.length = $ - str425
573
str500  db '500 Unsupported command', 13, 10
677
str500  db '500 Unsupported command', 13, 10
574
.length = $ - str500
678
.length = $ - str500
575
str550  db '550 No such file', 13, 10
679
str550  db '550 No such file', 13, 10
576
680
.length = $ - str550
577
681
578
682
579
683
-
 
684
580
685