2013-10-07 16:02:05 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2024-03-05 10:49:00 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
|
2013-10-07 16:02:05 +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-10-07 16:02:05 +02:00
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2013-11-01 15:02:08 +01:00
|
|
|
; TODO: work correctly with user prefixes.
|
|
|
|
; use first byte of nick for prefix ONLY (use a space for those that do not have special powers..)
|
|
|
|
|
|
|
|
user_prefixes db '~&@%+ ', 0 ; in descending order
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2014-03-16 12:50:59 +01:00
|
|
|
; TODO: update selected user if needed
|
2013-05-28 19:34:26 +02:00
|
|
|
; esi is ptr to nick
|
|
|
|
; ebx is ptr to window
|
|
|
|
align 4
|
|
|
|
user_add:
|
|
|
|
|
|
|
|
cmp [ebx + window.users], MAX_USERS
|
2014-03-28 21:03:30 +01:00
|
|
|
jae .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
|
2024-03-05 10:49:00 +01:00
|
|
|
; Check if user is already listed (case insensitive)
|
2013-05-28 19:34:26 +02:00
|
|
|
mov edi, [ebx + window.data_ptr]
|
|
|
|
add edi, window_data.names
|
|
|
|
mov ebp, [ebx + window.users]
|
2013-11-01 15:02:08 +01:00
|
|
|
inc ebp ; CHECKME
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
push esi edi
|
|
|
|
.restart:
|
|
|
|
mov ecx, MAX_NICK_LEN
|
|
|
|
.loop1:
|
|
|
|
lodsb
|
|
|
|
cmp al, '@'
|
|
|
|
jne @f
|
|
|
|
mov al, ' ' ; give @ highest priority
|
|
|
|
@@:
|
|
|
|
cmp al, 'A'
|
|
|
|
jb @f
|
|
|
|
cmp al, 'Z'
|
|
|
|
ja @f
|
|
|
|
add al, 'a' - 'A' ; convert to lowercase
|
|
|
|
@@:
|
|
|
|
dec ecx
|
|
|
|
jz .got_it
|
|
|
|
|
|
|
|
.loop2:
|
|
|
|
mov dl, [edi]
|
|
|
|
cmp dl, 0
|
|
|
|
je .got_it
|
|
|
|
cmp dl, '@'
|
|
|
|
jne @f
|
|
|
|
mov dl, ' ' ; give @ highest priority
|
|
|
|
@@:
|
|
|
|
cmp dl, 'A'
|
|
|
|
jb @f
|
|
|
|
cmp dl, 'Z'
|
|
|
|
ja @f
|
|
|
|
add dl, 'a' - 'A' ; convert to lowercase
|
|
|
|
@@:
|
|
|
|
cmp al, dl
|
|
|
|
jb .got_it
|
|
|
|
je .check_next
|
|
|
|
|
|
|
|
pop edi esi
|
|
|
|
add edi, MAX_NICK_LEN
|
|
|
|
push esi edi
|
|
|
|
|
|
|
|
dec ebp
|
|
|
|
jnz .restart
|
|
|
|
|
|
|
|
.check_next:
|
|
|
|
inc edi
|
|
|
|
jmp .loop1
|
|
|
|
|
|
|
|
.got_it:
|
|
|
|
pop edi esi
|
|
|
|
|
|
|
|
; OK, insert it here..
|
|
|
|
|
|
|
|
; mov all trailing usernames by MAX_NICK_LEN bytes
|
|
|
|
push esi edi
|
|
|
|
mov esi, [ebx + window.data_ptr]
|
2013-11-01 15:02:08 +01:00
|
|
|
add esi, window_data.names + MAX_NICK_LEN * (MAX_USERS - 1) - 4 ; -4 because we're copying backward, dword wise
|
2013-05-28 19:34:26 +02:00
|
|
|
mov ecx, esi
|
|
|
|
sub ecx, edi
|
|
|
|
add ecx, MAX_NICK_LEN
|
|
|
|
shr ecx, 2
|
|
|
|
lea edi, [esi + MAX_NICK_LEN]
|
|
|
|
std
|
|
|
|
rep movsd
|
|
|
|
cld
|
|
|
|
pop edi esi
|
|
|
|
|
|
|
|
; Now insert our new username
|
|
|
|
mov ecx, MAX_NICK_LEN-1
|
|
|
|
.fill:
|
|
|
|
lodsb
|
|
|
|
cmp al, ' '
|
|
|
|
je .done
|
|
|
|
cmp al, '!'
|
|
|
|
je .done
|
2013-11-01 15:02:08 +01:00
|
|
|
cmp al, 13
|
|
|
|
je .done
|
|
|
|
cmp al, 10
|
|
|
|
je .done
|
2024-03-05 10:49:00 +01:00
|
|
|
cmp al, 0
|
|
|
|
je .done
|
2013-05-28 19:34:26 +02:00
|
|
|
stosb
|
|
|
|
loop .fill
|
|
|
|
.done:
|
|
|
|
xor al, al
|
|
|
|
stosb
|
|
|
|
|
|
|
|
inc [ebx + window.users]
|
2013-11-01 15:02:08 +01:00
|
|
|
or [ebx + window.flags], FLAG_UPDATED
|
2024-03-05 10:49:00 +01:00
|
|
|
dec esi
|
2014-03-28 21:03:30 +01:00
|
|
|
.fail:
|
2013-05-28 19:34:26 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-16 12:50:59 +01:00
|
|
|
; TODO: update selected user if needed
|
2013-05-28 19:34:26 +02:00
|
|
|
; esi is ptr to nick
|
|
|
|
; ebx is ptr to window
|
|
|
|
align 4
|
|
|
|
user_remove:
|
|
|
|
|
|
|
|
call user_find
|
2014-03-28 21:03:30 +01:00
|
|
|
jz .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
lea esi, [edi + MAX_NICK_LEN]
|
|
|
|
mov ecx, [ebx + window.data_ptr]
|
|
|
|
add ecx, window_data.names + MAX_NICK_LEN * MAX_USERS
|
|
|
|
sub ecx, esi
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
|
|
|
|
|
|
|
dec [ebx + window.users]
|
2013-11-01 15:02:08 +01:00
|
|
|
or [ebx + window.flags], FLAG_UPDATED
|
2014-03-28 21:03:30 +01:00
|
|
|
.fail:
|
2013-05-28 19:34:26 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; IN:
|
|
|
|
; esi is ptr to nick
|
|
|
|
; ebx is ptr to window
|
|
|
|
; OUT:
|
|
|
|
; edi is ptr to nick in userlist
|
|
|
|
align 4
|
|
|
|
user_find:
|
|
|
|
|
|
|
|
mov eax, [ebx + window.users]
|
|
|
|
test eax, eax
|
2014-03-28 21:03:30 +01:00
|
|
|
jz .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
mov edi, [ebx + window.data_ptr]
|
|
|
|
add edi, window_data.names
|
|
|
|
|
|
|
|
.loop:
|
|
|
|
push esi edi
|
|
|
|
mov ecx, MAX_NICK_LEN
|
|
|
|
repe cmpsb
|
|
|
|
cmp byte[edi-1], 0
|
|
|
|
je .got_it
|
|
|
|
; TODO: check byte[esi] too!
|
|
|
|
pop edi esi
|
|
|
|
add edi, MAX_NICK_LEN
|
|
|
|
dec eax
|
|
|
|
jnz .loop
|
2014-03-28 21:03:30 +01:00
|
|
|
jmp .fail
|
2013-05-28 19:34:26 +02:00
|
|
|
|
|
|
|
.got_it:
|
|
|
|
pop edi esi
|
|
|
|
test edi, edi ; to clear zero flag
|
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
|
|
|
.fail:
|
|
|
|
xor edi, edi
|
2013-05-28 19:34:26 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-28 21:03:30 +01:00
|
|
|
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
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
ret
|