Mercurial > hg
comparison mcabber/src/commands.c @ 1352:61a54e172010
Add internal hooks support
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 10 Nov 2007 22:29:31 +0100 |
parents | 43e777a5ff06 |
children | 9716cf8a0726 |
comparison
equal
deleted
inserted
replaced
1351:43e777a5ff06 | 1352:61a54e172010 |
---|---|
290 // expandalias(line) | 290 // expandalias(line) |
291 // If there is one, expand the alias in line and returns a new allocated line | 291 // If there is one, expand the alias in line and returns a new allocated line |
292 // If no alias is found, returns line | 292 // If no alias is found, returns line |
293 // Note : if the returned pointer is different from line, the caller should | 293 // Note : if the returned pointer is different from line, the caller should |
294 // g_free() the pointer after use | 294 // g_free() the pointer after use |
295 char *expandalias(char *line) | 295 char *expandalias(const char *line) |
296 { | 296 { |
297 const char *p1, *p2; | 297 const char *p1, *p2; |
298 char *word; | 298 char *word; |
299 const gchar *value; | 299 const gchar *value; |
300 char *newline = line; | 300 char *newline = (char*)line; |
301 | 301 |
302 // Ignore leading COMMAND_CHAR | 302 // Ignore leading COMMAND_CHAR |
303 for (p1 = line ; *p1 == COMMAND_CHAR ; p1++) | 303 for (p1 = line ; *p1 == COMMAND_CHAR ; p1++) |
304 ; | 304 ; |
305 // Locate the end of the word | 305 // Locate the end of the word |
355 // process_command(line, iscmd) | 355 // process_command(line, iscmd) |
356 // Process a command line. | 356 // Process a command line. |
357 // If iscmd is TRUE, process the command even if verbatim mmode is set; | 357 // If iscmd is TRUE, process the command even if verbatim mmode is set; |
358 // it is intended to be used for key bindings. | 358 // it is intended to be used for key bindings. |
359 // Return 255 if this is the /quit command, and 0 for the other commands. | 359 // Return 255 if this is the /quit command, and 0 for the other commands. |
360 int process_command(char *line, guint iscmd) | 360 int process_command(const char *line, guint iscmd) |
361 { | 361 { |
362 char *p; | 362 char *p; |
363 char *xpline; | 363 char *xpline; |
364 cmd *curcmd; | 364 cmd *curcmd; |
365 | 365 |
366 // We do alias expansion here | 366 // We do alias expansion here |
367 if (iscmd || scr_get_multimode() != 2) | 367 if (iscmd || scr_get_multimode() != 2) |
368 xpline = expandalias(line); | 368 xpline = expandalias(line); |
369 else | 369 else |
370 xpline = line; // No expansion in verbatim multi-line mode | 370 xpline = (char*)line; // No expansion in verbatim multi-line mode |
371 | 371 |
372 // We want to have a copy | 372 // We want to use a copy |
373 if (xpline == line) | 373 if (xpline == line) |
374 xpline = g_strdup(line); | 374 xpline = g_strdup(line); |
375 | 375 |
376 // Remove trailing spaces: | 376 // Remove trailing spaces: |
377 for (p=xpline ; *p ; p++) | 377 for (p=xpline ; *p ; p++) |
428 // process_line(line) | 428 // process_line(line) |
429 // Process a command/message line. | 429 // Process a command/message line. |
430 // If this isn't a command, this is a message and it is sent to the | 430 // If this isn't a command, this is a message and it is sent to the |
431 // currently selected buddy. | 431 // currently selected buddy. |
432 // Return 255 if the line is the /quit command, or 0. | 432 // Return 255 if the line is the /quit command, or 0. |
433 int process_line(char *line) | 433 int process_line(const char *line) |
434 { | 434 { |
435 if (!*line) { // User only pressed enter | 435 if (!*line) { // User only pressed enter |
436 if (scr_get_multimode()) { | 436 if (scr_get_multimode()) { |
437 scr_append_multiline(""); | 437 scr_append_multiline(""); |
438 return 0; | 438 return 0; |
448 if (*line != COMMAND_CHAR) { | 448 if (*line != COMMAND_CHAR) { |
449 // This isn't a command | 449 // This isn't a command |
450 if (scr_get_multimode()) | 450 if (scr_get_multimode()) |
451 scr_append_multiline(line); | 451 scr_append_multiline(line); |
452 else | 452 else |
453 do_say_internal(line, 0); | 453 do_say_internal((char*)line, 0); |
454 return 0; | 454 return 0; |
455 } | 455 } |
456 | 456 |
457 /* It is _probably_ a command -- except for verbatim multi-line mode */ | 457 /* It is _probably_ a command -- except for verbatim multi-line mode */ |
458 return process_command(line, FALSE); | 458 return process_command(line, FALSE); |