Rev 3545 | Rev 4143 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3981 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License ;; |
||
5 | ;; ;; |
||
6 | ;; ;; |
||
7 | ;; GNU GENERAL PUBLIC LICENSE ;; |
||
8 | ;; Version 2, June 1991 ;; |
||
9 | ;; ;; |
||
10 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3545 | hidnplayr | 11 | |
12 | |||
13 | ; esi is ptr to nick |
||
14 | ; ebx is ptr to window |
||
15 | align 4 |
||
16 | user_add: |
||
17 | |||
18 | cmp [ebx + window.users], MAX_USERS |
||
19 | jae fail |
||
20 | |||
21 | mov edi, [ebx + window.data_ptr] |
||
22 | add edi, window_data.names |
||
23 | mov ebp, [ebx + window.users] |
||
24 | inc ebp ; CHECKME |
||
25 | |||
26 | push esi edi |
||
27 | .restart: |
||
28 | mov ecx, MAX_NICK_LEN |
||
29 | .loop1: |
||
30 | lodsb |
||
31 | cmp al, '@' |
||
32 | jne @f |
||
33 | mov al, ' ' ; give @ highest priority |
||
34 | @@: |
||
35 | cmp al, 'A' |
||
36 | jb @f |
||
37 | cmp al, 'Z' |
||
38 | ja @f |
||
39 | add al, 'a' - 'A' ; convert to lowercase |
||
40 | @@: |
||
41 | dec ecx |
||
42 | jz .got_it |
||
43 | |||
44 | .loop2: |
||
45 | mov dl, [edi] |
||
46 | cmp dl, 0 |
||
47 | je .got_it |
||
48 | cmp dl, '@' |
||
49 | jne @f |
||
50 | mov dl, ' ' ; give @ highest priority |
||
51 | @@: |
||
52 | cmp dl, 'A' |
||
53 | jb @f |
||
54 | cmp dl, 'Z' |
||
55 | ja @f |
||
56 | add dl, 'a' - 'A' ; convert to lowercase |
||
57 | @@: |
||
58 | cmp al, dl |
||
59 | jb .got_it |
||
60 | je .check_next |
||
61 | |||
62 | pop edi esi |
||
63 | add edi, MAX_NICK_LEN |
||
64 | push esi edi |
||
65 | |||
66 | dec ebp |
||
67 | jnz .restart |
||
68 | |||
69 | .check_next: |
||
70 | inc edi |
||
71 | jmp .loop1 |
||
72 | |||
73 | .got_it: |
||
74 | pop edi esi |
||
75 | |||
76 | ; OK, insert it here.. |
||
77 | |||
78 | ; mov all trailing usernames by MAX_NICK_LEN bytes |
||
79 | push esi edi |
||
80 | mov esi, [ebx + window.data_ptr] |
||
81 | add esi, window_data.names + MAX_NICK_LEN * (MAX_USERS - 1) |
||
82 | |||
83 | mov ecx, esi |
||
84 | sub ecx, edi |
||
85 | add ecx, MAX_NICK_LEN |
||
86 | shr ecx, 2 |
||
87 | lea edi, [esi + MAX_NICK_LEN] |
||
88 | std |
||
89 | rep movsd |
||
90 | cld |
||
91 | pop edi esi |
||
92 | |||
93 | ; Now insert our new username |
||
94 | mov ecx, MAX_NICK_LEN-1 |
||
95 | .fill: |
||
96 | lodsb |
||
97 | cmp al, ' ' |
||
98 | je .done |
||
99 | cmp al, '!' |
||
100 | je .done |
||
101 | stosb |
||
102 | loop .fill |
||
103 | .done: |
||
104 | xor al, al |
||
105 | stosb |
||
106 | |||
107 | inc [ebx + window.users] |
||
108 | |||
109 | ret |
||
110 | |||
111 | |||
112 | |||
113 | |||
114 | |||
115 | ; esi is ptr to nick |
||
116 | ; ebx is ptr to window |
||
117 | align 4 |
||
118 | user_remove: |
||
119 | |||
120 | call user_find |
||
121 | jz fail |
||
122 | |||
123 | lea esi, [edi + MAX_NICK_LEN] |
||
124 | mov ecx, [ebx + window.data_ptr] |
||
125 | add ecx, window_data.names + MAX_NICK_LEN * MAX_USERS |
||
126 | sub ecx, esi |
||
127 | shr ecx, 2 |
||
128 | rep movsd |
||
129 | |||
130 | dec [ebx + window.users] |
||
131 | xor eax, eax |
||
132 | |||
133 | ret |
||
134 | |||
135 | |||
136 | |||
137 | ; IN: |
||
138 | ; esi is ptr to nick |
||
139 | ; ebx is ptr to window |
||
140 | ; OUT: |
||
141 | ; edi is ptr to nick in userlist |
||
142 | align 4 |
||
143 | user_find: |
||
144 | |||
145 | mov eax, [ebx + window.users] |
||
146 | test eax, eax |
||
147 | jz fail |
||
148 | mov edi, [ebx + window.data_ptr] |
||
149 | add edi, window_data.names |
||
150 | |||
151 | .loop: |
||
152 | push esi edi |
||
153 | mov ecx, MAX_NICK_LEN |
||
154 | repe cmpsb |
||
155 | cmp byte[edi-1], 0 |
||
156 | je .got_it |
||
157 | ; TODO: check byte[esi] too! |
||
158 | pop edi esi |
||
159 | add edi, MAX_NICK_LEN |
||
160 | dec eax |
||
161 | jnz .loop |
||
162 | jmp fail |
||
163 | |||
164 | .got_it: |
||
165 | pop edi esi |
||
166 | test edi, edi ; to clear zero flag |
||
167 | |||
168 | ret |
||
169 | |||
170 | |||
171 | fail: |
||
172 | |||
173 | xor edi, edi |
||
174 | ret |