2013-05-28 21:34:26 +04:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2014-01-18 19:51:43 +04:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2014. 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 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
server_parser:
|
|
|
|
|
|
|
|
mov esi, servercommand
|
|
|
|
|
|
|
|
cmp byte [esi], ':'
|
|
|
|
jne .parse
|
|
|
|
|
|
|
|
.spaceloop:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .fail
|
|
|
|
cmp al, ' '
|
|
|
|
jne .spaceloop
|
|
|
|
|
|
|
|
.parse:
|
|
|
|
mov eax, [esi]
|
|
|
|
or eax, 0x20202020
|
|
|
|
mov edi, server_commands
|
|
|
|
mov ecx, server_commands.number
|
|
|
|
|
|
|
|
.loop:
|
|
|
|
scasd
|
|
|
|
je .got_cmd
|
|
|
|
add edi, 4
|
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.got_cmd:
|
|
|
|
jmp dword[edi]
|
|
|
|
|
|
|
|
|
|
|
|
server_commands:
|
|
|
|
|
2014-03-09 20:07:08 +04:00
|
|
|
dd '001 ', cmd_justprint
|
|
|
|
dd '002 ', cmd_justprint
|
|
|
|
dd '003 ', cmd_justprint
|
|
|
|
dd '004 ', cmd_justprint
|
|
|
|
dd '005 ', cmd_justprint
|
|
|
|
|
|
|
|
dd '250 ', cmd_justprint
|
|
|
|
dd '251 ', cmd_justprint
|
|
|
|
dd '252 ', cmd_justprint
|
|
|
|
dd '253 ', cmd_justprint
|
|
|
|
dd '254 ', cmd_justprint
|
|
|
|
dd '255 ', cmd_justprint
|
|
|
|
|
|
|
|
dd '265 ', cmd_justprint
|
|
|
|
dd '266 ', cmd_justprint
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
dd '322 ', cmd_322 ; RPL_LIST
|
|
|
|
dd '323 ', cmd_323 ; RPL_LISTEND
|
2014-03-09 20:07:08 +04:00
|
|
|
dd '324 ', cmd_justprint
|
|
|
|
dd '328 ', cmd_justprint ; RPL_CHANNEL_URL
|
|
|
|
dd '329 ', cmd_justprint
|
2013-05-28 21:34:26 +04:00
|
|
|
dd '332 ', cmd_topic
|
|
|
|
dd '333 ', cmd_333 ; nickname and time of topic
|
|
|
|
dd '353 ', cmd_353 ; name reply
|
|
|
|
dd '366 ', cmd_366 ; end of names list
|
2014-03-09 20:07:08 +04:00
|
|
|
dd '372 ', cmd_justprint ; motd
|
|
|
|
dd '375 ', cmd_justprint ; start of motd
|
|
|
|
dd '376 ', cmd_justprint ; end of motd
|
|
|
|
dd '421 ', cmd_justprint ; unknown command
|
|
|
|
dd '433 ', cmd_justprint ; nickname already in use
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
dd 'join', cmd_join
|
|
|
|
dd 'kick', cmd_kick
|
|
|
|
dd 'mode', cmd_mode
|
|
|
|
dd 'nick', cmd_nick
|
|
|
|
dd 'part', cmd_part
|
|
|
|
dd 'ping', cmd_ping
|
|
|
|
dd 'priv', cmd_privmsg
|
|
|
|
dd 'quit', cmd_quit
|
|
|
|
dd 'noti', cmd_notice
|
|
|
|
|
|
|
|
.number = ($ - server_commands) / 8
|
|
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
compare_to_nick:
|
|
|
|
|
|
|
|
push esi
|
|
|
|
mov ecx, MAX_NICK_LEN
|
|
|
|
mov esi, user_nick
|
|
|
|
.loop:
|
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
|
|
|
jbe .done
|
2014-01-18 19:51:43 +04:00
|
|
|
test al, al
|
|
|
|
jz .done
|
2013-05-28 21:34:26 +04:00
|
|
|
cmp al, 'a'
|
|
|
|
jb .ok
|
|
|
|
cmp al, 'z'
|
|
|
|
ja .ok
|
|
|
|
sub al, 0x20
|
|
|
|
.ok:
|
|
|
|
|
|
|
|
mov bl, byte[edi]
|
|
|
|
cmp bl, 'a'
|
|
|
|
jb .ok2
|
|
|
|
cmp bl, 'z'
|
|
|
|
ja .ok2
|
|
|
|
sub bl, 0x20
|
|
|
|
.ok2:
|
|
|
|
cmp bl, al
|
|
|
|
jne .not_equal
|
|
|
|
inc edi
|
|
|
|
dec ecx
|
|
|
|
jnz .loop
|
|
|
|
|
|
|
|
.done:
|
|
|
|
xor eax, eax
|
|
|
|
pop esi
|
|
|
|
ret
|
|
|
|
|
|
|
|
.not_equal:
|
|
|
|
or eax, -1
|
|
|
|
pop esi
|
|
|
|
ret
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
align 4
|
2014-01-18 19:51:43 +04:00
|
|
|
skip_parameter:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-02-26 02:18:36 +04:00
|
|
|
; First: skip the parameter (scan untill space or colon)
|
2014-01-18 19:51:43 +04:00
|
|
|
.part1:
|
2013-05-28 21:34:26 +04:00
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
2014-01-18 19:51:43 +04:00
|
|
|
je .part2
|
2013-05-28 21:34:26 +04:00
|
|
|
cmp al, ':'
|
2014-01-18 19:51:43 +04:00
|
|
|
jne .part1
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-02-26 02:18:36 +04:00
|
|
|
; Skip all trailing spaces
|
|
|
|
.part3:
|
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
|
|
|
je .part3
|
|
|
|
dec esi
|
|
|
|
ret
|
|
|
|
|
|
|
|
; Now, skip all trailing spaces and first semicolon
|
2014-01-18 19:51:43 +04:00
|
|
|
.part2:
|
2013-05-28 21:34:26 +04:00
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
2014-01-18 19:51:43 +04:00
|
|
|
je .part2
|
2013-05-28 21:34:26 +04:00
|
|
|
cmp al, ':'
|
2014-02-26 02:18:36 +04:00
|
|
|
je .part3
|
2013-05-28 21:34:26 +04:00
|
|
|
dec esi
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-26 02:18:36 +04:00
|
|
|
|
|
|
|
|
2014-03-09 20:07:08 +04:00
|
|
|
cmd_justprint:
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
add esi, 4
|
2014-03-09 20:07:08 +04:00
|
|
|
call skip_parameter
|
|
|
|
call print_text2
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-03-09 20:07:08 +04:00
|
|
|
ret
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
|
2014-03-09 20:07:08 +04:00
|
|
|
cmd_notice:
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
2014-03-09 20:07:08 +04:00
|
|
|
cmp byte[servercommand], ':'
|
|
|
|
jne .gogogo
|
|
|
|
|
|
|
|
mov byte [esi-1], 0
|
2013-05-28 21:34:26 +04:00
|
|
|
push esi
|
|
|
|
mov esi, str_1
|
|
|
|
call print_text2
|
2013-11-01 18:02:08 +04:00
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
2013-05-28 21:34:26 +04:00
|
|
|
mov esi, str_2
|
|
|
|
call print_text2
|
|
|
|
pop esi
|
|
|
|
|
|
|
|
.gogogo:
|
|
|
|
add esi, 6
|
2014-03-09 20:07:08 +04:00
|
|
|
call skip_parameter
|
|
|
|
call skip_parameter
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
2014-03-09 20:07:08 +04:00
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_ping:
|
|
|
|
|
|
|
|
; Just change PING to PONG
|
|
|
|
mov dword[esi], 'PONG'
|
|
|
|
|
|
|
|
; Find the end of the command
|
|
|
|
lea edi, [esi + 5]
|
|
|
|
xor al, al
|
|
|
|
repne scasb
|
|
|
|
|
|
|
|
; Now send it back
|
|
|
|
mov edx, esi
|
|
|
|
mov esi, edi
|
|
|
|
mov word [esi], 0x0d0a
|
|
|
|
inc esi
|
|
|
|
inc esi
|
|
|
|
sub esi, edx
|
|
|
|
mcall send, [socketnum], , , 0
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_privmsg:
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov eax, dword[esi+4]
|
|
|
|
or eax, 0x20202020
|
|
|
|
cmp eax, 'msg '
|
|
|
|
jne .fail
|
2013-05-28 21:34:26 +04:00
|
|
|
add esi, 8 ; skip 'PRIVMSG '
|
2014-01-18 19:51:43 +04:00
|
|
|
|
|
|
|
mov edi, esi
|
|
|
|
call compare_to_nick
|
|
|
|
jne .channel
|
|
|
|
|
|
|
|
; private chat message
|
|
|
|
push esi
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call window_open
|
|
|
|
pop esi
|
|
|
|
call skip_parameter ; our own nickname
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp byte[esi], 1 ; Client to Client protocol?
|
2013-05-28 21:34:26 +04:00
|
|
|
je cmd_ctcp
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
jmp .print
|
|
|
|
|
|
|
|
.channel:
|
|
|
|
call window_open
|
|
|
|
|
|
|
|
.print:
|
2013-11-01 18:02:08 +04:00
|
|
|
; nope, just plain old privmsg, print it using '<nick> message' format
|
|
|
|
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
|
|
|
|
|
|
|
push esi
|
|
|
|
mov bl, '<'
|
|
|
|
call print_character
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov bl, '>'
|
|
|
|
call print_character
|
|
|
|
|
|
|
|
mov bl, ' '
|
|
|
|
call print_character
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov bl, 10
|
|
|
|
call print_character
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2013-10-07 18:02:05 +04:00
|
|
|
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
cmd_ctcp:
|
2013-11-01 18:02:08 +04:00
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
inc esi
|
2013-11-01 18:02:08 +04:00
|
|
|
mov eax, dword[esi]
|
|
|
|
or eax, 0x20202020
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp eax, 'vers'
|
2013-05-28 21:34:26 +04:00
|
|
|
je .version
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp eax, 'time'
|
2013-05-28 21:34:26 +04:00
|
|
|
je .time
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp eax, 'ping'
|
2013-05-28 21:34:26 +04:00
|
|
|
je .ping
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp eax, 'acti'
|
|
|
|
je .action
|
2014-01-18 19:51:43 +04:00
|
|
|
cmp eax, 'dcc ' ; TODO
|
|
|
|
je cmd_dcc
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
; Unknown CTCP command: TODO: just print to window??
|
|
|
|
|
|
|
|
.fail:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
.time:
|
2013-11-01 18:02:08 +04:00
|
|
|
mov byte[esi+4], ' '
|
2013-05-28 21:34:26 +04:00
|
|
|
lea edi, [esi+5]
|
|
|
|
|
|
|
|
; TODO: add system date (fn 29) in human readable format
|
|
|
|
|
|
|
|
mcall 3 ; get system time
|
|
|
|
|
|
|
|
mov ecx, 3
|
|
|
|
.timeloop:
|
|
|
|
mov bl, al
|
|
|
|
shr al, 4
|
|
|
|
add al, '0'
|
|
|
|
stosb
|
|
|
|
|
|
|
|
mov al, bl
|
|
|
|
and al, 0x0f
|
|
|
|
add al, '0'
|
|
|
|
stosb
|
|
|
|
|
|
|
|
dec ecx
|
|
|
|
jz .timedone
|
|
|
|
|
|
|
|
mov al, ':'
|
|
|
|
stosb
|
|
|
|
shr eax, 8
|
|
|
|
jmp .timeloop
|
|
|
|
|
|
|
|
.timedone:
|
|
|
|
xor al, al
|
|
|
|
stosb
|
|
|
|
call ctcp_reply
|
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, ctcp_header
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, ctcp_time
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
.version:
|
|
|
|
mov esi, str_version
|
|
|
|
call ctcp_reply
|
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, ctcp_header
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, ctcp_version
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
.ping:
|
|
|
|
call ctcp_reply
|
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, ctcp_header
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, ctcp_ping
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
.action:
|
|
|
|
add esi, 7
|
|
|
|
push esi
|
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, action_header
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1 ; print nickname
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov bl, ' '
|
|
|
|
call print_character
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call print_text2 ; print message
|
|
|
|
|
|
|
|
mov bl, 10
|
|
|
|
call print_character
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
cmd_dcc:
|
|
|
|
add esi, 4
|
|
|
|
mov eax, dword[esi]
|
|
|
|
or eax, 0x202020
|
|
|
|
|
|
|
|
cmp eax, 'send'
|
|
|
|
je .send
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
.send:
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
call window_open
|
|
|
|
mov [ebx + window.type], WINDOWTYPE_DCC
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
ret
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
|
|
|
|
ctcp_reply:
|
|
|
|
|
|
|
|
push esi
|
|
|
|
mov dword [usercommand], 'NOTI'
|
|
|
|
mov dword [usercommand+4], 'CE '
|
|
|
|
|
|
|
|
mov esi, servercommand+1
|
|
|
|
mov edi, usercommand+7
|
|
|
|
.nickloop:
|
|
|
|
lodsb
|
|
|
|
cmp al, '!'
|
|
|
|
je .done
|
|
|
|
cmp al, ' '
|
|
|
|
je .done
|
|
|
|
test al, al
|
|
|
|
je .fail
|
|
|
|
stosb
|
|
|
|
jmp .nickloop
|
|
|
|
.done:
|
|
|
|
mov byte [esi-1], 0
|
|
|
|
mov ax, ' :'
|
|
|
|
stosw
|
|
|
|
mov al, 1
|
|
|
|
stosb
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
.replyloop:
|
|
|
|
lodsb
|
|
|
|
cmp al, 1
|
|
|
|
jbe .done2
|
|
|
|
stosb
|
|
|
|
jmp .replyloop
|
|
|
|
.done2:
|
|
|
|
|
|
|
|
mov al, 1
|
|
|
|
stosb
|
|
|
|
mov ax, 0x0a0d
|
|
|
|
stosw
|
|
|
|
|
|
|
|
lea esi, [edi - usercommand]
|
|
|
|
mcall send, [socketnum], usercommand, , 0
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_part:
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
cmp byte [esi+4], ' '
|
|
|
|
jne .fail
|
2013-05-28 21:34:26 +04:00
|
|
|
add esi, 5 ; skip 'PART '
|
|
|
|
|
|
|
|
; Is it me who parted?
|
|
|
|
mov edi, servercommand+1
|
|
|
|
call compare_to_nick
|
2014-01-18 19:51:43 +04:00
|
|
|
jne .not_me
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; yes, close the window (if its open)
|
|
|
|
call window_find
|
|
|
|
test ebx, ebx
|
|
|
|
jz @f
|
|
|
|
call window_close
|
|
|
|
@@:
|
|
|
|
.fail:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
; somebody else parted, just print message
|
2014-01-18 19:51:43 +04:00
|
|
|
.not_me:
|
2013-05-28 21:34:26 +04:00
|
|
|
push esi
|
2013-11-01 18:02:08 +04:00
|
|
|
call window_open
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov esi, part_header
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
mov cl, ' '
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, has_left_channel
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov ebx, [window_print]
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call user_remove
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_join:
|
2013-11-01 18:02:08 +04:00
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
cmp byte[esi+4], ' '
|
2013-11-01 18:02:08 +04:00
|
|
|
jne .fail
|
2013-05-28 21:34:26 +04:00
|
|
|
add esi, 5 ; skip 'JOIN '
|
|
|
|
|
|
|
|
; compare nick: did we join a channel?
|
|
|
|
mov edi, servercommand+1
|
|
|
|
call compare_to_nick
|
2014-01-18 19:51:43 +04:00
|
|
|
jne .not_me
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
push esi
|
|
|
|
call window_open
|
2013-05-28 21:34:26 +04:00
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
mov [ebx + window.type], WINDOWTYPE_CHANNEL
|
2013-10-07 18:02:05 +04:00
|
|
|
mov [window_active], ebx
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov esi, join_header
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_talking
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
pop eax
|
|
|
|
mov dl, ' '
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, str_dotnewline
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
call draw_window
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
.not_me:
|
2013-05-28 21:34:26 +04:00
|
|
|
push esi
|
2013-10-07 18:02:05 +04:00
|
|
|
call window_open
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, join_header
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, joins_channel
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov ebx, [window_print]
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call user_add
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
ret
|
2013-11-01 18:02:08 +04:00
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
.fail:
|
|
|
|
add esp, 4
|
2013-05-28 21:34:26 +04:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_nick:
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp byte[esi+4], ' '
|
|
|
|
jne .fail
|
|
|
|
add esi, 5 ; skip 'NICK '
|
|
|
|
cmp byte[esi], ':'
|
2013-05-28 21:34:26 +04:00
|
|
|
jne @f
|
|
|
|
inc esi
|
2013-11-01 18:02:08 +04:00
|
|
|
@@:
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
; Is it me who changed nick?
|
2013-11-01 18:02:08 +04:00
|
|
|
push esi
|
2013-05-28 21:34:26 +04:00
|
|
|
mov edi, servercommand+1
|
|
|
|
call compare_to_nick
|
|
|
|
jne .not_me
|
|
|
|
|
2014-03-07 09:04:10 +04:00
|
|
|
; Yup, update user_nick
|
2013-05-28 21:34:26 +04:00
|
|
|
mov ecx, MAX_NICK_LEN-1
|
2013-11-01 18:02:08 +04:00
|
|
|
mov esi, [esp]
|
2014-03-07 09:04:10 +04:00
|
|
|
mov edi, user_nick
|
2013-11-01 18:02:08 +04:00
|
|
|
@@:
|
2013-05-28 21:34:26 +04:00
|
|
|
lodsb
|
|
|
|
test al, al
|
2013-11-01 18:02:08 +04:00
|
|
|
jz @f
|
2013-05-28 21:34:26 +04:00
|
|
|
cmp al, ' '
|
2013-11-01 18:02:08 +04:00
|
|
|
je @f
|
|
|
|
cmp al, 10
|
|
|
|
je @f
|
|
|
|
cmp al, 13
|
|
|
|
je @f
|
2014-03-07 09:04:10 +04:00
|
|
|
cmp al, ':'
|
|
|
|
je @r
|
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
|
|
|
|
.not_me:
|
|
|
|
|
2014-03-07 09:04:10 +04:00
|
|
|
; Update in userlist
|
2013-11-01 18:02:08 +04:00
|
|
|
mov ebx, windows
|
|
|
|
mov ecx, MAX_WINDOWS
|
|
|
|
.window_loop:
|
|
|
|
push ecx ebx
|
|
|
|
cmp [ebx + window.type], WINDOWTYPE_CHANNEL
|
|
|
|
jne .next_window
|
|
|
|
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call user_remove
|
|
|
|
test edi, edi
|
|
|
|
jz .next_window
|
|
|
|
|
|
|
|
mov esi, [esp + 8]
|
|
|
|
call user_add
|
|
|
|
|
2014-03-07 09:04:10 +04:00
|
|
|
; And print a notification in the channel
|
2013-11-01 18:02:08 +04:00
|
|
|
mov [window_print], ebx
|
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, nick_header
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, is_now_known_as
|
|
|
|
call print_text2
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov esi, [esp + 8] ; FIXME: dont print the 0x0a0d!!!
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
2014-03-07 09:04:10 +04:00
|
|
|
; Now do this for all open windows
|
2013-11-01 18:02:08 +04:00
|
|
|
.next_window:
|
|
|
|
pop ebx ecx
|
|
|
|
add ebx, sizeof.window
|
|
|
|
dec ecx
|
|
|
|
jnz .window_loop
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_kick:
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
cmp byte [esi+4], ' '
|
|
|
|
jne .fail
|
2013-05-28 21:34:26 +04:00
|
|
|
add esi, 5 ; skip 'KICK '
|
|
|
|
|
2014-02-26 02:18:36 +04:00
|
|
|
; TODO: Is it me who got kicked?
|
|
|
|
; if so, mark channel as disconnected
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
.not_me:
|
|
|
|
; find the channel user has been kicked from
|
|
|
|
push esi
|
2013-10-07 18:02:05 +04:00
|
|
|
call window_open
|
2014-02-26 02:18:36 +04:00
|
|
|
push esi
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, kick_header
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
2014-02-26 02:18:36 +04:00
|
|
|
pop eax
|
|
|
|
mov dl, ' '
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text
|
|
|
|
|
2014-02-26 02:18:36 +04:00
|
|
|
mov esi, str_kicked
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
2014-02-26 02:18:36 +04:00
|
|
|
pop eax
|
|
|
|
mov dl, ' '
|
2014-03-07 09:04:10 +04:00
|
|
|
call print_text
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2014-02-26 02:18:36 +04:00
|
|
|
mov esi, str_by
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, str_dotnewline
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov ebx, [window_print]
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call user_remove
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
.fail:
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_quit:
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp byte [esi+4], ' '
|
|
|
|
jne .fail
|
|
|
|
|
|
|
|
mov ebx, windows
|
|
|
|
mov ecx, MAX_WINDOWS
|
|
|
|
|
|
|
|
.window_loop:
|
|
|
|
push ecx
|
|
|
|
cmp [ebx + window.type], WINDOWTYPE_CHANNEL
|
|
|
|
jne .next_window
|
|
|
|
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call user_remove
|
|
|
|
test edi, edi
|
|
|
|
jz .next_window
|
|
|
|
|
|
|
|
push ebx
|
|
|
|
mov [window_print], ebx
|
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, quit_header
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, has_quit_irc
|
|
|
|
call print_text2
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
; TODO: check if quit message was given, and print it to the window
|
|
|
|
pop ebx
|
|
|
|
.next_window:
|
|
|
|
pop ecx
|
|
|
|
add ebx, sizeof.window
|
|
|
|
dec ecx
|
|
|
|
jnz .window_loop
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_mode:
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmp byte [esi+4], ' '
|
|
|
|
jne .fail
|
2013-05-28 21:34:26 +04:00
|
|
|
add esi, 5 ; skip 'MODE '
|
2014-03-09 20:07:08 +04:00
|
|
|
push esi
|
2013-11-01 18:02:08 +04:00
|
|
|
call window_find
|
|
|
|
test ebx, ebx
|
2014-03-09 20:07:08 +04:00
|
|
|
jz .user
|
|
|
|
mov [esp], esi
|
2014-01-18 19:51:43 +04:00
|
|
|
mov [window_print], ebx
|
2013-11-01 18:02:08 +04:00
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, mode_header
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
2013-11-01 18:02:08 +04:00
|
|
|
mov dl, '!'
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, sets_mode
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
2014-03-09 20:07:08 +04:00
|
|
|
; TODO: keep track of user modes in username list
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
.fail:
|
2014-03-09 20:07:08 +04:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
.user:
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, mode_header
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, [esp]
|
|
|
|
mov dl, ' '
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, sets_mode
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call skip_parameter
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
2013-11-01 18:02:08 +04:00
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
cmd_353: ; channel usernames reply
|
|
|
|
|
|
|
|
add esi, 4 ; skip '353 '
|
2014-01-18 19:51:43 +04:00
|
|
|
call skip_parameter
|
2013-05-28 21:34:26 +04:00
|
|
|
inc esi ; channel type '*', '=' or '@'
|
|
|
|
inc esi ; ' '
|
2013-10-07 18:02:05 +04:00
|
|
|
call window_open
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
; now find window ptr and check if this is the first 353 message
|
|
|
|
mov ebx, [window_print]
|
|
|
|
test [ebx + window.flags], FLAG_RECEIVING_NAMES
|
|
|
|
jnz .add
|
|
|
|
|
|
|
|
or [ebx + window.flags], FLAG_RECEIVING_NAMES
|
|
|
|
; mov [ebx + window.users], 0
|
|
|
|
; TODO: remove all users?
|
|
|
|
|
|
|
|
.add:
|
|
|
|
push esi
|
|
|
|
call user_add
|
|
|
|
pop esi
|
|
|
|
|
|
|
|
.namesloop:
|
|
|
|
lodsb
|
|
|
|
test al, al
|
|
|
|
jz .done
|
|
|
|
cmp al, ' ' ; names list is separated with spaces
|
|
|
|
jne .namesloop
|
|
|
|
jmp .add
|
|
|
|
|
|
|
|
.done:
|
2013-11-01 18:02:08 +04:00
|
|
|
call draw_channel_list
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_366: ; channel usernames end
|
|
|
|
|
|
|
|
add esi, 4 ; skip '366 '
|
2014-01-18 19:51:43 +04:00
|
|
|
call skip_parameter
|
2013-10-07 18:02:05 +04:00
|
|
|
call window_open
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
mov ebx, [window_print]
|
|
|
|
and [ebx + window.flags], not FLAG_RECEIVING_NAMES
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_topic:
|
|
|
|
|
|
|
|
add esi, 4 ; skip '332 '
|
2014-01-18 19:51:43 +04:00
|
|
|
call skip_parameter
|
2013-10-07 18:02:05 +04:00
|
|
|
call window_open
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
push esi
|
2013-11-01 18:02:08 +04:00
|
|
|
mov esi, topic_header
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_topic
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call print_text2
|
|
|
|
|
2014-01-18 19:51:43 +04:00
|
|
|
mov esi, str_topic_end
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
cmd_333:
|
|
|
|
|
|
|
|
add esi, 4 ; skip '333 '
|
2014-03-09 20:07:08 +04:00
|
|
|
call skip_parameter
|
2013-10-07 18:02:05 +04:00
|
|
|
call window_open
|
2013-05-28 21:34:26 +04:00
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
push esi
|
2013-11-01 18:02:08 +04:00
|
|
|
mov esi, topic_header
|
2013-05-28 21:34:26 +04:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_setby
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
pop eax
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmd_322: ; LIST
|
|
|
|
|
2013-05-28 21:34:26 +04:00
|
|
|
add esi, 4
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
mov [window_print], windows ; FIXME
|
2014-01-18 19:51:43 +04:00
|
|
|
call skip_parameter
|
2013-11-01 18:02:08 +04:00
|
|
|
mov eax, esi
|
|
|
|
mov dl, 13
|
|
|
|
call print_text
|
2013-05-28 21:34:26 +04:00
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2013-11-01 18:02:08 +04:00
|
|
|
cmd_323: ; LIST END
|
2013-05-28 21:34:26 +04:00
|
|
|
|
|
|
|
ret
|