Subversion Repositories Kolibri OS

Rev

Rev 6027 | Rev 9092 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3545 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
7300 hidnplayr 3
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved.    ;;
3545 hidnplayr 4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
4143 hidnplayr 6
;;   Written by hidnplayr@kolibrios.org                            ;;
3545 hidnplayr 7
;;                                                                 ;;
8
;;         GNU GENERAL PUBLIC LICENSE                              ;;
9
;;          Version 2, June 1991                                   ;;
10
;;                                                                 ;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
 
13
 
14
server_parser:
15
 
16
        mov     esi, servercommand
17
 
18
        cmp     byte [esi], ':'
19
        jne     .parse
20
 
21
  .spaceloop:
22
        lodsb
23
        test    al, al
24
        jz      .fail
25
        cmp     al, ' '
26
        jne     .spaceloop
27
 
28
  .parse:
29
        mov     eax, [esi]
30
        or      eax, 0x20202020
31
        mov     edi, server_commands
32
        mov     ecx, server_commands.number
33
 
34
  .loop:
35
        scasd
36
        je      .got_cmd
37
        add     edi, 4
38
        dec     ecx
39
        jnz     .loop
40
 
41
  .fail:
42
        ret
43
 
44
  .got_cmd:
45
        jmp     dword[edi]
46
 
47
 
48
server_commands:
49
 
6027 hidnplayr 50
        dd      '001 ', cmd_welcome
4622 hidnplayr 51
        dd      '002 ', cmd_justprint
52
        dd      '003 ', cmd_justprint
53
        dd      '004 ', cmd_justprint
54
        dd      '005 ', cmd_justprint
55
 
56
        dd      '250 ', cmd_justprint
57
        dd      '251 ', cmd_justprint
58
        dd      '252 ', cmd_justprint
59
        dd      '253 ', cmd_justprint
60
        dd      '254 ', cmd_justprint
61
        dd      '255 ', cmd_justprint
62
 
63
        dd      '265 ', cmd_justprint
64
        dd      '266 ', cmd_justprint
65
 
5411 hidnplayr 66
        dd      '311 ', cmd_justprint   ; RPL_WHOISUSER
67
        dd      '312 ', cmd_justprint   ; RPL_WHOISSERVER
68
        dd      '318 ', cmd_justprint   ; RPL_ENDOFWHOIS
3545 hidnplayr 69
        dd      '322 ', cmd_322         ; RPL_LIST
70
        dd      '323 ', cmd_323         ; RPL_LISTEND
5411 hidnplayr 71
        dd      '324 ', cmd_justprint   ; RPL_CHANNELMODEIS
4622 hidnplayr 72
        dd      '328 ', cmd_justprint   ; RPL_CHANNEL_URL
5411 hidnplayr 73
        dd      '329 ', cmd_justprint   ; RPL_CREATIONTIME
74
        dd      '330 ', cmd_justprint
75
        dd      '332 ', cmd_topic       ; topic
3545 hidnplayr 76
        dd      '333 ', cmd_333         ; nickname and time of topic
77
        dd      '353 ', cmd_353         ; name reply
78
        dd      '366 ', cmd_366         ; end of names list
4622 hidnplayr 79
        dd      '372 ', cmd_justprint   ; motd
80
        dd      '375 ', cmd_justprint   ; start of motd
81
        dd      '376 ', cmd_justprint   ; end of motd
82
        dd      '421 ', cmd_justprint   ; unknown command
6027 hidnplayr 83
        dd      '432 ', cmd_justprint   ; erroneous nickname
4622 hidnplayr 84
        dd      '433 ', cmd_justprint   ; nickname already in use
6027 hidnplayr 85
        dd      '436 ', cmd_justprint   ; nickname collision
4622 hidnplayr 86
 
3545 hidnplayr 87
        dd      'join', cmd_join
88
        dd      'kick', cmd_kick
89
        dd      'mode', cmd_mode
90
        dd      'nick', cmd_nick
91
        dd      'part', cmd_part
92
        dd      'ping', cmd_ping
93
        dd      'priv', cmd_privmsg
94
        dd      'quit', cmd_quit
