Subversion Repositories Kolibri OS

Rev

Rev 2571 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2554 hidnplayr 1
 
2
 
2578 hidnplayr 3
        stack           rb 0
4
5
        home_dir        rb 1024
2554 hidnplayr 6
 
2578 hidnplayr 7
        fpath           rb 1024*3
8
9
        type            db ?    ; ASCII/EBDIC/IMAGE/..
10
 
11
        socketnum       dd ?    ; Commands socket
12
        state           dd ?    ; disconnected/logging in/logged in/..
13
        passivesocknum  dd ?    ; when in passive mode, this is the listening socket
14
        datasocketnum   dd ?    ; socket used for data transfers
15
16
        datasock        sockaddr_in
17
 
18
        buffer          rb BUFFERSIZE
19
 
20
21
22
 
23
 
24
 
25
 
2554 hidnplayr 26
27
        cmp     byte [esi], 0x20        ; skip all leading characters
28
 
2578 hidnplayr 29
        inc     esi
30
        dec     ecx
31
        cmp     ecx, 3
32
        ja      parse_cmd
33
        ret
34
  .ok:
35
36
        cmp     byte [esi+3], 0x20
37
 
2557 hidnplayr 38
        mov     byte [esi+3], 0
39
       @@:
40
41
        mov     eax, [esi]
42
 
2554 hidnplayr 43
        mov     edi, commands           ; list of commands to scan
44
  .scanloop:
45
        cmp     eax, [edi]
46
        jne     .try_next
47
2557 hidnplayr 48
        jmp     dword [edi+4]
2554 hidnplayr 49
 
50
  .try_next:
51
 
52
        cmp     byte [edi], 0
53
        jne     .scanloop
54
55
  .error:
56
 
57
2578 hidnplayr 58
        ret
2557 hidnplayr 59
 
2554 hidnplayr 60
61
 
62
 
63
2562 hidnplayr 64
        db 'ABOR'
2554 hidnplayr 65
 
66
        db 'CDUP'
67
        dd cmdCDUP
2571 hidnplayr 68
        db 'CWD', 0
69
        dd cmdCWD
2554 hidnplayr 70
        db 'DELE'
71
        dd cmdDELE
72
        db 'LIST'
73
        dd cmdLIST
74
        db 'NLST'
75
        dd cmdNLST
76
        db 'NOOP'
77
        dd cmdNOOP
78
        db 'PASS'
79
        dd cmdPASS
2557 hidnplayr 80
        db 'PASV'
81
        dd cmdPASV
2562 hidnplayr 82
        db 'PWD', 0
83
        dd cmdPWD
2563 hidnplayr 84
        db 'PORT'
2554 hidnplayr 85
        dd cmdPORT
86
        db 'QUIT'
87
        dd cmdQUIT
88
        db 'RETR'
89
        dd cmdRETR
90
        db 'STOR'
91
        dd cmdSTOR
92
        db 'SYST'
93
        dd cmdSYST
94
        db 'TYPE'
95
        dd cmdTYPE
96
        db 'USER'
97
        dd cmdUSER
98
        db 'XPWD'
99
        dd cmdPWD
100
        db 0            ; end marker
101
2562 hidnplayr 102
2554 hidnplayr 103
 
104
 
105
106
        ; TODO: abort the current filetransfer
107
 
2578 hidnplayr 108
        ret
109
 
2554 hidnplayr 110
align 4
111
 
112
2571 hidnplayr 113
        cmp     byte [edx + thread_data.work_dir+1], 0
114
 
2578 hidnplayr 115
2571 hidnplayr 116
        mov     ecx, 1024
117
 
118
        lea     edi, [edx + thread_data.work_dir+1024]
119
        repne   scasb
2578 hidnplayr 120
        std
2571 hidnplayr 121
        dec     edi
122
        mov     al,'/'
123
        scasb
124
        cld
125
        mov     byte[edi], 0
126
127
  .done:
128
 
129
        ret
2578 hidnplayr 130
2571 hidnplayr 131
align 4
132
 
133
2563 hidnplayr 134
        sub     ecx, 4
2554 hidnplayr 135
 
2563 hidnplayr 136
        add     esi, 4
137
138
  .scan:
2571 hidnplayr 139
 
