Rev 4710 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3981 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
6023 | hidnplayr | 3 | ;; Copyright (C) KolibriOS team 2004-2016. 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 | |
27 | mov edi, [ebx + window.data_ptr] |
||
28 | add edi, window_data.names |
||
29 | mov ebp, [ebx + window.users] |
||
4143 | hidnplayr | 30 | inc ebp ; CHECKME |
3545 | hidnplayr | 31 | |
32 | push esi edi |
||
33 | .restart: |
||
34 | mov ecx, MAX_NICK_LEN |
||
35 | .loop1: |
||
36 | lodsb |
||
37 | cmp al, '@' |
||
38 | jne @f |
||
39 | mov al, ' ' ; give @ highest priority |
||
40 | @@: |
||
41 | cmp al, 'A' |
||
42 | jb @f |
||
43 | cmp al, 'Z' |
||
44 | ja @f |
||
45 | add al, 'a' - 'A' ; convert to lowercase |
||
46 | @@: |
||
47 | dec ecx |
||
48 | jz .got_it |
||
49 | |||
50 | .loop2: |
||
51 | mov dl, [edi] |
||
52 | cmp dl, 0 |
||
53 | je .got_it |
||
54 | cmp dl, '@' |
||
55 | jne @f |
||
56 | mov dl, ' ' ; give @ highest priority |
||
57 | @@: |
||
58 | cmp dl, 'A' |
||
59 | jb @f |
||
60 | cmp dl, 'Z' |
||
61 | ja @f |
||
62 | add dl, 'a' - 'A' ; convert to lowercase |
||
63 | @@: |
||
64 | cmp al, dl |
||
65 | jb .got_it |
||
66 | je .check_next |
||
67 | |||
68 | pop edi esi |
||
69 | add edi, MAX_NICK_LEN |
||
70 | push esi edi |
||
71 | |||
72 | dec ebp |
||
73 | jnz .restart |
||
74 | |||
75 | .check_next: |
||
76 | inc edi |
||
77 | jmp .loop1 |
||
78 | |||
79 | .got_it: |
||
80 | pop edi esi |
||
81 | |||
82 | ; OK, insert it here.. |
||
83 | |||
84 | ; mov all trailing usernames by MAX_NICK_LEN bytes |
||
85 | push esi edi |
||
86 | mov esi, [ebx + window.data_ptr] |
||
4143 | hidnplayr | 87 | add esi, window_data.names + MAX_NICK_LEN * (MAX_USERS - 1) - 4 ; -4 because we're copying backward, dword wise |
3545 | hidnplayr | 88 | mov ecx, esi |
89 | sub ecx, edi |
||
90 | add ecx, MAX_NICK_LEN |
||
91 | shr ecx, 2 |
||
92 | lea edi, [esi + MAX_NICK_LEN] |
||
93 | std |
||
94 | rep movsd |
||
95 | cld |
||
96 | pop edi esi |
||
97 | |||
98 | ; Now insert our new username |
||
99 | mov ecx, MAX_NICK_LEN-1 |
||
100 | .fill: |
||
101 | lodsb |
||
102 | cmp al, ' ' |
||
103 | je .done |
||
104 | cmp al, '!' |
||
105 | je .done |
||
4143 | hidnplayr | 106 | cmp al, 13 |
107 | je .done |
||
108 | cmp al, 10 |
||
109 | je .done |
||
3545 | hidnplayr | 110 | stosb |
111 | loop .fill |
||
112 | .done: |
||
113 | xor al, al |
||
114 | stosb |
||
115 | |||
116 | inc [ebx + window.users] |
||
4143 | hidnplayr | 117 | or [ebx + window.flags], FLAG_UPDATED |
4710 | hidnplayr | 118 | .fail: |
3545 | hidnplayr | 119 | ret |
120 | |||
121 | |||
122 | |||
123 | |||
4659 | hidnplayr | 124 | ; TODO: update selected user if needed |
3545 | hidnplayr | 125 | ; esi is ptr to nick |
126 | ; ebx is ptr to window |
||
127 | align 4 |
||
128 | user_remove: |
||
129 | |||
130 | call user_find |
||
4710 | hidnplayr | 131 | jz .fail |
3545 | hidnplayr | 132 | |
133 | lea esi, [edi + MAX_NICK_LEN] |
||
134 | mov ecx, [ebx + window.data_ptr] |
||
135 | add ecx, window_data.names + MAX_NICK_LEN * MAX_USERS |
||
136 | sub ecx, esi |
||
137 | shr ecx, 2 |
||
138 | rep movsd |
||
139 | |||
140 | dec [ebx + window.users] |
||
4143 | hidnplayr | 141 | or [ebx + window.flags], FLAG_UPDATED |
4710 | hidnplayr | 142 | .fail: |
3545 | hidnplayr | 143 | ret |
144 | |||
145 | |||
146 | |||
147 | ; IN: |
||
148 | ; esi is ptr to nick |
||
149 | ; ebx is ptr to window |
||
150 | ; OUT: |
||
151 | ; edi is ptr to nick in userlist |
||
152 | align 4 |
||
153 | user_find: |
||
154 | |||
155 | mov eax, [ebx + window.users] |
||
156 | test eax, eax |
||
4710 | hidnplayr | 157 | jz .fail |
3545 | hidnplayr | 158 | mov edi, [ebx + window.data_ptr] |
159 | add edi, window_data.names |
||
160 | |||
161 | .loop: |
||
162 | push esi edi |
||
163 | mov ecx, MAX_NICK_LEN |
||
164 | repe cmpsb |
||
165 | cmp byte[edi-1], 0 |
||
166 | je .got_it |
||
167 | ; TODO: check byte[esi] too! |
||
168 | pop edi esi |
||
169 | add edi, MAX_NICK_LEN |
||
170 | dec eax |
||
171 | jnz .loop |
||
4710 | hidnplayr | 172 | jmp .fail |
3545 | hidnplayr | 173 | |
174 | .got_it: |
||
175 | pop edi esi |
||
176 | test edi, edi ; to clear zero flag |
||
4710 | hidnplayr | 177 | ret |
3545 | hidnplayr | 178 | |
4710 | hidnplayr | 179 | .fail: |
180 | xor edi, edi |
||
3545 | hidnplayr | 181 | ret |
182 | |||
183 | |||
184 | |||
4710 | hidnplayr | 185 | user_remove_all: |
186 | |||
187 | xor eax, eax |
||
188 | mov edi, [window_print] |
||
189 | mov [edi + window.users], eax |
||
190 | mov [edi + window.selected], eax |
||
191 | mov edi, [edi + window.data_ptr] |
||
192 | add edi, window_data.names |
||
193 | mov ecx, MAX_NICK_LEN * MAX_USERS / 4 |
||
194 | rep stosd |
||
195 | |||
3545 | hidnplayr | 196 | ret |