2013-05-28 19:34:26 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2014-01-18 16:51:43 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2014. 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 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
dd '322 ', cmd_322 ; RPL_LIST
|
|
|
|
dd '323 ', cmd_323 ; RPL_LISTEND
|
2013-11-01 15:02:08 +01:00
|
|
|
dd '324 ', cmd_324 ;;;;
|
2013-10-20 20:47:47 +02:00
|
|
|
dd '328 ', cmd_328 ; RPL_CHANNEL_URL
|
2013-11-01 15:02:08 +01:00
|
|
|
dd '329 ', cmd_329
|
2013-05-28 19:34:26 +02: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
|
|
|
|
dd '372 ', cmd_372 ; motd
|
|
|
|
dd '375 ', cmd_375 ; start of motd
|
|
|
|
dd '376 ', cmd_376 ; end of motd
|
|
|
|
dd '421 ', cmd_421 ; unknown command
|
2014-01-18 16:51:43 +01:00
|
|
|
dd '433 ', cmd_433 ; nickname already in use
|
2013-05-28 19:34:26 +02: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 16:51:43 +01:00
|
|
|
test al, al
|
|
|
|
jz .done
|
2013-05-28 19:34:26 +02: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 15:02:08 +01:00
|
|
|
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
align 4
|
2014-01-18 16:51:43 +01:00
|
|
|
skip_parameter:
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-02-25 23:18:36 +01:00
|
|
|
; First: skip the parameter (scan untill space or colon)
|
2014-01-18 16:51:43 +01:00
|
|
|
.part1:
|
2013-05-28 19:34:26 +02:00
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
2014-01-18 16:51:43 +01:00
|
|
|
je .part2
|
2013-05-28 19:34:26 +02:00
|
|
|
cmp al, ':'
|
2014-01-18 16:51:43 +01:00
|
|
|
jne .part1
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-02-25 23:18:36 +01: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 16:51:43 +01:00
|
|
|
.part2:
|
2013-05-28 19:34:26 +02:00
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
2014-01-18 16:51:43 +01:00
|
|
|
je .part2
|
2013-05-28 19:34:26 +02:00
|
|
|
cmp al, ':'
|
2014-02-25 23:18:36 +01:00
|
|
|
je .part3
|
2013-05-28 19:34:26 +02:00
|
|
|
dec esi
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-25 23:18:36 +01:00
|
|
|
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
cmd_324:
|
|
|
|
cmd_329:
|
2013-05-28 19:34:26 +02:00
|
|
|
cmd_328:
|
|
|
|
cmd_421:
|
|
|
|
cmd_372:
|
|
|
|
cmd_375:
|
|
|
|
cmd_376:
|
2014-01-18 16:51:43 +01:00
|
|
|
cmd_433:
|
2013-05-28 19:34:26 +02:00
|
|
|
add esi, 4
|
|
|
|
jmp cmd_notice.loop
|
|
|
|
|
|
|
|
cmd_notice:
|
|
|
|
|
|
|
|
cmp byte[servercommand], ':'
|
|
|
|
jne .gogogo
|
|
|
|
|
|
|
|
mov byte [esi-1], 0
|
2013-11-01 15:02:08 +01:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
push esi
|
|
|
|
mov esi, str_1
|
|
|
|
call print_text2
|
2013-11-01 15:02:08 +01:00
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
2013-05-28 19:34:26 +02:00
|
|
|
mov esi, str_2
|
|
|
|
call print_text2
|
|
|
|
pop esi
|
|
|
|
|
|
|
|
.gogogo:
|
|
|
|
add esi, 6
|
|
|
|
|
|
|
|
.loop:
|
|
|
|
inc esi
|
|
|
|
cmp byte [esi], 0
|
|
|
|
je .fail
|
|
|
|
cmp byte [esi], ' '
|
|
|
|
jne .loop
|
|
|
|
|
|
|
|
.loop2:
|
|
|
|
inc esi
|
|
|
|
cmp byte [esi], 0
|
|
|
|
je .fail
|
|
|
|
cmp byte [esi], ' '
|
|
|
|
je .loop2
|
|
|
|
cmp byte [esi], ':'
|
|
|
|
je .loop2
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
.fail:
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
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 15:02:08 +01:00
|
|
|
mov eax, dword[esi+4]
|
|
|
|
or eax, 0x20202020
|
|
|
|
cmp eax, 'msg '
|
|
|
|
jne .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
add esi, 8 ; skip 'PRIVMSG '
|
2014-01-18 16:51:43 +01: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 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
cmp byte[esi], 1 ; Client to Client protocol?
|
2013-05-28 19:34:26 +02:00
|
|
|
je cmd_ctcp
|
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
jmp .print
|
|
|
|
|
|
|
|
.channel:
|
|
|
|
call window_open
|
|
|
|
|
|
|
|
.print:
|
2013-11-01 15:02:08 +01:00
|
|
|
; nope, just plain old privmsg, print it using '<nick> message' format
|
|
|
|
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
|
|
|
|
|
|
|
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 16:02:05 +02:00
|
|
|
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
cmd_ctcp:
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
inc esi
|
2013-11-01 15:02:08 +01:00
|
|
|
mov eax, dword[esi]
|
|
|
|
or eax, 0x20202020
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
cmp eax, 'vers'
|
2013-05-28 19:34:26 +02:00
|
|
|
je .version
|
2013-11-01 15:02:08 +01:00
|
|
|
cmp eax, 'time'
|
2013-05-28 19:34:26 +02:00
|
|
|
je .time
|
2013-11-01 15:02:08 +01:00
|
|
|
cmp eax, 'ping'
|
2013-05-28 19:34:26 +02:00
|
|
|
je .ping
|
2013-11-01 15:02:08 +01:00
|
|
|
cmp eax, 'acti'
|
|
|
|
je .action
|
2014-01-18 16:51:43 +01:00
|
|
|
cmp eax, 'dcc ' ; TODO
|
|
|
|
je cmd_dcc
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
; Unknown CTCP command: TODO: just print to window??
|
|
|
|
|
|
|
|
.fail:
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
.time:
|
2013-11-01 15:02:08 +01:00
|
|
|
mov byte[esi+4], ' '
|
2013-05-28 19:34:26 +02: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 15:02:08 +01: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 16:51:43 +01:00
|
|
|
call window_open
|
|
|
|
mov [ebx + window.type], WINDOWTYPE_DCC
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
ret
|
|
|
|
|
2013-05-28 19:34:26 +02: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 15:02:08 +01:00
|
|
|
|
|
|
|
cmp byte [esi+4], ' '
|
|
|
|
jne .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
add esi, 5 ; skip 'PART '
|
|
|
|
|
|
|
|
; Is it me who parted?
|
|
|
|
mov edi, servercommand+1
|
|
|
|
call compare_to_nick
|
2014-01-18 16:51:43 +01:00
|
|
|
jne .not_me
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; yes, close the window (if its open)
|
|
|
|
call window_find
|
|
|
|
test ebx, ebx
|
|
|
|
jz @f
|
|
|
|
call window_close
|
|
|
|
@@:
|
|
|
|
.fail:
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
; somebody else parted, just print message
|
2014-01-18 16:51:43 +01:00
|
|
|
.not_me:
|
2013-05-28 19:34:26 +02:00
|
|
|
push esi
|
2013-11-01 15:02:08 +01:00
|
|
|
call window_open
|
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
mov esi, part_header
|
2013-05-28 19:34:26 +02: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 15:02:08 +01:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
cmp byte[esi+4], ' '
|
2013-11-01 15:02:08 +01:00
|
|
|
jne .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
add esi, 5 ; skip 'JOIN '
|
|
|
|
|
|
|
|
; compare nick: did we join a channel?
|
|
|
|
mov edi, servercommand+1
|
|
|
|
call compare_to_nick
|
2014-01-18 16:51:43 +01:00
|
|
|
jne .not_me
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
push esi
|
|
|
|
call window_open
|
2013-05-28 19:34:26 +02:00
|
|
|
test eax, eax
|
|
|
|
jz .fail
|
|
|
|
mov [ebx + window.type], WINDOWTYPE_CHANNEL
|
2013-10-07 16:02:05 +02:00
|
|
|
mov [window_active], ebx
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
mov esi, join_header
|
2013-05-28 19:34:26 +02: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 16:51:43 +01:00
|
|
|
.not_me:
|
2013-05-28 19:34:26 +02:00
|
|
|
push esi
|
2013-10-07 16:02:05 +02:00
|
|
|
call window_open
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, join_header
|
2013-05-28 19:34:26 +02: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 16:51:43 +01:00
|
|
|
ret
|
2013-11-01 15:02:08 +01:00
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
.fail:
|
|
|
|
add esp, 4
|
2013-05-28 19:34:26 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_nick:
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
cmp byte[esi+4], ' '
|
|
|
|
jne .fail
|
|
|
|
add esi, 5 ; skip 'NICK '
|
|
|
|
cmp byte[esi], ':'
|
2013-05-28 19:34:26 +02:00
|
|
|
jne @f
|
|
|
|
inc esi
|
2013-11-01 15:02:08 +01:00
|
|
|
@@:
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
; Is it me who changed nick?
|
2013-11-01 15:02:08 +01:00
|
|
|
push esi
|
2013-05-28 19:34:26 +02:00
|
|
|
mov edi, servercommand+1
|
|
|
|
call compare_to_nick
|
|
|
|
jne .not_me
|
|
|
|
|
|
|
|
mov ecx, MAX_NICK_LEN-1
|
2013-11-01 15:02:08 +01:00
|
|
|
mov esi, [esp]
|
|
|
|
@@:
|
2013-05-28 19:34:26 +02:00
|
|
|
lodsb
|
|
|
|
test al, al
|
2013-11-01 15:02:08 +01:00
|
|
|
jz @f
|
2013-05-28 19:34:26 +02:00
|
|
|
cmp al, ' '
|
2013-11-01 15:02:08 +01:00
|
|
|
je @f
|
|
|
|
cmp al, 10
|
|
|
|
je @f
|
|
|
|
cmp al, 13
|
|
|
|
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
|
|
|
|
.not_me:
|
|
|
|
|
2013-11-01 15:02:08 +01: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
|
|
|
|
|
|
|
|
mov [window_print], ebx
|
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, nick_header
|
2013-05-28 19:34:26 +02: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 15:02:08 +01:00
|
|
|
mov esi, [esp + 8] ; FIXME: dont print the 0x0a0d!!!
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
.next_window:
|
|
|
|
pop ebx ecx
|
|
|
|
add ebx, sizeof.window
|
|
|
|
dec ecx
|
|
|
|
jnz .window_loop
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_kick:
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
cmp byte [esi+4], ' '
|
|
|
|
jne .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
add esi, 5 ; skip 'KICK '
|
|
|
|
|
2014-02-25 23:18:36 +01:00
|
|
|
; TODO: Is it me who got kicked?
|
|
|
|
; if so, mark channel as disconnected
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
.not_me:
|
|
|
|
; find the channel user has been kicked from
|
|
|
|
push esi
|
2013-10-07 16:02:05 +02:00
|
|
|
call window_open
|
2014-02-25 23:18:36 +01:00
|
|
|
push esi
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, kick_header
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
2014-02-25 23:18:36 +01:00
|
|
|
pop eax
|
|
|
|
mov dl, ' '
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text
|
|
|
|
|
2014-02-25 23:18:36 +01:00
|
|
|
mov esi, str_kicked
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
2014-02-25 23:18:36 +01:00
|
|
|
pop eax
|
|
|
|
mov dl, ' '
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
2014-02-25 23:18:36 +01:00
|
|
|
mov esi, str_by
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, str_dotnewline
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov ebx, [window_print]
|
|
|
|
mov esi, servercommand+1
|
|
|
|
call user_remove
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
.fail:
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_quit:
|
|
|
|
|
2013-11-01 15:02:08 +01: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 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, has_quit_irc
|
|
|
|
call print_text2
|
|
|
|
|
2013-11-01 15:02:08 +01: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 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_mode:
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
cmp byte [esi+4], ' '
|
|
|
|
jne .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
add esi, 5 ; skip 'MODE '
|
2013-11-01 15:02:08 +01:00
|
|
|
call window_find
|
|
|
|
test ebx, ebx
|
|
|
|
jz .fail
|
2014-01-18 16:51:43 +01:00
|
|
|
mov [window_print], ebx
|
2013-05-28 19:34:26 +02:00
|
|
|
push esi
|
2013-11-01 15:02:08 +01:00
|
|
|
|
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
|
|
|
mov esi, mode_header
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov eax, servercommand+1
|
2013-11-01 15:02:08 +01:00
|
|
|
mov dl, '!'
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, sets_mode
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
;;; TODO: change username if needed
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
.fail:
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
cmd_353: ; channel usernames reply
|
|
|
|
|
|
|
|
add esi, 4 ; skip '353 '
|
2014-01-18 16:51:43 +01:00
|
|
|
call skip_parameter
|
2013-05-28 19:34:26 +02:00
|
|
|
inc esi ; channel type '*', '=' or '@'
|
|
|
|
inc esi ; ' '
|
2013-10-07 16:02:05 +02:00
|
|
|
call window_open
|
2013-05-28 19:34:26 +02: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 15:02:08 +01:00
|
|
|
call draw_channel_list
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_366: ; channel usernames end
|
|
|
|
|
|
|
|
add esi, 4 ; skip '366 '
|
2014-01-18 16:51:43 +01:00
|
|
|
call skip_parameter
|
2013-10-07 16:02:05 +02:00
|
|
|
call window_open
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
mov ebx, [window_print]
|
|
|
|
and [ebx + window.flags], not FLAG_RECEIVING_NAMES
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmd_topic:
|
|
|
|
|
|
|
|
add esi, 4 ; skip '332 '
|
2014-01-18 16:51:43 +01:00
|
|
|
call skip_parameter
|
2013-10-07 16:02:05 +02:00
|
|
|
call window_open
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
push esi
|
2013-11-01 15:02:08 +01:00
|
|
|
mov esi, topic_header
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_topic
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
call print_text2
|
|
|
|
|
2014-01-18 16:51:43 +01:00
|
|
|
mov esi, str_topic_end
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
cmd_333:
|
|
|
|
|
|
|
|
add esi, 4 ; skip '333 '
|
2014-01-18 16:51:43 +01:00
|
|
|
call skip_parameter ;;;;
|
2013-10-07 16:02:05 +02:00
|
|
|
call window_open
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
if TIMESTAMP
|
|
|
|
call print_timestamp
|
|
|
|
end if
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
push esi
|
2013-11-01 15:02:08 +01:00
|
|
|
mov esi, topic_header
|
2013-05-28 19:34:26 +02:00
|
|
|
call print_text2
|
|
|
|
|
|
|
|
mov esi, str_setby
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
; pop esi
|
|
|
|
; call print_text2
|
|
|
|
|
|
|
|
pop eax
|
|
|
|
mov dl, '!'
|
|
|
|
call print_text
|
|
|
|
|
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
ret
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
cmd_322: ; LIST
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
add esi, 4
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
mov [window_print], windows ; FIXME
|
2014-01-18 16:51:43 +01:00
|
|
|
call skip_parameter
|
2013-11-01 15:02:08 +01:00
|
|
|
mov eax, esi
|
|
|
|
mov dl, 13
|
|
|
|
call print_text
|
2013-05-28 19:34:26 +02:00
|
|
|
mov esi, str_newline
|
|
|
|
call print_text2
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
cmd_323: ; LIST END
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
ret
|