140
        push    ecx
2578 hidnplayr 141
        mov     ecx, 1024
142
  .find_zero:
143
        cmp     byte [edi], 0
144
        je      .found_zero
145
        inc     edi
146
        loop    .find_zero
147
  .found_zero:
148
        pop     ecx
149
150
        cmp     byte [esi], '/'
2563 hidnplayr 151
 
152
        inc     esi
153
        dec     ecx
154
        jz      .done
155
       @@:
156
157
  .loop:
158
 
159
        cmp     al, 0x20
160
        jb      .done
161
        cmp     al, '.'
162
        je      .up
2571 hidnplayr 163
  .continue:
164
        stosb
165
        loop    .loop
2563 hidnplayr 166
  .done:
167
        cmp     byte [edi-1], '/'
168
        je      @f
169
        mov     byte [edi], '/'
170
        inc     edi
171
       @@:
172
        mov     byte [edi], 0
173
174
        mcall   send, [edx + thread_data.socketnum], str250, str250.length, 0
175
 
2578 hidnplayr 176
        ret
2563 hidnplayr 177
 
2554 hidnplayr 178
  .up:
179
 
2571 hidnplayr 180
        cmp     al, '.'
181
        jne     .continue
182
183
;;;;        call    cmdCDUP     ;;;;;; FIXME
184
 
2578 hidnplayr 185
2571 hidnplayr 186
  .err:
187
 
2563 hidnplayr 188
2578 hidnplayr 189
        ret
2563 hidnplayr 190
 
191
align 4
192
 
2554 hidnplayr 193
194
        ret
195
 
196
align 4
197
 
198
199
; If we are in active mode, it's time to open a data socket..
200
 
2563 hidnplayr 201
        jne     @f
2578 hidnplayr 202
        mov     ecx, [edx + thread_data.datasocketnum]
2562 hidnplayr 203
        lea     edx, [edx + thread_data.datasock]
2578 hidnplayr 204
        mov     esi, sizeof.thread_data.datasock
205
        mcall   connect
206
        mov     edx, [esp+4]                                    ; thread_data pointer
207
        cmp     eax, -1
208
        je      socketerror
2562 hidnplayr 209
        mov     [edx + thread_data.datasocketnum], eax
2571 hidnplayr 210
  @@:
2578 hidnplayr 211
2562 hidnplayr 212
; Create fpath from home_dir and work_dir
213
 
2563 hidnplayr 214
215
        lea     eax, [edx + thread_data.fpath]
216
 
2578 hidnplayr 217
        call    [con_write_asciiz]
218
        push    str_newline
2571 hidnplayr 219
        call    [con_write_asciiz]
220
221
; Start the search
222
 
2563 hidnplayr 223
        push    str_mask
2571 hidnplayr 224
        lea     eax, [edx + thread_data.fpath]
2562 hidnplayr 225
        push    eax
2578 hidnplayr 226
        call    [file.find.first]
227
2562 hidnplayr 228
        test    eax, eax
229
 
2578 hidnplayr 230
231
        lea     edi, [edx + thread_data.buffer]
232
 
233
        test    eax, eax        ; did we find a file?
2562 hidnplayr 234
        jz      .done
2563 hidnplayr 235
        mov     ebx, eax        ; yes, save the descripter in ebx
2562 hidnplayr 236
2578 hidnplayr 237
; first, convert the attributes
2562 hidnplayr 238
 
239
        jnz     .folder
2578 hidnplayr 240
2562 hidnplayr 241
        test    [ebx + FileInfoA.Attributes], FA_READONLY
242
 
2578 hidnplayr 243
2562 hidnplayr 244
        mov     eax, '-rw-'
245
 
246
        jmp     .attr
247
248
  .folder:
249
 
250
        stosd
251
        jmp     .attr
2563 hidnplayr 252
2562 hidnplayr 253
  .readonly:
254
 
255
        stosd
256
257
  .attr:
258
 
259
        stosd
260
        mov     ax, 'w-'
261
        stosw
262
        mov     al, ' '
263
        stosb
264
265
; now..
266
 
267
        stosw
268
269
; now write owner, everything is owned by FTP, woohoo!
270
 
271
        stosd
272
        stosd
273
274
; now the filesize in ascii
275
 
