Rev 4623 | Rev 4982 | 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 |
||
686 | .not_me: |
||
687 | |||
4617 | hidnplayr | 688 | ; Update in userlist |
4143 | hidnplayr | 689 | mov ebx, windows |
690 | mov ecx, MAX_WINDOWS |
||
691 | .window_loop: |
||
692 | push ecx ebx |
||
693 | cmp [ebx + window.type], WINDOWTYPE_CHANNEL |
||
694 | jne .next_window |
||
695 | |||
696 | mov esi, servercommand+1 |
||
697 | call user_remove |
||
698 | test edi, edi |
||
699 | jz .next_window |
||
700 | |||
701 | mov esi, [esp + 8] |
||
702 | call user_add |
||
703 | |||
4617 | hidnplayr | 704 | ; And print a notification in the channel |
4143 | hidnplayr | 705 | mov [window_print], ebx |
706 | |||
707 | if TIMESTAMP |
||
708 | call print_timestamp |
||
709 | end if |
||
710 | |||
711 | mov esi, nick_header |
||
4623 | hidnplayr | 712 | call print_asciiz |
3545 | hidnplayr | 713 | |
4623 | hidnplayr | 714 | mov esi, servercommand+1 |
715 | mov bl, '!' |
||
716 | call print_string |
||
3545 | hidnplayr | 717 | |
718 | mov esi, is_now_known_as |
||
4623 | hidnplayr | 719 | call print_asciiz |
3545 | hidnplayr | 720 | |
4623 | hidnplayr | 721 | mov esi, [esp + 8] |
722 | call print_asciiz |
||
3545 | hidnplayr | 723 | |
4623 | hidnplayr | 724 | mov al, 10 |
725 | call print_char |
||
3545 | hidnplayr | 726 | |
4617 | hidnplayr | 727 | ; Now do this for all open windows |
4143 | hidnplayr | 728 | .next_window: |
729 | pop ebx ecx |
||
730 | add ebx, sizeof.window |
||
731 | dec ecx |
||
732 | jnz .window_loop |
||
733 | |||
734 | pop esi |
||
735 | |||
736 | .fail: |
||
737 | |||
3545 | hidnplayr | 738 | ret |
739 | |||
740 | |||
741 | |||
742 | |||
743 | cmd_kick: |
||
4143 | hidnplayr | 744 | |
745 | cmp byte [esi+4], ' ' |
||
746 | jne .fail |
||
3545 | hidnplayr | 747 | add esi, 5 ; skip 'KICK ' |
748 | |||
4595 | hidnplayr | 749 | ; TODO: Is it me who got kicked? |
750 | ; if so, mark channel as disconnected |
||
3545 | hidnplayr | 751 | |
752 | .not_me: |
||
753 | ; find the channel user has been kicked from |
||
754 | push esi |
||
3981 | hidnplayr | 755 | call window_open |
4623 | hidnplayr | 756 | test ebx, ebx |
757 | jz .fail |
||
4595 | hidnplayr | 758 | push esi |
3545 | hidnplayr | 759 | |
4143 | hidnplayr | 760 | if TIMESTAMP |
761 | call print_timestamp |
||
762 | end if |
||
763 | |||
764 | mov esi, kick_header |
||
4623 | hidnplayr | 765 | call print_asciiz |
3545 | hidnplayr | 766 | |
4623 | hidnplayr | 767 | pop esi |
768 | mov bl, ' ' |
||
769 | call print_string |
||
3545 | hidnplayr | 770 | |
4595 | hidnplayr | 771 | mov esi, str_kicked |
4623 | hidnplayr | 772 | call print_asciiz |
3545 | hidnplayr | 773 | |
4623 | hidnplayr | 774 | pop esi |
775 | mov bl, ' ' |
||
776 | call print_string |
||
3545 | hidnplayr | 777 | |
4595 | hidnplayr | 778 | mov esi, str_by |
4623 | hidnplayr | 779 | call print_asciiz |
3545 | hidnplayr | 780 | |
4623 | hidnplayr | 781 | mov esi, servercommand+1 |
782 | mov bl, '!' |
||
783 | call print_string |
||
4595 | hidnplayr | 784 | |
4623 | hidnplayr | 785 | mov al, 10 |
786 | call print_char |
||
4595 | hidnplayr | 787 | |
3545 | hidnplayr | 788 | mov ebx, [window_print] |
789 | mov esi, servercommand+1 |
||
790 | call user_remove |
||
791 | |||
4623 | hidnplayr | 792 | ret |
793 | |||
4143 | hidnplayr | 794 | .fail: |
4623 | hidnplayr | 795 | pop esi |
4143 | hidnplayr | 796 | |
3545 | hidnplayr | 797 | ret |
798 | |||
799 | |||
800 | |||
801 | cmd_quit: |
||
802 | |||
4143 | hidnplayr | 803 | cmp byte [esi+4], ' ' |
804 | jne .fail |
||
805 | |||
806 | mov ebx, windows |
||
807 | mov ecx, MAX_WINDOWS |
||
808 | |||
809 | .window_loop: |
||
810 | push ecx |
||
811 | cmp [ebx + window.type], WINDOWTYPE_CHANNEL |
||
812 | jne .next_window |
||
813 | |||
814 | mov esi, servercommand+1 |
||
815 | call user_remove |
||
816 | test edi, edi |
||
817 | jz .next_window |
||
818 | |||
819 | push ebx |
||
820 | mov [window_print], ebx |
||
821 | |||
822 | if TIMESTAMP |
||
823 | call print_timestamp |
||
824 | end if |
||
825 | |||
826 | mov esi, quit_header |
||
4623 | hidnplayr | 827 | call print_asciiz |
3545 | hidnplayr | 828 | |
4623 | hidnplayr | 829 | mov esi, servercommand+1 |
830 | mov bl, '!' |
||
831 | call print_string |
||
3545 | hidnplayr | 832 | |
833 | mov esi, has_quit_irc |
||
4623 | hidnplayr | 834 | call print_asciiz |
3545 | hidnplayr | 835 | |
4143 | hidnplayr | 836 | ; TODO: check if quit message was given, and print it to the window |
837 | pop ebx |
||
838 | .next_window: |
||
839 | pop ecx |
||
840 | add ebx, sizeof.window |
||
841 | dec ecx |
||
842 | jnz .window_loop |
||
3545 | hidnplayr | 843 | |
4143 | hidnplayr | 844 | .fail: |
845 | |||
846 | |||
3545 | hidnplayr | 847 | ret |
848 | |||
849 | |||
850 | |||
851 | cmd_mode: |
||
852 | |||
4143 | hidnplayr | 853 | cmp byte [esi+4], ' ' |
854 | jne .fail |
||
3545 | hidnplayr | 855 | add esi, 5 ; skip 'MODE ' |
4622 | hidnplayr | 856 | push esi |
4143 | hidnplayr | 857 | call window_find |
858 | test ebx, ebx |
||
4622 | hidnplayr | 859 | jz .user |
860 | mov [esp], esi |
||
4477 | hidnplayr | 861 | mov [window_print], ebx |
4143 | hidnplayr | 862 | |
863 | if TIMESTAMP |
||
864 | call print_timestamp |
||
865 | end if |
||
866 | |||
867 | mov esi, mode_header |
||
4623 | hidnplayr | 868 | call print_asciiz |
3545 | hidnplayr | 869 | |
4623 | hidnplayr | 870 | mov esi, servercommand+1 |
871 | mov bl, '!' |
||
872 | call print_string |
||
3545 | hidnplayr | 873 | |
874 | mov esi, sets_mode |
||
4623 | hidnplayr | 875 | call print_asciiz |
3545 | hidnplayr | 876 | |
877 | pop esi |
||
4623 | hidnplayr | 878 | call print_asciiz |
3545 | hidnplayr | 879 | |
4623 | hidnplayr | 880 | mov al, 10 |
881 | call print_char |
||
3545 | hidnplayr | 882 | |
4622 | hidnplayr | 883 | ; TODO: keep track of user modes in username list |
3545 | hidnplayr | 884 | |
4143 | hidnplayr | 885 | .fail: |
4622 | hidnplayr | 886 | ret |
4143 | hidnplayr | 887 | |
4622 | hidnplayr | 888 | |
889 | .user: |
||
890 | if TIMESTAMP |
||
891 | call print_timestamp |
||
892 | end if |
||
893 | |||
894 | mov esi, mode_header |
||
4623 | hidnplayr | 895 | call print_asciiz |
4622 | hidnplayr | 896 | |
4623 | hidnplayr | 897 | mov esi, [esp] |
898 | mov bl, ' ' |
||
899 | call print_string |
||
4622 | hidnplayr | 900 | |
901 | mov esi, sets_mode |
||
4623 | hidnplayr | 902 | call print_asciiz |
4622 | hidnplayr | 903 | |
904 | pop esi |
||
905 | call skip_parameter |
||
4623 | hidnplayr | 906 | call print_asciiz |
4622 | hidnplayr | 907 | |
4623 | hidnplayr | 908 | mov al, 10 |
909 | call print_char |
||
4622 | hidnplayr | 910 | |
3545 | hidnplayr | 911 | ret |
912 | |||
913 | |||
914 | cmd_353: ; channel usernames reply |
||
915 | |||
916 | add esi, 4 ; skip '353 ' |
||
4477 | hidnplayr | 917 | call skip_parameter |
3545 | hidnplayr | 918 | inc esi ; channel type '*', '=' or '@' |
919 | inc esi ; ' ' |
||
3981 | hidnplayr | 920 | call window_open |
4623 | hidnplayr | 921 | test ebx, ebx |
922 | jz .fail |
||
3545 | hidnplayr | 923 | |
924 | ; now find window ptr and check if this is the first 353 message |
||
925 | mov ebx, [window_print] |
||
926 | test [ebx + window.flags], FLAG_RECEIVING_NAMES |
||
927 | jnz .add |
||
928 | |||
929 | or [ebx + window.flags], FLAG_RECEIVING_NAMES |
||
930 | ; mov [ebx + window.users], 0 |
||
931 | ; TODO: remove all users? |
||
932 | |||
933 | .add: |
||
934 | push esi |
||
935 | call user_add |
||
936 | pop esi |
||
937 | |||
938 | .namesloop: |
||
939 | lodsb |
||
940 | test al, al |
||
941 | jz .done |
||
942 | cmp al, ' ' ; names list is separated with spaces |
||
943 | jne .namesloop |
||
944 | jmp .add |
||
945 | |||
946 | .done: |
||
4143 | hidnplayr | 947 | call draw_channel_list |
4623 | hidnplayr | 948 | .fail: |
3545 | hidnplayr | 949 | |
950 | ret |
||
951 | |||
952 | |||
953 | |||
954 | |||
955 | |||
956 | cmd_366: ; channel usernames end |
||
957 | |||
958 | add esi, 4 ; skip '366 ' |
||
4477 | hidnplayr | 959 | call skip_parameter |
3981 | hidnplayr | 960 | call window_open |
4623 | hidnplayr | 961 | test ebx, ebx |
962 | jz .fail |
||
3545 | hidnplayr | 963 | and [ebx + window.flags], not FLAG_RECEIVING_NAMES |
4623 | hidnplayr | 964 | .fail: |
3545 | hidnplayr | 965 | |
966 | ret |
||
967 | |||
968 | |||
969 | |||
970 | |||
971 | cmd_topic: |
||
972 | |||
973 | add esi, 4 ; skip '332 ' |
||
4477 | hidnplayr | 974 | call skip_parameter |
3981 | hidnplayr | 975 | call window_open |
4623 | hidnplayr | 976 | test ebx, ebx |
977 | jz .fail |
||
3545 | hidnplayr | 978 | |
4143 | hidnplayr | 979 | if TIMESTAMP |
980 | call print_timestamp |
||
981 | end if |
||
982 | |||
3545 | hidnplayr | 983 | push esi |
4143 | hidnplayr | 984 | mov esi, topic_header |
4623 | hidnplayr | 985 | call print_asciiz |
3545 | hidnplayr | 986 | |
987 | mov esi, str_topic |
||
4623 | hidnplayr | 988 | call print_asciiz |
3545 | hidnplayr | 989 | |
990 | pop esi |
||
4623 | hidnplayr | 991 | call print_asciiz |
3545 | hidnplayr | 992 | |
4477 | hidnplayr | 993 | mov esi, str_topic_end |
4623 | hidnplayr | 994 | call print_asciiz |
3545 | hidnplayr | 995 | |
4623 | hidnplayr | 996 | .fail: |
997 | |||
3545 | hidnplayr | 998 | ret |
999 | |||
1000 | |||
1001 | cmd_333: |
||
1002 | |||
1003 | add esi, 4 ; skip '333 ' |
||
4622 | hidnplayr | 1004 | call skip_parameter |
3981 | hidnplayr | 1005 | call window_open |
4623 | hidnplayr | 1006 | test ebx, ebx |
1007 | jz .fail |
||
3545 | hidnplayr | 1008 | |
4143 | hidnplayr | 1009 | if TIMESTAMP |
1010 | call print_timestamp |
||
1011 | end if |
||
1012 | |||
3545 | hidnplayr | 1013 | push esi |
4143 | hidnplayr | 1014 | mov esi, topic_header |
4623 | hidnplayr | 1015 | call print_asciiz |
3545 | hidnplayr | 1016 | |
1017 | mov esi, str_setby |
||
4623 | hidnplayr | 1018 | call print_asciiz |
3545 | hidnplayr | 1019 | |
4623 | hidnplayr | 1020 | pop esi |
1021 | mov bl, '!' |
||
1022 | call print_string |
||
3545 | hidnplayr | 1023 | |
4623 | hidnplayr | 1024 | mov al, 10 |
1025 | call print_char |
||
3545 | hidnplayr | 1026 | |
1027 | .fail: |
||
4623 | hidnplayr | 1028 | |
3545 | hidnplayr | 1029 | ret |
1030 | |||
4623 | hidnplayr | 1031 | |
1032 | |||
4143 | hidnplayr | 1033 | cmd_322: ; LIST |
1034 | |||
3545 | hidnplayr | 1035 | add esi, 4 |
4477 | hidnplayr | 1036 | call skip_parameter |
3545 | hidnplayr | 1037 | |
4623 | hidnplayr | 1038 | push esi |
1039 | mov esi, str_list |
||
1040 | call window_open |
||
1041 | test ebx, ebx |
||
1042 | jz .fail |
||
1043 | |||
1044 | mov [window_active], ebx |
||
1045 | call draw_windowtabs |
||
1046 | pop esi |
||
1047 | call print_asciiz |
||
1048 | mov al, 10 |
||
1049 | call print_char |
||
1050 | |||
3545 | hidnplayr | 1051 | ret |
1052 | |||
4623 | hidnplayr | 1053 | .fail: |
1054 | pop esi |
||
1055 | |||
1056 | ret |
||
1057 | |||
4143 | hidnplayr | 1058 | cmd_323: ; LIST END |
3545 | hidnplayr | 1059 | |
1060 | ret' |