Subversion Repositories Kolibri OS

Rev

Rev 5011 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. cmd_help:
  2.  
  3.         push    str_help
  4.         call    [con_write_asciiz]
  5.  
  6.         jmp     wait_for_usercommand
  7.  
  8.  
  9. cmd_bye:
  10.  
  11. ; Send BYE message to the server
  12.         mov     dword[buf_cmd], "BYE" + 13 shl 24
  13.         mov     byte[buf_cmd+4], 10
  14.         mcall   send, [controlsocket], buf_cmd, 5, 0
  15.  
  16. ; Close the control connection
  17.         mcall   close, [controlsocket]
  18.         ijmp    eax, interface_addr, interface.server_addr
  19.  
  20.  
  21. cmd_pwd:
  22.  
  23.         mov     dword[buf_cmd], "PWD" + 13 shl 24
  24.         mov     byte[buf_cmd+4], 10
  25.         mcall   send, [controlsocket], buf_cmd, 5, 0
  26.  
  27.         jmp     wait_for_servercommand
  28.  
  29.  
  30. cmd_cwd:
  31.  
  32.         mov     dword[buf_cmd], "CWD "
  33.  
  34.         mov     ecx, 256
  35.         xor     al, al
  36.         mov     edi, buf_cmd
  37.         repne scasb
  38.         lea     esi, [edi - buf_cmd]
  39.         mov     word [edi - 2], 0x0a0d
  40.  
  41.         mcall   send, [controlsocket], buf_cmd, , 0
  42.  
  43.         jmp     wait_for_servercommand
  44.  
  45.  
  46. cmd_dele:
  47.  
  48.         mov     dword[buf_cmd], "DELE"
  49.         mov     byte[buf_cmd+4], " "
  50.  
  51.         mov     ecx, 256
  52.         xor     al, al
  53.         mov     edi, buf_cmd
  54.         repne scasb
  55.         lea     esi, [edi - buf_cmd]
  56.         mov     word [edi - 2], 0x0a0d
  57.  
  58.         mcall   send, [controlsocket], buf_cmd, , 0
  59.  
  60.         jmp     wait_for_servercommand
  61.  
  62.  
  63. cmd_list:
  64.         call    open_dataconnection
  65.  
  66.         mov     [operation], OPERATION_LIST
  67.  
  68.         mov     dword[buf_cmd], "LIST"
  69.         mov     word[buf_cmd+4], 0x0a0d
  70.         mcall   send, [controlsocket], buf_cmd, 6, 0
  71.  
  72.         jmp     wait_for_servercommand
  73.  
  74.  
  75. cmd_retr:
  76.         call    open_dataconnection
  77.        
  78. ; Create/open the file
  79. ; TODO: check beforehand if the disk has enough free space available to store the file
  80.  
  81.         mov     esi, buf_cmd+5
  82.         mov     ecx, 256-5
  83.         call    set_filename
  84.  
  85.         mov     [filestruct.subfn], 2   ; create/rewrite file
  86.         mov     [filestruct.offset], 0
  87.         mov     [filestruct.offset+4], 0
  88.         mov     [filestruct.size], 0
  89.         mov     [filestruct.ptr], 0
  90.  
  91.         mcall   70, filestruct
  92.         test    eax, eax
  93.         jz      @f
  94.         call    error_fs
  95.         jmp     close_datacon
  96.       @@:
  97. ; Prepare to write to the file
  98.  
  99.         mov     [filestruct.subfn], 3   ; write to file
  100.         mov     [operation], OPERATION_RETR
  101.  
  102. ; Request the file from server
  103.    
  104.         mov     dword[buf_cmd], "RETR"
  105.         mov     byte[buf_cmd+4], " "
  106.  
  107.         mov     ecx, 256
  108.         xor     al, al
  109.         mov     edi, buf_cmd
  110.         repne scasb
  111.         lea     esi, [edi - buf_cmd]
  112.         mov     dword[edi - 2], 0x0a0d
  113.         mcall   send, [controlsocket], buf_cmd, , 0
  114.  
  115.         icall   eax, interface_addr, interface.print, buf_cmd
  116.         jmp     wait_for_servercommand
  117.  
  118. cmd_rdir:        
  119.  
  120.         mov     [operation], OPERATION_RDIR
  121.  
  122. ; Request filename list from the server
  123.  
  124.         call    open_dataconnection
  125.  
  126.         mov     [ptr_fname], 0
  127.         mov     [size_fname], 0
  128.         mov     dword[buf_cmd], "NLST"
  129.         mov     word[buf_cmd+4], 0x0a0d
  130.         mcall   send, [controlsocket], buf_cmd, 6, 0
  131.  
  132.         jmp     wait_for_servercommand  
  133.        
  134. cmd_stor:
  135.  
  136.         call    open_dataconnection
  137.  
  138.         mov     [operation], OPERATION_STOR
  139.  
  140.         ; get file size
  141.         mov     [filestruct.subfn], 5
  142.         mov     [filestruct.offset], 0
  143.         mov     [filestruct.offset+4], 0
  144.         mov     [filestruct.size], 0
  145.         mov     [filestruct.ptr], folder_buf
  146.  
  147.         mov     esi, buf_cmd+5
  148.         mov     ecx, 256-5
  149.         call    set_filename
  150.  
  151.         mcall   70, filestruct
  152.  
  153.         mov     eax, dword[folder_buf+32] ; supports file size upto 4GB
  154.         mov     [file_size], eax
  155.  
  156.         mov     [filestruct.subfn], 0   ; read file
  157.         ; mov     [filestruct.offset], 0
  158.         ; mov     [filestruct.offset+4], 0
  159.         mov     [filestruct.size], BUFFERSIZE
  160.         mov     [filestruct.ptr], buf_buffer2
  161.  
  162.         mov     dword[buf_cmd], "STOR"
  163.         mov     byte[buf_cmd+4], " "
  164.  
  165.         mov     ecx, 256
  166.         xor     al, al
  167.         mov     edi, buf_cmd
  168.         repne scasb
  169.         lea     esi, [edi - buf_cmd]
  170.         mov     word [edi - 2], 0x0a0d
  171.         mcall   send, [controlsocket], buf_cmd, , 0
  172.  
  173.         jmp     wait_for_servercommand
  174.  
  175.  
  176. cmd_lcwd:
  177.  
  178.         mov     esi, buf_cmd+5
  179.         cmp     byte[esi], 10
  180.         je      .print
  181.         mov     ecx, 256-5
  182.   .loop:
  183.         lodsb
  184.         cmp     al, 10
  185.         je      .check
  186.         test    al, al
  187.         je      .check
  188.         loop    .loop
  189.  
  190.   .check:
  191.         mov     byte[esi-1], 0
  192.  
  193.         ; check whether entered path is valid (folder exists)
  194.         mov     [filestruct2.subfn], 5
  195.         mov     [filestruct2.offset], 0
  196.         mov     [filestruct2.size], 0
  197.         mov     [filestruct2.ptr], folder_buf
  198.         mov     [filestruct2.name], buf_cmd+5
  199.         mcall   70, filestruct2
  200.         test    eax, eax
  201.         jz      @f
  202.         cmp     eax, 2
  203.         je      @f
  204.         call    error_fs
  205.         jmp     wait_for_usercommand
  206.  
  207.   @@:
  208.         mcall   30, 1, buf_cmd+5              ; set working directory
  209.  
  210.   .print:
  211.         mcall   30, 2, buf_cmd, 256           ; and read it again
  212.         icall   eax, interface_addr, interface.print, str_lcwd, buf_cmd, str_newline
  213.  
  214.         jmp     wait_for_usercommand
  215.  
  216.  
  217. cmd_cdup:
  218.  
  219.         mov     dword[buf_cmd], "CDUP"
  220.         mov     word[buf_cmd+4], 0x0a0d
  221.         mcall   send, [controlsocket], buf_cmd, 6, 0
  222.  
  223.         jmp     wait_for_servercommand
  224.  
  225.  
  226. cmd_rmd:
  227.  
  228.         mov     dword[buf_cmd], "RMD "
  229.  
  230.         mov     ecx, 256
  231.         xor     al, al
  232.         mov     edi, buf_cmd
  233.         repne scasb
  234.         lea     esi, [edi - buf_cmd]
  235.         mov     word [edi - 2], 0x0a0d
  236.  
  237.         mcall   send, [controlsocket], buf_cmd, , 0
  238.  
  239.         jmp     wait_for_servercommand
  240.  
  241.  
  242. cmd_mkd:
  243.  
  244.         mov     dword[buf_cmd], "MKD "
  245.  
  246.         mov     ecx, 256
  247.         xor     al, al
  248.         mov     edi, buf_cmd
  249.         repne scasb
  250.         lea     esi, [edi - buf_cmd]
  251.         mov     word [edi - 2], 0x0a0d
  252.  
  253.         mcall   send, [controlsocket], buf_cmd, , 0
  254.  
  255.         jmp     wait_for_servercommand
  256.  
  257.  
  258. cmd_abor:
  259.  
  260.         mcall   close, [datasocket]
  261.         jmp     wait_for_servercommand
  262.  
  263.  
  264. ; esi   = source ptr
  265. ; ecx   = max length of source buffer
  266. set_filename:
  267.  
  268.         mov     edi, filestruct.name
  269.   .loop:
  270.         lodsb
  271.         test    al, al
  272.         jz      .done
  273.         cmp     al, 10
  274.         je      .done
  275.         stosb
  276.         loop    .loop
  277.   .done:
  278.         xor     al, al          ; append a 0 byte
  279.         stosb
  280.  
  281.         ret