Rev 4659 | Rev 5411 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3545 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
4477 | hidnplayr | 3 | ;; Copyright (C) KolibriOS team 2004-2014. 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 | |||
4622 | hidnplayr | 50 | dd '001 ', cmd_justprint |
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 | |||
3545 | hidnplayr | 66 | dd '322 ', cmd_322 ; RPL_LIST |
67 | dd '323 ', cmd_323 ; RPL_LISTEND |
||
4622 | hidnplayr | 68 | dd '324 ', cmd_justprint |
69 | dd '328 ', cmd_justprint ; RPL_CHANNEL_URL |
||
70 | dd '329 ', cmd_justprint |
||
3545 | hidnplayr | 71 | dd '332 ', cmd_topic |
72 | dd '333 ', cmd_333 ; nickname and time of topic |
||
73 | dd '353 ', cmd_353 ; name reply |
||
74 | dd '366 ', cmd_366 ; end of names list |
||
4622 | hidnplayr | 75 | dd '372 ', cmd_justprint ; motd |
76 | dd '375 ', cmd_justprint ; start of motd |
||
77 | dd '376 ', cmd_justprint ; end of motd |
||
78 | dd '421 ', cmd_justprint ; unknown command |
||
79 | dd '433 ', cmd_justprint ; nickname already in use |
||
80 | |||
3545 | hidnplayr | 81 | dd 'join', cmd_join |
82 | dd 'kick', cmd_kick |
||
83 | dd 'mode', cmd_mode |
||
84 | dd 'nick', cmd_nick |
||
85 | dd 'part', cmd_part |
||
86 | dd 'ping', cmd_ping |
||
87 | dd 'priv', cmd_privmsg |
||
88 | dd 'quit', cmd_quit |
||
89 | dd 'noti', cmd_notice |
||
90 | |||
91 | .number = ($ - server_commands) / 8 |
||
92 | |||
93 | |||
94 | align 4 |
||
95 | compare_to_nick: |
||
96 | |||
97 | push esi |
||
98 | mov ecx, MAX_NICK_LEN |
||
99 | mov esi, user_nick |
||
100 | .loop: |
||
101 | lodsb |
||
102 | cmp al, ' ' |
||
103 | jbe .done |
||
4477 | hidnplayr | 104 | test al, al |
105 | jz .done |
||
3545 | hidnplayr | 106 | cmp al, 'a' |
107 | jb .ok |
||
108 | cmp al, 'z' |
||
109 | ja .ok |
||
110 | sub al, 0x20 |
||
111 | .ok: |
||
112 | |||
113 | mov bl, byte[edi] |
||
114 | cmp bl, 'a' |
||
115 | jb .ok2 |
||
116 | cmp bl, 'z' |
||
117 | ja .ok2 |
||
118 | sub bl, 0x20 |
||
119 | .ok2: |
||
120 | cmp bl, al |
||
121 | jne .not_equal |
||
122 | inc edi |
||
123 | dec ecx |
||
124 | jnz .loop |
||
125 | |||
126 | .done: |
||
127 | xor eax, eax |
||
128 | pop esi |
||
129 | ret |
||
130 | |||
131 | .not_equal: |
||
132 | or eax, -1 |
||
133 | pop esi |
||
134 | ret |
||
135 | |||
4143 | hidnplayr | 136 | |
137 | |||
3545 | hidnplayr | 138 | align 4 |
4477 | hidnplayr | 139 | skip_parameter: |
3545 | hidnplayr | 140 | |
4595 | hidnplayr | 141 | ; First: skip the parameter (scan untill space or colon) |
4477 | hidnplayr | 142 | .part1: |
3545 | hidnplayr | 143 | lodsb |
144 | cmp al, ' ' |
||
4477 | hidnplayr | 145 | je .part2 |
3545 | hidnplayr | 146 | cmp al, ':' |
4477 | hidnplayr | 147 | jne .part1 |
3545 | hidnplayr | 148 | |
4595 | hidnplayr | 149 | ; Skip all trailing spaces |
150 | .part3: |
||
151 | lodsb |
||
152 | cmp al, ' ' |
||
153 | je .part3 |
||
154 | dec esi |
||
155 | ret |
||
156 | |||
157 | ; Now, skip all trailing spaces and first semicolon |
||
4477 | hidnplayr | 158 | .part2: |
3545 | hidnplayr | 159 | lodsb |
160 | cmp al, ' ' |
||
4477 | hidnplayr | 161 | je .part2 |
3545 | hidnplayr | 162 | cmp al, ':' |
4595 | hidnplayr | 163 | je .part3 |
3545 | hidnplayr | 164 | dec esi |
165 | ret |
||
166 | |||
167 | |||
168 | |||
4595 | hidnplayr | 169 | |
170 | |||
4622 | hidnplayr | 171 | cmd_justprint: |
172 | |||
3545 | hidnplayr | 173 | add esi, 4 |
4623 | hidnplayr | 174 | call skip_parameter ; our nickname |
3545 | hidnplayr | 175 | |
4623 | hidnplayr | 176 | call print_asciiz |
177 | |||
178 | mov al, 10 |
||
179 | call print_char |
||
180 | |||
4622 | hidnplayr | 181 | ret |
182 | |||
183 | |||
3545 | hidnplayr | 184 | cmd_notice: |
185 | |||
4622 | hidnplayr | 186 | if TIMESTAMP |
187 | call print_timestamp |
||
188 | end if |
||
189 | |||
3545 | hidnplayr | 190 | cmp byte[servercommand], ':' |
191 | jne .gogogo |
||
192 | |||
193 | mov byte [esi-1], 0 |
||
194 | push esi |
||
195 | mov esi, str_1 |
||
4623 | hidnplayr | 196 | call print_asciiz |
197 | mov esi, servercommand+1 |
||
198 | mov bl, '!' |
||
199 | call print_string |
||
3545 | hidnplayr | 200 | mov esi, str_2 |
4623 | hidnplayr | 201 | call print_asciiz |
3545 | hidnplayr | 202 | pop esi |
203 | |||
204 | .gogogo: |
||
205 | add esi, 6 |
||
4622 | hidnplayr | 206 | call skip_parameter |
207 | call skip_parameter |
||
4623 | hidnplayr | 208 | call print_asciiz |
3545 | hidnplayr | 209 | |
4623 | hidnplayr | 210 | mov al, 10 |
211 | call print_char |
||
3545 | hidnplayr | 212 | |
213 | ret |
||
214 | |||
215 | |||
216 | |||
217 | cmd_ping: |
||
218 | |||
219 | ; Just change PING to PONG |
||
220 | mov dword[esi], 'PONG' |
||
221 | |||
222 | ; Find the end of the command |
||
223 | lea edi, [esi + 5] |
||
224 | xor al, al |
||
225 | repne scasb |
||
226 | |||
227 | ; Now send it back |
||
228 | mov edx, esi |
||
229 | mov esi, edi |
||
230 | mov word [esi], 0x0d0a |
||
231 | inc esi |
||
232 | inc esi |
||
233 | sub esi, edx |
||
234 | mcall send, [socketnum], , , 0 |
||
235 | |||
236 | ret |
||
237 | |||
238 | |||
239 | |||
240 | cmd_privmsg: |
||
241 | |||
4143 | hidnplayr | 242 | mov eax, dword[esi+4] |
243 | or eax, 0x20202020 |
||
244 | cmp eax, 'msg ' |
||
245 | jne .fail |
||
3545 | hidnplayr | 246 | add esi, 8 ; skip 'PRIVMSG ' |
247 | |||
4477 | hidnplayr | 248 | mov edi, esi |
249 | call compare_to_nick |
||
250 | jne .channel |
||
251 | |||
252 | ; private chat message |
||
253 | push esi |
||
254 | mov esi, servercommand+1 |
||
255 | call window_open |
||
4623 | hidnplayr | 256 | test ebx, ebx |
257 | jz .fail2 |
||
4477 | hidnplayr | 258 | pop esi |
259 | call skip_parameter ; our own nickname |
||
260 | jmp .print |
||
261 | |||
262 | .channel: |
||
263 | call window_open |
||
4623 | hidnplayr | 264 | test ebx, ebx |
265 | jz .fail |
||
4477 | hidnplayr | 266 | |
267 | .print: |
||
4659 | hidnplayr | 268 | cmp byte[esi], 1 ; Client to Client protocol? |
269 | je cmd_ctcp |
||
270 | |||
4143 | hidnplayr | 271 | if TIMESTAMP |
3545 | hidnplayr | 272 | call print_timestamp |
4143 | hidnplayr | 273 | end if |
3545 | hidnplayr | 274 | |
275 | push esi |
||
4623 | hidnplayr | 276 | mov al, '<' |
277 | call print_char |
||
3545 | hidnplayr | 278 | |
4623 | hidnplayr | 279 | mov esi, servercommand+1 |
280 | mov bl, '!' |
||
281 | call print_string |
||
3545 | hidnplayr | 282 | |
4623 | hidnplayr | 283 | mov al, '>' |
284 | call print_char |
||
3545 | hidnplayr | 285 | |
4623 | hidnplayr | 286 | mov al, ' ' |
287 | call print_char |
||
3545 | hidnplayr | 288 | |
289 | pop esi |
||
4623 | hidnplayr | 290 | call print_asciiz |
3545 | hidnplayr | 291 | |
4623 | hidnplayr | 292 | mov al, 10 |
293 | call print_char |
||
3545 | hidnplayr | 294 | |
4623 | hidnplayr | 295 | ret |
296 | |||
297 | .fail2: |
||
298 | pop esi |
||
3545 | hidnplayr | 299 | .fail: |
300 | ret |
||
301 | |||
302 | |||
303 | |||
304 | |||
4143 | hidnplayr | 305 | cmd_ctcp: |
3545 | hidnplayr | 306 | |
307 | inc esi |
||
4143 | hidnplayr | 308 | mov eax, dword[esi] |
309 | or eax, 0x20202020 |
||
3545 | hidnplayr | 310 | |
4143 | hidnplayr | 311 | cmp eax, 'vers' |
3545 | hidnplayr | 312 | je .version |
4143 | hidnplayr | 313 | cmp eax, 'time' |
3545 | hidnplayr | 314 | je .time |
4143 | hidnplayr | 315 | cmp eax, 'ping' |
3545 | hidnplayr | 316 | je .ping |
4143 | hidnplayr | 317 | cmp eax, 'acti' |
318 | je .action |
||
4477 | hidnplayr | 319 | cmp eax, 'dcc ' ; TODO |
320 | je cmd_dcc |
||
3545 | hidnplayr | 321 | |
4143 | hidnplayr | 322 | ; Unknown CTCP command: TODO: just print to window?? |
323 | |||
324 | .fail: |
||
325 | |||
3545 | hidnplayr | 326 | ret |
327 | |||
328 | .time: |
||
4143 | hidnplayr | 329 | mov byte[esi+4], ' ' |
3545 | hidnplayr | 330 | lea edi, [esi+5] |
331 | |||
332 | ; TODO: add system date (fn 29) in human readable format |
||
333 | |||
334 | mcall 3 ; get system time |
||
335 | |||
336 | mov ecx, 3 |
||
337 | .timeloop: |
||
338 | mov bl, al |
||
339 | shr al, 4 |
||
340 | add al, '0' |
||
341 | stosb |
||
342 | |||
343 | mov al, bl |
||
344 | and al, 0x0f |
||
345 | add al, '0' |
||
346 | stosb |
||
347 | |||
348 | dec ecx |
||
349 | jz .timedone |
||
350 | |||
351 | mov al, ':' |
||
352 | stosb |
||
353 | shr eax, 8 |
||
354 | jmp .timeloop |
||
355 | |||
356 | .timedone: |
||
357 | xor al, al |
||
358 | stosb |
||
359 | call ctcp_reply |
||
360 | |||
361 | if TIMESTAMP |
||
362 | call print_timestamp |
||
363 | end if |
||
364 | |||
365 | mov esi, ctcp_header |
||
4623 | hidnplayr | 366 | call print_asciiz |
3545 | hidnplayr | 367 | |
368 | mov esi, servercommand+1 |
||
4623 | hidnplayr | 369 | call print_asciiz |
3545 | hidnplayr | 370 | |
371 | mov esi, ctcp_time |
||
4623 | hidnplayr | 372 | call print_asciiz |
3545 | hidnplayr | 373 | |
374 | ret |
||
375 | |||
376 | .version: |
||
377 | mov esi, str_version |
||
378 | call ctcp_reply |
||
379 | |||
380 | if TIMESTAMP |
||
381 | call print_timestamp |
||
382 | end if |
||
383 | |||
384 | mov esi, ctcp_header |
||
4623 | hidnplayr | 385 | call print_asciiz |
3545 | hidnplayr | 386 | |
387 | mov esi, servercommand+1 |
||
4623 | hidnplayr | 388 | call print_asciiz |
3545 | hidnplayr | 389 | |
390 | mov esi, ctcp_version |
||
4623 | hidnplayr | 391 | call print_asciiz |
3545 | hidnplayr | 392 | |
393 | ret |
||
394 | |||
395 | .ping: |
||
396 | call ctcp_reply |
||
397 | |||
398 | if TIMESTAMP |
||
399 | call print_timestamp |
||
400 | end if |
||
401 | |||
402 | mov esi, ctcp_header |
||
4623 | hidnplayr | 403 | call print_asciiz |
3545 | hidnplayr | 404 | |
405 | mov esi, servercommand+1 |
||
4623 | hidnplayr | 406 | call print_asciiz |
3545 | hidnplayr | 407 | |
408 | mov esi, ctcp_ping |
||
4623 | hidnplayr | 409 | call print_asciiz |
3545 | hidnplayr | 410 | |
411 | ret |
||
412 | |||
4143 | hidnplayr | 413 | .action: |
414 | add esi, 7 |
||
415 | push esi |
||
3545 | hidnplayr | 416 | |
4143 | hidnplayr | 417 | if TIMESTAMP |
418 | call print_timestamp |
||
419 | end if |
||
3545 | hidnplayr | 420 | |
4143 | hidnplayr | 421 | mov esi, action_header |
4623 | hidnplayr | 422 | call print_asciiz |
4143 | hidnplayr | 423 | |
4623 | hidnplayr | 424 | mov esi, servercommand+1 ; print nickname |
425 | mov bl, '!' |
||
426 | call print_string |
||
4143 | hidnplayr | 427 | |
4623 | hidnplayr | 428 | mov al, ' ' |
429 | call print_char |
||
4143 | hidnplayr | 430 | |
431 | pop esi |
||
4623 | hidnplayr | 432 | call print_asciiz |
4143 | hidnplayr | 433 | |
4623 | hidnplayr | 434 | mov al, 10 |
435 | call print_char |
||
4143 | hidnplayr | 436 | |
437 | ret |
||
438 | |||
439 | |||
440 | cmd_dcc: |
||
441 | add esi, 4 |
||
442 | mov eax, dword[esi] |
||
443 | or eax, 0x202020 |
||
444 | |||
445 | cmp eax, 'send' |
||
446 | je .send |
||
447 | |||
448 | ret |
||
449 | |||
450 | .send: |
||
4477 | hidnplayr | 451 | call window_open |
4623 | hidnplayr | 452 | test ebx, ebx |
453 | jz .fail |
||
4477 | hidnplayr | 454 | mov [ebx + window.type], WINDOWTYPE_DCC |
455 | |||
4623 | hidnplayr | 456 | .fail: |
457 | |||
4143 | hidnplayr | 458 | ret |
459 | |||
460 | |||
461 | |||
3545 | hidnplayr | 462 | ctcp_reply: |
463 | |||
464 | push esi |
||
465 | mov dword [usercommand], 'NOTI' |
||
466 | mov dword [usercommand+4], 'CE ' |
||
467 | |||
468 | mov esi, servercommand+1 |
||
469 | mov edi, usercommand+7 |
||
470 | .nickloop: |
||
471 | lodsb |
||
472 | cmp al, '!' |
||
473 | je .done |
||
474 | cmp al, ' ' |
||
475 | je .done |
||
476 | test al, al |
||
477 | je .fail |
||
478 | stosb |
||
479 | jmp .nickloop |
||
480 | .done: |
||
481 | mov byte [esi-1], 0 |
||
482 | mov ax, ' :' |
||
483 | stosw |
||
484 | mov al, 1 |
||
485 | stosb |
||
486 | |||
487 | pop esi |
||
488 | .replyloop: |
||
489 | lodsb |
||
490 | cmp al, 1 |
||
491 | jbe .done2 |
||
492 | stosb |
||
493 | jmp .replyloop |
||
494 | .done2: |
||
495 | |||
496 | mov al, 1 |
||
497 | stosb |
||
498 | mov ax, 0x0a0d |
||
499 | stosw |
||
500 | |||
501 | lea esi, [edi - usercommand] |
||
502 | mcall send, [socketnum], usercommand, , 0 |
||
503 | .fail: |
||
504 | ret |
||
505 | |||
506 | |||
507 | |||
508 | cmd_part: |
||
4143 | hidnplayr | 509 | |
510 | cmp byte [esi+4], ' ' |
||
511 | jne .fail |
||
3545 | hidnplayr | 512 | add esi, 5 ; skip 'PART ' |
513 | |||
514 | ; Is it me who parted? |
||
515 | mov edi, servercommand+1 |
||
516 | call compare_to_nick |
||
4477 | hidnplayr | 517 | jne .not_me |
3545 | hidnplayr | 518 | |
4143 | hidnplayr | 519 | ; yes, close the window (if its open) |
520 | call window_find |
||
521 | test ebx, ebx |
||
522 | jz @f |
||
523 | call window_close |
||
524 | @@: |
||
525 | .fail: |
||
3545 | hidnplayr | 526 | |
527 | ret |
||
528 | |||
4143 | hidnplayr | 529 | |
3545 | hidnplayr | 530 | ; somebody else parted, just print message |
4477 | hidnplayr | 531 | .not_me: |
3545 | hidnplayr | 532 | push esi |
4143 | hidnplayr | 533 | call window_open |
4623 | hidnplayr | 534 | test ebx, ebx |
535 | jz .fail2 |
||
4143 | hidnplayr | 536 | |
4477 | hidnplayr | 537 | if TIMESTAMP |
538 | call print_timestamp |
||
539 | end if |
||
540 | |||
4143 | hidnplayr | 541 | mov esi, part_header |
4623 | hidnplayr | 542 | call print_asciiz |
3545 | hidnplayr | 543 | |
4623 | hidnplayr | 544 | mov esi, servercommand+1 |
545 | mov bl, '!' |
||
546 | call print_string |
||
3545 | hidnplayr | 547 | |
548 | mov esi, has_left_channel |
||
4623 | hidnplayr | 549 | call print_asciiz |
3545 | hidnplayr | 550 | |
551 | pop esi |
||
4623 | hidnplayr | 552 | call print_asciiz |
3545 | hidnplayr | 553 | |
4623 | hidnplayr | 554 | mov al, 10 |
555 | call print_char |
||
3545 | hidnplayr | 556 | |
557 | mov ebx, [window_print] |
||
558 | mov esi, servercommand+1 |
||
559 | call user_remove |
||
560 | |||
561 | ret |
||
562 | |||
4623 | hidnplayr | 563 | .fail2: |
564 | pop esi |
||
3545 | hidnplayr | 565 | |
4623 | hidnplayr | 566 | ret |
3545 | hidnplayr | 567 | |
4623 | hidnplayr | 568 | |
569 | |||
3545 | hidnplayr | 570 | cmd_join: |
4143 | hidnplayr | 571 | |
4477 | hidnplayr | 572 | cmp byte[esi+4], ' ' |
4143 | hidnplayr | 573 | jne .fail |
3545 | hidnplayr | 574 | add esi, 5 ; skip 'JOIN ' |
575 | |||
4623 | hidnplayr | 576 | ; did we join a channel? |
3545 | hidnplayr | 577 | mov edi, servercommand+1 |
578 | call compare_to_nick |
||
4477 | hidnplayr | 579 | jne .not_me |
3545 | hidnplayr | 580 | |
4477 | hidnplayr | 581 | push esi |
582 | call window_open |
||
4623 | hidnplayr | 583 | test ebx, ebx |
3545 | hidnplayr | 584 | jz .fail |
585 | mov [ebx + window.type], WINDOWTYPE_CHANNEL |
||
3981 | hidnplayr | 586 | mov [window_active], ebx |
3545 | hidnplayr | 587 | |
4143 | hidnplayr | 588 | if TIMESTAMP |
589 | call print_timestamp |
||
590 | end if |
||
591 | |||
592 | mov esi, join_header |
||
4623 | hidnplayr | 593 | call print_asciiz |
3545 | hidnplayr | 594 | |
595 | mov esi, str_talking |
||
4623 | hidnplayr | 596 | call print_asciiz |
3545 | hidnplayr | 597 | |
4623 | hidnplayr | 598 | pop esi |
599 | mov bl, ' ' |
||
600 | call print_string |
||
3545 | hidnplayr | 601 | |
4623 | hidnplayr | 602 | mov al, 10 |
603 | call print_char |
||
3545 | hidnplayr | 604 | |
605 | call draw_window |
||
606 | |||
607 | ret |
||
608 | |||
4477 | hidnplayr | 609 | .not_me: |
3545 | hidnplayr | 610 | push esi |
3981 | hidnplayr | 611 | call window_open |
4623 | hidnplayr | 612 | test ebx, ebx |
613 | jz .fail |
||
3545 | hidnplayr | 614 | |
4143 | hidnplayr | 615 | if TIMESTAMP |
616 | call print_timestamp |
||
617 | end if |
||
618 | |||
619 | mov esi, join_header |
||
4623 | hidnplayr | 620 | call print_asciiz |
3545 | hidnplayr | 621 | |
4623 | hidnplayr | 622 | mov esi, servercommand+1 |
623 | mov bl, '!' |
||
624 | call print_string |
||
3545 | hidnplayr | 625 | |
626 | mov esi, joins_channel |
||
4623 | hidnplayr | 627 | call print_asciiz |
3545 | hidnplayr | 628 | |
629 | pop esi |
||
4623 | hidnplayr | 630 | call print_asciiz |
3545 | hidnplayr | 631 | |
4623 | hidnplayr | 632 | mov al, 10 |
633 | call print_char |
||
3545 | hidnplayr | 634 | |
635 | mov ebx, [window_print] |
||
636 | mov esi, servercommand+1 |
||
637 | call user_add |
||
638 | |||
4477 | hidnplayr | 639 | ret |
640 | |||
4143 | hidnplayr | 641 | .fail: |
4623 | hidnplayr | 642 | pop esi |
3545 | hidnplayr | 643 | ret |
644 | |||
645 | |||
646 | |||
647 | |||
648 | cmd_nick: |
||
649 | |||
4143 | hidnplayr | 650 | cmp byte[esi+4], ' ' |
651 | jne .fail |
||
652 | add esi, 5 ; skip 'NICK ' |
||
653 | cmp byte[esi], ':' |
||
3545 | hidnplayr | 654 | jne @f |
655 | inc esi |
||
4143 | hidnplayr | 656 | @@: |
3545 | hidnplayr | 657 | |
4143 | hidnplayr | 658 | ; Is it me who changed nick? |
3545 | hidnplayr | 659 | push esi |
660 | mov edi, servercommand+1 |
||
661 | call compare_to_nick |
||
662 | jne .not_me |
||
663 | |||
4617 | hidnplayr | 664 | ; Yup, update user_nick |
3545 | hidnplayr | 665 | mov ecx, MAX_NICK_LEN-1 |
4143 | hidnplayr | 666 | mov esi, [esp] |
4617 | hidnplayr | 667 | mov edi, user_nick |
4143 | hidnplayr | 668 | @@: |
3545 | hidnplayr | 669 | lodsb |
670 | test al, al |
||
4143 | hidnplayr | 671 | jz @f |
3545 | hidnplayr | 672 | cmp al, ' ' |
4143 | hidnplayr | 673 | je @f |
674 | cmp al, 10 |
||
675 | je @f |
||
676 | cmp al, 13 |
||
677 | je @f |
||
4617 | hidnplayr | 678 | cmp al, ':' |
679 | je @r |
||
3545 | hidnplayr | 680 | stosb |
681 | dec ecx |
||
4143 | hidnplayr | 682 | jnz @r |
683 | @@: |
||
3545 | hidnplayr | 684 | xor al, al |
685 | stosb |
||
4982 | hidnplayr | 686 | |
687 | ; Print a message on the server window |
||
688 | mov [window_print], windows |
||
689 | |||
690 | mov esi, str_nickchange |
||
691 | call print_asciiz |
||
692 | |||
693 | mov esi, user_nick |
||
694 | call print_asciiz |
||
695 | |||
696 | mov al, 10 |
||
697 | call print_char |
||
698 | |||
3545 | hidnplayr | 699 | .not_me: |
700 | |||
4617 | hidnplayr | 701 | ; Update in userlist |
4143 | hidnplayr | 702 | mov ebx, windows |
703 | mov ecx, MAX_WINDOWS |
||
704 | .window_loop: |
||
705 | push ecx ebx |
||
706 | cmp [ebx + window.type], WINDOWTYPE_CHANNEL |
||
707 | jne .next_window |
||
708 | |||
709 | mov esi, servercommand+1 |
||
710 | call user_remove |
||
711 | test edi, edi |
||
712 | jz .next_window |
||
713 | |||
714 | mov esi, [esp + 8] |
||
715 | call user_add |
||
716 | |||
4617 | hidnplayr | 717 | ; And print a notification in the channel |
4143 | hidnplayr | 718 | mov [window_print], ebx |
719 | |||
720 | if TIMESTAMP |
||
721 | call print_timestamp |
||
722 | end if |
||
723 | |||
724 | mov esi, nick_header |
||
4623 | hidnplayr | 725 | call print_asciiz |
3545 | hidnplayr | 726 | |
4623 | hidnplayr | 727 | mov esi, servercommand+1 |
728 | mov bl, '!' |
||
729 | call print_string |
||
3545 | hidnplayr | 730 | |
731 | mov esi, is_now_known_as |
||
4623 | hidnplayr | 732 | call print_asciiz |
3545 | hidnplayr | 733 | |
4623 | hidnplayr | 734 | mov esi, [esp + 8] |
735 | call print_asciiz |
||
3545 | hidnplayr | 736 | |
4623 | hidnplayr | 737 | mov al, 10 |
738 | call print_char |
||
3545 | hidnplayr | 739 | |
4617 | hidnplayr | 740 | ; Now do this for all open windows |
4143 | hidnplayr | 741 | .next_window: |
742 | pop ebx ecx |
||
743 | add ebx, sizeof.window |
||
744 | dec ecx |
||
745 | jnz .window_loop |
||
746 | |||
747 | pop esi |
||
748 | |||
749 | .fail: |
||
750 | |||
3545 | hidnplayr | 751 | ret |
752 | |||
753 | |||
754 | |||
755 | |||
756 | cmd_kick: |
||
4143 | hidnplayr | 757 | |
758 | cmp byte [esi+4], ' ' |
||
759 | jne .fail |
||
3545 | hidnplayr | 760 | add esi, 5 ; skip 'KICK ' |
761 | |||
4595 | hidnplayr | 762 | ; TODO: Is it me who got kicked? |
763 | ; if so, mark channel as disconnected |
||
3545 | hidnplayr | 764 | |
765 | .not_me: |
||
766 | ; find the channel user has been kicked from |
||
767 | push esi |
||
3981 | hidnplayr | 768 | call window_open |
4623 | hidnplayr | 769 | test ebx, ebx |
770 | jz .fail |
||
4595 | hidnplayr | 771 | push esi |
3545 | hidnplayr | 772 | |
4143 | hidnplayr | 773 | if TIMESTAMP |
774 | call print_timestamp |
||
775 | end if |
||
776 | |||
777 | mov esi, kick_header |
||
4623 | hidnplayr | 778 | call print_asciiz |
3545 | hidnplayr | 779 | |
4623 | hidnplayr | 780 | pop esi |
781 | mov bl, ' ' |
||
782 | call print_string |
||
3545 | hidnplayr | 783 | |
4595 | hidnplayr | 784 | mov esi, str_kicked |
4623 | hidnplayr | 785 | call print_asciiz |
3545 | hidnplayr | 786 | |
4623 | hidnplayr | 787 | pop esi |
788 | mov bl, ' ' |
||
789 | call print_string |
||
3545 | hidnplayr | 790 | |
4595 | hidnplayr | 791 | mov esi, str_by |
4623 | hidnplayr | 792 | call print_asciiz |
3545 | hidnplayr | 793 | |
4623 | hidnplayr | 794 | mov esi, servercommand+1 |
795 | mov bl, '!' |
||
796 | call print_string |
||
4595 | hidnplayr | 797 | |
4623 | hidnplayr | 798 | mov al, 10 |
799 | call print_char |
||
4595 | hidnplayr | 800 | |
3545 | hidnplayr | 801 | mov ebx, [window_print] |
802 | mov esi, servercommand+1 |
||
803 | call user_remove |
||
804 | |||
4623 | hidnplayr | 805 | ret |
806 | |||
4143 | hidnplayr | 807 | .fail: |
4623 | hidnplayr | 808 | pop esi |
4143 | hidnplayr | 809 | |
3545 | hidnplayr | 810 | ret |
811 | |||
812 | |||
813 | |||
814 | cmd_quit: |
||
815 | |||
4143 | hidnplayr | 816 | cmp byte [esi+4], ' ' |
817 | jne .fail |
||
818 | |||
819 | mov ebx, windows |
||
820 | mov ecx, MAX_WINDOWS |
||
821 | |||
822 | .window_loop: |
||
823 | push ecx |
||
824 | cmp [ebx + window.type], WINDOWTYPE_CHANNEL |
||
825 | jne .next_window |
||
826 | |||
827 | mov esi, servercommand+1 |
||
828 | call user_remove |
||
829 | test edi, edi |
||
830 | jz .next_window |
||
831 | |||
832 | push ebx |
||
833 | mov [window_print], ebx |
||
834 | |||
835 | if TIMESTAMP |
||
836 | call print_timestamp |
||
837 | end if |
||
838 | |||
839 | mov esi, quit_header |
||
4623 | hidnplayr | 840 | call print_asciiz |
3545 | hidnplayr | 841 | |
4623 | hidnplayr | 842 | mov esi, servercommand+1 |
843 | mov bl, '!' |
||
844 | call print_string |
||
3545 | hidnplayr | 845 | |
846 | mov esi, has_quit_irc |
||
4623 | hidnplayr | 847 | call print_asciiz |
3545 | hidnplayr | 848 | |
4143 | hidnplayr | 849 | ; TODO: check if quit message was given, and print it to the window |
850 | pop ebx |
||
851 | .next_window: |
||
852 | pop ecx |
||
853 | add ebx, sizeof.window |
||
854 | dec ecx |
||
855 | jnz .window_loop |
||
3545 | hidnplayr | 856 | |
4143 | hidnplayr | 857 | .fail: |
858 | |||
859 | |||
3545 | hidnplayr | 860 | ret |
861 | |||
862 | |||
863 | |||
864 | cmd_mode: |
||
865 | |||
4143 | hidnplayr | 866 | cmp byte [esi+4], ' ' |
867 | jne .fail |
||
3545 | hidnplayr | 868 | add esi, 5 ; skip 'MODE ' |
4622 | hidnplayr | 869 | push esi |
4143 | hidnplayr | 870 | call window_find |
871 | test ebx, ebx |
||
4622 | hidnplayr | 872 | jz .user |
873 | mov [esp], esi |
||
4477 | hidnplayr | 874 | mov [window_print], ebx |
4143 | hidnplayr | 875 | |
876 | if TIMESTAMP |
||
877 | call print_timestamp |
||
878 | end if |
||
879 | |||
880 | mov esi, mode_header |
||
4623 | hidnplayr | 881 | call print_asciiz |
3545 | hidnplayr | 882 | |
4623 | hidnplayr | 883 | mov esi, servercommand+1 |
884 | mov bl, '!' |
||
885 | call print_string |
||
3545 | hidnplayr | 886 | |
887 | mov esi, sets_mode |
||
4623 | hidnplayr | 888 | call print_asciiz |
3545 | hidnplayr | 889 | |
890 | pop esi |
||
4623 | hidnplayr | 891 | call print_asciiz |
3545 | hidnplayr | 892 | |
4623 | hidnplayr | 893 | mov al, 10 |
894 | call print_char |
||
3545 | hidnplayr | 895 | |
4622 | hidnplayr | 896 | ; TODO: keep track of user modes in username list |
3545 | hidnplayr | 897 | |
4143 | hidnplayr | 898 | .fail: |
4622 | hidnplayr | 899 | ret |
4143 | hidnplayr | 900 | |
4622 | hidnplayr | 901 | |
902 | .user: |
||
903 | if TIMESTAMP |
||
904 | call print_timestamp |
||
905 | end if |
||
906 | |||
907 | mov esi, mode_header |
||
4623 | hidnplayr | 908 | call print_asciiz |
4622 | hidnplayr | 909 | |
4623 | hidnplayr | 910 | mov esi, [esp] |
911 | mov bl, ' ' |
||
912 | call print_string |
||
4622 | hidnplayr | 913 | |
914 | mov esi, sets_mode |
||
4623 | hidnplayr | 915 | call print_asciiz |
4622 | hidnplayr | 916 | |
917 | pop esi |
||
918 | call skip_parameter |
||
4623 | hidnplayr | 919 | call print_asciiz |
4622 | hidnplayr | 920 | |
4623 | hidnplayr | 921 | mov al, 10 |
922 | call print_char |
||
4622 | hidnplayr | 923 | |
3545 | hidnplayr | 924 | ret |
925 | |||
926 | |||
927 | cmd_353: ; channel usernames reply |
||
928 | |||
929 | add esi, 4 ; skip '353 ' |
||
4477 | hidnplayr | 930 | call skip_parameter |
3545 | hidnplayr | 931 | inc esi ; channel type '*', '=' or '@' |
932 | inc esi ; ' ' |
||
3981 | hidnplayr | 933 | call window_open |
4623 | hidnplayr | 934 | test ebx, ebx |
935 | jz .fail |
||
3545 | hidnplayr | 936 | |
937 | ; now find window ptr and check if this is the first 353 message |
||
938 | mov ebx, [window_print] |
||
939 | test [ebx + window.flags], FLAG_RECEIVING_NAMES |
||
940 | jnz .add |
||
941 | |||
942 | or [ebx + window.flags], FLAG_RECEIVING_NAMES |
||
943 | ; mov [ebx + window.users], 0 |
||
944 | ; TODO: remove all users? |
||
945 | |||
946 | .add: |
||
947 | push esi |
||
948 | call user_add |
||
949 | pop esi |
||
950 | |||
951 | .namesloop: |
||
952 | lodsb |
||
953 | test al, al |
||
954 | jz .done |
||
955 | cmp al, ' ' ; names list is separated with spaces |
||
956 | jne .namesloop |
||
957 | jmp .add |
||
958 | |||
959 | .done: |
||
4143 | hidnplayr | 960 | call draw_channel_list |
4623 | hidnplayr | 961 | .fail: |
3545 | hidnplayr | 962 | |
963 | ret |
||
964 | |||
965 | |||
966 | |||
967 | |||
968 | |||
969 | cmd_366: ; channel usernames end |
||
970 | |||
971 | add esi, 4 ; skip '366 ' |
||
4477 | hidnplayr | 972 | call skip_parameter |
3981 | hidnplayr | 973 | call window_open |
4623 | hidnplayr | 974 | test ebx, ebx |
975 | jz .fail |
||
3545 | hidnplayr | 976 | and [ebx + window.flags], not FLAG_RECEIVING_NAMES |
4623 | hidnplayr | 977 | .fail: |
3545 | hidnplayr | 978 | |
979 | ret |
||
980 | |||
981 | |||
982 | |||
983 | |||
984 | cmd_topic: |
||
985 | |||
986 | add esi, 4 ; skip '332 ' |
||
4477 | hidnplayr | 987 | call skip_parameter |
3981 | hidnplayr | 988 | call window_open |
4623 | hidnplayr | 989 | test ebx, ebx |
990 | jz .fail |
||
3545 | hidnplayr | 991 | |
4143 | hidnplayr | 992 | if TIMESTAMP |
993 | call print_timestamp |
||
994 | end if |
||
995 | |||
3545 | hidnplayr | 996 | push esi |
4143 | hidnplayr | 997 | mov esi, topic_header |
4623 | hidnplayr | 998 | call print_asciiz |
3545 | hidnplayr | 999 | |
1000 | mov esi, str_topic |
||
4623 | hidnplayr | 1001 | call print_asciiz |
3545 | hidnplayr | 1002 | |
1003 | pop esi |
||
4623 | hidnplayr | 1004 | call print_asciiz |
3545 | hidnplayr | 1005 | |
4477 | hidnplayr | 1006 | mov esi, str_topic_end |
4623 | hidnplayr | 1007 | call print_asciiz |
3545 | hidnplayr | 1008 | |
4623 | hidnplayr | 1009 | .fail: |
1010 | |||
3545 | hidnplayr | 1011 | ret |
1012 | |||
1013 | |||
1014 | cmd_333: |
||
1015 | |||
1016 | add esi, 4 ; skip '333 ' |
||
4622 | hidnplayr | 1017 | call skip_parameter |
3981 | hidnplayr | 1018 | call window_open |
4623 | hidnplayr | 1019 | test ebx, ebx |
1020 | jz .fail |
||
3545 | hidnplayr | 1021 | |
4143 | hidnplayr | 1022 | if TIMESTAMP |
1023 | call print_timestamp |
||
1024 | end if |
||
1025 | |||
3545 | hidnplayr | 1026 | push esi |
4143 | hidnplayr | 1027 | mov esi, topic_header |
4623 | hidnplayr | 1028 | call print_asciiz |
3545 | hidnplayr | 1029 | |
1030 | mov esi, str_setby |
||
4623 | hidnplayr | 1031 | call print_asciiz |
3545 | hidnplayr | 1032 | |
4623 | hidnplayr | 1033 | pop esi |
1034 | mov bl, '!' |
||
1035 | call print_string |
||
3545 | hidnplayr | 1036 | |
4623 | hidnplayr | 1037 | mov al, 10 |
1038 | call print_char |
||
3545 | hidnplayr | 1039 | |
1040 | .fail: |
||
4623 | hidnplayr | 1041 | |
3545 | hidnplayr | 1042 | ret |
1043 | |||
4623 | hidnplayr | 1044 | |
1045 | |||
4143 | hidnplayr | 1046 | cmd_322: ; LIST |
1047 | |||
3545 | hidnplayr | 1048 | add esi, 4 |
4477 | hidnplayr | 1049 | call skip_parameter |
3545 | hidnplayr | 1050 | |
4623 | hidnplayr | 1051 | push esi |
1052 | mov esi, str_list |
||
1053 | call window_open |
||
1054 | test ebx, ebx |
||
1055 | jz .fail |
||
1056 | |||
1057 | mov [window_active], ebx |
||
1058 | call draw_windowtabs |
||
1059 | pop esi |
||
1060 | call print_asciiz |
||
1061 | mov al, 10 |
||
1062 | call print_char |
||
1063 | |||
3545 | hidnplayr | 1064 | ret |
1065 | |||
4623 | hidnplayr | 1066 | .fail: |
1067 | pop esi |
||
1068 | |||
1069 | ret |
||
1070 | |||
4143 | hidnplayr | 1071 | cmd_323: ; LIST END |
3545 | hidnplayr | 1072 | |
1073 | ret' |