Rev 4659 | Rev 4981 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4659 | Rev 4710 | ||
---|---|---|---|
Line 11... | Line 11... | ||
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 12... | Line 12... | ||
12 | 12 | ||
Line 13... | Line 13... | ||
13 | 13 | ||
14 | user_parser: |
14 | user_parser: |
Line 15... | Line 15... | ||
15 | 15 | ||
16 | push [window_active] ; print to the current window |
16 | mov ebp, [window_active] ; print to the current window |
17 | pop [window_print] |
17 | mov [window_print], ebp |
18 | 18 | ||
Line 19... | Line 19... | ||
19 | mov eax, [edit1.size] |
19 | mov eax, [edit1.size] |
20 | test eax, eax |
20 | test eax, eax |
Line 21... | Line -... | ||
21 | jz .ret ; ignore empty commands |
- | |
22 | mov word[usercommand + eax], 0x0a0d ; terminate the line |
21 | jz .ret ; ignore empty commands |
23 | 22 | mov word[usercommand + eax], 0x0a0d ; terminate the line |
|
Line 24... | Line 23... | ||
24 | cmp byte[usercommand], '/' ; is it a server command ? |
23 | |
25 | je server_command |
24 | cmp byte[usercommand], '/' ; is it a server command ? |
- | 25 | je .command |
|
- | 26 | ||
Line -... | Line 27... | ||
- | 27 | cmp [status], STATUS_CONNECTED |
|
26 | 28 | jne .not_connected |
|
27 | ; Ignore data commands when not connected. |
29 | |
28 | cmp [status], STATUS_CONNECTED |
30 | cmp [ebp + window.type], WINDOWTYPE_CHANNEL |
Line 29... | Line 31... | ||
29 | jne .notconnected |
31 | je .send_privmsg |
Line 57... | Line 59... | ||
57 | 59 | ||
58 | ; and now send it to the server |
60 | ; and now send it to the server |
59 | mov dword[packetbuf], 'PRIV' |
61 | mov dword[packetbuf], 'PRIV' |
Line 60... | Line -... | ||
60 | mov dword[packetbuf+4], 'MSG ' |
- | |
61 | 62 | mov dword[packetbuf+4], 'MSG ' |
|
62 | mov esi, [window_active] |
63 | |
63 | add esi, window.name |
64 | lea esi, [ebp + window.name] |
64 | mov edi, packetbuf+8 |
65 | mov edi, packetbuf+8 |
65 | mov ecx, MAX_WINDOWNAME_LEN |
66 | mov ecx, MAX_WINDOWNAME_LEN |
66 | .loop: |
67 | .loop: |
Line 84... | Line 85... | ||
84 | mov ax, 0x0a0d |
85 | mov ax, 0x0a0d |
85 | stosw |
86 | stosw |
Line 86... | Line 87... | ||
86 | 87 | ||
87 | lea esi, [edi - packetbuf] |
88 | lea esi, [edi - packetbuf] |
88 | mcall send, [socketnum], packetbuf, , 0 |
- | |
89 | .ret: |
- | |
90 | - | ||
91 | ret |
- | |
92 | - | ||
93 | .notconnected: |
- | |
94 | mov esi, str_notconnected |
- | |
Line -... | Line 89... | ||
- | 89 | mcall send, [socketnum], packetbuf, , 0 |
|
95 | call print_asciiz |
90 | |
Line 96... | Line -... | ||
96 | - | ||
97 | ret |
- | |
98 | - | ||
99 | - | ||
100 | - | ||
101 | user_commands: |
- | |
102 | dd 'nick', cmd_usr_nick |
- | |
103 | dd 'real', cmd_usr_real |
- | |
104 | dd 'serv', cmd_usr_server |
- | |
105 | dd 'help', cmd_usr_help |
- | |
106 | dd 'code', cmd_usr_code |
- | |
107 | 91 | .ret: |
|
108 | .number2 = ($ - user_commands) / 8 |
- | |
109 | - | ||
110 | ; All following commands require a connection to the server. |
- | |
111 | dd 'quer', cmd_usr_quer |
- | |
112 | dd 'quit', cmd_usr_quit |
- | |
113 | dd 'part', cmd_usr_part |
- | |
114 | dd 'ctcp', cmd_usr_ctcp |
- | |
115 | dd 'msg ', cmd_usr_msg |
- | |
116 | - | ||
117 | .number = ($ - user_commands) / 8 |
92 | ret |
118 | - | ||
119 | 93 | ||
120 | server_command: |
94 | ; Text begins with a '/' lets try to find the command in the lookup table. |
Line 121... | Line 95... | ||
121 | 95 | .command: |
|
122 | mov eax, dword[usercommand+1] ; skip '/' |
96 | mov eax, dword[usercommand+1] ; skip '/' |
123 | or eax, 0x20202020 ; convert to lowercase |
97 | or eax, 0x20202020 ; convert to lowercase |
124 | 98 | ||
125 | mov edi, user_commands |
99 | mov edi, user_commands |
126 | mov ecx, user_commands.number |
100 | mov ecx, user_commands.number |
127 | cmp [status], STATUS_CONNECTED |
101 | cmp [status], STATUS_CONNECTED |
128 | je .loop |
102 | je .cmd_loop |
129 | mov ecx, user_commands.number2 |
103 | mov ecx, user_commands.number2 |
130 | .loop: |
104 | .cmd_loop: |
131 | scasd |
105 | scasd |
Line 132... | Line 106... | ||
132 | je .got_cmd |
106 | je .got_cmd |
133 | add edi, 4 |
107 | add edi, 4 |
- | 108 | dec ecx |
|
134 | dec ecx |
109 | jnz .cmd_loop |
135 | jnz .loop |
110 | |
136 | 111 | cmp [status], STATUS_CONNECTED |
|
137 | cmp [status], STATUS_CONNECTED |
112 | jne .not_connected |
Line 138... | Line 113... | ||
138 | jne .notconnected |
113 | |
- | 114 | ; Commands shorter then 3 chars are placed here |
|
Line 139... | Line 115... | ||
139 | ; Commands shorter then 3 chars are placed here |
115 | and eax, 0x00ffffff |
140 | and eax, 0x00ffffff |
116 | cmp eax, 'me ' |
Line 141... | Line 117... | ||
141 | cmp eax, 'me ' |
117 | je cmd_usr_me |
142 | je cmd_usr_me |
118 | |
143 | 119 | ; If none of the listed commands, send text straight to server |
|
- | 120 | jmp cmd_usr_send |
|
Line -... | Line 121... | ||
- | 121 | ||
- | 122 | .got_cmd: |
|
- | 123 | jmp dword[edi] |
|
144 | jmp cmd_usr_send ; If none of the previous commands, just send to server |
124 | |
Line -... | Line 125... | ||
- | 125 | .not_connected: |
|
- | 126 | mov esi, str_notconnected |
|
- | 127 | call print_asciiz |
|
- | 128 | ret |
|
- | 129 | ||
- | 130 | .not_channel: |
|
- | 131 | mov esi, str_notchannel |
|
- | 132 | call print_asciiz |
|
- | 133 | ret |
|
- | 134 | ||
- | 135 | ||
- | 136 | ; user commands lookup table |
|
- | 137 | user_commands: |
|
- | 138 | dd 'nick', cmd_usr_nick |
|
- | 139 | dd 'real', cmd_usr_real |
|
- | 140 | dd 'serv', cmd_usr_server |
|
- | 141 | dd 'help', cmd_usr_help |
|
- | 142 | dd 'code', cmd_usr_code |
|
- | 143 | ||
- | 144 | .number2 = ($ - user_commands) / 8 |
|
Line 145... | Line 145... | ||
145 | 145 | ||
Line 146... | Line 146... | ||
146 | .got_cmd: |
146 | ; All following commands require a connection to the server. |
Line 222... | Line 222... | ||
222 | ret |
222 | ret |
Line 223... | Line 223... | ||
223 | 223 | ||
224 | - | ||
Line -... | Line 224... | ||
- | 224 | ||
225 | 225 | ||
226 | cmd_usr_quit: |
226 | cmd_usr_quit: |
227 | mov esi, quit_msg |
227 | |
228 | - | ||
229 | cmp byte[usercommand+5], ' ' |
- | |
230 | jne .with_message |
- | |
231 | lea esi, [usercommand+6] |
- | |
232 | .with_message: |
- | |
233 | call cmd_usr_quit_server |
- | |
234 | - | ||
235 | mcall close, [socketnum] |
- | |
236 | mov [status], STATUS_DISCONNECTED |
- | |
237 | - | ||
238 | mov ecx, MAX_WINDOWS |
- | |
239 | mov edi, windows |
- | |
240 | .loop: |
- | |
241 | mov [window_print], edi |
- | |
242 | push edi ecx |
- | |
243 | call window_close |
- | |
244 | pop ecx edi |
- | |
245 | add edi, sizeof.window |
- | |
246 | dec ecx |
- | |
247 | jnz .loop |
- | |
Line 248... | Line 228... | ||
248 | 228 | mov esi, quit_msg |
|
249 | ret |
229 | cmp byte[usercommand+5], ' ' |
Line 250... | Line 230... | ||
250 | 230 | jne quit_server |
|
251 | 231 | lea esi, [usercommand+6] |
|
252 | 232 | ||
253 | ; esi = quit message |
233 | ; esi = quit message |
Line 272... | Line 252... | ||
272 | stosw |
252 | stosw |
Line 273... | Line 253... | ||
273 | 253 | ||
274 | lea esi, [edi - packetbuf] ; calculate length |
254 | lea esi, [edi - packetbuf] ; calculate length |
Line -... | Line 255... | ||
- | 255 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
|
- | 256 | ||
- | 257 | mov ebp, windows |
|
- | 258 | .window_loop: |
|
- | 259 | cmp [ebp + window.type], WINDOWTYPE_NONE |
|
- | 260 | je .next_window |
|
- | 261 | mov [window_print], ebp |
|
- | 262 | if TIMESTAMP |
|
- | 263 | call print_timestamp |
|
- | 264 | end if |
|
- | 265 | mov esi, str_disconnected |
|
- | 266 | call print_asciiz |
|
- | 267 | cmp [ebp + window.type], WINDOWTYPE_CHANNEL |
|
- | 268 | jne .next_window |
|
- | 269 | call user_remove_all |
|
- | 270 | .next_window: |
|
- | 271 | add ebp, sizeof.window |
|
- | 272 | cmp ebp, windows + (MAX_WINDOWS * sizeof.window) |
|
- | 273 | jb .window_loop |
|
- | 274 | ||
- | 275 | mov [status], STATUS_DISCONNECTED |
|
275 | mcall send, [socketnum], packetbuf, , 0 ; and finally send to server |
276 | mcall close, [socketnum] |
Line 366... | Line 367... | ||
366 | or eax, 0x00002020 |
367 | or eax, 0x00002020 |
367 | and eax, 0x00ffffff |
368 | and eax, 0x00ffffff |
368 | cmp eax, 'er ' |
369 | cmp eax, 'er ' |
369 | jne cmd_usr_send |
370 | jne cmd_usr_send |
Line -... | Line 371... | ||
- | 371 | ||
- | 372 | ; Server window is always first window in the list, switch to it. |
|
- | 373 | mov [window_print], windows |
|
- | 374 | mov [window_active], windows |
|
370 | 375 | ||
371 | mov ecx, [edit1.size] ; ok now set the address |
376 | mov ecx, [edit1.size] ; ok now set the address |
Line 372... | Line 377... | ||
372 | sub ecx, 8 |
377 | sub ecx, 8 |
373 | 378 |