276
        call    dword_to_ascii
2578 hidnplayr 277
2562 hidnplayr 278
        mov     al, ' '
279
 
280
281
; then date (month/day/year)
282
 
283
        mov     eax, [months + 4*eax]
2578 hidnplayr 284
        stosd
285
2562 hidnplayr 286
        movzx   eax, [ebx + FileInfoA.DateModify + FileDateTime.day]
287
 
2578 hidnplayr 288
2562 hidnplayr 289
        mov     al, ' '
290
 
291
292
        movzx   eax, [ebx + FileInfoA.DateModify + FileDateTime.year]
293
 
2578 hidnplayr 294
2562 hidnplayr 295
        mov     al, ' '
296
 
297
298
; and last but not least, filename
299
 
300
        mov     ecx, 264
2578 hidnplayr 301
  .nameloop:
302
        lodsb
2562 hidnplayr 303
        test    al, al
304
        jz      .namedone
305
        stosb
306
        loop    .nameloop
307
308
; insert a cr lf
309
 
2563 hidnplayr 310
        mov     ax, 0x0a0d
2562 hidnplayr 311
        stosw
2571 hidnplayr 312
2562 hidnplayr 313
; check next file
314
 
2563 hidnplayr 315
        call    [file.find.next]
2578 hidnplayr 316
        jmp     .parse_file
2563 hidnplayr 317
318
; close file desc
319
 
320
        push    ebx
2562 hidnplayr 321
        call    [file.find.close]
2578 hidnplayr 322
2562 hidnplayr 323
; append the string with a 0
324
 
2563 hidnplayr 325
        stosb
2562 hidnplayr 326
327
; Warn the client we're about to send the data
328
 
2571 hidnplayr 329
        mcall   send, [edx + thread_data.socketnum], str150, str150.length, 0    ; here it comes..
2578 hidnplayr 330
        pop     edx esi
331
332
; and send it to the client
2562 hidnplayr 333
 
2563 hidnplayr 334
        lea     edx, [edx + thread_data.buffer]
2578 hidnplayr 335
        sub     esi, edx
336
        xor     edi, edi
337
        mcall   send
338
339
; close the data socket..
2562 hidnplayr 340
 
2563 hidnplayr 341
        mcall   close, [edx + thread_data.datasocketnum]
2578 hidnplayr 342
343
        cmp     [edx + thread_data.mode], MODE_PASSIVE_OK
2562 hidnplayr 344
 
2578 hidnplayr 345
        mov     [edx + thread_data.mode], MODE_NOTREADY
2562 hidnplayr 346
      @@:
2578 hidnplayr 347
2562 hidnplayr 348
; And send "transfer ok" on the base connection
349
 
2563 hidnplayr 350
2578 hidnplayr 351
        ret
2562 hidnplayr 352
 
2554 hidnplayr 353
  .nosuchdir:
354
 
2578 hidnplayr 355
356
        ret
2562 hidnplayr 357
 
2578 hidnplayr 358
359
 
360
 
2554 hidnplayr 361
362
        ; TODO: same as list but simpler output format
363
 
2578 hidnplayr 364
        ret
365
 
2554 hidnplayr 366
align 4
367
 
368
369
        ret
370
 
371
align 4
372
 
373
2557 hidnplayr 374
        ; TODO: verify password
375
 
2578 hidnplayr 376
        mcall   send, [edx + thread_data.socketnum], str230, str230.length, 0
2560 hidnplayr 377
 
2578 hidnplayr 378
        push    str_pass_ok
379
 
2560 hidnplayr 380
381
        mov     edx, [esp+4]                                    ; thread_data pointer
382
 
2578 hidnplayr 383
384
        ret
2557 hidnplayr 385
 
386
align 4
387
 
388
2560 hidnplayr 389
; Open a new TCP socket
390
 
2578 hidnplayr 391
        mov     edx, [esp+4]                                    ; thread_data pointer
2562 hidnplayr 392
        cmp     eax, -1
2578 hidnplayr 393
        je      socketerror
2562 hidnplayr 394
        mov     [edx + thread_data.passivesocknum], eax
2578 hidnplayr 395
396
; Bind it to a known local port
2562 hidnplayr 397
 
