Subversion Repositories Kolibri OS

Rev

Rev 3794 | Rev 3802 | Go to most recent revision | 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. cmd_bye:
  9.  
  10.         mcall   close, [socketnum]
  11.         mcall   close, [datasocket]
  12.  
  13.         jmp     main
  14.  
  15. cmd_pwd:
  16.  
  17.         mov     dword[s], "PWD" + 10 shl 24
  18.         mcall   send, [socketnum], s, 4, 0
  19.  
  20.         jmp     wait_for_servercommand
  21.  
  22. cmd_cwd:
  23.  
  24.         mov     dword[s], "CWD "
  25.  
  26.         mov     ecx, 256
  27.         xor     al, al
  28.         mov     edi, s
  29.         repne scasb
  30.         lea     esi, [edi - s - 1]
  31.  
  32.         mcall   send, [socketnum], s, , 0
  33.  
  34.         jmp     wait_for_servercommand
  35.  
  36. cmd_dele:
  37.  
  38.         mov     dword[s], "DELE"
  39.         mov     byte[s], " "
  40.  
  41.         mov     ecx, 256
  42.         xor     al, al
  43.         mov     edi, s
  44.         repne scasb
  45.         lea     esi, [edi - s - 1]
  46.  
  47.         mcall   send, [socketnum], s, , 0
  48.  
  49.         jmp     wait_for_servercommand
  50.  
  51. cmd_list:
  52.  
  53.         call    open_dataconnection
  54.  
  55.         mov     [operation], OPERATION_LIST
  56.  
  57.         mov     dword[s], "LIST"
  58.         mov     byte[s+4], 0x0a
  59.         mcall   send, [socketnum], s, 5, 0
  60.  
  61.         jmp     wait_for_servercommand
  62.  
  63.  
  64. cmd_retr:
  65.  
  66.         call    open_dataconnection
  67.  
  68.         mov     [operation], OPERATION_RETR
  69.  
  70.         mov     [filestruct.subfn], 2   ; create/rewrite file
  71.         mov     [filestruct.offset], 0
  72.         mov     [filestruct.offset+4], 0
  73.         mov     [filestruct.size], 0
  74.         mov     [filestruct.ptr], 0
  75.  
  76.         lea     esi, [s+5]
  77.         mov     edi, filestruct.name
  78.         mov     ecx, 256-5
  79.         call    set_filename
  80.  
  81.         mcall   70, filestruct
  82.         cmp     eax, -1
  83. ;        je      fileerror
  84.  
  85.         mov     [filestruct.subfn], 3   ; write to file
  86.  
  87.         mov     dword[s], "RETR"
  88.         mov     byte[s+4], " "
  89.  
  90.         mov     ecx, 256
  91.         xor     al, al
  92.         mov     edi, s
  93.         repne scasb
  94.         lea     esi, [edi - s - 1]
  95.         mcall   send, [socketnum], s, , 0
  96.  
  97.         jmp     wait_for_servercommand
  98.  
  99.  
  100. cmd_stor:
  101.  
  102.         call    open_dataconnection
  103.  
  104.         mov     [operation], OPERATION_STOR
  105.  
  106.         mov     [filestruct.subfn], 0   ; read file
  107.         mov     [filestruct.offset], 0
  108.         mov     [filestruct.offset+4], 0
  109.         mov     [filestruct.size], BUFFERSIZE
  110.         mov     [filestruct.ptr], buffer_ptr2
  111.  
  112.         lea     esi, [s+5]
  113.         mov     edi, filestruct.name
  114.         mov     ecx, 256-5
  115.         call    set_filename
  116.  
  117.         mov     dword[s], "STOR"
  118.         mov     byte[s+4], " "
  119.  
  120.         mov     ecx, 256
  121.         xor     al, al
  122.         mov     edi, s
  123.         repne scasb
  124.         lea     esi, [edi - s - 1]
  125.         mcall   send, [socketnum], s, , 0
  126.  
  127.         jmp     wait_for_servercommand
  128.  
  129.  
  130.  
  131. ; esi   = source ptr
  132. ; edi   = dest ptr
  133. ; ecx   = max length of source buffer
  134. set_filename:
  135.  
  136.   .loop:
  137.         lodsb
  138.         test    al, al
  139.         jz      .done
  140.         cmp     al, ' '
  141.         je      .done
  142.         cmp     al, 10
  143.         je      .done
  144.         stosb
  145.         loop    .loop
  146.   .done:
  147.         xor     al, al          ; append a 0 byte
  148.         stosb
  149.  
  150.         ret
  151.  
  152.