Subversion Repositories Kolibri OS

Rev

Rev 3981 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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