2578 hidnplayr 398
        mov     [edx + thread_data.datasock.sin_port], 2000
399
        mov     [edx + thread_data.datasock.sin_addr], 0
400
401
        mov     ecx, eax ;[edx + thread_data.passivesocknum]
2562 hidnplayr 402
 
2578 hidnplayr 403
        mcall   bind, , , sizeof.thread_data.datasock
404
        mov     edx, [esp+4]                                    ; thread_data pointer
405
        cmp     eax, -1
406
        je      bind_err
2562 hidnplayr 407
408
; And set it to listen!
409
 
2578 hidnplayr 410
411
; Tell our thread we are ready to accept incoming calls
2562 hidnplayr 412
 
2578 hidnplayr 413
        mov     [edx + thread_data.mode], MODE_PASSIVE_WAIT
414
415
; Now tell the client where to connect to in this format:
2562 hidnplayr 416
 
2578 hidnplayr 417
; where a1.a2.a3.a4 is the IP address and p1*256+p2 is the port number.
418
        lea     edi, [edx + thread_data.buffer]
419
        mov     eax, '227 '     ; FIXME (now hardcoded to 127.0.0.1:2000)
420
        stosd
2562 hidnplayr 421
        mov     eax, '(127'
422
        stosd
423
        mov     eax, ',0,0'
424
        stosd
425
        mov     eax, ',1,7'
426
        stosd
427
        mov     eax, ',208'
428
        stosd
429
        mov     al, ')'
430
        stosb
431
        mov     ax, 0x0a0d
432
        stosw
2571 hidnplayr 433
        xor     al, al
2562 hidnplayr 434
        stosb
435
436
        lea     esi, [edi - thread_data.buffer]
437
 
2578 hidnplayr 438
        mov     ecx, [edx + thread_data.socketnum]
439
        lea     edx, [edx + thread_data.buffer]
440
        mcall   send, , , ,0
441
442
        ret
2562 hidnplayr 443
 
2560 hidnplayr 444
align 4
445
 
446
2563 hidnplayr 447
        mov     dword [edx + thread_data.buffer], '257 '
2554 hidnplayr 448
 
2578 hidnplayr 449
450
        lea     edi, [edx + thread_data.buffer+5]
2560 hidnplayr 451
 
2578 hidnplayr 452
        mov     ecx, 1024
453
  .loop:
2560 hidnplayr 454
        lodsb
455
        or      al, al
456
        jz      .ok
457
        stosb
458
        dec     ecx
459
        jnz     .loop
460
461
  .ok:
462
 
463
        lea     esi, [edi - thread_data.buffer + 4]
2578 hidnplayr 464
        sub     esi, edx
465
        mov     ecx, [edx + thread_data.socketnum]
466
        lea     edx, [edx + thread_data.buffer]
467
        mcall   send, , , , 0
468
469
;        push    work_dir
2560 hidnplayr 470
 
2562 hidnplayr 471
;        call    [con_printf]
472
473
        ret
474
 
2554 hidnplayr 475
align 4
476
 
477
478
; PORT a1,a2,a3,a4,p1,p2
479
 
2560 hidnplayr 480
481
        mov     [edx + thread_data.mode], MODE_ACTIVE
482
 
2578 hidnplayr 483
        lea     esi, [esi+5]
2560 hidnplayr 484
 
485
        call    ascii_to_byte
2578 hidnplayr 486
        mov     bh, al
2560 hidnplayr 487
        inc     esi             ; skip past ','
2578 hidnplayr 488
        call    ascii_to_byte
489
        mov     bl, al
2560 hidnplayr 490
        shl     ebx, 16
2578 hidnplayr 491
        inc     esi
492
        call    ascii_to_byte
2560 hidnplayr 493
        mov     bh, al
494
        inc     esi
2578 hidnplayr 495
        call    ascii_to_byte
2560 hidnplayr 496
        mov     bl, al
497
        inc     esi
2578 hidnplayr 498
2560 hidnplayr 499
; And put it in datasock
500
 
2578 hidnplayr 501
502
; Now the same with portnumber
2560 hidnplayr 503
 
2578 hidnplayr 504
        mov     bh, al
2560 hidnplayr 505
        inc     esi
2578 hidnplayr 506
        call    ascii_to_byte