95
        dd      'noti', cmd_notice
96
 
97
        .number = ($ - server_commands) / 8
98
 
99
 
100
align 4
101
compare_to_nick:
102
 
103
        push    esi
104
        mov     ecx, MAX_NICK_LEN
105
        mov     esi, user_nick
106
  .loop:
107
        lodsb
108
        cmp     al, ' '
109
        jbe     .done
4477 hidnplayr 110
        test    al, al
111
        jz      .done
3545 hidnplayr 112
        cmp     al, 'a'
113
        jb      .ok
114
        cmp     al, 'z'
115
        ja      .ok
116
        sub     al, 0x20
117
  .ok:
118
 
119
        mov     bl, byte[edi]
120
        cmp     bl, 'a'
121
        jb      .ok2
122
        cmp     bl, 'z'
123
        ja      .ok2
124
        sub     bl, 0x20
125
  .ok2:
126
        cmp     bl, al
127
        jne     .not_equal
128
        inc     edi
129
        dec     ecx
130
        jnz     .loop
131
 
132
  .done:
133
        xor     eax, eax
134
        pop     esi
135
        ret
136
 
137
  .not_equal:
138
        or      eax, -1
139
        pop     esi
140
        ret
141
 
4143 hidnplayr 142
 
143
 
3545 hidnplayr 144
align 4
4477 hidnplayr 145
skip_parameter:
3545 hidnplayr 146
 
4595 hidnplayr 147
; First: skip the parameter (scan untill space or colon)
4477 hidnplayr 148
  .part1:
3545 hidnplayr 149
        lodsb
150
        cmp     al, ' '
4477 hidnplayr 151
        je      .part2
3545 hidnplayr 152
        cmp     al, ':'
4477 hidnplayr 153
        jne     .part1
3545 hidnplayr 154
 
4595 hidnplayr 155
; Skip all trailing spaces
156
  .part3:
157
        lodsb
158
        cmp     al, ' '
159
        je      .part3
160
        dec     esi
161
        ret
162
 
163
; Now, skip all trailing spaces and first semicolon
4477 hidnplayr 164
  .part2:
3545 hidnplayr 165
        lodsb
166
        cmp     al, ' '
4477 hidnplayr 167
        je      .part2
3545 hidnplayr 168
        cmp     al, ':'
4595 hidnplayr 169
        je      .part3
3545 hidnplayr 170
        dec     esi
171
        ret
172
 
173
 
174
 
6027 hidnplayr 175
cmd_welcome:
4595 hidnplayr 176
 
6027 hidnplayr 177
        mov     [status], STATUS_LOGGED_IN
4595 hidnplayr 178
 
4622 hidnplayr 179
cmd_justprint:
180
 
3545 hidnplayr 181
        add     esi, 4
4623 hidnplayr 182
        call    skip_parameter          ; our nickname
3545 hidnplayr 183
 
4623 hidnplayr 184
        call    print_asciiz
185
 
186
        mov     al, 10
187
        call    print_char
188
 
4622 hidnplayr 189
        ret
190
 
191
 
6027 hidnplayr 192
 
3545 hidnplayr 193
cmd_notice:
194
 
4622 hidnplayr 195
        if TIMESTAMP
196
        call    print_timestamp
197
        end if
198
 
3545 hidnplayr 199
        cmp     byte[servercommand], ':'
200
        jne     .gogogo
201
 
202
        mov     byte [esi-1], 0
203
        push    esi
204
        mov     esi, str_1
4623 hidnplayr 205
        call    print_asciiz
206
        mov     esi, servercommand+1
207
        mov     bl, '!'
208
        call    print_string
3545 hidnplayr 209
        mov     esi, str_2
4623 hidnplayr 210
        call    print_asciiz
3545 hidnplayr 211
        pop     esi
212
 
213
  .gogogo:
214
        add     esi, 6
4622 hidnplayr 215
        call    skip_parameter
216
        call    skip_parameter
4623 hidnplayr 217
        call    print_asciiz
3545 hidnplayr 218
 
4623 hidnplayr 219
        mov     al, 10
220
        call    print_char
3545 hidnplayr 221