Rev 6023 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3981 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
9984 | hidnplayr | 3 | ;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;; |
3981 | hidnplayr | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
4143 | hidnplayr | 6 | ;; Written by hidnplayr@kolibrios.org ;; |
3981 | hidnplayr | 7 | ;; ;; |
8 | ;; GNU GENERAL PUBLIC LICENSE ;; |
||
9 | ;; Version 2, June 1991 ;; |
||
10 | ;; ;; |
||
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3545 | hidnplayr | 12 | |
4143 | hidnplayr | 13 | ; TODO: work correctly with user prefixes. |
14 | ; use first byte of nick for prefix ONLY (use a space for those that do not have special powers..) |
||
3545 | hidnplayr | 15 | |
4143 | hidnplayr | 16 | user_prefixes db '~&@%+ ', 0 ; in descending order |
17 | |||
4659 | hidnplayr | 18 | ; TODO: update selected user if needed |
3545 | hidnplayr | 19 | ; esi is ptr to nick |
20 | ; ebx is ptr to window |
||
21 | align 4 |
||
22 | user_add: |
||
23 | |||
24 | cmp [ebx + window.users], MAX_USERS |
||
4710 | hidnplayr | 25 | jae .fail |
3545 | hidnplayr | 26 | |
9984 | hidnplayr | 27 | ; Check if user is already listed (case insensitive) |
3545 | hidnplayr | 28 | mov edi, [ebx + window.data_ptr] |
29 | add edi, window_data.names |
||
30 | mov ebp, [ebx + window.users] |
||
4143 | hidnplayr | 31 | inc ebp ; CHECKME |
3545 | hidnplayr | 32 | |
33 | push esi edi |
||
34 | .restart: |
||
35 | mov ecx, MAX_NICK_LEN |
||
36 | .loop1: |
||
37 | lodsb |
||
38 | cmp al, '@' |
||
39 | jne @f |
||
40 | mov al, ' ' ; give @ highest priority |
||
41 | @@: |
||
42 | cmp al, 'A' |
||
43 | jb @f |
||
44 | cmp al, 'Z' |
||
45 | ja @f |
||
46 | add al, 'a' - 'A' ; convert to lowercase |
||
47 | @@: |
||
48 | dec ecx |
||
49 | jz .got_it |
||
50 | |||
51 | .loop2: |
||
52 | mov dl, [edi] |
||
53 | cmp dl, 0 |
||
54 | je .got_it |
||
55 | cmp dl, '@' |
||
56 | jne @f |
||
57 | mov dl, ' ' ; give @ highest priority |
||
58 | @@: |
||
59 | cmp dl, 'A' |
||
60 | jb @f |
||
61 | cmp dl, 'Z' |
||
62 | ja @f |
||
63 | add dl, 'a' - 'A' ; convert to lowercase |
||
64 | @@: |
||
65 | cmp al, dl |
||
66 | jb .got_it |
||
67 | je .check_next |
||
68 | |||
69 | pop edi esi |
||
70 | add edi, MAX_NICK_LEN |
||
71 | push esi edi |
||
72 | |||
73 | dec ebp |
||
74 | jnz .restart |
||
75 | |||
76 | .check_next: |
||
77 | inc edi |
||
78 | jmp .loop1 |
||
79 | |||
80 | .got_it: |
||
81 | pop edi esi |
||
82 | |||
83 | ; OK, insert it here.. |
||
84 | |||
85 | ; mov all trailing usernames by MAX_NICK_LEN bytes |
||
86 | push esi edi |
||
87 | mov esi, [ebx + window.data_ptr] |
||
4143 | hidnplayr | 88 | add esi, window_data.names + MAX_NICK_LEN * (MAX_USERS - 1) - 4 ; -4 because we're copying backward, dword wise |
3545 | hidnplayr | 89 | mov ecx, esi |
90 | sub ecx, edi |
||
91 | add ecx, MAX_NICK_LEN |
||
92 | shr ecx, 2 |
||
93 | lea edi, [esi + MAX_NICK_LEN] |
||
94 | std |
||
95 | rep movsd |
||
96 | cld |
||
97 | pop edi esi |
||
98 | |||
99 | ; Now insert our new username |
||
100 | mov ecx, MAX_NICK_LEN-1 |
||
101 | .fill: |
||
102 | lodsb |
||
103 | cmp al, ' ' |
||
104 | je .done |
||
105 | cmp al, '!' |
||
106 | je .done |
||
4143 | hidnplayr | 107 | cmp al, 13 |
108 | je .done |
||
109 | cmp al, 10 |
||
110 | je .done |
||
9984 | hidnplayr | 111 | cmp al, 0 |
112 | je .done |
||
3545 | hidnplayr | 113 | stosb |
114 | loop .fill |
||
115 | .done: |
||
116 | xor al, al |
||
117 | stosb |
||
118 | |||
119 | inc [ebx + window.users] |
||
4143 | hidnplayr | 120 | or [ebx + window.flags], FLAG_UPDATED |
9984 | hidnplayr | 121 | dec esi |
4710 | hidnplayr | 122 | .fail: |
3545 | hidnplayr | 123 | ret |
124 | |||
125 | |||
126 | |||
127 | |||
4659 | hidnplayr | 128 | ; TODO: update selected user if needed |
3545 | hidnplayr | 129 | ; esi is ptr to nick |
130 | ; ebx is ptr to window |
||
131 | align 4 |
||
132 | user_remove: |
||
133 | |||
134 | call user_find |
||
4710 | hidnplayr | 135 | jz .fail |
3545 | hidnplayr | 136 | |
137 | lea esi, [edi + MAX_NICK_LEN] |
||
138 | mov ecx, [ebx + window.data_ptr] |
||
139 | add ecx, window_data.names + MAX_NICK_LEN * MAX_USERS |
||
140 | sub ecx, esi |
||
141 | shr ecx, 2 |
||
142 | rep movsd |
||
143 | |||
144 | dec [ebx + window.users] |
||
4143 | hidnplayr | 145 | or [ebx + window.flags], FLAG_UPDATED |
4710 | hidnplayr | 146 | .fail: |
3545 | hidnplayr | 147 | ret |
148 | |||
149 | |||
150 | |||
151 | ; IN: |
||
152 | ; esi is ptr to nick |
||
153 | ; ebx is ptr to window |
||
154 | ; OUT: |
||
155 | ; edi is ptr to nick in userlist |
||
156 | align 4 |
||
157 | user_find: |
||
158 | |||
159 | mov eax, [ebx + window.users] |
||
160 | test eax, eax |
||
4710 | hidnplayr | 161 | jz .fail |
3545 | hidnplayr | 162 | mov edi, [ebx + window.data_ptr] |
163 | add edi, window_data.names |
||
164 | |||
165 | .loop: |
||
166 | push esi edi |
||
167 | mov ecx, MAX_NICK_LEN |
||
168 | repe cmpsb |
||
169 | cmp byte[edi-1], 0 |
||
170 | je .got_it |
||
171 | ; TODO: check byte[esi] too! |
||
172 | pop edi esi |
||
173 | add edi, MAX_NICK_LEN |
||
174 | dec eax |
||
175 | jnz .loop |
||
4710 | hidnplayr | 176 | jmp .fail |
3545 | hidnplayr | 177 | |
178 | .got_it: |
||
179 | pop edi esi |
||
180 | test edi, edi ; to clear zero flag |
||
4710 | hidnplayr | 181 | ret |
3545 | hidnplayr | 182 | |
4710 | hidnplayr | 183 | .fail: |
184 | xor edi, edi |
||
3545 | hidnplayr | 185 | ret |
186 | |||
187 | |||
188 | |||
4710 | hidnplayr | 189 | user_remove_all: |
190 | |||
191 | xor eax, eax |
||
192 | mov edi, [window_print] |
||
193 | mov [edi + window.users], eax |
||
194 | mov [edi + window.selected], eax |
||
195 | mov edi, [edi + window.data_ptr] |
||
196 | add edi, window_data.names |
||
197 | mov ecx, MAX_NICK_LEN * MAX_USERS / 4 |
||
198 | rep stosd |
||
199 | |||
3545 | hidnplayr | 200 | ret |