Subversion Repositories Kolibri OS

Rev

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

  1. ;;================================================================================================;;
  2. console: ;////////////////////////////////////////////////////////////////////////////////////////;;
  3. ;;------------------------------------------------------------------------------------------------;;
  4. ;? Console-specific functions - initialization, clear screen,                                     ;;
  5. ;? .get_cmd - Takes user command as input from the console                                        ;;
  6. ;? .server_addr - Gets server address from user in the form address:port                          ;;
  7. ;? .get_username/.get_pass - Takes username/password as input from the user                       ;;
  8. ;;------------------------------------------------------------------------------------------------;;
  9. ;>                                                                                                ;;
  10. ;;------------------------------------------------------------------------------------------------;;
  11. ;< none                                                                                           ;;
  12. ;;================================================================================================;;
  13.  
  14.   dd .init
  15.   dd .server_addr
  16.   dd .get_username
  17.   dd .get_cmd
  18.   dd .print
  19.   dd .set_flags
  20.   dd .list
  21.   dd .progress
  22.   dd .error
  23.  
  24.   .init:
  25. ; load console library
  26.         stdcall dll.Load, @IMPORT_CONSOLE
  27. ; initialize console
  28.         invoke  con_start, 1
  29.         invoke  con_init, 120, 43, 120, 300, str_title
  30.         invoke  con_cls
  31. ; Welcome user
  32.         invoke  con_write_asciiz, str_welcome
  33.         ret
  34.  
  35.   .server_addr:
  36.         mov     [initial_login], 1
  37.         invoke  con_cls
  38.         invoke  con_set_flags, 0x07
  39. ; ask for server addr
  40.         invoke  con_write_asciiz, str_srv_addr
  41. ; write prompt (in green color)
  42.         invoke  con_set_flags, 0x0a
  43.         invoke  con_write_asciiz, str_prompt
  44. ; read string
  45.         invoke  con_gets, param_server_addr, 256
  46. ; check for exit
  47.         test    eax, eax
  48.         jz      .exit
  49.         cmp     byte [param_server_addr], 10
  50.         jz      .exit
  51.  
  52.   .port:
  53.         invoke  con_write_asciiz, str_port
  54.         invoke  con_gets, param_port, 256
  55.  
  56.   ; read username
  57.   .get_username:
  58.         invoke  con_set_flags, 0x0a
  59.         invoke  con_write_asciiz, str_user
  60.         invoke  con_gets, param_user, 256
  61.  
  62.   ; read password
  63.   .get_pass:
  64.         invoke  con_write_asciiz, str_pass
  65.         invoke  con_set_flags, 0x00             ; black text on black background for password
  66.         invoke  con_gets, param_password, 256
  67.         invoke  con_set_flags, 0x0a
  68.  
  69.         cmp     [initial_login], 1
  70.         jne     arg_handler.copy_user
  71.         mov     [initial_login], 0
  72.  
  73.   ; get initial path
  74.   .get_path:
  75.         invoke  con_write_asciiz, str_path
  76.         invoke  con_gets, param_path, 256
  77.         invoke  con_write_asciiz, str_newline
  78.  
  79.         jmp     arg_handler.connect
  80.  
  81.   .get_cmd:
  82.         ; write prompt
  83.         invoke  con_write_asciiz, str_prompt
  84.         ; read string
  85.         invoke  con_gets, buf_cmd, 256
  86.  
  87.         ; print a newline and reset the color back to grey
  88.         invoke  con_write_asciiz, str_newline
  89.         invoke  con_set_flags, 0x07
  90.  
  91.         jmp     wait_for_usercommand.parse_cmd
  92.  
  93.   .print:
  94.         pushad
  95.  
  96.         invoke  con_write_asciiz, [esp+36]
  97.         mov     esi, [esp+36]
  98.         mov     ecx, -1
  99.     @@:
  100.         inc     ecx
  101.         lodsb
  102.         test    al, al
  103.         jnz     @b
  104.         ; write to log file
  105.         mov     eax, [esp+36]
  106.         call    write_to_file
  107.  
  108.       @@:
  109.         popad
  110.         ret     4
  111.  
  112.   .set_flags:
  113.         invoke  con_set_flags, [esp+4]
  114.         ret     4
  115.  
  116.   .list:
  117.         invoke  con_write_asciiz, buf_buffer2
  118.         jmp     data_loop
  119.  
  120.   .progress: ; edx = no. of bytes transferred
  121.         mov     eax, edx
  122.         mov     edi, str_bytes_done
  123.         call    dword_ascii
  124.         mov     byte[edi],0
  125.         icall   eax, interface_addr, interface.print, str_downloaded, str_bytes_done, str_bytes
  126.         ret
  127.  
  128.   .error:
  129.         invoke  con_getch2
  130.         jmp     .server_addr
  131.  
  132.   .exit:
  133.         invoke  con_exit, 1
  134.         jmp     exit
  135.  
  136.  
  137. align 4
  138. @IMPORT_CONSOLE:
  139.  
  140. library console, 'console.obj'
  141.  
  142. import  console, \
  143.         con_start,          'START', \
  144.         con_init,           'con_init', \
  145.         con_write_asciiz,   'con_write_asciiz', \
  146.         con_exit,           'con_exit', \
  147.         con_gets,           'con_gets', \
  148.         con_cls,            'con_cls', \
  149.         con_getch2,         'con_getch2', \
  150.         con_set_cursor_pos, 'con_set_cursor_pos', \
  151.         con_write_string,   'con_write_string', \
  152.         con_get_flags,      'con_get_flags', \
  153.         con_set_flags,      'con_set_flags'