Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4709 → Rev 4710

/programs/network/ircc/ircc.asm
13,7 → 13,7
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
version equ '0.21'
version equ '0.22'
 
; connection status
STATUS_DISCONNECTED = 0
334,7 → 334,7
cmp [socketnum], 0
je @f
mov esi, quit_msg
call cmd_usr_quit_server
call quit_server
@@:
 
error:
462,9 → 462,11
str_sockerr db 3, '5* Socket error', 10, 0
str_dnserr db 3, '5* Unable to resolve hostname', 10, 0
str_refused db 3, '5* Connection refused', 10, 0
str_disconnected db 3, '5* Server disconnected', 10, 0
str_srv_disconnected db 3, '5* Server disconnected', 10, 0
str_disconnected db 3, '5* Disconnected', 10, 0
str_reconnect db 3, '5* Connection reset by user', 10, 0
str_notconnected db 3, '5* Not connected to server', 10, 0
str_notchannel db 3, '5* You are not on a channel', 10, 0
 
str_1 db 3, '13 -', 0
str_2 db '- ', 0
/programs/network/ircc/socket.inc
109,7 → 109,7
call print_asciiz
 
mov esi, quit_msg
call cmd_usr_quit.with_message
call quit_server
 
jmp socket_connect
 
250,7 → 250,10
 
 
.disconnected:
mov esi, str_disconnected
if TIMESTAMP
call print_timestamp
end if
mov esi, str_srv_disconnected
call print_asciiz
 
mov [status], STATUS_DISCONNECTED
/programs/network/ircc/userparser.inc
13,8 → 13,8
 
user_parser:
 
push [window_active] ; print to the current window
pop [window_print]
mov ebp, [window_active] ; print to the current window
mov [window_print], ebp
 
mov eax, [edit1.size]
test eax, eax
22,15 → 22,17
mov word[usercommand + eax], 0x0a0d ; terminate the line
 
cmp byte[usercommand], '/' ; is it a server command ?
je server_command
je .command
 
; Ignore data commands when not connected.
cmp [status], STATUS_CONNECTED
jne .notconnected
jne .not_connected
 
; Ok, we said something, print it to our textbox
; TODO: dont send if it's a server window?
cmp [ebp + window.type], WINDOWTYPE_CHANNEL
je .send_privmsg
cmp [ebp + window.type], WINDOWTYPE_CHAT
jne .not_channel
 
.send_privmsg:
if TIMESTAMP
call print_timestamp
end if
59,8 → 61,7
mov dword[packetbuf], 'PRIV'
mov dword[packetbuf+4], 'MSG '
 
mov esi, [window_active]
add esi, window.name
lea esi, [ebp + window.name]
mov edi, packetbuf+8
mov ecx, MAX_WINDOWNAME_LEN
.loop:
86,39 → 87,12
 
lea esi, [edi - packetbuf]
mcall send, [socketnum], packetbuf, , 0
 
.ret:
 
ret
 
.notconnected:
mov esi, str_notconnected
call print_asciiz
 
ret
 
 
 
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
 
 
server_command:
 
; Text begins with a '/' lets try to find the command in the lookup table.
.command:
mov eax, dword[usercommand+1] ; skip '/'
or eax, 0x20202020 ; convert to lowercase
 
125,35 → 99,61
mov edi, user_commands
mov ecx, user_commands.number
cmp [status], STATUS_CONNECTED
je .loop
je .cmd_loop
mov ecx, user_commands.number2
.loop:
.cmd_loop:
scasd
je .got_cmd
add edi, 4
dec ecx
jnz .loop
jnz .cmd_loop
 
cmp [status], STATUS_CONNECTED
jne .notconnected
jne .not_connected
 
; Commands shorter then 3 chars are placed here
and eax, 0x00ffffff
cmp eax, 'me '
je cmd_usr_me
 
jmp cmd_usr_send ; If none of the previous commands, just send to server
; If none of the listed commands, send text straight to server
jmp cmd_usr_send
 
.got_cmd:
jmp dword[edi]
 
.notconnected:
.not_connected:
mov esi, str_notconnected
call print_asciiz
ret
 
.not_channel:
mov esi, str_notchannel
call print_asciiz
ret
 
 
; 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
 
 
 
cmd_usr_msg:
 
lea esi, [usercommand+5]
224,34 → 224,14
 
 
cmd_usr_quit:
 
mov esi, quit_msg
 
cmp byte[usercommand+5], ' '
jne .with_message
jne quit_server
lea esi, [usercommand+6]
.with_message:
call cmd_usr_quit_server
 
mcall close, [socketnum]
mov [status], STATUS_DISCONNECTED
 
mov ecx, MAX_WINDOWS
mov edi, windows
.loop:
mov [window_print], edi
push edi ecx
call window_close
pop ecx edi
add edi, sizeof.window
dec ecx
jnz .loop
 
ret
 
 
 
; esi = quit message
cmd_usr_quit_server:
quit_server:
 
; User wants to close a channel, send PART command to server
mov dword[packetbuf], 'QUIT'
274,6 → 254,27
lea esi, [edi - packetbuf] ; calculate length
mcall send, [socketnum], packetbuf, , 0 ; and finally send to server
 
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]
 
ret
 
 
368,6 → 369,10
cmp eax, 'er '
jne cmd_usr_send
 
; Server window is always first window in the list, switch to it.
mov [window_print], windows
mov [window_active], windows
 
mov ecx, [edit1.size] ; ok now set the address
sub ecx, 8
 
/programs/network/ircc/users.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
22,7 → 22,7
user_add:
 
cmp [ebx + window.users], MAX_USERS
jae fail
jae .fail
 
mov edi, [ebx + window.data_ptr]
add edi, window_data.names
115,7 → 115,7
 
inc [ebx + window.users]
or [ebx + window.flags], FLAG_UPDATED
 
.fail:
ret
 
 
128,7 → 128,7
user_remove:
 
call user_find
jz fail
jz .fail
 
lea esi, [edi + MAX_NICK_LEN]
mov ecx, [ebx + window.data_ptr]
139,7 → 139,7
 
dec [ebx + window.users]
or [ebx + window.flags], FLAG_UPDATED
 
.fail:
ret
 
 
154,7 → 154,7
 
mov eax, [ebx + window.users]
test eax, eax
jz fail
jz .fail
mov edi, [ebx + window.data_ptr]
add edi, window_data.names
 
169,16 → 169,28
add edi, MAX_NICK_LEN
dec eax
jnz .loop
jmp fail
jmp .fail
 
.got_it:
pop edi esi
test edi, edi ; to clear zero flag
ret
 
.fail:
xor edi, edi
ret
 
 
fail:
 
xor edi, edi
user_remove_all:
 
xor eax, eax
mov edi, [window_print]
mov [edi + window.users], eax
mov [edi + window.selected], eax
mov edi, [edi + window.data_ptr]
add edi, window_data.names
mov ecx, MAX_NICK_LEN * MAX_USERS / 4
rep stosd
 
ret