Rev 6027 | Rev 9979 | 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 | user_parser: |
||
15 | |||
6027 | hidnplayr | 16 | mov ebp, [window_active] ; print to the current window |
4710 | hidnplayr | 17 | mov [window_print], ebp |
4143 | hidnplayr | 18 | |
6027 | hidnplayr | 19 | mov ecx, [edit1.size] |
20 | test ecx, ecx |
||
4477 | hidnplayr | 21 | jz .ret ; ignore empty commands |
3545 | hidnplayr | 22 | |
6027 | hidnplayr | 23 | mov esi, input_text |
24 | mov edi, user_command |
||
25 | call recode ; Convert to UTF-8 |
||
26 | mov word[edi], 0x0a0d ; terminate the line |
||
27 | sub edi, user_command |
||
28 | mov [user_command.size], edi |
||
29 | |||
30 | cmp byte[user_command], '/' ; is it a server command ? |
||
4710 | hidnplayr | 31 | je .command |
3545 | hidnplayr | 32 | |
6027 | hidnplayr | 33 | cmp [status], STATUS_LOGGED_IN |
34 | jne .not_loggedin |
||
3545 | hidnplayr | 35 | |
4710 | hidnplayr | 36 | cmp [ebp + window.type], WINDOWTYPE_CHANNEL |
37 | je .send_privmsg |
||
38 | cmp [ebp + window.type], WINDOWTYPE_CHAT |
||
39 | jne .not_channel |
||
3545 | hidnplayr | 40 | |
4710 | hidnplayr | 41 | .send_privmsg: |
4143 | hidnplayr | 42 | if TIMESTAMP |
3545 | hidnplayr | 43 | call print_timestamp |
4143 | hidnplayr | 44 | end if |
3545 | hidnplayr | 45 | |
4623 | hidnplayr | 46 | mov al, '<' |
47 | call print_char |
||
3545 | hidnplayr | 48 | |
49 | mov esi, user_nick |
||
4623 | hidnplayr | 50 | call print_asciiz |
3545 | hidnplayr | 51 | |
4623 | hidnplayr | 52 | mov al, '>' |
53 | call print_char |
||
54 | mov al, ' ' |
||
55 | call print_char |
||
3545 | hidnplayr | 56 | |
6027 | hidnplayr | 57 | mov eax, [user_command.size] |
58 | mov byte[user_command + eax],0 |
||
59 | mov esi, user_command |
||
4623 | hidnplayr | 60 | call print_asciiz |
3545 | hidnplayr | 61 | |
4623 | hidnplayr | 62 | mov al, 10 |
63 | call print_char |
||
3545 | hidnplayr | 64 | |
65 | ; and now send it to the server |
||
4143 | hidnplayr | 66 | mov dword[packetbuf], 'PRIV' |
67 | mov dword[packetbuf+4], 'MSG ' |
||
3545 | hidnplayr | 68 | |
4710 | hidnplayr | 69 | lea esi, [ebp + window.name] |
3545 | hidnplayr | 70 | mov edi, packetbuf+8 |
71 | mov ecx, MAX_WINDOWNAME_LEN |
||
72 | .loop: |
||
73 | lodsb |
||
74 | test al, al |
||
75 | jz .done |
||
76 | stosb |
||
77 | dec ecx |
||
78 | jnz .loop |
||
79 | .done: |
||
80 | |||
81 | mov ax, ' :' |
||
82 | stosw |
||
83 | |||
6027 | hidnplayr | 84 | mov esi, user_command |
85 | mov ecx, [user_command.size] |
||
86 | ; inc ecx |
||
87 | rep movsb |
||
3545 | hidnplayr | 88 | |
4143 | hidnplayr | 89 | ; end the command with a CRLF |
90 | mov ax, 0x0a0d |
||
91 | stosw |
||
3545 | hidnplayr | 92 | |
93 | lea esi, [edi - packetbuf] |
||
94 | mcall send, [socketnum], packetbuf, , 0 |
||
4710 | hidnplayr | 95 | |
4477 | hidnplayr | 96 | .ret: |
97 | ret |
||
3545 | hidnplayr | 98 | |
4710 | hidnplayr | 99 | ; Text begins with a '/' lets try to find the command in the lookup table. |
100 | .command: |
||
6027 | hidnplayr | 101 | mov eax, dword[user_command+1] ; skip '/' |
4477 | hidnplayr | 102 | or eax, 0x20202020 ; convert to lowercase |
3545 | hidnplayr | 103 | |
104 | mov edi, user_commands |
||
105 | mov ecx, user_commands.number |
||
4477 | hidnplayr | 106 | cmp [status], STATUS_CONNECTED |
6027 | hidnplayr | 107 | jae .cmd_loop |
4477 | hidnplayr | 108 | mov ecx, user_commands.number2 |
4710 | hidnplayr | 109 | .cmd_loop: |
3545 | hidnplayr | 110 | scasd |
111 | je .got_cmd |
||
112 | add edi, 4 |
||
113 | dec ecx |
||
4710 | hidnplayr | 114 | jnz .cmd_loop |
3545 | hidnplayr | 115 | |
4477 | hidnplayr | 116 | cmp [status], STATUS_CONNECTED |
6027 | hidnplayr | 117 | jb .not_connected |
4710 | hidnplayr | 118 | |
4659 | hidnplayr | 119 | ; Commands shorter then 3 chars are placed here |
120 | and eax, 0x00ffffff |
||
121 | cmp eax, 'me ' |
||
122 | je cmd_usr_me |
||
4477 | hidnplayr | 123 | |
4710 | hidnplayr | 124 | ; If none of the listed commands, send text straight to server |
125 | jmp cmd_usr_send |
||
4477 | hidnplayr | 126 | |
3545 | hidnplayr | 127 | .got_cmd: |
128 | jmp dword[edi] |
||
129 | |||
6027 | hidnplayr | 130 | .not_loggedin: |
131 | mov esi, str_notloggedin |
||
132 | call print_asciiz |
||
133 | ret |
||
134 | |||
4710 | hidnplayr | 135 | .not_connected: |
4477 | hidnplayr | 136 | mov esi, str_notconnected |
4623 | hidnplayr | 137 | call print_asciiz |
4710 | hidnplayr | 138 | ret |
3545 | hidnplayr | 139 | |
4710 | hidnplayr | 140 | .not_channel: |
141 | mov esi, str_notchannel |
||
142 | call print_asciiz |
||
4477 | hidnplayr | 143 | ret |
3545 | hidnplayr | 144 | |
145 | |||
4710 | hidnplayr | 146 | ; user commands lookup table |
147 | user_commands: |
||
148 | dd 'nick', cmd_usr_nick |
||
149 | dd 'real', cmd_usr_real |
||
150 | dd 'serv', cmd_usr_server |
||
151 | dd 'help', cmd_usr_help |
||
152 | dd 'code', cmd_usr_code |
||
3545 | hidnplayr | 153 | |
4710 | hidnplayr | 154 | .number2 = ($ - user_commands) / 8 |
155 | |||
156 | ; All following commands require a connection to the server. |
||
157 | dd 'quer', cmd_usr_quer |
||
158 | dd 'quit', cmd_usr_quit |
||
159 | dd 'part', cmd_usr_part |
||
160 | dd 'ctcp', cmd_usr_ctcp |
||
161 | dd 'msg ', cmd_usr_msg |
||
162 | |||
163 | .number = ($ - user_commands) / 8 |
||
164 | |||
165 | |||
166 | |||
4143 | hidnplayr | 167 | cmd_usr_msg: |
168 | |||
6027 | hidnplayr | 169 | lea esi, [user_command+5] |
4143 | hidnplayr | 170 | |
171 | mov dword[packetbuf], 'PRIV' |
||
172 | mov dword[packetbuf+4], 'MSG ' |
||
173 | lea edi, [packetbuf+8] |
||
174 | |||
175 | @@: |
||
176 | lodsb |
||
177 | test al, al |
||
178 | jz .fail |
||
179 | cmp al, 10 |
||
180 | je .fail |
||
181 | cmp al, 13 |
||
182 | je .fail |
||
183 | stosb |
||
184 | cmp al, ' ' |
||
185 | jne @r |
||
186 | |||
187 | mov al, ':' |
||
188 | stosb |
||
189 | |||
190 | push edi |
||
191 | @@: |
||
192 | lodsb |
||
193 | test al, al |
||
194 | jz @f |
||
195 | cmp al, 10 |
||
196 | je @f |
||
197 | cmp al, 13 |
||
198 | je @f |
||
199 | stosb |
||
200 | jmp @r |
||
201 | @@: |
||
202 | ; end the command with a CRLF |
||
203 | mov ax, 0x0a0d |
||
204 | stosw |
||
205 | mov byte[edi], 0 |
||
206 | |||
207 | ; now print to the window |
||
208 | if TIMESTAMP |
||
209 | call print_timestamp |
||
210 | end if |
||
211 | |||
212 | mov esi, msg_header |
||
4623 | hidnplayr | 213 | call print_asciiz |
4143 | hidnplayr | 214 | |
4623 | hidnplayr | 215 | mov esi, packetbuf+8 |
216 | mov bl, ' ' |
||
217 | call print_string |
||
4143 | hidnplayr | 218 | |
4623 | hidnplayr | 219 | mov al, '*' |
220 | call print_char |
||
4143 | hidnplayr | 221 | |
4623 | hidnplayr | 222 | mov al, ' ' |
223 | call print_char |
||
4143 | hidnplayr | 224 | |
225 | pop esi |
||
7300 | hidnplayr | 226 | push esi |
4623 | hidnplayr | 227 | call print_asciiz |
7300 | hidnplayr | 228 | pop esi |
4143 | hidnplayr | 229 | |
7300 | hidnplayr | 230 | |
231 | lea esi, [edi - packetbuf] |
||
232 | mcall send, [socketnum], packetbuf, , 0 |
||
233 | |||
4143 | hidnplayr | 234 | .fail: |
235 | ret |
||
236 | |||
237 | |||
238 | |||
3545 | hidnplayr | 239 | cmd_usr_quit: |
4710 | hidnplayr | 240 | |
3981 | hidnplayr | 241 | mov esi, quit_msg |
6027 | hidnplayr | 242 | cmp byte[user_command+5], ' ' |
4710 | hidnplayr | 243 | jne quit_server |
6027 | hidnplayr | 244 | lea esi, [user_command+6] |
3545 | hidnplayr | 245 | |
3981 | hidnplayr | 246 | ; esi = quit message |
4710 | hidnplayr | 247 | quit_server: |
3545 | hidnplayr | 248 | |
3981 | hidnplayr | 249 | ; User wants to close a channel, send PART command to server |
250 | mov dword[packetbuf], 'QUIT' |
||
251 | mov word[packetbuf+4], ' :' |
||
252 | lea edi, [packetbuf+6] |
||
253 | ; Append our quit msg |
||
254 | @@: |
||
255 | lodsb |
||
4143 | hidnplayr | 256 | cmp al, 13 |
257 | je @f |
||
258 | test al, al |
||
259 | jz @f |
||
3981 | hidnplayr | 260 | stosb |
4143 | hidnplayr | 261 | jmp @r |
262 | @@: |
||
3981 | hidnplayr | 263 | ; end the command with a CRLF |
264 | mov ax, 0x0a0d |
||
265 | stosw |
||
266 | |||
267 | lea esi, [edi - packetbuf] ; calculate length |
||
268 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
||
269 | |||
4710 | hidnplayr | 270 | mov ebp, windows |
271 | .window_loop: |
||
272 | cmp [ebp + window.type], WINDOWTYPE_NONE |
||
273 | je .next_window |
||
274 | mov [window_print], ebp |
||
275 | if TIMESTAMP |
||
276 | call print_timestamp |
||
277 | end if |
||
278 | mov esi, str_disconnected |
||
279 | call print_asciiz |
||
280 | cmp [ebp + window.type], WINDOWTYPE_CHANNEL |
||
281 | jne .next_window |
||
282 | call user_remove_all |
||
283 | .next_window: |
||
284 | add ebp, sizeof.window |
||
285 | cmp ebp, windows + (MAX_WINDOWS * sizeof.window) |
||
286 | jb .window_loop |
||
287 | |||
288 | mov [status], STATUS_DISCONNECTED |
||
289 | mcall close, [socketnum] |
||
290 | |||
3981 | hidnplayr | 291 | ret |
292 | |||
293 | |||
294 | |||
295 | |||
3545 | hidnplayr | 296 | cmd_usr_nick: |
297 | |||
6027 | hidnplayr | 298 | cmp [user_command.size], 5 |
4981 | hidnplayr | 299 | je .justprint |
6027 | hidnplayr | 300 | cmp byte[user_command+5], ' ' |
4143 | hidnplayr | 301 | jne .fail |
302 | cmp [socketnum], 0 |
||
303 | je .dontsend |
||
3545 | hidnplayr | 304 | |
4617 | hidnplayr | 305 | ; Request nickname change to server |
6027 | hidnplayr | 306 | mov dword[user_command+1], 'NICK' |
307 | mov esi, [user_command.size] |
||
308 | mov word[user_command + esi], 0x0a0d |
||
4143 | hidnplayr | 309 | inc esi |
6027 | hidnplayr | 310 | mcall send, [socketnum], user_command+1, , 0 |
4143 | hidnplayr | 311 | |
312 | .fail: |
||
313 | ret |
||
314 | |||
4617 | hidnplayr | 315 | ; We arent logged in yet, directly change user_nick field and print notification to user. |
4143 | hidnplayr | 316 | .dontsend: |
3545 | hidnplayr | 317 | mov ecx, MAX_NICK_LEN |
6027 | hidnplayr | 318 | mov esi, user_command+6 |
3545 | hidnplayr | 319 | mov edi, user_nick |
4143 | hidnplayr | 320 | @@: |
3545 | hidnplayr | 321 | lodsb |
322 | cmp al, 13 |
||
4143 | hidnplayr | 323 | je @f |
3545 | hidnplayr | 324 | stosb |
325 | dec ecx |
||
4143 | hidnplayr | 326 | jnz @r |
327 | @@: |
||
3545 | hidnplayr | 328 | xor al, al |
329 | stosb |
||
330 | |||
4981 | hidnplayr | 331 | .justprint: |
3545 | hidnplayr | 332 | mov esi, str_nickchange |
4623 | hidnplayr | 333 | call print_asciiz |
334 | |||
3545 | hidnplayr | 335 | mov esi, user_nick |
4623 | hidnplayr | 336 | call print_asciiz |
3545 | hidnplayr | 337 | |
4623 | hidnplayr | 338 | mov al, 10 |
339 | call print_char |
||
340 | |||
3545 | hidnplayr | 341 | ret |
342 | |||
343 | |||
344 | |||
345 | cmd_usr_real: |
||
346 | |||
6027 | hidnplayr | 347 | cmp byte[user_command+5], ' ' |
3545 | hidnplayr | 348 | jne cmd_usr_send |
349 | |||
350 | mov ecx, MAX_REAL_LEN |
||
6027 | hidnplayr | 351 | mov esi, user_command+6 |
3545 | hidnplayr | 352 | mov edi, user_real_name |
353 | .loop: |
||
354 | lodsb |
||
355 | cmp al, 13 |
||
356 | je .done |
||
357 | stosb |
||
358 | dec ecx |
||
359 | jnz .loop |
||
360 | .done: |
||
361 | xor al, al |
||
362 | stosb |
||
363 | |||
364 | mov esi, str_realchange |
||
4623 | hidnplayr | 365 | call print_asciiz |
366 | |||
3545 | hidnplayr | 367 | mov esi, user_real_name |
4623 | hidnplayr | 368 | call print_asciiz |
3545 | hidnplayr | 369 | |
4623 | hidnplayr | 370 | mov al, 10 |
371 | call print_char |
||
372 | |||
3545 | hidnplayr | 373 | ret |
374 | |||
375 | |||
376 | |||
377 | cmd_usr_server: |
||
378 | |||
6027 | hidnplayr | 379 | mov eax, dword[user_command+5] ; check for 'er ', we only checked 'serv' |
3545 | hidnplayr | 380 | or eax, 0x00002020 |
381 | and eax, 0x00ffffff |
||
382 | cmp eax, 'er ' |
||
383 | jne cmd_usr_send |
||
384 | |||
4710 | hidnplayr | 385 | ; Server window is always first window in the list, switch to it. |
386 | mov [window_print], windows |
||
387 | mov [window_active], windows |
||
388 | |||
6027 | hidnplayr | 389 | mov ecx, [user_command.size] ; ok now set the address |
3545 | hidnplayr | 390 | sub ecx, 8 |
391 | |||
6027 | hidnplayr | 392 | mov esi, user_command+8 |
4477 | hidnplayr | 393 | .now: |
3545 | hidnplayr | 394 | push esi |
395 | mov edi, irc_server_name |
||
4477 | hidnplayr | 396 | .loop: ; copy until zero byte, or ecx reaches zero. |
397 | lodsb |
||
398 | stosb |
||
399 | test al, al |
||
400 | jz .done |
||
401 | dec ecx |
||
402 | jnz .loop |
||
3545 | hidnplayr | 403 | xor al, al |
404 | stosb |
||
4477 | hidnplayr | 405 | .done: |
3545 | hidnplayr | 406 | pop esi |
407 | |||
408 | ; set it also in window name |
||
409 | mov ebx, [window_print] |
||
410 | call window_set_name |
||
411 | |||
412 | ; now connect |
||
413 | call socket_connect |
||
414 | |||
415 | ret |
||
416 | |||
417 | |||
418 | cmd_usr_quer: |
||
419 | |||
6027 | hidnplayr | 420 | mov esi, user_command+7 |
4477 | hidnplayr | 421 | call window_open |
4623 | hidnplayr | 422 | ; test ebx, ebx |
423 | ; jz .fail |
||
3545 | hidnplayr | 424 | |
425 | ret |
||
426 | |||
427 | |||
428 | |||
429 | cmd_usr_help: |
||
430 | |||
431 | mov esi, str_help |
||
4623 | hidnplayr | 432 | call print_asciiz |
3545 | hidnplayr | 433 | |
434 | ret |
||
435 | |||
436 | |||
437 | |||
438 | cmd_usr_code: |
||
439 | |||
440 | ; TODO |
||
441 | |||
442 | ret |
||
443 | |||
444 | |||
445 | |||
3981 | hidnplayr | 446 | ; User typed a part command |
447 | cmd_usr_part: |
||
448 | |||
6027 | hidnplayr | 449 | cmp byte[user_command+5], 13 ; parameters given? |
4143 | hidnplayr | 450 | jne cmd_usr_send ; yes, send command straight to server |
3981 | hidnplayr | 451 | |
4143 | hidnplayr | 452 | ; close active window |
453 | cmd_usr_close_window: |
||
454 | |||
455 | mov esi, [window_active] |
||
6026 | hidnplayr | 456 | mov [window_print], esi |
3981 | hidnplayr | 457 | cmp [esi + window.type], WINDOWTYPE_SERVER |
4143 | hidnplayr | 458 | je .not_channel |
3981 | hidnplayr | 459 | |
4143 | hidnplayr | 460 | lea esi, [esi + window.name] |
461 | call cmd_usr_part_channel |
||
462 | call window_close |
||
463 | ret |
||
3981 | hidnplayr | 464 | |
4143 | hidnplayr | 465 | .not_channel: |
466 | cmp [esi + window.type], WINDOWTYPE_CHAT |
||
467 | jne .not_chat |
||
468 | |||
469 | call window_close |
||
470 | .not_chat: |
||
471 | |||
3981 | hidnplayr | 472 | ret |
473 | |||
4143 | hidnplayr | 474 | |
475 | |||
3981 | hidnplayr | 476 | ; Send part command to server |
477 | ; esi must point to channel name (ASCIIZ) |
||
478 | cmd_usr_part_channel: |
||
479 | |||
480 | ; User wants to close a channel, send PART command to server |
||
481 | mov dword[packetbuf], 'PART' |
||
482 | mov byte[packetbuf+4], ' ' |
||
483 | lea edi, [packetbuf+5] |
||
484 | @@: |
||
485 | lodsb |
||
4143 | hidnplayr | 486 | test al, al |
487 | jz @f |
||
488 | cmp al, 13 |
||
489 | je @f |
||
490 | cmp al, 10 |
||
491 | je @f |
||
3981 | hidnplayr | 492 | stosb |
4143 | hidnplayr | 493 | jmp @r |
494 | @@: |
||
3981 | hidnplayr | 495 | ; end the command with a CRLF |
496 | mov ax, 0x0a0d |
||
497 | stosw |
||
498 | |||
499 | lea esi, [edi - packetbuf] ; calculate length |
||
500 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
||
501 | |||
502 | ret |
||
503 | |||
504 | |||
4477 | hidnplayr | 505 | |
4143 | hidnplayr | 506 | cmd_usr_ctcp: |
507 | |||
6027 | hidnplayr | 508 | cmp byte[user_command+5], ' ' |
4143 | hidnplayr | 509 | jne cmd_usr_send |
510 | |||
6027 | hidnplayr | 511 | mov esi, user_command+6 |
4143 | hidnplayr | 512 | ; prepare a 'PRIVMSG ' |
513 | mov dword[packetbuf], 'PRIV' |
||
514 | mov dword[packetbuf+4], 'MSG ' |
||
515 | lea edi, [packetbuf+8] |
||
516 | |||
517 | ; append the destination (nickname/channel) |
||
518 | @@: |
||
519 | lodsb |
||
520 | test al, al |
||
521 | jz .fail |
||
522 | cmp al, ' ' |
||
523 | je @f |
||
524 | stosb |
||
525 | jmp @r |
||
526 | @@: |
||
527 | |||
528 | mov ax, ' :' |
||
529 | stosw |
||
530 | mov al, 0x01 |
||
531 | stosb |
||
532 | |||
7300 | hidnplayr | 533 | push edi esi |
534 | |||
4143 | hidnplayr | 535 | ; copy the message itself |
536 | @@: |
||
537 | lodsb |
||
538 | test al, al |
||
539 | jz @f |
||
540 | cmp al, 13 |
||
541 | je @f |
||
542 | cmp al, 10 |
||
543 | je @f |
||
544 | stosb |
||
545 | jmp @r |
||
546 | @@: |
||
547 | |||
548 | ; end of message |
||
549 | mov al, 0x01 |
||
550 | stosb |
||
551 | mov ax, 0x0a0d |
||
552 | stosw |
||
7300 | hidnplayr | 553 | mov byte[edi], 0 |
4143 | hidnplayr | 554 | |
7300 | hidnplayr | 555 | ; now print to the window |
556 | if TIMESTAMP |
||
557 | call print_timestamp |
||
558 | end if |
||
559 | |||
560 | mov esi, ctcp_header |
||
561 | call print_asciiz |
||
562 | |||
563 | mov esi, packetbuf+8 |
||
564 | mov bl, ' ' |
||
565 | call print_string |
||
566 | |||
567 | mov al, ']' |
||
568 | call print_char |
||
569 | |||
570 | mov al, ' ' |
||
571 | call print_char |
||
572 | |||
573 | pop esi |
||
574 | call print_asciiz |
||
575 | pop esi |
||
576 | |||
577 | |||
4143 | hidnplayr | 578 | ; now send it away |
579 | lea esi, [edi - packetbuf] ; calculate length |
||
580 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
||
581 | |||
582 | .fail: |
||
583 | |||
584 | ret |
||
585 | |||
586 | |||
4477 | hidnplayr | 587 | |
4659 | hidnplayr | 588 | cmd_usr_me: |
589 | |||
590 | ; prepare a 'PRIVMSG ' |
||
591 | mov dword[packetbuf], 'PRIV' |
||
592 | mov dword[packetbuf+4], 'MSG ' |
||
593 | lea edi, [packetbuf+8] |
||
594 | |||
595 | ; append the destination (nickname/channel) |
||
596 | mov esi, [window_active] |
||
597 | lea esi, [esi + window.name] |
||
598 | @@: |
||
599 | lodsb |
||
600 | test al, al |
||
601 | je @f |
||
602 | stosb |
||
603 | jmp @r |
||
604 | @@: |
||
605 | |||
606 | ; Make the CTCP action header |
||
607 | mov eax, ' :' + 0x01 shl 16 + 'A' shl 24 |
||
608 | stosd |
||
609 | mov eax, 'CTIO' |
||
610 | stosd |
||
611 | mov al, 'N' |
||
612 | stosb |
||
613 | |||
614 | ; copy the message itself (including first space) |
||
6027 | hidnplayr | 615 | mov esi, user_command+3 |
4659 | hidnplayr | 616 | @@: |
617 | lodsb |
||
618 | cmp al, 13 |
||
619 | je @f |
||
620 | stosb |
||
621 | jmp @r |
||
622 | @@: |
||
623 | |||
624 | ; end of CTCP message |
||
625 | mov al, 0x01 |
||
626 | stosb |
||
627 | mov ax, 0x0a0d |
||
628 | stosw |
||
629 | |||
630 | ; now send it to the server |
||
631 | lea esi, [edi - packetbuf] ; calculate length |
||
632 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
||
633 | |||
634 | ; print to local window |
||
635 | if TIMESTAMP |
||
636 | call print_timestamp |
||
637 | end if |
||
638 | |||
639 | mov esi, action_header |
||
640 | call print_asciiz |
||
641 | |||
642 | mov esi, user_nick |
||
643 | call print_asciiz |
||
644 | |||
6027 | hidnplayr | 645 | mov esi, user_command+3 |
4659 | hidnplayr | 646 | mov bl, 13 |
647 | call print_string |
||
648 | |||
649 | mov al, 10 |
||
650 | call print_char |
||
651 | |||
652 | ret |
||
653 | |||
654 | |||
655 | |||
6027 | hidnplayr | 656 | ; The user typed some undefined command, just send it to the server |
3545 | hidnplayr | 657 | cmd_usr_send: |
658 | |||
6027 | hidnplayr | 659 | mov esi, [user_command.size] |
660 | mov eax, [user_command.size] |
||
661 | add eax, user_command+1 |
||
662 | mov word[eax], 0x0d0a |
||
663 | inc esi |
||
664 | mcall send, [socketnum], user_command+1, , 0 |
||
3545 | hidnplayr | 665 | |
666 | ret' |
||
667 | |||
4143 | hidnplayr | 668 |