Rev 4622 | Rev 4659 | 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 | |||
4143 | hidnplayr | 261 | cmp byte[esi], 1 ; Client to Client protocol? |
3545 | hidnplayr | 262 | je cmd_ctcp |
263 | |||
4477 | hidnplayr | 264 | jmp .print |
265 | |||
266 | .channel: |
||
267 | call window_open |
||
4623 | hidnplayr | 268 | test ebx, ebx |
269 | jz .fail |
||
4477 | hidnplayr | 270 | |
271 | .print: |
||
4143 | hidnplayr | 272 | ; nope, just plain old privmsg, print it using ' |
273 | if TIMESTAMP |
||
3545 | hidnplayr | 274 | call print_timestamp |
4143 | hidnplayr | 275 | end if |
3545 | hidnplayr | 276 | |
277 | push esi |
||
4623 | hidnplayr | 278 | mov al, '<' |
279 | call print_char |
||
3545 | hidnplayr | 280 | |
4623 | hidnplayr | 281 | mov esi, servercommand+1 |
282 | mov bl, '!' |
||
283 | call print_string |
||
3545 | hidnplayr | 284 | |
4623 | hidnplayr | 285 | mov al, '>' |
286 | call print_char |
||
3545 | hidnplayr | 287 | |
4623 | hidnplayr | 288 | mov al, ' ' |
289 | call print_char |
||
3545 | hidnplayr | 290 | |
291 | pop esi |
||
4623 | hidnplayr | 292 | call print_asciiz |
3545 | hidnplayr | 293 | |
4623 | hidnplayr | 294 | mov al, 10 |
295 | call print_char |
||
3545 | hidnplayr | 296 | |
4623 | hidnplayr | 297 | ret |
298 | |||
299 | .fail2: |
||
300 | pop esi |
||
3545 | hidnplayr | 301 | .fail: |
302 | ret |
||
303 | |||
304 | |||
305 | |||
306 | |||
4143 | hidnplayr | 307 | cmd_ctcp: |
3545 | hidnplayr | 308 | |
309 | inc esi |
||
4143 | hidnplayr | 310 | mov eax, dword[esi] |
311 | or eax, 0x20202020 |
||
3545 | hidnplayr | 312 | |
4143 | hidnplayr | 313 | cmp eax, 'vers' |
3545 | hidnplayr | 314 | je .version |
4143 | hidnplayr | 315 | cmp eax, 'time' |
3545 | hidnplayr | 316 | je .time |
4143 | hidnplayr | 317 | cmp eax, 'ping' |
3545 | hidnplayr | 318 | je .ping |
4143 | hidnplayr | 319 | cmp eax, 'acti' |
320 | je .action |
||
4477 | hidnplayr | 321 | cmp eax, 'dcc ' ; TODO |
322 | je cmd_dcc |
||
3545 | hidnplayr | 323 | |
4143 | hidnplayr | 324 | ; Unknown CTCP command: TODO: just print to window?? |
325 | |||
326 | .fail: |
||
327 | |||
3545 | hidnplayr | 328 | ret |
329 | |||
330 | .time: |
||
4143 | hidnplayr | 331 | mov byte[esi+4], ' ' |
3545 | hidnplayr | 332 | lea edi, [esi+5] |
333 | |||
334 | ; TODO: add system date (fn 29) in human readable format |
||
335 | |||
336 | mcall 3 ; get system time |
||
337 | |||
338 | mov ecx, 3 |
||
339 | .timeloop: |
||
340 | mov bl, al |
||
341 | shr al, 4 |
||
342 | add al, '0' |
||
343 | stosb |
||
344 | |||
345 | mov al, bl |
||
346 | and al, 0x0f |
||
347 | add al, '0' |
||
348 | stosb |
||
349 | |||
350 | dec ecx |
||
351 | jz .timedone |
||
352 | |||
353 | mov al, ':' |
||
354 | stosb |
||
355 | shr eax, 8 |
||
356 | jmp .timeloop |
||
357 | |||
358 | .timedone: |
||
359 | xor al, al |
||
360 | stosb |
||
361 | call ctcp_reply |
||
362 | |||
363 | if TIMESTAMP |
||
364 | call print_timestamp |
||
365 | end if |
||
366 | |||
367 | mov esi, ctcp_header |
||
4623 | hidnplayr | 368 | call print_asciiz |
3545 | hidnplayr | 369 | |
370 | mov esi, servercommand+1 |
||
4623 | hidnplayr | 371 | call print_asciiz |
3545 | hidnplayr | 372 | |
373 | mov esi, ctcp_time |
||
4623 | hidnplayr | 374 | call print_asciiz |
3545 | hidnplayr | 375 | |
376 | ret |
||
377 | |||
378 | .version: |
||
379 | mov esi, str_version |
||
380 | call ctcp_reply |
||
381 | |||
382 | if TIMESTAMP |
||
383 | call print_timestamp |
||
384 | end if |
||
385 | |||
386 | mov esi, ctcp_header |
||
4623 | hidnplayr | 387 | call print_asciiz |
3545 | hidnplayr | 388 | |
389 | mov esi, servercommand+1 |
||
4623 | hidnplayr | 390 | call print_asciiz |
3545 | hidnplayr | 391 | |
392 | mov esi, ctcp_version |
||
4623 | hidnplayr | 393 | call print_asciiz |
3545 | hidnplayr | 394 | |
395 | ret |
||
396 | |||
397 | .ping: |
||
398 | call ctcp_reply |
||
399 | |||
400 | if TIMESTAMP |
||
401 | call print_timestamp |
||
402 | end if |
||
403 | |||
404 | mov esi, ctcp_header |
||
4623 | hidnplayr | 405 | call print_asciiz |
3545 | hidnplayr | 406 | |
407 | mov esi, servercommand+1 |
||
4623 | hidnplayr | 408 | call print_asciiz |
3545 | hidnplayr | 409 | |
410 | mov esi, ctcp_ping |
||
4623 | hidnplayr | 411 | call print_asciiz |
3545 | hidnplayr | 412 | |
413 | ret |
||
414 | |||
4143 | hidnplayr | 415 | .action: |
416 | add esi, 7 |
||
417 | push esi |
||
3545 | hidnplayr | 418 | |
4143 | hidnplayr | 419 | if TIMESTAMP |
420 | call print_timestamp |
||
421 | end if |
||
3545 | hidnplayr | 422 | |
4143 | hidnplayr | 423 | mov esi, action_header |
4623 | hidnplayr | 424 | call print_asciiz |
4143 | hidnplayr | 425 | |
4623 | hidnplayr | 426 | mov esi, servercommand+1 ; print nickname |
427 | mov bl, '!' |
||
428 | call print_string |
||
4143 | hidnplayr | 429 | |
4623 | hidnplayr | 430 | mov al, ' ' |
431 | call print_char |
||
4143 | hidnplayr | 432 | |
433 | pop esi |
||
4623 | hidnplayr | 434 | call print_asciiz |
4143 | hidnplayr | 435 | |
4623 | hidnplayr | 436 | mov al, 10 |
437 | call print_char |
||
4143 | hidnplayr | 438 | |
439 | ret |
||
440 | |||
441 | |||
442 | cmd_dcc: |
||
443 | add esi, 4 |
||
444 | mov eax, dword[esi] |
||
445 | or eax, 0x202020 |
||
446 | |||
447 | cmp eax, 'send' |
||
448 | je .send |
||
449 | |||
450 | ret |
||
451 | |||
452 | .send: |
||
4477 | hidnplayr | 453 | call window_open |
4623 | hidnplayr | 454 | test ebx, ebx |
455 | jz .fail |
||
4477 | hidnplayr | 456 | mov [ebx + window.type], WINDOWTYPE_DCC |
457 | |||
4623 | hidnplayr | 458 | .fail: |
459 | |||
4143 | hidnplayr | 460 | ret |
461 | |||
462 | |||
463 | |||
3545 | hidnplayr | 464 | ctcp_reply: |
465 | |||
466 | push esi |
||
467 | mov dword [usercommand], 'NOTI' |
||
468 | mov dword [usercommand+4], 'CE ' |
||
469 | |||
470 | mov esi, servercommand+1 |
||
471 | mov edi, usercommand+7 |
||
472 | .nickloop: |
||
473 | lodsb |
||
474 | cmp al, '!' |
||
475 | je .done |
||
476 | cmp al, ' ' |
||
477 | je .done |
||
478 | test al, al |
||
479 | je .fail |
||
480 | stosb |
||
481 | jmp .nickloop |
||
482 | .done: |
||
483 | mov byte [esi-1], 0 |
||
484 | mov ax, ' :' |
||
485 | stosw |
||
486 | mov al, 1 |
||
487 | stosb |
||
488 | |||
489 | pop esi |
||
490 | .replyloop: |
||
491 | lodsb |
||
492 | cmp al, 1 |
||
493 | jbe .done2 |
||
494 | stosb |
||
495 | jmp .replyloop |
||
496 | .done2: |
||
497 | |||
498 | mov al, 1 |
||
499 | stosb |
||
500 | mov ax, 0x0a0d |
||
501 | stosw |
||
502 | |||
503 | lea esi, [edi - usercommand] |
||
504 | mcall send, [socketnum], usercommand, , 0 |
||
505 | .fail: |
||
506 | ret |
||
507 | |||
508 | |||
509 | |||
510 | cmd_part: |
||
4143 | hidnplayr | 511 | |
512 | cmp byte [esi+4], ' ' |
||
513 | jne .fail |
||
3545 | hidnplayr | 514 | add esi, 5 ; skip 'PART ' |
515 | |||
516 | ; Is it me who parted? |
||
517 | mov edi, servercommand+1 |
||
518 | call compare_to_nick |
||
4477 | hidnplayr | 519 | jne .not_me |
3545 | hidnplayr | 520 | |
4143 | hidnplayr | 521 | ; yes, close the window (if its open) |
522 | call window_find |
||
523 | test ebx, ebx |
||
524 | jz @f |
||
525 | call window_close |
||
526 | @@: |
||
527 | .fail: |
||
3545 | hidnplayr | 528 | |
529 | ret |
||
530 | |||
4143 | hidnplayr | 531 | |
3545 | hidnplayr | 532 | ; somebody else parted, just print message |
4477 | hidnplayr | 533 | .not_me: |
3545 | hidnplayr | 534 | push esi |
4143 | hidnplayr | 535 | call window_open |
4623 | hidnplayr | 536 | test ebx, ebx |
537 | jz .fail2 |
||
4143 | hidnplayr | 538 | |
4477 | hidnplayr | 539 | if TIMESTAMP |
540 | call print_timestamp |
||
541 | end if |
||
542 | |||
4143 | hidnplayr | 543 | mov esi, part_header |
4623 | hidnplayr | 544 | call print_asciiz |
3545 | hidnplayr | 545 | |
4623 | hidnplayr | 546 | mov esi, servercommand+1 |
547 | mov bl, '!' |
||
548 | call print_string |
||
3545 | hidnplayr | 549 | |
550 | mov esi, has_left_channel |
||
4623 | hidnplayr | 551 | call print_asciiz |
3545 | hidnplayr | 552 | |
553 | pop esi |
||
4623 | hidnplayr | 554 | call print_asciiz |
3545 | hidnplayr | 555 | |
4623 | hidnplayr | 556 | mov al, 10 |
557 | call print_char |
||
3545 | hidnplayr | 558 | |
559 | mov ebx, [window_print] |
||
560 | mov esi, servercommand+1 |
||
561 | call user_remove |
||
562 | |||
563 | ret |
||
564 | |||
4623 | hidnplayr | 565 | .fail2: |
566 | pop esi |
||
3545 | hidnplayr | 567 | |
4623 | hidnplayr | 568 | ret |
3545 | hidnplayr | 569 | |
4623 | hidnplayr | 570 | |
571 | |||
3545 | hidnplayr | 572 | cmd_join: |
4143 | hidnplayr | 573 | |
4477 | hidnplayr | 574 | cmp byte[esi+4], ' ' |
4143 | hidnplayr | 575 | jne .fail |
3545 | hidnplayr | 576 | add esi, 5 ; skip 'JOIN ' |
577 | |||
4623 | hidnplayr | 578 | ; did we join a channel? |
3545 | hidnplayr | 579 | mov edi, servercommand+1 |
580 | call compare_to_nick |
||
4477 | hidnplayr | 581 | jne .not_me |
3545 | hidnplayr | 582 | |
4477 | hidnplayr | 583 | push esi |
584 | call window_open |
||
4623 | hidnplayr | 585 | test ebx, ebx |
3545 | hidnplayr | 586 | jz .fail |
587 | mov [ebx + window.type], WINDOWTYPE_CHANNEL |
||
3981 | hidnplayr | 588 | mov [window_active], ebx |
3545 | hidnplayr | 589 | |
4143 | hidnplayr | 590 | if TIMESTAMP |
591 | call print_timestamp |
||
592 | end if |
||
593 | |||
594 | mov esi, join_header |
||
4623 | hidnplayr | 595 | call print_asciiz |
3545 | hidnplayr | 596 | |
597 | mov esi, str_talking |
||
4623 | hidnplayr | 598 | call print_asciiz |
3545 | hidnplayr | 599 | |
4623 | hidnplayr | 600 | pop esi |
601 | mov bl, ' ' |
||
602 | call print_string |
||
3545 | hidnplayr | 603 | |
4623 | hidnplayr | 604 | mov al, 10 |
605 | call print_char |
||
3545 | hidnplayr | 606 | |
607 | call draw_window |
||
608 | |||
609 | ret |
||
610 | |||
4477 | hidnplayr | 611 | .not_me: |
3545 | hidnplayr | 612 | push esi |
3981 | hidnplayr | 613 | call window_open |
4623 | hidnplayr | 614 | test ebx, ebx |
615 | jz .fail |
||
3545 | hidnplayr | 616 | |
4143 | hidnplayr | 617 | if TIMESTAMP |
618 | call print_timestamp |
||
619 | end if |
||
620 | |||
621 | mov esi, join_header |
||
4623 | hidnplayr | 622 | call print_asciiz |
3545 | hidnplayr | 623 | |
4623 | hidnplayr | 624 | mov esi, servercommand+1 |
625 | mov bl, '!' |
||
626 | call print_string |
||
3545 | hidnplayr | 627 | |
628 | mov esi, joins_channel |
||
4623 | hidnplayr | 629 | call print_asciiz |
3545 | hidnplayr | 630 | |
631 | pop esi |
||
4623 | hidnplayr | 632 | call print_asciiz |
3545 | hidnplayr | 633 | |
4623 | hidnplayr | 634 | mov al, 10 |
635 | call print_char |
||
3545 | hidnplayr | 636 | |
637 | mov ebx, [window_print] |
||
638 | mov esi, servercommand+1 |
||
639 | call user_add |
||
640 | |||
4477 | hidnplayr | 641 | ret |
642 | |||
4143 | hidnplayr | 643 | .fail: |
4623 | hidnplayr | 644 | pop esi |
3545 | hidnplayr | 645 | ret |
646 | |||
647 | |||
648 | |||
649 | |||
650 | cmd_nick: |
||
651 | |||
4143 | hidnplayr | 652 | cmp byte[esi+4], ' ' |
653 | jne .fail |
||
654 | add esi, 5 ; skip 'NICK ' |
||
655 | cmp byte[esi], ':' |
||
3545 | hidnplayr | 656 | jne @f |
657 | inc esi |
||
4143 | hidnplayr | 658 | @@: |
3545 | hidnplayr | 659 | |
4143 | hidnplayr | 660 | ; Is it me who changed nick? |
3545 | hidnplayr | 661 | push esi |
662 | mov edi, servercommand+1 |
||
663 | call compare_to_nick |
||
664 | jne .not_me |
||
665 | |||
4617 | hidnplayr | 666 | ; Yup, update user_nick |
3545 | hidnplayr | 667 | mov ecx, MAX_NICK_LEN-1 |
4143 | hidnplayr | 668 | mov esi, [esp] |
4617 | hidnplayr | 669 | mov edi, user_nick |
4143 | hidnplayr | 670 | @@: |
3545 | hidnplayr | 671 | lodsb |
672 | test al, al |
||
4143 | hidnplayr | 673 | jz @f |
3545 | hidnplayr | 674 | cmp al, ' ' |
4143 | hidnplayr | 675 | je @f |
676 | cmp al, 10 |
||
677 | je @f |
||
678 | cmp al, 13 |
||
679 | je @f |
||
4617 | hidnplayr | 680 | cmp al, ':' |
681 | je @r |
||
3545 | hidnplayr | 682 | stosb |
683 | dec ecx |
||
4143 | hidnplayr | 684 | jnz @r |
685 | @@: |
||
3545 | hidnplayr | 686 | xor al, al |
687 | stosb |
||
688 | .not_me: |
||
689 | |||
4617 | hidnplayr | 690 | ; Update in userlist |
4143 | hidnplayr | 691 | mov ebx, windows |
692 | mov ecx, MAX_WINDOWS |
||
693 | .window_loop: |
||
694 | push ecx ebx |
||
695 | cmp [ebx + window.type], WINDOWTYPE_CHANNEL |
||
696 | jne .next_window |
||
697 | |||
698 | mov esi, servercommand+1 |
||
699 | call user_remove |
||
700 | test edi, edi |
||
701 | jz .next_window |
||
702 | |||
703 | mov esi, [esp + 8] |
||
704 | call user_add |
||
705 | |||
4617 | hidnplayr | 706 | ; And print a notification in the channel |
4143 | hidnplayr | 707 | mov [window_print], ebx |
708 | |||
709 | if TIMESTAMP |
||
710 | call print_timestamp |
||
711 | end if |
||
712 | |||
713 | mov esi, nick_header |
||
4623 | hidnplayr | 714 | call print_asciiz |
3545 | hidnplayr | 715 | |
4623 | hidnplayr | 716 | mov esi, servercommand+1 |
717 | mov bl, '!' |
||
718 | call print_string |
||
3545 | hidnplayr | 719 | |
720 | mov esi, is_now_known_as |
||
4623 | hidnplayr | 721 | call print_asciiz |
3545 | hidnplayr | 722 | |
4623 | hidnplayr | 723 | mov esi, [esp + 8] |
724 | call print_asciiz |
||
3545 | hidnplayr | 725 | |
4623 | hidnplayr | 726 | mov al, 10 |
727 | call print_char |
||
3545 | hidnplayr | 728 | |
4617 | hidnplayr | 729 | ; Now do this for all open windows |
4143 | hidnplayr | 730 | .next_window: |
731 | pop ebx ecx |
||
732 | add ebx, sizeof.window |
||
733 | dec ecx |
||
734 | jnz .window_loop |
||
735 | |||
736 | pop esi |
||
737 | |||
738 | .fail: |
||
739 | |||
3545 | hidnplayr | 740 | ret |
741 | |||
742 | |||
743 | |||
744 | |||
745 | cmd_kick: |
||
4143 | hidnplayr | 746 | |
747 | cmp byte [esi+4], ' ' |
||
748 | jne .fail |
||
3545 | hidnplayr | 749 | add esi, 5 ; skip 'KICK ' |
750 | |||
4595 | hidnplayr | 751 | ; TODO: Is it me who got kicked? |
752 | ; if so, mark channel as disconnected |
||
3545 | hidnplayr | 753 | |
754 | .not_me: |
||
755 | ; find the channel user has been kicked from |
||
756 | push esi |
||
3981 | hidnplayr | 757 | call window_open |
4623 | hidnplayr | 758 | test ebx, ebx |
759 | jz .fail |
||
4595 | hidnplayr | 760 | push esi |
3545 | hidnplayr | 761 | |
4143 | hidnplayr | 762 | if TIMESTAMP |
763 | call print_timestamp |
||
764 | end if |
||
765 | |||
766 | mov esi, kick_header |
||
4623 | hidnplayr | 767 | call print_asciiz |
3545 | hidnplayr | 768 | |
4623 | hidnplayr | 769 | pop esi |
770 | mov bl, ' ' |
||
771 | call print_string |
||
3545 | hidnplayr | 772 | |
4595 | hidnplayr | 773 | mov esi, str_kicked |
4623 | hidnplayr | 774 | call print_asciiz |
3545 | hidnplayr | 775 | |
4623 | hidnplayr | 776 | pop esi |
777 | mov bl, ' ' |
||
778 | call print_string |
||
3545 | hidnplayr | 779 | |
4595 | hidnplayr | 780 | mov esi, str_by |
4623 | hidnplayr | 781 | call print_asciiz |
3545 | hidnplayr | 782 | |
4623 | hidnplayr | 783 | mov esi, servercommand+1 |
784 | mov bl, '!' |
||
785 | call print_string |
||
4595 | hidnplayr | 786 | |
4623 | hidnplayr | 787 | mov al, 10 |
788 | call print_char |
||
4595 | hidnplayr | 789 | |
3545 | hidnplayr | 790 | mov ebx, [window_print] |
791 | mov esi, servercommand+1 |
||
792 | call user_remove |
||
793 | |||
4623 | hidnplayr | 794 | ret |
795 | |||
4143 | hidnplayr | 796 | .fail: |
4623 | hidnplayr | 797 | pop esi |
4143 | hidnplayr | 798 | |
3545 | hidnplayr | 799 | ret |
800 | |||
801 | |||
802 | |||
803 | cmd_quit: |
||
804 | |||
4143 | hidnplayr | 805 | cmp byte [esi+4], ' ' |
806 | jne .fail |
||
807 | |||
808 | mov ebx, windows |
||
809 | mov ecx, MAX_WINDOWS |
||
810 | |||
811 | .window_loop: |
||
812 | push ecx |
||
813 | cmp [ebx + window.type], WINDOWTYPE_CHANNEL |
||
814 | jne .next_window |
||
815 | |||
816 | mov esi, servercommand+1 |
||
817 | call user_remove |
||
818 | test edi, edi |
||
819 | jz .next_window |
||
820 | |||
821 | push ebx |
||
822 | mov [window_print], ebx |
||
823 | |||
824 | if TIMESTAMP |
||
825 | call print_timestamp |
||
826 | end if |
||
827 | |||
828 | mov esi, quit_header |
||
4623 | hidnplayr | 829 | call print_asciiz |
3545 | hidnplayr | 830 | |
4623 | hidnplayr | 831 | mov esi, servercommand+1 |
832 | mov bl, '!' |
||
833 | call print_string |
||
3545 | hidnplayr | 834 | |
835 | mov esi, has_quit_irc |
||
4623 | hidnplayr | 836 | call print_asciiz |
3545 | hidnplayr | 837 | |
4143 | hidnplayr | 838 | ; TODO: check if quit message was given, and print it to the window |
839 | pop ebx |
||
840 | .next_window: |
||
841 | pop ecx |
||
842 | add ebx, sizeof.window |
||
843 | dec ecx |
||
844 | jnz .window_loop |
||
3545 | hidnplayr | 845 | |
4143 | hidnplayr | 846 | .fail: |
847 | |||
848 | |||
3545 | hidnplayr | 849 | ret |
850 | |||
851 | |||
852 | |||
853 | cmd_mode: |
||
854 | |||
4143 | hidnplayr | 855 | cmp byte [esi+4], ' ' |
856 | jne .fail |
||
3545 | hidnplayr | 857 | add esi, 5 ; skip 'MODE ' |
4622 | hidnplayr | 858 | push esi |
4143 | hidnplayr | 859 | call window_find |
860 | test ebx, ebx |
||
4622 | hidnplayr | 861 | jz .user |
862 | mov [esp], esi |
||
4477 | hidnplayr | 863 | mov [window_print], ebx |
4143 | hidnplayr | 864 | |
865 | if TIMESTAMP |
||
866 | call print_timestamp |
||
867 | end if |
||
868 | |||
869 | mov esi, mode_header |
||
4623 | hidnplayr | 870 | call print_asciiz |
3545 | hidnplayr | 871 | |
4623 | hidnplayr | 872 | mov esi, servercommand+1 |
873 | mov bl, '!' |
||
874 | call print_string |
||
3545 | hidnplayr | 875 | |
876 | mov esi, sets_mode |
||
4623 | hidnplayr | 877 | call print_asciiz |
3545 | hidnplayr | 878 | |
879 | pop esi |
||
4623 | hidnplayr | 880 | call print_asciiz |
3545 | hidnplayr | 881 | |
4623 | hidnplayr | 882 | mov al, 10 |
883 | call print_char |
||
3545 | hidnplayr | 884 | |
4622 | hidnplayr | 885 | ; TODO: keep track of user modes in username list |
3545 | hidnplayr | 886 | |
4143 | hidnplayr | 887 | .fail: |
4622 | hidnplayr | 888 | ret |
4143 | hidnplayr | 889 | |
4622 | hidnplayr | 890 | |
891 | .user: |
||
892 | if TIMESTAMP |
||
893 | call print_timestamp |
||
894 | end if |
||
895 | |||
896 | mov esi, mode_header |
||
4623 | hidnplayr | 897 | call print_asciiz |
4622 | hidnplayr | 898 | |
4623 | hidnplayr | 899 | mov esi, [esp] |
900 | mov bl, ' ' |
||
901 | call print_string |
||
4622 | hidnplayr | 902 | |
903 | mov esi, sets_mode |
||
4623 | hidnplayr | 904 | call print_asciiz |
4622 | hidnplayr | 905 | |
906 | pop esi |
||
907 | call skip_parameter |
||
4623 | hidnplayr | 908 | call print_asciiz |
4622 | hidnplayr | 909 | |
4623 | hidnplayr | 910 | mov al, 10 |
911 | call print_char |
||
4622 | hidnplayr | 912 | |
3545 | hidnplayr | 913 | ret |
914 | |||
915 | |||
916 | cmd_353: ; channel usernames reply |
||
917 | |||
918 | add esi, 4 ; skip '353 ' |
||
4477 | hidnplayr | 919 | call skip_parameter |
3545 | hidnplayr | 920 | inc esi ; channel type '*', '=' or '@' |
921 | inc esi ; ' ' |
||
3981 | hidnplayr | 922 | call window_open |
4623 | hidnplayr | 923 | test ebx, ebx |
924 | jz .fail |
||
3545 | hidnplayr | 925 | |
926 | ; now find window ptr and check if this is the first 353 message |
||
927 | mov ebx, [window_print] |
||
928 | test [ebx + window.flags], FLAG_RECEIVING_NAMES |
||
929 | jnz .add |
||
930 | |||
931 | or [ebx + window.flags], FLAG_RECEIVING_NAMES |
||
932 | ; mov [ebx + window.users], 0 |
||
933 | ; TODO: remove all users? |
||
934 | |||
935 | .add: |
||
936 | push esi |
||
937 | call user_add |
||
938 | pop esi |
||
939 | |||
940 | .namesloop: |
||
941 | lodsb |
||
942 | test al, al |
||
943 | jz .done |
||
944 | cmp al, ' ' ; names list is separated with spaces |
||
945 | jne .namesloop |
||
946 | jmp .add |
||
947 | |||
948 | .done: |
||
4143 | hidnplayr | 949 | call draw_channel_list |
4623 | hidnplayr | 950 | .fail: |
3545 | hidnplayr | 951 | |
952 | ret |
||
953 | |||
954 | |||
955 | |||
956 | |||
957 | |||
958 | cmd_366: ; channel usernames end |
||
959 | |||
960 | add esi, 4 ; skip '366 ' |
||
4477 | hidnplayr | 961 | call skip_parameter |
3981 | hidnplayr | 962 | call window_open |
4623 | hidnplayr | 963 | test ebx, ebx |
964 | jz .fail |
||
3545 | hidnplayr | 965 | and [ebx + window.flags], not FLAG_RECEIVING_NAMES |
4623 | hidnplayr | 966 | .fail: |
3545 | hidnplayr | 967 | |
968 | ret |
||
969 | |||
970 | |||
971 | |||
972 | |||
973 | cmd_topic: |
||
974 | |||
975 | add esi, 4 ; skip '332 ' |
||
4477 | hidnplayr | 976 | call skip_parameter |
3981 | hidnplayr | 977 | call window_open |
4623 | hidnplayr | 978 | test ebx, ebx |
979 | jz .fail |
||
3545 | hidnplayr | 980 | |
4143 | hidnplayr | 981 | if TIMESTAMP |
982 | call print_timestamp |
||
983 | end if |
||
984 | |||
3545 | hidnplayr | 985 | push esi |
4143 | hidnplayr | 986 | mov esi, topic_header |
4623 | hidnplayr | 987 | call print_asciiz |
3545 | hidnplayr | 988 | |
989 | mov esi, str_topic |
||
4623 | hidnplayr | 990 | call print_asciiz |
3545 | hidnplayr | 991 | |
992 | pop esi |
||
4623 | hidnplayr | 993 | call print_asciiz |
3545 | hidnplayr | 994 | |
4477 | hidnplayr | 995 | mov esi, str_topic_end |
4623 | hidnplayr | 996 | call print_asciiz |
3545 | hidnplayr | 997 | |
4623 | hidnplayr | 998 | .fail: |
999 | |||
3545 | hidnplayr | 1000 | ret |
1001 | |||
1002 | |||
1003 | cmd_333: |
||
1004 | |||
1005 | add esi, 4 ; skip '333 ' |
||
4622 | hidnplayr | 1006 | call skip_parameter |
3981 | hidnplayr | 1007 | call window_open |
4623 | hidnplayr | 1008 | test ebx, ebx |
1009 | jz .fail |
||
3545 | hidnplayr | 1010 | |
4143 | hidnplayr | 1011 | if TIMESTAMP |
1012 | call print_timestamp |
||
1013 | end if |
||
1014 | |||
3545 | hidnplayr | 1015 | push esi |
4143 | hidnplayr | 1016 | mov esi, topic_header |
4623 | hidnplayr | 1017 | call print_asciiz |
3545 | hidnplayr | 1018 | |
1019 | mov esi, str_setby |
||
4623 | hidnplayr | 1020 | call print_asciiz |
3545 | hidnplayr | 1021 | |
4623 | hidnplayr | 1022 | pop esi |
1023 | mov bl, '!' |
||
1024 | call print_string |
||
3545 | hidnplayr | 1025 | |
4623 | hidnplayr | 1026 | mov al, 10 |
1027 | call print_char |
||
3545 | hidnplayr | 1028 | |
1029 | .fail: |
||
4623 | hidnplayr | 1030 | |
3545 | hidnplayr | 1031 | ret |
1032 | |||
4623 | hidnplayr | 1033 | |
1034 | |||
4143 | hidnplayr | 1035 | cmd_322: ; LIST |
1036 | |||
3545 | hidnplayr | 1037 | add esi, 4 |
4477 | hidnplayr | 1038 | call skip_parameter |
3545 | hidnplayr | 1039 | |
4623 | hidnplayr | 1040 | push esi |
1041 | mov esi, str_list |
||
1042 | call window_open |
||
1043 | test ebx, ebx |
||
1044 | jz .fail |
||
1045 | |||
1046 | mov [window_active], ebx |
||
1047 | call draw_windowtabs |
||
1048 | pop esi |
||
1049 | call print_asciiz |
||
1050 | mov al, 10 |
||
1051 | call print_char |
||
1052 | |||
3545 | hidnplayr | 1053 | ret |
1054 | |||
4623 | hidnplayr | 1055 | .fail: |
1056 | pop esi |
||
1057 | |||
1058 | ret |
||
1059 | |||
4143 | hidnplayr | 1060 | cmd_323: ; LIST END |
3545 | hidnplayr | 1061 | |
1062 | ret' |