2013-05-28 19:34:26 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2024-02-23 22:15:46 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
|
2013-05-28 19:34:26 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
2013-11-01 15:02:08 +01:00
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
2013-05-28 19:34:26 +02:00
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
user_parser:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov ebp, [window_active] ; print to the current window
|
2014-03-28 21:03:30 +01:00
|
|
|
mov [window_print], ebp
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov ecx, [edit1.size]
|
|
|
|
test ecx, ecx
|
2014-01-18 16:51:43 +01:00
|
|
|
jz .ret ; ignore empty commands
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, input_text
|
|
|
|
mov edi, user_command
|
|
|
|
call recode ; Convert to UTF-8
|
2024-02-28 21:48:02 +01:00
|
|
|
mov byte[edi], 0x0 ; Terminate string with \0
|
2016-01-03 15:50:44 +01:00
|
|
|
sub edi, user_command
|
|
|
|
mov [user_command.size], edi
|
|
|
|
|
|
|
|
cmp byte[user_command], '/' ; is it a server command ?
|
2014-03-28 21:03:30 +01:00
|
|
|
je .command
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
cmp [status], STATUS_LOGGED_IN
|
|
|
|
jne .not_loggedin
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
cmp [ebp + window.type], WINDOWTYPE_CHANNEL
|
|
|
|
je .send_privmsg
|
|
|
|
cmp [ebp + window.type], WINDOWTYPE_CHAT
|
|
|
|
jne .not_channel
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
.send_privmsg:
|
2013-11-01 15:02:08 +01:00
|
|
|
if TIMESTAMP
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_timestamp
|
2013-11-01 15:02:08 +01:00
|
|
|
end if
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
mov al, '<'
|
|
|
|
call print_char
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
mov esi, user_nick
|
2014-03-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
mov al, '>'
|
|
|
|
call print_char
|
|
|
|
mov al, ' '
|
|
|
|
call print_char
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov eax, [user_command.size]
|
|
|
|
mov byte[user_command + eax],0
|
|
|
|
mov esi, user_command
|
2014-03-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
mov al, 10
|
|
|
|
call print_char
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; and now send it to the server
|
2013-11-01 15:02:08 +01:00
|
|
|
mov dword[packetbuf], 'PRIV'
|
|
|
|
mov dword[packetbuf+4], 'MSG '
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
lea esi, [ebp + window.name]
|
2013-05-28 19:34:26 +02: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
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, user_command
|
|
|
|
mov ecx, [user_command.size]
|
|
|
|
; inc ecx
|
|
|
|
rep movsb
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; end the command with a CRLF
|
|
|
|
mov ax, 0x0a0d
|
|
|
|
stosw
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
lea esi, [edi - packetbuf]
|
|
|
|
mcall send, [socketnum], packetbuf, , 0
|
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
.ret:
|
2013-05-28 19:34:26 +02:00
|
|
|
ret
|
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
; Text begins with a '/' lets try to find the command in the lookup table.
|
|
|
|
.command:
|
2016-01-03 15:50:44 +01:00
|
|
|
mov eax, dword[user_command+1] ; skip '/'
|
2014-01-18 16:51:43 +01:00
|
|
|
or eax, 0x20202020 ; convert to lowercase
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
mov edi, user_commands
|
|
|
|
mov ecx, user_commands.number
|
2014-01-18 16:51:43 +01:00
|
|
|
cmp [status], STATUS_CONNECTED
|
2016-01-03 15:50:44 +01:00
|
|
|
jae .cmd_loop
|
2014-01-18 16:51:43 +01:00
|
|
|
mov ecx, user_commands.number2
|
2014-03-28 21:03:30 +01:00
|
|
|
.cmd_loop:
|
2013-05-28 19:34:26 +02:00
|
|
|
scasd
|
|
|
|
je .got_cmd
|
|
|
|
add edi, 4
|
|
|
|
dec ecx
|
2014-03-28 21:03:30 +01:00
|
|
|
jnz .cmd_loop
|
2014-01-18 16:51:43 +01:00
|
|
|
|
|
|
|
cmp [status], STATUS_CONNECTED
|
2016-01-03 15:50:44 +01:00
|
|
|
jb .not_connected
|
2014-03-28 21:03:30 +01:00
|
|
|
|
2014-03-16 12:50:59 +01:00
|
|
|
; Commands shorter then 3 chars are placed here
|
|
|
|
and eax, 0x00ffffff
|
|
|
|
cmp eax, 'me '
|
|
|
|
je cmd_usr_me
|
2014-01-18 16:51:43 +01:00
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
; If none of the listed commands, send text straight to server
|
|
|
|
jmp cmd_usr_send
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
.got_cmd:
|
|
|
|
jmp dword[edi]
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
.not_loggedin:
|
|
|
|
mov esi, str_notloggedin
|
|
|
|
call print_asciiz
|
|
|
|
ret
|
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
.not_connected:
|
2014-01-18 16:51:43 +01:00
|
|
|
mov esi, str_notconnected
|
2014-03-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
2014-03-28 21:03:30 +01:00
|
|
|
ret
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
.not_channel:
|
|
|
|
mov esi, str_notchannel
|
|
|
|
call print_asciiz
|
2014-01-18 16:51:43 +01:00
|
|
|
ret
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
|
2014-03-28 21:03:30 +01: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 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
cmd_usr_msg:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
lea esi, [user_command+5]
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
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 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; now print to the window
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, msg_header
|
2014-03-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
mov esi, packetbuf+8
|
|
|
|
mov bl, ' '
|
|
|
|
call print_string
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
mov al, '*'
|
|
|
|
call print_char
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2014-03-09 22:57:21 +01:00
|
|
|
mov al, ' '
|
|
|
|
call print_char
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
pop esi
|
2018-07-01 16:29:23 +02:00
|
|
|
push esi
|
2014-03-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
2018-07-01 16:29:23 +02:00
|
|
|
pop esi
|
|
|
|
|
|
|
|
|
|
|
|
lea esi, [edi - packetbuf]
|
|
|
|
mcall send, [socketnum], packetbuf, , 0
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_quit:
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
mov esi, quit_msg
|
2016-01-03 15:50:44 +01:00
|
|
|
cmp byte[user_command+5], ' '
|
2014-03-28 21:03:30 +01:00
|
|
|
jne quit_server
|
2016-01-03 15:50:44 +01:00
|
|
|
lea esi, [user_command+6]
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-10-07 16:02:05 +02:00
|
|
|
; esi = quit message
|
2014-03-28 21:03:30 +01:00
|
|
|
quit_server:
|
2013-10-07 16:02:05 +02: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 15:02:08 +01:00
|
|
|
cmp al, 13
|
|
|
|
je @f
|
2013-10-07 16:02:05 +02:00
|
|
|
test al, al
|
2013-11-01 15:02:08 +01:00
|
|
|
jz @f
|
|
|
|
stosb
|
|
|
|
jmp @r
|
|
|
|
@@:
|
2013-10-07 16:02:05 +02: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-28 21:03:30 +01: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 16:02:05 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
cmd_usr_nick:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
cmp [user_command.size], 5
|
2014-06-17 22:34:54 +02:00
|
|
|
je .justprint
|
2016-01-03 15:50:44 +01:00
|
|
|
cmp byte[user_command+5], ' '
|
2013-11-01 15:02:08 +01:00
|
|
|
jne .fail
|
|
|
|
cmp [socketnum], 0
|
|
|
|
je .dontsend
|
|
|
|
|
2014-03-07 06:04:10 +01:00
|
|
|
; Request nickname change to server
|
2016-01-03 15:50:44 +01:00
|
|
|
mov dword[user_command+1], 'NICK'
|
|
|
|
mov esi, [user_command.size]
|
|
|
|
mov word[user_command + esi], 0x0a0d
|
2013-11-01 15:02:08 +01:00
|
|
|
inc esi
|
2016-01-03 15:50:44 +01:00
|
|
|
mcall send, [socketnum], user_command+1, , 0
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
2014-03-07 06:04:10 +01:00
|
|
|
; We arent logged in yet, directly change user_nick field and print notification to user.
|
2013-11-01 15:02:08 +01:00
|
|
|
.dontsend:
|
2013-05-28 19:34:26 +02:00
|
|
|
mov ecx, MAX_NICK_LEN
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, user_command+6
|
2013-05-28 19:34:26 +02:00
|
|
|
mov edi, user_nick
|
2013-11-01 15:02:08 +01:00
|
|
|
@@:
|
2013-05-28 19:34:26 +02:00
|
|
|
lodsb
|
|
|
|
cmp al, 13
|
2013-11-01 15:02:08 +01:00
|
|
|
je @f
|
2013-05-28 19:34:26 +02:00
|
|
|
stosb
|
|
|
|
dec ecx
|
2013-11-01 15:02:08 +01:00
|
|
|
jnz @r
|
|
|
|
@@:
|
2013-05-28 19:34:26 +02:00
|
|
|
xor al, al
|
|
|
|
stosb
|
|
|
|
|
2014-06-17 22:34:54 +02:00
|
|
|
.justprint:
|
2013-05-28 19:34:26 +02:00
|
|
|
mov esi, str_nickchange
|
2014-03-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
mov esi, user_nick
|
2014-03-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
|
|
|
|
|
|
|
mov al, 10
|
|
|
|
call print_char
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_real:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
cmp byte[user_command+5], ' '
|
2013-05-28 19:34:26 +02:00
|
|
|
jne cmd_usr_send
|
|
|
|
|
|
|
|
mov ecx, MAX_REAL_LEN
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, user_command+6
|
2013-05-28 19:34:26 +02:00
|
|
|
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-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
mov esi, user_real_name
|
2014-03-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
|
|
|
|
|
|
|
mov al, 10
|
|
|
|
call print_char
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_server:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov eax, dword[user_command+5] ; check for 'er ', we only checked 'serv'
|
2013-05-28 19:34:26 +02:00
|
|
|
or eax, 0x00002020
|
|
|
|
and eax, 0x00ffffff
|
|
|
|
cmp eax, 'er '
|
|
|
|
jne cmd_usr_send
|
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
; Server window is always first window in the list, switch to it.
|
|
|
|
mov [window_print], windows
|
|
|
|
mov [window_active], windows
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov ecx, [user_command.size] ; ok now set the address
|
2013-05-28 19:34:26 +02:00
|
|
|
sub ecx, 8
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, user_command+8
|
2014-01-18 16:51:43 +01:00
|
|
|
.now:
|
2013-05-28 19:34:26 +02:00
|
|
|
push esi
|
|
|
|
mov edi, irc_server_name
|
2014-01-18 16:51:43 +01:00
|
|
|
.loop: ; copy until zero byte, or ecx reaches zero.
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
test al, al
|
|
|
|
jz .done
|
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
2013-05-28 19:34:26 +02:00
|
|
|
xor al, al
|
|
|
|
stosb
|
2014-01-18 16:51:43 +01:00
|
|
|
.done:
|
2013-05-28 19:34:26 +02: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:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, user_command+7
|
2014-01-18 16:51:43 +01:00
|
|
|
call window_open
|
2014-03-09 22:57:21 +01:00
|
|
|
; test ebx, ebx
|
|
|
|
; jz .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_help:
|
|
|
|
|
|
|
|
mov esi, str_help
|
2014-03-09 22:57:21 +01:00
|
|
|
call print_asciiz
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_usr_code:
|
|
|
|
|
|
|
|
; TODO
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-10-07 16:02:05 +02:00
|
|
|
; User typed a part command
|
|
|
|
cmd_usr_part:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
cmp byte[user_command+5], 13 ; parameters given?
|
2013-11-01 15:02:08 +01:00
|
|
|
jne cmd_usr_send ; yes, send command straight to server
|
|
|
|
|
|
|
|
; close active window
|
|
|
|
cmd_usr_close_window:
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
mov esi, [window_active]
|
2016-01-02 22:03:09 +01:00
|
|
|
mov [window_print], esi
|
2013-10-07 16:02:05 +02:00
|
|
|
cmp [esi + window.type], WINDOWTYPE_SERVER
|
2013-11-01 15:02:08 +01:00
|
|
|
je .not_channel
|
2013-10-07 16:02:05 +02:00
|
|
|
|
2013-11-01 15:02:08 +01: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 16:02:05 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
|
2013-10-07 16:02:05 +02: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 15:02:08 +01:00
|
|
|
jz @f
|
|
|
|
cmp al, 13
|
|
|
|
je @f
|
|
|
|
cmp al, 10
|
|
|
|
je @f
|
|
|
|
stosb
|
|
|
|
jmp @r
|
|
|
|
@@:
|
2013-10-07 16:02:05 +02: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 16:51:43 +01:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
cmd_usr_ctcp:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
cmp byte[user_command+5], ' '
|
2013-11-01 15:02:08 +01:00
|
|
|
jne cmd_usr_send
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, user_command+6
|
2013-11-01 15:02:08 +01:00
|
|
|
; 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
|
|
|
|
|
2018-07-01 16:29:23 +02:00
|
|
|
push edi esi
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; 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
|
2018-07-01 16:29:23 +02:00
|
|
|
mov byte[edi], 0
|
|
|
|
|
|
|
|
; now print to the window
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, ctcp_header
|
|
|
|
call print_asciiz
|
|
|
|
|
|
|
|
mov esi, packetbuf+8
|
|
|
|
mov bl, ' '
|
|
|
|
call print_string
|
|
|
|
|
|
|
|
mov al, ']'
|
|
|
|
call print_char
|
|
|
|
|
|
|
|
mov al, ' '
|
|
|
|
call print_char
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call print_asciiz
|
|
|
|
pop esi
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
; now send it away
|
|
|
|
lea esi, [edi - packetbuf] ; calculate length
|
|
|
|
mcall send, [socketnum], packetbuf, , 0 ; and finally send to server
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
|
2014-03-16 12:50:59 +01: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)
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, user_command+3
|
2014-03-16 12:50:59 +01:00
|
|
|
@@:
|
|
|
|
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
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, user_command+3
|
2014-03-16 12:50:59 +01:00
|
|
|
mov bl, 13
|
|
|
|
call print_string
|
|
|
|
|
|
|
|
mov al, 10
|
|
|
|
call print_char
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
; The user typed some undefined command, just send it to the server
|
2013-05-28 19:34:26 +02:00
|
|
|
cmd_usr_send:
|
|
|
|
|
2016-01-03 15:50:44 +01:00
|
|
|
mov esi, [user_command.size]
|
|
|
|
mov eax, [user_command.size]
|
2024-02-28 21:48:02 +01:00
|
|
|
add eax, user_command
|
2024-02-23 22:15:46 +01:00
|
|
|
mov word[eax], 0x0a0d
|
2024-02-28 21:48:02 +01:00
|
|
|
inc esi ; Skip / add \r\n
|
2016-01-03 15:50:44 +01:00
|
|
|
mcall send, [socketnum], user_command+1, , 0
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|