2560 hidnplayr 507
        mov     bl, al
508
2578 hidnplayr 509
; Save it in datasock too
2560 hidnplayr 510
 
2578 hidnplayr 511
512
; We will open the socket, but do not connect yet!
2560 hidnplayr 513
 
2578 hidnplayr 514
        mcall   socket, AF_INET4, SOCK_STREAM, 0
515
        mov     edx, [esp+4]                                    ; thread_data pointer
2562 hidnplayr 516
        cmp     eax, -1
2578 hidnplayr 517
        je      socketerror
2560 hidnplayr 518
        mov     [edx + thread_data.datasocketnum], eax
2578 hidnplayr 519
520
; Tell the client we are ready
2560 hidnplayr 521
 
2578 hidnplayr 522
        mcall   send, [edx + thread_data.socketnum], str225, str225.length, 0
523
        ret
524
2554 hidnplayr 525
526
 
2560 hidnplayr 527
 
2554 hidnplayr 528
529
        mcall   close, [edx + thread_data.datasocketnum]
530
 
2578 hidnplayr 531
        mcall   close;, [edx + thread_data.socketnum]
532
533
        jmp     thread_exit    ; now close this thread
2557 hidnplayr 534
 
2578 hidnplayr 535
align 4
2554 hidnplayr 536
 
537
538
        sub     ecx, 5
539
 
2571 hidnplayr 540
541
        cmp     [edx + thread_data.mode], MODE_ACTIVE
542
 
2578 hidnplayr 543
        push    esi
2563 hidnplayr 544
        mov     ecx, [edx + thread_data.datasocketnum]
2571 hidnplayr 545
        lea     edx, [edx + thread_data.datasock]
2578 hidnplayr 546
        mcall   connect, , , sizeof.thread_data.datasock
547
        pop     esi
548
        mov     edx, [esp+4]                                    ; thread_data pointer
2571 hidnplayr 549
        cmp     eax, -1
2578 hidnplayr 550
        je      socketerror
2571 hidnplayr 551
        mov     [edx + thread_data.datasocketnum], eax
552
  @@:
2578 hidnplayr 553
2563 hidnplayr 554
        push    esi
2562 hidnplayr 555
 
2571 hidnplayr 556
        pop     esi
557
        dec     edi
558
        add     esi, 5
559
        mov     ecx, 1024
560
  .loop:
561
        lodsb
562
        cmp     al, 0x20
563
        jl      .done
564
        stosb
565
        loop    .loop
566
  .done:
567
        xor     al, al
568
        stosb
569
570
        lea     eax, [edx + thread_data.fpath]
2563 hidnplayr 571
 
2578 hidnplayr 572
        call    [con_write_asciiz]
573
        push    str_newline
2571 hidnplayr 574
        call    [con_write_asciiz]
575
576
        push    O_READ
577
 
2563 hidnplayr 578
        push    eax
2578 hidnplayr 579
        call    [file.open]
580
        test    eax, eax
2563 hidnplayr 581
        jz      .cannot_open
2571 hidnplayr 582
583
        push    eax
2563 hidnplayr 584
 
2571 hidnplayr 585
        pop     ebx
2578 hidnplayr 586
2571 hidnplayr 587
        mov     edx, [esp+4]                                    ; thread_data pointer
2563 hidnplayr 588
 
2578 hidnplayr 589
        push    BUFFERSIZE
2563 hidnplayr 590
        lea     eax, [edx + thread_data.buffer]
591
        push    eax
2578 hidnplayr 592
        push    ebx
593
        call    [file.read]
2563 hidnplayr 594
        cmp     eax, -1
595
        je      .cannot_open    ; fixme: this is not the correct error
2571 hidnplayr 596
597
        push    eax
2562 hidnplayr 598
 
2563 hidnplayr 599
        mov     esi, eax
600
        mov     ecx, [edx + thread_data.datasocketnum]
601
        lea     edx, [edx + thread_data.buffer]
2578 hidnplayr 602
        mcall   send, , , , 0
603
        pop     ebx
604
        pop     ecx
2563 hidnplayr 605
        mov     edx, [esp+4]                                    ; thread_data pointer
606
        cmp     eax, -1
2578 hidnplayr 607
        je      socketerror
