2013-05-28 21:34:26 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2016-01-02 00:01:59 +03:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
|
2013-05-28 21:34:26 +04:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
2013-11-01 18:02:08 +04:00
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
2013-05-28 21:34:26 +04:00
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
user_parser:
|
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
mov ebp, [window_active] ; print to the current window
|
|
|
|
mov [window_print], ebp
|
2013-11-01 18:02:08 +04:00
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
mov eax, [edit1.size]
|
2013-05-29 12:47:31 +04:00
|
|
|
test eax, eax
|
2014-01-18 19:51:43 +04:00
|
|
|
jz .ret ; ignore empty commands
|
2014-03-07 09:04:10 +04:00
|
|
|
mov word[usercommand + eax], 0x0a0d ; terminate the line
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
cmp byte[usercommand], '/' ; is it a server command ?
|
2014-03-29 00:03:30 +04:00
|
|
|
je .command
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
cmp [status], STATUS_CONNECTED
|
2014-03-29 00:03:30 +04:00
|
|
|
jne .not_connected
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
cmp [ebp + window.type], WINDOWTYPE_CHANNEL
|
|
|
|
je .send_privmsg
|
|
|
|
cmp [ebp + window.type], WINDOWTYPE_CHAT
|
|
|
|
jne .not_channel
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
.send_privmsg:
|
2013-11-01 18:02:08 +04:00
|
|
|
if TIMESTAMP
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_timestamp
|
2013-11-01 18:02:08 +04:00
|
|
|
end if
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-10 01:57:21 +04:00
|
|
|
mov al, '<'
|
|
|
|
call print_char
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
mov esi, user_nick
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-10 01:57:21 +04:00
|
|
|
mov al, '>'
|
|
|
|
call print_char
|
|
|
|
mov al, ' '
|
|
|
|
call print_char
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
mov eax, [edit1.size]
|
|
|
|
mov byte[usercommand + eax],0
|
|
|
|
|
|
|
|
mov esi, usercommand
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-10 01:57:21 +04:00
|
|
|
mov al, 10
|
|
|
|
call print_char
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
; and now send it to the server
|
2013-11-01 18:02:08 +04:00
|
|
|
mov dword[packetbuf], 'PRIV'
|
|
|
|
mov dword[packetbuf+4], 'MSG '
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
lea esi, [ebp + window.name]
|
2013-05-28 21:34:26 +04:00
|
|
|
mov edi, packetbuf+8
|
|
|
|
mov ecx, MAX_WINDOWNAME_LEN
|
|
|
|
.loop:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .done
|
|
|
|
stosb
|
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
|
|
|
.done:
|
|
|
|
|
|
|
|
mov ax, ' :'
|
|
|
|
stosw
|
|
|
|
|
|
|
|
mov esi, usercommand
|
|
|
|
mov ecx, [edit1.size]
|
|
|
|
inc ecx
|
|
|
|
call recode
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; end the command with a CRLF
|
|
|
|
mov ax, 0x0a0d
|
|
|
|
stosw
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
lea esi, [edi - packetbuf]
|
|
|
|
mcall send, [socketnum], packetbuf, , 0
|
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
.ret:
|
2013-05-28 21:34:26 +04:00
|
|
|
ret
|
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
; Text begins with a '/' lets try to find the command in the lookup table.
|
|
|
|
.command:
|
2014-01-18 19:51:43 +04:00
|
|
|
mov eax, dword[usercommand+1] ; skip '/'
|
|
|
|
or eax, 0x20202020 ; convert to lowercase
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
mov edi, user_commands
|
|
|
|
mov ecx, user_commands.number
|
2014-01-18 19:51:43 +04:00
|
|
|
cmp [status], STATUS_CONNECTED
|
2014-03-29 00:03:30 +04:00
|
|
|
je .cmd_loop
|
2014-01-18 19:51:43 +04:00
|
|
|
mov ecx, user_commands.number2
|
2014-03-29 00:03:30 +04:00
|
|
|
.cmd_loop:
|
2013-05-28 21:34:26 +04:00
|
|
|
scasd
|
|
|
|
je .got_cmd
|
|
|
|
add edi, 4
|
|
|
|
dec ecx
|
2014-03-29 00:03:30 +04:00
|
|
|
jnz .cmd_loop
|
2014-01-18 19:51:43 +04:00
|
|
|
|
|
|
|
cmp [status], STATUS_CONNECTED
|
2014-03-29 00:03:30 +04:00
|
|
|
jne .not_connected
|
|
|
|
|
2014-03-16 15:50:59 +04:00
|
|
|
; Commands shorter then 3 chars are placed here
|
|
|
|
and eax, 0x00ffffff
|
|
|
|
cmp eax, 'me '
|
|
|
|
je cmd_usr_me
|
2014-01-18 19:51:43 +04:00
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
; If none of the listed commands, send text straight to server
|
|
|
|
jmp cmd_usr_send
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
.got_cmd:
|
|
|
|
jmp dword[edi]
|
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
.not_connected:
|
2014-01-18 19:51:43 +04:00
|
|
|
mov esi, str_notconnected
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
2014-03-29 00:03:30 +04:00
|
|
|
ret
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
.not_channel:
|
|
|
|
mov esi, str_notchannel
|
|
|
|
call print_asciiz
|
2014-01-18 19:51:43 +04:00
|
|
|
ret
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
; user commands lookup table
|
|
|
|
user_commands:
|
|
|
|
dd 'nick', cmd_usr_nick
|
|
|
|
dd 'real', cmd_usr_real
|
|
|
|
dd 'serv', cmd_usr_server
|
|
|
|
dd 'help', cmd_usr_help
|
|
|
|
dd 'code', cmd_usr_code
|
|
|
|
|
|
|
|
.number2 = ($ - user_commands) / 8
|
|
|
|
|
|
|
|
; All following commands require a connection to the server.
|
|
|
|
dd 'quer', cmd_usr_quer
|
|
|
|
dd 'quit', cmd_usr_quit
|
|
|
|
dd 'part', cmd_usr_part
|
|
|
|
dd 'ctcp', cmd_usr_ctcp
|
|
|
|
dd 'msg ', cmd_usr_msg
|
|
|
|
|
|
|
|
.number = ($ - user_commands) / 8
|
|
|
|
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmd_usr_msg:
|
|
|
|
|
|
|
|
lea esi, [usercommand+5]
|
|
|
|
|
|
|
|
mov dword[packetbuf], 'PRIV'
|
|
|
|
mov dword[packetbuf+4], 'MSG '
|
|
|
|
lea edi, [packetbuf+8]
|
|
|
|
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .fail
|
|
|
|
cmp al, 10
|
|
|
|
je .fail
|
|
|
|
cmp al, 13
|
|
|
|
je .fail
|
|
|
|
stosb
|
|
|
|
cmp al, ' '
|
|
|
|
jne @r
|
|
|
|
|
|
|
|
mov al, ':'
|
|
|
|
stosb
|
|
|
|
|
|
|
|
push edi
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz @f
|
|
|
|
cmp al, 10
|
|
|
|
je @f
|
|
|
|
cmp al, 13
|
|
|
|
je @f
|
|
|
|
stosb
|
|
|
|
jmp @r
|
|
|
|
@@:
|
|
|
|
; end the command with a CRLF
|
|
|
|
mov ax, 0x0a0d
|
|
|
|
stosw
|
|
|
|
mov byte[edi], 0
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
lea esi, [edi - packetbuf]
|
|
|
|
mcall send, [socketnum], packetbuf, , 0
|
|
|
|
|
|
|
|
; now print to the window
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, msg_header
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
2013-11-01 18:02:08 +04:00
|
|
|
|
2014-03-10 01:57:21 +04:00
|
|
|
mov esi, packetbuf+8
|
|
|
|
mov bl, ' '
|
|
|
|
call print_string
|
2013-11-01 18:02:08 +04:00
|
|
|
|
2014-03-10 01:57:21 +04:00
|
|
|
mov al, '*'
|
|
|
|
call print_char
|
2013-11-01 18:02:08 +04:00
|
|
|
|
2014-03-10 01:57:21 +04:00
|
|
|
mov al, ' '
|
|
|
|
call print_char
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
pop esi
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_quit:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
mov esi, quit_msg
|
2013-10-07 18:02:05 +04:00
|
|
|
cmp byte[usercommand+5], ' '
|
2014-03-29 00:03:30 +04:00
|
|
|
jne quit_server
|
2013-11-01 18:02:08 +04:00
|
|
|
lea esi, [usercommand+6]
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
; esi = quit message
|
2014-03-29 00:03:30 +04:00
|
|
|
quit_server:
|
2013-10-07 18:02:05 +04:00
|
|
|
|
|
|
|
; User wants to close a channel, send PART command to server
|
|
|
|
mov dword[packetbuf], 'QUIT'
|
|
|
|
mov word[packetbuf+4], ' :'
|
|
|
|
lea edi, [packetbuf+6]
|
|
|
|
; Append our quit msg
|
|
|
|
@@:
|
|
|
|
lodsb
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp al, 13
|
|
|
|
je @f
|
2013-10-07 18:02:05 +04:00
|
|
|
test al, al
|
2013-11-01 18:02:08 +04:00
|
|
|
jz @f
|
|
|
|
stosb
|
|
|
|
jmp @r
|
|
|
|
@@:
|
2013-10-07 18:02:05 +04:00
|
|
|
; end the command with a CRLF
|
|
|
|
mov ax, 0x0a0d
|
|
|
|
stosw
|
|
|
|
|
|
|
|
lea esi, [edi - packetbuf] ; calculate length
|
|
|
|
mcall send, [socketnum], packetbuf, , 0 ; and finally send to server
|
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
mov ebp, windows
|
|
|
|
.window_loop:
|
|
|
|
cmp [ebp + window.type], WINDOWTYPE_NONE
|
|
|
|
je .next_window
|
|
|
|
mov [window_print], ebp
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
mov esi, str_disconnected
|
|
|
|
call print_asciiz
|
|
|
|
cmp [ebp + window.type], WINDOWTYPE_CHANNEL
|
|
|
|
jne .next_window
|
|
|
|
call user_remove_all
|
|
|
|
.next_window:
|
|
|
|
add ebp, sizeof.window
|
|
|
|
cmp ebp, windows + (MAX_WINDOWS * sizeof.window)
|
|
|
|
jb .window_loop
|
|
|
|
|
|
|
|
mov [status], STATUS_DISCONNECTED
|
|
|
|
mcall close, [socketnum]
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
cmd_usr_nick:
|
|
|
|
|
|
|
|
cmp [edit1.size], 5
|
2014-06-18 00:34:54 +04:00
|
|
|
je .justprint
|
2013-05-28 21:34:26 +04:00
|
|
|
cmp byte[usercommand+5], ' '
|
2013-11-01 18:02:08 +04:00
|
|
|
jne .fail
|
|
|
|
cmp [socketnum], 0
|
|
|
|
je .dontsend
|
|
|
|
|
2014-03-07 09:04:10 +04:00
|
|
|
; Request nickname change to server
|
2013-11-01 18:02:08 +04:00
|
|
|
mov dword[usercommand+1], 'NICK'
|
|
|
|
mov esi, [edit1.size]
|
|
|
|
mov word[usercommand + esi], 0x0a0d
|
|
|
|
inc esi
|
|
|
|
mcall send, [socketnum], usercommand+1, , 0
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
2014-03-07 09:04:10 +04:00
|
|
|
; We arent logged in yet, directly change user_nick field and print notification to user.
|
2013-11-01 18:02:08 +04:00
|
|
|
.dontsend:
|
2013-05-28 21:34:26 +04:00
|
|
|
mov ecx, MAX_NICK_LEN
|
|
|
|
mov esi, usercommand+6
|
|
|
|
mov edi, user_nick
|
2013-11-01 18:02:08 +04:00
|
|
|
@@:
|
2013-05-28 21:34:26 +04:00
|
|
|
lodsb
|
|
|
|
cmp al, 13
|
2013-11-01 18:02:08 +04:00
|
|
|
je @f
|
2013-05-28 21:34:26 +04:00
|
|
|
stosb
|
|
|
|
dec ecx
|
2013-11-01 18:02:08 +04:00
|
|
|
jnz @r
|
|
|
|
@@:
|
2013-05-28 21:34:26 +04:00
|
|
|
xor al, al
|
|
|
|
stosb
|
|
|
|
|
2014-06-18 00:34:54 +04:00
|
|
|
.justprint:
|
2013-05-28 21:34:26 +04:00
|
|
|
mov esi, str_nickchange
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
mov esi, user_nick
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
|
|
|
|
|
|
|
mov al, 10
|
|
|
|
call print_char
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_real:
|
|
|
|
|
|
|
|
cmp byte[usercommand+5], ' '
|
|
|
|
jne cmd_usr_send
|
|
|
|
|
|
|
|
mov ecx, MAX_REAL_LEN
|
|
|
|
mov esi, usercommand+6
|
|
|
|
mov edi, user_real_name
|
|
|
|
.loop:
|
|
|
|
lodsb
|
|
|
|
cmp al, 13
|
|
|
|
je .done
|
|
|
|
stosb
|
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
|
|
|
.done:
|
|
|
|
xor al, al
|
|
|
|
stosb
|
|
|
|
|
|
|
|
mov esi, str_realchange
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
mov esi, user_real_name
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
|
|
|
|
|
|
|
mov al, 10
|
|
|
|
call print_char
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_server:
|
|
|
|
|
|
|
|
mov eax, dword[usercommand+5] ; check for 'er ', we only checked 'serv'
|
|
|
|
or eax, 0x00002020
|
|
|
|
and eax, 0x00ffffff
|
|
|
|
cmp eax, 'er '
|
|
|
|
jne cmd_usr_send
|
|
|
|
|
2014-03-29 00:03:30 +04:00
|
|
|
; Server window is always first window in the list, switch to it.
|
|
|
|
mov [window_print], windows
|
|
|
|
mov [window_active], windows
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
mov ecx, [edit1.size] ; ok now set the address
|
2013-05-28 21:34:26 +04:00
|
|
|
sub ecx, 8
|
|
|
|
|
|
|
|
mov esi, usercommand+8
|
2014-01-18 19:51:43 +04:00
|
|
|
.now:
|
2013-05-28 21:34:26 +04:00
|
|
|
push esi
|
|
|
|
mov edi, irc_server_name
|
2014-01-18 19:51:43 +04:00
|
|
|
.loop: ; copy until zero byte, or ecx reaches zero.
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
test al, al
|
|
|
|
jz .done
|
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
2013-05-28 21:34:26 +04:00
|
|
|
xor al, al
|
|
|
|
stosb
|
2014-01-18 19:51:43 +04:00
|
|
|
.done:
|
2013-05-28 21:34:26 +04:00
|
|
|
pop esi
|
|
|
|
|
|
|
|
; set it also in window name
|
|
|
|
mov ebx, [window_print]
|
|
|
|
call window_set_name
|
|
|
|
|
|
|
|
; now connect
|
|
|
|
call socket_connect
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_quer:
|
|
|
|
|
|
|
|
mov esi, usercommand+7
|
2014-01-18 19:51:43 +04:00
|
|
|
call window_open
|
2014-03-10 01:57:21 +04:00
|
|
|
; test ebx, ebx
|
|
|
|
; jz .fail
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_help:
|
|
|
|
|
|
|
|
mov esi, str_help
|
2014-03-10 01:57:21 +04:00
|
|
|
call print_asciiz
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_code:
|
|
|
|
|
|
|
|
; TODO
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
; User typed a part command
|
|
|
|
cmd_usr_part:
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp byte[usercommand+5], 13 ; parameters given?
|
|
|
|
jne cmd_usr_send ; yes, send command straight to server
|
|
|
|
|
|
|
|
; close active window
|
|
|
|
cmd_usr_close_window:
|
2013-10-07 18:02:05 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov esi, [window_active]
|
2013-10-07 18:02:05 +04:00
|
|
|
cmp [esi + window.type], WINDOWTYPE_SERVER
|
2013-11-01 18:02:08 +04:00
|
|
|
je .not_channel
|
2013-10-07 18:02:05 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
lea esi, [esi + window.name]
|
|
|
|
call cmd_usr_part_channel
|
|
|
|
call window_close
|
|
|
|
ret
|
|
|
|
|
|
|
|
.not_channel:
|
|
|
|
cmp [esi + window.type], WINDOWTYPE_CHAT
|
|
|
|
jne .not_chat
|
|
|
|
|
|
|
|
call window_close
|
|
|
|
.not_chat:
|
2013-10-07 18:02:05 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
; Send part command to server
|
|
|
|
; esi must point to channel name (ASCIIZ)
|
|
|
|
cmd_usr_part_channel:
|
|
|
|
|
|
|
|
; User wants to close a channel, send PART command to server
|
|
|
|
mov dword[packetbuf], 'PART'
|
|
|
|
mov byte[packetbuf+4], ' '
|
|
|
|
lea edi, [packetbuf+5]
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
2013-11-01 18:02:08 +04:00
|
|
|
jz @f
|
|
|
|
cmp al, 13
|
|
|
|
je @f
|
|
|
|
cmp al, 10
|
|
|
|
je @f
|
|
|
|
stosb
|
|
|
|
jmp @r
|
|
|
|
@@:
|
2013-10-07 18:02:05 +04:00
|
|
|
; end the command with a CRLF
|
|
|
|
mov ax, 0x0a0d
|
|
|
|
stosw
|
|
|
|
|
|
|
|
lea esi, [edi - packetbuf] ; calculate length
|
|
|
|
mcall send, [socketnum], packetbuf, , 0 ; and finally send to server
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmd_usr_ctcp:
|
|
|
|
|
|
|
|
cmp byte[usercommand+5], ' '
|
|
|
|
jne cmd_usr_send
|
|
|
|
|
|
|
|
mov esi, usercommand+6
|
|
|
|
; prepare a 'PRIVMSG '
|
|
|
|
mov dword[packetbuf], 'PRIV'
|
|
|
|
mov dword[packetbuf+4], 'MSG '
|
|
|
|
lea edi, [packetbuf+8]
|
|
|
|
|
|
|
|
; append the destination (nickname/channel)
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .fail
|
|
|
|
cmp al, ' '
|
|
|
|
je @f
|
|
|
|
stosb
|
|
|
|
jmp @r
|
|
|
|
@@:
|
|
|
|
|
|
|
|
mov ax, ' :'
|
|
|
|
stosw
|
|
|
|
mov al, 0x01
|
|
|
|
stosb
|
|
|
|
|
|
|
|
; copy the message itself
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz @f
|
|
|
|
cmp al, 13
|
|
|
|
je @f
|
|
|
|
cmp al, 10
|
|
|
|
je @f
|
|
|
|
stosb
|
|
|
|
jmp @r
|
|
|
|
@@:
|
|
|
|
|
|
|
|
; end of message
|
|
|
|
mov al, 0x01
|
|
|
|
stosb
|
|
|
|
mov ax, 0x0a0d
|
|
|
|
stosw
|
|
|
|
|
|
|
|
; now send it away
|
|
|
|
lea esi, [edi - packetbuf] ; calculate length
|
|
|
|
mcall send, [socketnum], packetbuf, , 0 ; and finally send to server
|
|
|
|
|
|
|
|
;; TODO: print to window
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
|
2014-03-16 15:50:59 +04:00
|
|
|
cmd_usr_me:
|
|
|
|
|
|
|
|
; prepare a 'PRIVMSG '
|
|
|
|
mov dword[packetbuf], 'PRIV'
|
|
|
|
mov dword[packetbuf+4], 'MSG '
|
|
|
|
lea edi, [packetbuf+8]
|
|
|
|
|
|
|
|
; append the destination (nickname/channel)
|
|
|
|
mov esi, [window_active]
|
|
|
|
lea esi, [esi + window.name]
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
je @f
|
|
|
|
stosb
|
|
|
|
jmp @r
|
|
|
|
@@:
|
|
|
|
|
|
|
|
; Make the CTCP action header
|
|
|
|
mov eax, ' :' + 0x01 shl 16 + 'A' shl 24
|
|
|
|
stosd
|
|
|
|
mov eax, 'CTIO'
|
|
|
|
stosd
|
|
|
|
mov al, 'N'
|
|
|
|
stosb
|
|
|
|
|
|
|
|
; copy the message itself (including first space)
|
|
|
|
mov esi, usercommand+3
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
cmp al, 13
|
|
|
|
je @f
|
|
|
|
stosb
|
|
|
|
jmp @r
|
|
|
|
@@:
|
|
|
|
|
|
|
|
; end of CTCP message
|
|
|
|
mov al, 0x01
|
|
|
|
stosb
|
|
|
|
mov ax, 0x0a0d
|
|
|
|
stosw
|
|
|
|
|
|
|
|
; now send it to the server
|
|
|
|
lea esi, [edi - packetbuf] ; calculate length
|
|
|
|
mcall send, [socketnum], packetbuf, , 0 ; and finally send to server
|
|
|
|
|
|
|
|
; print to local window
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, action_header
|
|
|
|
call print_asciiz
|
|
|
|
|
|
|
|
mov esi, user_nick
|
|
|
|
call print_asciiz
|
|
|
|
|
|
|
|
mov esi, usercommand+3
|
|
|
|
mov bl, 13
|
|
|
|
call print_string
|
|
|
|
|
|
|
|
mov al, 10
|
|
|
|
call print_char
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
; The user typed some undefined command, just recode it and send to the server
|
2013-05-28 21:34:26 +04:00
|
|
|
cmd_usr_send:
|
|
|
|
|
|
|
|
mov esi, usercommand+1
|
|
|
|
mov ecx, [edit1.size]
|
|
|
|
inc ecx
|
|
|
|
mov edi, packetbuf
|
|
|
|
call recode
|
|
|
|
|
|
|
|
lea esi, [edi - packetbuf]
|
|
|
|
mcall send, [socketnum], packetbuf, , 0
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|