diff options
Diffstat (limited to 'vchat-commands.c')
-rw-r--r--[-rwxr-xr-x] | vchat-commands.c | 523 |
1 files changed, 257 insertions, 266 deletions
diff --git a/vchat-commands.c b/vchat-commands.c index 06c9010..3ef3132 100755..100644 --- a/vchat-commands.c +++ b/vchat-commands.c | |||
@@ -10,26 +10,29 @@ | |||
10 | * without even the implied warranty of merchantability or fitness for a | 10 | * without even the implied warranty of merchantability or fitness for a |
11 | * particular purpose. In no event shall the copyright holder be liable for | 11 | * particular purpose. In no event shall the copyright holder be liable for |
12 | * any direct, indirect, incidental or special damages arising in any way out | 12 | * any direct, indirect, incidental or special damages arising in any way out |
13 | * of the use of this software. | 13 | * of the use of this software. |
14 | * | 14 | * |
15 | */ | 15 | */ |
16 | 16 | ||
17 | /* general includes */ | 17 | /* general includes */ |
18 | #include <stdlib.h> | ||
19 | #include <unistd.h> | ||
20 | #include <errno.h> | 18 | #include <errno.h> |
21 | #include <stdio.h> | 19 | #include <stdio.h> |
20 | #include <stdlib.h> | ||
22 | #include <string.h> | 21 | #include <string.h> |
23 | #include <sys/stat.h> | 22 | #include <sys/stat.h> |
23 | #include <unistd.h> | ||
24 | |||
24 | #include <readline/readline.h> | 25 | #include <readline/readline.h> |
25 | 26 | ||
26 | /* local includes */ | 27 | /* local includes */ |
27 | #include "vchat.h" | 28 | #include "vchat-connection.h" |
28 | #include "vchat-help.h" | 29 | #include "vchat-help.h" |
29 | #include "vchat-user.h" | 30 | #include "vchat-user.h" |
31 | #include "vchat.h" | ||
30 | 32 | ||
31 | /* version of this module */ | 33 | /* version of this module */ |
32 | const char *vchat_cm_version = "vchat-commands.c $Id$"; | 34 | const char *vchat_cm_version = |
35 | "vchat-commands.c $Id$"; | ||
33 | 36 | ||
34 | /* from vchat-client.c */ | 37 | /* from vchat-client.c */ |
35 | extern int ownquit; | 38 | extern int ownquit; |
@@ -38,45 +41,45 @@ extern int status; | |||
38 | 41 | ||
39 | /* our "/command " table */ | 42 | /* our "/command " table */ |
40 | enum { | 43 | enum { |
41 | COMMAND_VERSION, | 44 | COMMAND_VERSION, |
42 | COMMAND_FILTERS, | 45 | COMMAND_FILTERS, |
43 | COMMAND_LSFLT, | 46 | COMMAND_LSFLT, |
44 | COMMAND_RMFLT, | 47 | COMMAND_RMFLT, |
45 | COMMAND_CLFLT, | 48 | COMMAND_CLFLT, |
46 | COMMAND_HELP, | 49 | COMMAND_HELP, |
47 | COMMAND_FORMAT, | 50 | COMMAND_FORMAT, |
48 | COMMAND_KEYS, | 51 | COMMAND_KEYS, |
49 | COMMAND_QUIT, | 52 | COMMAND_QUIT, |
50 | COMMAND_USER, | 53 | COMMAND_USER, |
51 | COMMAND_DICT, | 54 | COMMAND_DICT, |
52 | COMMAND_FLT, | 55 | COMMAND_FLT, |
53 | COMMAND_PM, | 56 | COMMAND_PM, |
54 | COMMAND_ACTION, | 57 | COMMAND_ACTION, |
55 | COMMAND_PMSHORT, | 58 | COMMAND_PMSHORT, |
56 | COMMAND_QUERY, | 59 | COMMAND_QUERY, |
57 | COMMAND_QUITSHORT, | 60 | COMMAND_QUITSHORT, |
58 | COMMAND_PLAIN, | 61 | COMMAND_PLAIN, |
59 | COMMAND_RECONNECT, | 62 | COMMAND_RECONNECT, |
60 | COMMAND_NONE | 63 | COMMAND_NONE |
61 | }; | 64 | }; |
62 | 65 | ||
63 | static void command_quit ( char *tail); | 66 | static void command_quit(char *tail); |
64 | static void command_user ( char *tail); | 67 | static void command_user(char *tail); |
65 | static void command_pm ( char *tail); | 68 | static void command_pm(char *tail); |
66 | static void command_action ( char *tail); | 69 | static void command_action(char *tail); |
67 | static void command_help ( char *tail); | 70 | static void command_help(char *tail); |
68 | static void command_format ( char *tail); | 71 | static void command_format(char *tail); |
69 | static void command_flt ( char *tail); | 72 | static void command_flt(char *tail); |
70 | static void command_lsflt ( char *tail); | 73 | static void command_lsflt(char *tail); |
71 | static void command_clflt ( char *tail); | 74 | static void command_clflt(char *tail); |
72 | static void command_rmflt ( char *tail); | 75 | static void command_rmflt(char *tail); |
73 | void command_version ( char *tail); | 76 | void command_version(char *tail); |
74 | static void command_none ( char *line); | 77 | static void command_none(char *line); |
75 | static void command_query ( char *tail); | 78 | static void command_query(char *tail); |
76 | static void command_reconnect ( char *tail); | 79 | static void command_reconnect(char *tail); |
77 | static void command_dict ( char *tail); | 80 | static void command_dict(char *tail); |
78 | 81 | ||
79 | static void output_default ( char *tail); | 82 | static void output_default(char *tail); |
80 | 83 | ||
81 | /* commandentry defined in vchat.h */ | 84 | /* commandentry defined in vchat.h */ |
82 | 85 | ||
@@ -105,9 +108,7 @@ commandtable[] = { | |||
105 | }; | 108 | }; |
106 | 109 | ||
107 | /* parse "/command" */ | 110 | /* parse "/command" */ |
108 | static int | 111 | static int translatecommand(char **cmd) { |
109 | translatecommand( char **cmd) | ||
110 | { | ||
111 | int result; | 112 | int result; |
112 | int cut = 0; | 113 | int cut = 0; |
113 | int maxcut = 0; | 114 | int maxcut = 0; |
@@ -115,214 +116,215 @@ translatecommand( char **cmd) | |||
115 | /* We do only want to allow Command abbrevation to | 116 | /* We do only want to allow Command abbrevation to |
116 | the next newline, so that /VRES won't expand to /V RES */ | 117 | the next newline, so that /VRES won't expand to /V RES */ |
117 | 118 | ||
118 | while( (*cmd)[maxcut] && ((*cmd)[maxcut] != 0x20) && ((*cmd)[maxcut] != '\n')) maxcut++; | 119 | while ((*cmd)[maxcut] && ((*cmd)[maxcut] != 0x20) && ((*cmd)[maxcut] != '\n')) |
119 | if( maxcut ) maxcut--; | 120 | maxcut++; |
121 | if (maxcut) | ||
122 | maxcut--; | ||
120 | 123 | ||
121 | /* Repeatedly scan command table for command, with growing abbrevation cut off */ | 124 | /* Repeatedly scan command table for command, with growing abbrevation cut off |
125 | */ | ||
122 | do { | 126 | do { |
123 | /* Looks ugly, needs rewrite for better understanding */ | 127 | /* Looks ugly, needs rewrite for better understanding */ |
124 | for( result = 0; | 128 | for (result = 0; |
125 | (result != COMMAND_NONE) && | 129 | (result != COMMAND_NONE) && |
126 | (strncasecmp(*cmd, commandtable[result].name, commandtable[result].len - | 130 | (strncasecmp( |
127 | ((commandtable[result].len - maxcut - cut > 0) ? cut : 0))); | 131 | *cmd, commandtable[result].name, |
128 | result++); | 132 | commandtable[result].len - |
129 | } while ((cut < commandtable[0].len) && (commandtable[result].number == COMMAND_NONE) && (++cut)); | 133 | ((commandtable[result].len - maxcut - cut > 0) ? cut : 0))); |
134 | result++) | ||
135 | ; | ||
136 | } while ((cut < commandtable[0].len) && | ||
137 | (commandtable[result].number == COMMAND_NONE) && (++cut)); | ||
130 | 138 | ||
131 | /* Just leave the tail... */ | 139 | /* Just leave the tail... */ |
132 | (*cmd) += commandtable[result].len; | 140 | (*cmd) += commandtable[result].len; |
133 | 141 | ||
134 | /* ... whose start may be affected by abbrevation */ | 142 | /* ... whose start may be affected by abbrevation */ |
135 | if( commandtable[result].number != COMMAND_NONE ) | 143 | if (commandtable[result].number != COMMAND_NONE) |
136 | (*cmd) -= cut; | 144 | (*cmd) -= cut; |
137 | 145 | ||
138 | return result; | 146 | return result; |
139 | } | 147 | } |
140 | 148 | ||
141 | /* handle thought */ | 149 | /* handle thought */ |
142 | static void | 150 | static void dothink(const char *tail, const char nice) { |
143 | dothink( char *tail, char nice ) | 151 | while (*tail == ' ') |
144 | { | 152 | tail++; |
145 | while( *tail == ' ' ) tail++; | ||
146 | 153 | ||
147 | /* send users message to server */ | 154 | /* send users message to server */ |
148 | snprintf (tmpstr, TMPSTRSIZE, ".%c %s", nice, tail); | 155 | snprintf(tmpstr, TMPSTRSIZE, ".%c %s", nice, tail); |
149 | networkoutput (tmpstr); | 156 | vc_sendmessage(tmpstr); |
150 | 157 | ||
151 | /* show action in channel window */ | 158 | /* show action in channel window */ |
152 | snprintf (tmpstr, TMPSTRSIZE, nice == 'O' ? getformatstr(FS_TXPUBNTHOUGHT) : getformatstr(FS_TXPUBTHOUGHT), tail); | 159 | snprintf(tmpstr, TMPSTRSIZE, |
153 | writechan (tmpstr); | 160 | nice == 'O' ? getformatstr(FS_TXPUBNTHOUGHT) |
161 | : getformatstr(FS_TXPUBTHOUGHT), | ||
162 | tail); | ||
163 | writechan(tmpstr); | ||
154 | } | 164 | } |
155 | 165 | ||
156 | |||
157 | /* handle action */ | 166 | /* handle action */ |
158 | static void | 167 | static void doaction(const char *tail) { |
159 | doaction( char *tail ) | 168 | while (*tail == ' ') |
160 | { | 169 | tail++; |
161 | while( *tail == ' ' ) tail++; | 170 | |
162 | 171 | if (*tail) { | |
163 | if( *tail ) { | 172 | /* send users message to server */ |
164 | /* send users message to server */ | 173 | snprintf(tmpstr, TMPSTRSIZE, ".a %s", tail); |
165 | snprintf (tmpstr, TMPSTRSIZE, ".a %s", tail); | 174 | vc_sendmessage(tmpstr); |
166 | networkoutput (tmpstr); | 175 | |
167 | 176 | /* show action in channel window */ | |
168 | /* show action in channel window */ | 177 | snprintf(tmpstr, TMPSTRSIZE, getformatstr(FS_TXPUBACTION), own_nick_get(), |
169 | snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_TXPUBACTION), own_nick_get(), tail); | 178 | tail); |
170 | writechan (tmpstr); | 179 | writechan(tmpstr); |
171 | } else { | 180 | } else { |
172 | /* missing action */ | 181 | /* missing action */ |
173 | msgout( " You do nothing. " ); | 182 | msgout(" You do nothing. "); |
174 | } | 183 | } |
175 | } | 184 | } |
176 | 185 | ||
177 | /* handle private message outgoing */ | 186 | /* handle private message outgoing */ |
178 | static void | 187 | static void privatemessagetx(char *tail) { |
179 | privatemessagetx ( char *tail ) { | ||
180 | char *mesg; | 188 | char *mesg; |
181 | 189 | ||
182 | /* find nick */ | 190 | /* find nick */ |
183 | while( *tail==' ') tail++; | 191 | while (*tail == ' ') |
192 | tail++; | ||
184 | 193 | ||
185 | /* find message */ | 194 | /* find message */ |
186 | mesg = tail; | 195 | mesg = tail; |
187 | while ( *mesg && *mesg!=' ') mesg++; | 196 | while (*mesg && *mesg != ' ') |
197 | mesg++; | ||
188 | 198 | ||
189 | /* check for nick && message */ | 199 | /* check for nick && message */ |
190 | if(*tail && *mesg) { | 200 | if (*tail && *mesg) { |
191 | 201 | ||
192 | /* terminate nick, move to rel start */ | 202 | /* terminate nick, move to rel start */ |
193 | *mesg++ = '\0'; | 203 | *mesg++ = '\0'; |
194 | 204 | ||
195 | /* form message and send to server */ | 205 | /* form message and send to server */ |
196 | snprintf (tmpstr, TMPSTRSIZE, ".m %s %s", tail, mesg); | 206 | snprintf(tmpstr, TMPSTRSIZE, ".m %s %s", tail, mesg); |
197 | networkoutput (tmpstr); | 207 | vc_sendmessage(tmpstr); |
198 | 208 | ||
199 | /* show message in private window */ | 209 | /* show message in private window */ |
200 | snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_TXPRIVMSG), tail, mesg); | 210 | snprintf(tmpstr, TMPSTRSIZE, getformatstr(FS_TXPRIVMSG), tail, mesg); |
201 | writepriv (tmpstr, 0); | 211 | writepriv(tmpstr, 0); |
202 | 212 | ||
203 | /* note we messaged someone */ | 213 | /* note we messaged someone */ |
204 | ul_private_action(tail); | 214 | ul_private_action(tail); |
205 | 215 | ||
206 | } else { | 216 | } else { |
207 | /* Bump user to fill in missing parts */ | 217 | /* Bump user to fill in missing parts */ |
208 | msgout( *tail ? " Won't send empty message. ":" Recipient missing. " ); | 218 | msgout(*tail ? " Won't send empty message. " : " Recipient missing. "); |
209 | } | 219 | } |
210 | } | 220 | } |
211 | 221 | ||
212 | /* handle line entered by user */ | 222 | /* handle line entered by user */ |
213 | void | 223 | void handleline(char *line) { |
214 | handleline (char *line) | ||
215 | { | ||
216 | #ifdef DEBUG | 224 | #ifdef DEBUG |
217 | /* debugging? log users input! */ | 225 | /* debugging? log users input! */ |
218 | fprintf (stderr, "=| %s\n", line); | 226 | fprintf(stderr, "=| %s\n", line); |
219 | #endif | 227 | #endif |
220 | 228 | ||
221 | switch ( line[0] ) | 229 | switch (line[0]) { |
222 | { | ||
223 | case '.': | 230 | case '.': |
224 | switch ( line[1] ) { | 231 | switch (line[1]) { |
225 | case 'm': /* sending a private message? */ | 232 | case 'm': /* sending a private message? */ |
226 | privatemessagetx( line+2 ); | 233 | privatemessagetx(line + 2); |
227 | break; | 234 | break; |
228 | case 'a': /* Do an action */ | 235 | case 'a': /* Do an action */ |
229 | doaction( line+2 ); | 236 | doaction(line + 2); |
230 | break; | 237 | break; |
231 | case '.': | 238 | case '.': |
232 | /* .. on start of line is public */ | 239 | /* .. on start of line is public */ |
233 | if( line[2] != 'm' ) { | 240 | if (line[2] != 'm') { |
234 | output_default( line ); | 241 | output_default(line); |
235 | } else { | 242 | } else { |
236 | /* oopsi, "..m " detected */ | 243 | /* oopsi, "..m " detected */ |
237 | /* dunno what to do */ | 244 | /* dunno what to do */ |
238 | flushout( ); | 245 | flushout(); |
239 | writeout("? You probably misstyped ?"); | 246 | writeout("? You probably misstyped ?"); |
240 | writeout(" "); | 247 | writeout(" "); |
241 | writeout(line ); | 248 | writeout(line); |
242 | showout( ); | 249 | showout(); |
243 | } | ||
244 | break; | ||
245 | case 'o': | ||
246 | case 'O': | ||
247 | dothink( line + 2, line[1] ); | ||
248 | break; | ||
249 | case 'x': | ||
250 | /* inform vchat-client, that the following connection | ||
251 | drop was intentional */ | ||
252 | ownquit = 1; /* fallthrough intended */ | ||
253 | default: | ||
254 | /* generic server command, send to server, show to user */ | ||
255 | snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_COMMAND), line); | ||
256 | writechan (tmpstr); | ||
257 | networkoutput (line); | ||
258 | break; | ||
259 | } | 250 | } |
260 | break; | 251 | break; |
261 | case '/': | 252 | case 'o': |
262 | line++; | 253 | case 'O': |
263 | commandtable[translatecommand(&line)].handler(line); | 254 | dothink(line + 2, line[1]); |
264 | break; | 255 | break; |
265 | default: | 256 | case 'x': |
266 | output_default( line ); | 257 | /* inform vchat-client, that the following connection |
258 | drop was intentional */ | ||
259 | ownquit = 1; /* fallthrough intended */ | ||
260 | default: | ||
261 | /* generic server command, send to server, show to user */ | ||
262 | snprintf(tmpstr, TMPSTRSIZE, getformatstr(FS_COMMAND), line); | ||
263 | writechan(tmpstr); | ||
264 | vc_sendmessage(line); | ||
267 | break; | 265 | break; |
266 | } | ||
267 | break; | ||
268 | case '/': | ||
269 | line++; | ||
270 | commandtable[translatecommand(&line)].handler(line); | ||
271 | break; | ||
272 | default: | ||
273 | output_default(line); | ||
274 | break; | ||
268 | } | 275 | } |
269 | } | 276 | } |
270 | 277 | ||
271 | static void | 278 | static void output_default(char *line) { |
272 | output_default(char *line ) { | 279 | /* prepare for output on display */ |
273 | /* prepare for output on display */ | 280 | snprintf(tmpstr, TMPSTRSIZE, getformatstr(FS_TXPUBMSG), own_nick_get(), line); |
274 | snprintf (tmpstr, TMPSTRSIZE, getformatstr(FS_TXPUBMSG), own_nick_get(), line); | ||
275 | 281 | ||
276 | /* send original line to server */ | 282 | /* send original line to server */ |
277 | networkoutput (line); | 283 | vc_sendmessage(line); |
278 | 284 | ||
279 | /* output message to channel window */ | 285 | /* output message to channel window */ |
280 | writechan (tmpstr); | 286 | writechan(tmpstr); |
281 | } | 287 | } |
282 | 288 | ||
283 | /* handle a "/user " request */ | 289 | /* handle a "/user " request */ |
284 | static void | 290 | static void command_user(char *tail) { |
285 | command_user(char *tail) | 291 | while (*tail == ' ') |
286 | { | 292 | tail++; |
287 | while( *tail == ' ') tail++; | 293 | if (*tail) { |
288 | if( *tail ) { | 294 | char *out = ul_match_user(tail); |
289 | char * out = ul_match_user( tail); | 295 | if (*out) { |
290 | if( *out ) { | 296 | snprintf(tmpstr, TMPSTRSIZE, getformatstr(FS_USMATCH), tail, out); |
291 | snprintf( tmpstr, TMPSTRSIZE, getformatstr(FS_USMATCH), tail, out); | 297 | } else { |
292 | } else { | 298 | snprintf(tmpstr, TMPSTRSIZE, getformatstr(FS_ERR), |
293 | snprintf( tmpstr, TMPSTRSIZE, getformatstr(FS_ERR), " No user matched that regex. "); | 299 | " No user matched that regex. "); |
294 | } | 300 | } |
295 | } else { | 301 | } else { |
296 | snprintf( tmpstr, TMPSTRSIZE, getformatstr(FS_ERR), " Which user? "); | 302 | snprintf(tmpstr, TMPSTRSIZE, getformatstr(FS_ERR), " Which user? "); |
297 | } | 303 | } |
298 | msgout( tmpstr ); | 304 | msgout(tmpstr); |
299 | } | 305 | } |
300 | 306 | ||
301 | /* handle a "/msg " request */ | 307 | /* handle a "/msg " request */ |
302 | static void | 308 | static void command_pm(char *tail) { privatemessagetx(tail); } |
303 | command_pm (char *tail) | ||
304 | { | ||
305 | privatemessagetx( tail ); | ||
306 | } | ||
307 | 309 | ||
308 | static void | 310 | static void command_format(char *line) { |
309 | command_format(char *line) { | ||
310 | struct stat testexist; | 311 | struct stat testexist; |
311 | char * tildex = NULL; | 312 | char *tildex = NULL; |
312 | 313 | ||
313 | flushout(); | 314 | flushout(); |
314 | while( *line==' ') line++; | 315 | while (*line == ' ') |
315 | if(line) { | 316 | line++; |
316 | tildex = tilde_expand( line ); | 317 | if (line) { |
317 | if(tildex && !stat(tildex, &testexist )) | 318 | tildex = tilde_expand(line); |
319 | if (tildex && !stat(tildex, &testexist)) | ||
318 | loadformats(tildex); | 320 | loadformats(tildex); |
319 | else { | 321 | else { |
320 | #define BUFSIZE 4096 | 322 | #define BUFSIZE 4096 |
321 | char buf[BUFSIZE]; | 323 | char buf[BUFSIZE]; |
322 | snprintf( buf, BUFSIZE, "~/.vchat/sample-%s.fmt", line ); | 324 | snprintf(buf, BUFSIZE, "~/.vchat/sample-%s.fmt", line); |
323 | free(tildex); | 325 | free(tildex); |
324 | tildex = tilde_expand( line ); | 326 | tildex = tilde_expand(line); |
325 | if(tildex && !stat(tildex, &testexist )) | 327 | if (tildex && !stat(tildex, &testexist)) |
326 | loadformats(tildex); | 328 | loadformats(tildex); |
327 | } | 329 | } |
328 | writeout(" Sort of done. "); | 330 | writeout(" Sort of done. "); |
@@ -334,106 +336,101 @@ command_format(char *line) { | |||
334 | } | 336 | } |
335 | 337 | ||
336 | /* handle a help request */ | 338 | /* handle a help request */ |
337 | static void | 339 | static void command_help(char *line) { |
338 | command_help (char *line) { | 340 | flushout(); |
339 | flushout( ); | 341 | while (*line == ' ') |
340 | while( *line==' ') line++; | 342 | line++; |
341 | if( *line ) { /* Get help on command */ | 343 | if (*line) { /* Get help on command */ |
342 | int i; | 344 | int i; |
343 | if( ( i = translatecommand( &line ) ) != COMMAND_NONE ) { | 345 | if ((i = translatecommand(&line)) != COMMAND_NONE) { |
344 | snprintf( tmpstr, TMPSTRSIZE, "Help on command: %s", commandtable[i].name); | 346 | snprintf(tmpstr, TMPSTRSIZE, "Help on command: %s", commandtable[i].name); |
345 | writeout( tmpstr ); | 347 | writeout(tmpstr); |
346 | writeout(" "); | 348 | writeout(" "); |
347 | if( commandtable[i].short_help && !commandtable[i].help ) | 349 | if (commandtable[i].short_help && !commandtable[i].help) |
348 | writeout(commandtable[i].short_help ); | 350 | writeout(commandtable[i].short_help); |
349 | line = commandtable[i].help; | 351 | line = commandtable[i].help; |
350 | if( line ) { | 352 | if (line) { |
351 | while( *line ) { | 353 | while (*line) { |
352 | char *tmp = tmpstr; | 354 | char *tmp = tmpstr; |
353 | while( *line && (*line != '\n') ) | 355 | while (*line && (*line != '\n')) |
354 | *tmp++ = *line++; | 356 | *tmp++ = *line++; |
355 | *tmp = '\0'; if( *line == '\n') line++; | 357 | *tmp = '\0'; |
356 | writeout ( tmpstr ); | 358 | if (*line == '\n') |
357 | } | 359 | line++; |
358 | } | 360 | writeout(tmpstr); |
359 | } else { | 361 | } |
360 | command_help( " " ); | ||
361 | } | ||
362 | } else { /* Get overall help */ | ||
363 | int i; | ||
364 | for( i = 0; commandtable[i].number != COMMAND_NONE; i++ ) { | ||
365 | if( commandtable[i].short_help ) | ||
366 | writeout( commandtable[i].short_help ); | ||
367 | } | 362 | } |
363 | } else { | ||
364 | command_help(" "); | ||
365 | } | ||
366 | } else { /* Get overall help */ | ||
367 | int i; | ||
368 | for (i = 0; commandtable[i].number != COMMAND_NONE; i++) { | ||
369 | if (commandtable[i].short_help) | ||
370 | writeout(commandtable[i].short_help); | ||
371 | } | ||
368 | } | 372 | } |
369 | showout(); | 373 | showout(); |
370 | } | 374 | } |
371 | 375 | ||
372 | /* handle an unknown command */ | 376 | /* handle an unknown command */ |
373 | static void | 377 | static void command_none(char *line) { |
374 | command_none(char *line) { | 378 | snprintf(tmpstr, TMPSTRSIZE, " Unknown client command: %s ", line); |
375 | snprintf(tmpstr, TMPSTRSIZE, " Unknown client command: %s ", line); | 379 | msgout(tmpstr); |
376 | msgout(tmpstr); | ||
377 | } | 380 | } |
378 | 381 | ||
379 | /* handle a "/flt " request */ | 382 | /* handle a "/flt " request */ |
380 | static void | 383 | static void command_flt(char *tail) { |
381 | command_flt(char *tail){ | ||
382 | char colour; | 384 | char colour; |
383 | while(*tail==' ') tail++; | 385 | while (*tail == ' ') |
386 | tail++; | ||
384 | colour = *tail++; | 387 | colour = *tail++; |
385 | while( colour && *tail == ' ') tail++; | 388 | while (colour && *tail == ' ') |
386 | if( colour && *tail) { | 389 | tail++; |
387 | addfilter( colour, tail); | 390 | if (colour && *tail) { |
391 | addfilter(colour, tail); | ||
388 | } | 392 | } |
389 | } | 393 | } |
390 | 394 | ||
391 | /* handle a "/clflt " request */ | 395 | /* handle a "/clflt " request */ |
392 | static void | 396 | static void command_clflt(char *tail) { |
393 | command_clflt (char *tail) { | 397 | while (*tail == ' ') |
394 | while( *tail == ' ') tail++; | 398 | tail++; |
395 | clearfilters( *tail ); | 399 | clearfilters(*tail); |
396 | } | 400 | } |
397 | 401 | ||
398 | /* handle a "/rmflt " request */ | 402 | /* handle a "/rmflt " request */ |
399 | static void | 403 | static void command_rmflt(char *tail) { |
400 | command_rmflt (char *tail) { | 404 | while (*tail == ' ') |
401 | while( *tail == ' ') tail++; | 405 | tail++; |
402 | removefilter( tail ); | 406 | removefilter(tail); |
403 | } | 407 | } |
404 | 408 | ||
405 | /* list filters */ | 409 | /* list filters */ |
406 | static void | 410 | static void command_lsflt(char *tail) { |
407 | command_lsflt (char *tail) { | 411 | (void)tail; |
408 | listfilters(); | 412 | listfilters(); |
409 | } | 413 | } |
410 | 414 | ||
411 | /* handle a "/me " action */ | 415 | /* handle a "/me " action */ |
412 | static void | 416 | static void command_action(char *tail) { doaction(tail); } |
413 | command_action(char *tail) | ||
414 | { | ||
415 | doaction( tail); | ||
416 | } | ||
417 | 417 | ||
418 | /* handle a "/reconnect" request */ | 418 | /* handle a "/reconnect" request */ |
419 | static void | 419 | static void command_reconnect(char *tail) { |
420 | command_reconnect(char *tail) | 420 | (void)tail; |
421 | { | ||
422 | status = 0; | 421 | status = 0; |
423 | wantreconnect = 1; | 422 | wantreconnect = 1; |
424 | ownquit = 0; | 423 | ownquit = 0; |
425 | } | 424 | } |
426 | 425 | ||
427 | /* handle a "/quit " exit */ | 426 | /* handle a "/quit " exit */ |
428 | static void | 427 | static void command_quit(char *tail) { |
429 | command_quit(char *tail) | ||
430 | { | ||
431 | /* send users message to server */ | 428 | /* send users message to server */ |
432 | snprintf (tmpstr, TMPSTRSIZE, ".x %s", tail); | 429 | snprintf(tmpstr, TMPSTRSIZE, ".x %s", tail); |
433 | networkoutput (tmpstr); | 430 | vc_sendmessage(tmpstr); |
434 | 431 | ||
435 | /* show action in channel window */ | 432 | /* show action in channel window */ |
436 | writechan (tmpstr); | 433 | writechan(tmpstr); |
437 | 434 | ||
438 | /* Inform vchat-client, that the closing connection | 435 | /* Inform vchat-client, that the closing connection |
439 | following is intended */ | 436 | following is intended */ |
@@ -442,41 +439,35 @@ command_quit(char *tail) | |||
442 | } | 439 | } |
443 | 440 | ||
444 | /* print out version */ | 441 | /* print out version */ |
445 | void | 442 | void command_version(char *tail) { |
446 | command_version(char *tail) | 443 | (void)tail; |
447 | { | ||
448 | /* output internal versions of all modules */ | 444 | /* output internal versions of all modules */ |
449 | flushout(); | 445 | flushout(); |
450 | writeout (vchat_cl_version); | 446 | writeout(vchat_cl_version); |
451 | writeout (vchat_ui_version); | 447 | writeout(vchat_ui_version); |
452 | writeout (vchat_io_version); | 448 | writeout(vchat_io_version); |
453 | writeout (vchat_us_version); | 449 | writeout(vchat_us_version); |
454 | writeout (vchat_cm_version); | 450 | writeout(vchat_cm_version); |
455 | writeout (vchat_ssl_version); | 451 | writeout(vchat_tls_version); |
456 | writeout (vchat_ssl_version_external); | 452 | writeout(vchat_tls_version_external()); |
457 | showout(); | 453 | showout(); |
458 | } | 454 | } |
459 | 455 | ||
460 | /* start or end a query */ | 456 | /* start or end a query */ |
461 | void | 457 | void command_query(char *tail) { |
462 | command_query(char *tail) | ||
463 | { | ||
464 | char *msg; | 458 | char *msg; |
465 | while( *tail == ' ') tail++; | 459 | while (*tail == ' ') |
460 | tail++; | ||
466 | 461 | ||
467 | // Check, if a message is to be sent in first query | 462 | // Check, if a message is to be sent in first query |
468 | // Note: this is safe, since readline chops trailing spaces | 463 | // Note: this is safe, since readline chops trailing spaces |
469 | if((msg = strchr(tail, ' '))) { | 464 | if ((msg = strchr(tail, ' '))) { |
470 | privatemessagetx( tail ); | 465 | privatemessagetx(tail); |
471 | *msg = 0; | 466 | *msg = 0; |
472 | } | 467 | } |
473 | 468 | ||
474 | // Do the ui stuff for query | 469 | // Do the ui stuff for query |
475 | handlequery( tail ); | 470 | handlequery(tail); |
476 | } | 471 | } |
477 | 472 | ||
478 | void | 473 | void command_dict(char *tail) { ul_add_to_dict(tail); } |
479 | command_dict(char *tail) | ||
480 | { | ||
481 | ul_add_to_dict(tail); | ||
482 | } | ||