2571 hidnplayr 608
609
        cmp     ecx, BUFFERSIZE
2563 hidnplayr 610
 
611
612
        mcall   close, [edx + thread_data.datasocketnum]
613
 
2578 hidnplayr 614
        cmp     [edx + thread_data.mode], MODE_PASSIVE_OK
2563 hidnplayr 615
 
2578 hidnplayr 616
        mov     [edx + thread_data.mode], MODE_PASSIVE_WAIT
2563 hidnplayr 617
      @@:
2578 hidnplayr 618
2563 hidnplayr 619
        mcall   send, [edx + thread_data.socketnum], str226, str226.length, 0    ; transfer ok
620
 
2578 hidnplayr 621
        ret
2563 hidnplayr 622
 
2554 hidnplayr 623
  .cannot_open:
624
 
2571 hidnplayr 625
        call    [con_set_flags]
626
        push    str_notfound
627
        call    [con_write_asciiz]
628
        pushd   0x07
629
        call    [con_set_flags]
630
631
        mcall   send, [edx + thread_data.socketnum], str550, str550.length, 0    ; file not found
632
 
2578 hidnplayr 633
        ret
2571 hidnplayr 634
 
635
align 4
636
 
2554 hidnplayr 637
638
        ; TODO: check if user has write permission, and write file if so
639
 
2578 hidnplayr 640
        ret
641
 
2554 hidnplayr 642
align 4
643
 
644
645
        mcall   send, [edx + thread_data.socketnum], str215, str215.length, 0
646
 
2578 hidnplayr 647
        ret
2557 hidnplayr 648
 
2554 hidnplayr 649
align 4
650
 
651
652
        cmp     ecx, 6
653
 
2560 hidnplayr 654
655
        mov     al, byte[esi+5]
656
 
657
658
        cmp     al, 'A'
659
 
660
        cmp     al, 'E'
661
        je      .ebdic
662
        cmp     al, 'I'
663
        je      .image
664
        cmp     al, 'L'
665
        je      .local
666
667
        jmp     parse_cmd.error
668
 
669
  .ascii:
670
 
671
        jmp     .subtype
2578 hidnplayr 672
2560 hidnplayr 673
  .ebdic:
674
 
675
2578 hidnplayr 676
  .subtype:
2560 hidnplayr 677
 
678
        cmp     ecx, 8
679
 
680
681
        mov     al, byte[esi+7]
682
 
683
684
        cmp     al, 'N'
685
 
686
        cmp     al, 'T'
687
        je      .telnet
688
        cmp     al, 'C'
689
        je      .asacc
690
691
        jmp     parse_cmd.error
692
 
693
  .non_print:
694
 
695
        jmp     .ok
2578 hidnplayr 696
2560 hidnplayr 697
  .telnet:
698
 
699
        jmp     .ok
2578 hidnplayr 700
2560 hidnplayr 701
  .asacc:
702
 
703
        jmp     .ok
2578 hidnplayr 704
2560 hidnplayr 705
  .image:
706
 
707
        jmp     .ok
2578 hidnplayr 708
2560 hidnplayr 709
  .local:
710
 
711
        jb      parse_cmd.error
712
713
        mov     al, byte[esi+7]
714
 
715
        jb      parse_cmd.error
716
        cmp     al, 9
717
        ja      parse_cmd.error
718
        or      al, TYPE_LOCAL
719
        mov     [edx + thread_data.type], al
720
2578 hidnplayr 721
  .ok:
2560 hidnplayr 722
 
723
2578 hidnplayr 724
        ret
2560 hidnplayr 725
 
2554 hidnplayr 726
align 4
727
 
728
729
        ; TODO: check user and set home directory (and permissions)
730
 
2578 hidnplayr 731
        mcall   send, [edx + thread_data.socketnum], str331, str331.length, 0
2557 hidnplayr 732
 
2578 hidnplayr 733
        mov     [edx + thread_data.state], STATE_LOGIN
734
735
        mov     byte [edx + thread_data.work_dir], "/"
2560 hidnplayr 736
 
2578 hidnplayr 737
738
        push    str_logged_in
739
 
2560 hidnplayr 740
741
        ret
742
 
2554 hidnplayr 743
744
 
745
 
746
 
2578 hidnplayr 747
2560 hidnplayr 748
        xor     eax, eax
749
 
2578 hidnplayr 750
751
  .loop:
2560 hidnplayr 752
 
753
        sub     bl, '0'
2578 hidnplayr 754
        jb      .done
755
        cmp     bl, 9
2560 hidnplayr 756
        ja      .done
2578 hidnplayr 757
        lea     eax, [eax*4 + eax]      ;
2560 hidnplayr 758
        shl     eax, 1                  ; eax = eax * 10
2578 hidnplayr 759
        add     eax, ebx
760
        inc     esi
761
2560 hidnplayr 762
        jmp     .loop
763
 
764
  .done:
765
 
766
        ret
2578 hidnplayr 767
2560 hidnplayr 768
align 4
769
 
2562 hidnplayr 770
2578 hidnplayr 771
        mov     eax, '1'
2560 hidnplayr 772
 
2562 hidnplayr 773
774
        ret
2560 hidnplayr 775
 
2562 hidnplayr 776
align 4
2560 hidnplayr 777
 
2563 hidnplayr 778
        lea     edi, [edx + thread_data.fpath]
779
        lea     esi, [edx + thread_data.home_dir]
2578 hidnplayr 780
        mov     ecx, 1024
781
2563 hidnplayr 782
  .loop1:
2560 hidnplayr 783
 
2563 hidnplayr 784
        or      al, al
785
        jz      .next
786
        stosb
787
        loop    .loop1
788
  .next:
789
790
        cmp     byte[edi-1], '/'
2562 hidnplayr 791
 
2563 hidnplayr 792
        dec     edi
793
       @@:
794
795
        lea     esi, [edx + thread_data.work_dir]
2562 hidnplayr 796
 
2578 hidnplayr 797
2563 hidnplayr 798
  .loop2:
2562 hidnplayr 799
 
2563 hidnplayr 800
        or      al, al
801
        jz      .done
802
        stosb
803
        loop    .loop2
804
805
  .done:
806
 
807
808
        ret
809
 
810
811
 
812
 
2571 hidnplayr 813
814
        pushd   0x0c
2563 hidnplayr 815
 
2571 hidnplayr 816
        push    str_sockerr
817
        call    [con_write_asciiz]
818
        pushd   0x07
819
        call    [con_set_flags]
820
821
        mcall   send, [edx + thread_data.socketnum], str425, str425.length, 0    ; data connection error
2563 hidnplayr 822
 
2578 hidnplayr 823
        ret
2571 hidnplayr 824
 
825
826
 
827
 
828
 
829
 
2554 hidnplayr 830
str200  db '200 Command OK.', 13, 10
2562 hidnplayr 831
.length = $ - str200
2554 hidnplayr 832
str215  db '215 UNIX type: L8', 13, 10
2560 hidnplayr 833
.length = $ - str215
2554 hidnplayr 834
str220  db '220 KolibriOS FTP Daemon 1.0', 13, 10
2557 hidnplayr 835
.length = $ - str220
2554 hidnplayr 836
str221  db '221 Bye!', 13, 10
837
.length = $ - str221
838
str225  db '225 Data connection open', 13, 10
2557 hidnplayr 839
.length = $ - str225
2560 hidnplayr 840
str226  db '226 Transfer OK, Closing connection', 13, 10
841
.length = $ - str226
2554 hidnplayr 842
str230  db '230 You are now logged in.', 13, 10
2562 hidnplayr 843
.length = $ - str230
2554 hidnplayr 844
str250  db '250 command successful', 13, 10
2557 hidnplayr 845
.length = $ - str250
2554 hidnplayr 846
str331  db '331 Please specify the password.', 13, 10
2563 hidnplayr 847
.length = $ - str331
2554 hidnplayr 848
str421  db '421 Timeout!', 13, 10
2557 hidnplayr 849
.length = $ - str421
2560 hidnplayr 850
str425  db '425 Cant open data connection.', 13, 10
851
.length = $ - str425
852
str500  db '500 Unsupported command', 13, 10
853
.length = $ - str500
2554 hidnplayr 854
str550  db '550 No such file', 13, 10
2557 hidnplayr 855
.length = $ - str550
2563 hidnplayr 856