89 |
"functions: list internal functions for key bindings\n" |
"functions: list internal functions for key bindings\n" |
90 |
"reset: restore bindings to the default values and delete ALL personal binding (use carefully!)"), |
"reset: restore bindings to the default values and delete ALL personal binding (use carefully!)"), |
91 |
0, MAX_ARGS, NULL, weechat_cmd_key }, |
0, MAX_ARGS, NULL, weechat_cmd_key }, |
92 |
{ "perl", N_("list/load/unload Perl scripts"), |
{ "plugin", N_("list/load/unload plugins"), |
93 |
N_("[load filename] | [autoload] | [reload] | [unload]"), |
N_("[load filename] | [autoload] | [reload] | [unload]"), |
94 |
N_("filename: Perl script (file) to load\n\n" |
N_("filename: WeeChat plugin (file) to load\n\n" |
95 |
"Without argument, /perl command lists all loaded Perl scripts."), |
"Without argument, /plugin command lists all loaded plugins."), |
96 |
0, 2, weechat_cmd_perl, NULL }, |
0, 2, weechat_cmd_plugin, NULL }, |
|
{ "python", N_("list/load/unload Python scripts"), |
|
|
N_("[load filename] | [autoload] | [reload] | [unload]"), |
|
|
N_("filename: Python script (file) to load\n\n" |
|
|
"Without argument, /python command lists all loaded Python scripts."), |
|
|
0, 2, weechat_cmd_python, NULL }, |
|
|
{ "ruby", N_("list/load/unload Ruby scripts"), |
|
|
N_("[load filename] | [autoload] | [reload] | [unload]"), |
|
|
N_("filename: Ruby script (file) to load\n\n" |
|
|
"Without argument, /ruby command lists all loaded Ruby scripts."), |
|
|
0, 2, weechat_cmd_ruby, NULL }, |
|
97 |
{ "server", N_("list, add or remove servers"), |
{ "server", N_("list, add or remove servers"), |
98 |
N_("[servername] | " |
N_("[servername] | " |
99 |
"[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 " |
"[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 " |
371 |
*/ |
*/ |
372 |
|
|
373 |
char ** |
char ** |
374 |
explode_string (/*@null@*/ char *string, char *separators, int num_items_max, |
explode_string (char *string, char *separators, int num_items_max, |
375 |
int *num_items) |
int *num_items) |
376 |
{ |
{ |
377 |
int i, n_items; |
int i, n_items; |
452 |
} |
} |
453 |
|
|
454 |
/* |
/* |
455 |
|
* free_exploded_string: free an exploded string |
456 |
|
*/ |
457 |
|
|
458 |
|
void |
459 |
|
free_exploded_string (char **exploded_string) |
460 |
|
{ |
461 |
|
int i; |
462 |
|
|
463 |
|
if (exploded_string) |
464 |
|
{ |
465 |
|
for (i = 0; exploded_string[i]; i++) |
466 |
|
free (exploded_string[i]); |
467 |
|
free (exploded_string); |
468 |
|
} |
469 |
|
} |
470 |
|
|
471 |
|
/* |
472 |
* exec_weechat_command: executes a command (WeeChat internal or IRC) |
* exec_weechat_command: executes a command (WeeChat internal or IRC) |
473 |
* returns: 1 if command was executed succesfully |
* returns: 1 if command was executed succesfully |
474 |
* 0 if error (command not executed) |
* 0 if error (command not executed) |
477 |
int |
int |
478 |
exec_weechat_command (t_irc_server *server, char *string) |
exec_weechat_command (t_irc_server *server, char *string) |
479 |
{ |
{ |
480 |
int i, j, argc, return_code, length1, length2; |
int i, argc, return_code, length1, length2; |
481 |
char *command, *pos, *ptr_args, **argv, *alias_command; |
char *command, *pos, *ptr_args, **argv, *alias_command; |
482 |
t_weechat_alias *ptr_alias; |
t_weechat_alias *ptr_alias; |
483 |
|
|
509 |
ptr_args = NULL; |
ptr_args = NULL; |
510 |
} |
} |
511 |
|
|
512 |
if (!plugin_exec_command (command + 1, (server) ? server->name : "", ptr_args)) |
#ifdef PLUGINS |
513 |
|
if (!plugin_cmd_handler_exec ((server) ? server->name : "", command + 1, ptr_args)) |
514 |
|
#else |
515 |
|
if (1) |
516 |
|
#endif |
517 |
{ |
{ |
518 |
argv = explode_string (ptr_args, " ", 0, &argc); |
argv = explode_string (ptr_args, " ", 0, &argc); |
519 |
|
|
567 |
WEECHAT_ERROR, command + 1); |
WEECHAT_ERROR, command + 1); |
568 |
} |
} |
569 |
} |
} |
570 |
if (argv) |
free_exploded_string (argv); |
|
{ |
|
|
for (j = 0; argv[j]; j++) |
|
|
free (argv[j]); |
|
|
free (argv); |
|
|
} |
|
571 |
free (command); |
free (command); |
572 |
return 1; |
return 1; |
573 |
} |
} |
632 |
WEECHAT_ERROR, command + 1); |
WEECHAT_ERROR, command + 1); |
633 |
} |
} |
634 |
} |
} |
635 |
if (argv) |
free_exploded_string (argv); |
|
{ |
|
|
for (j = 0; argv[j]; j++) |
|
|
free (argv[j]); |
|
|
free (argv); |
|
|
} |
|
636 |
free (command); |
free (command); |
637 |
return 1; |
return 1; |
638 |
} |
} |
660 |
else |
else |
661 |
(void) exec_weechat_command (server, ptr_alias->alias_command); |
(void) exec_weechat_command (server, ptr_alias->alias_command); |
662 |
|
|
663 |
if (argv) |
free_exploded_string (argv); |
|
{ |
|
|
for (j = 0; argv[j]; j++) |
|
|
free (argv[j]); |
|
|
free (argv); |
|
|
} |
|
664 |
free (command); |
free (command); |
665 |
return 1; |
return 1; |
666 |
} |
} |
670 |
_("%s unknown command \"%s\" (type /help for help)\n"), |
_("%s unknown command \"%s\" (type /help for help)\n"), |
671 |
WEECHAT_ERROR, |
WEECHAT_ERROR, |
672 |
command + 1); |
command + 1); |
673 |
if (argv) |
free_exploded_string (argv); |
|
{ |
|
|
for (j = 0; argv[j]; j++) |
|
|
free (argv[j]); |
|
|
free (argv); |
|
|
} |
|
674 |
} |
} |
675 |
free (command); |
free (command); |
676 |
return 0; |
return 0; |
758 |
snprintf (plugin_args, plugin_args_length, |
snprintf (plugin_args, plugin_args_length, |
759 |
"localhost PRIVMSG %s :%s", |
"localhost PRIVMSG %s :%s", |
760 |
CHANNEL(buffer)->name, command); |
CHANNEL(buffer)->name, command); |
761 |
plugin_event_msg ("privmsg", server->name, plugin_args); |
#ifdef PLUGINS |
762 |
|
plugin_msg_handler_exec (server->name, "privmsg", plugin_args); |
763 |
|
#endif |
764 |
free (plugin_args); |
free (plugin_args); |
765 |
} |
} |
766 |
else |
else |
1287 |
weechat_cmd_help (int argc, char **argv) |
weechat_cmd_help (int argc, char **argv) |
1288 |
{ |
{ |
1289 |
int i; |
int i; |
1290 |
|
#ifdef PLUGINS |
1291 |
|
t_weechat_plugin *ptr_plugin; |
1292 |
|
t_plugin_cmd_handler *ptr_cmd_handler; |
1293 |
|
#endif |
1294 |
|
|
1295 |
if (argc == 0) |
switch (argc) |
1296 |
{ |
{ |
1297 |
gui_printf (NULL, "\n"); |
case 0: |
1298 |
gui_printf (NULL, _("%s internal commands:\n"), PACKAGE_NAME); |
gui_printf (NULL, "\n"); |
1299 |
for (i = 0; weechat_commands[i].command_name; i++) |
gui_printf (NULL, _("%s internal commands:\n"), PACKAGE_NAME); |
1300 |
{ |
for (i = 0; weechat_commands[i].command_name; i++) |
|
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", |
|
|
weechat_commands[i].command_name); |
|
|
gui_printf (NULL, " - %s\n", |
|
|
_(weechat_commands[i].command_description)); |
|
|
} |
|
|
gui_printf (NULL, "\n"); |
|
|
gui_printf (NULL, _("IRC commands:\n")); |
|
|
for (i = 0; irc_commands[i].command_name; i++) |
|
|
{ |
|
|
if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) |
|
1301 |
{ |
{ |
1302 |
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", |
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", |
1303 |
irc_commands[i].command_name); |
weechat_commands[i].command_name); |
1304 |
gui_printf (NULL, " - %s\n", |
gui_printf (NULL, " - %s\n", |
1305 |
_(irc_commands[i].command_description)); |
_(weechat_commands[i].command_description)); |
1306 |
} |
} |
1307 |
} |
gui_printf (NULL, "\n"); |
1308 |
} |
gui_printf (NULL, _("IRC commands:\n")); |
1309 |
if (argc == 1) |
for (i = 0; irc_commands[i].command_name; i++) |
|
{ |
|
|
for (i = 0; weechat_commands[i].command_name; i++) |
|
|
{ |
|
|
if (ascii_strcasecmp (weechat_commands[i].command_name, argv[0]) == 0) |
|
1310 |
{ |
{ |
1311 |
gui_printf (NULL, "\n"); |
if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) |
1312 |
gui_printf (NULL, "[w]"); |
{ |
1313 |
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " /%s", |
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", |
1314 |
weechat_commands[i].command_name); |
irc_commands[i].command_name); |
1315 |
if (weechat_commands[i].arguments && |
gui_printf (NULL, " - %s\n", |
1316 |
weechat_commands[i].arguments[0]) |
_(irc_commands[i].command_description)); |
1317 |
gui_printf (NULL, " %s\n", |
} |
1318 |
_(weechat_commands[i].arguments)); |
} |
1319 |
else |
#ifdef PLUGINS |
1320 |
|
gui_printf (NULL, "\n"); |
1321 |
|
gui_printf (NULL, _("Plugin commands:\n")); |
1322 |
|
for (ptr_plugin = weechat_plugins; ptr_plugin; |
1323 |
|
ptr_plugin = ptr_plugin->next_plugin) |
1324 |
|
{ |
1325 |
|
for (ptr_cmd_handler = ptr_plugin->cmd_handlers; ptr_cmd_handler; |
1326 |
|
ptr_cmd_handler = ptr_cmd_handler->next_handler) |
1327 |
|
{ |
1328 |
|
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", |
1329 |
|
ptr_cmd_handler->command); |
1330 |
|
if (ptr_cmd_handler->description |
1331 |
|
&& ptr_cmd_handler->description[0]) |
1332 |
|
gui_printf (NULL, " - %s", |
1333 |
|
ptr_cmd_handler->description); |
1334 |
gui_printf (NULL, "\n"); |
gui_printf (NULL, "\n"); |
1335 |
if (weechat_commands[i].command_description && |
} |
|
weechat_commands[i].command_description[0]) |
|
|
gui_printf (NULL, "\n%s\n", |
|
|
_(weechat_commands[i].command_description)); |
|
|
if (weechat_commands[i].arguments_description && |
|
|
weechat_commands[i].arguments_description[0]) |
|
|
gui_printf (NULL, "\n%s\n", |
|
|
_(weechat_commands[i].arguments_description)); |
|
|
return 0; |
|
1336 |
} |
} |
1337 |
} |
#endif |
1338 |
for (i = 0; irc_commands[i].command_name; i++) |
break; |
1339 |
{ |
case 1: |
1340 |
if ((ascii_strcasecmp (irc_commands[i].command_name, argv[0]) == 0) |
for (i = 0; weechat_commands[i].command_name; i++) |
|
&& (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)) |
|
1341 |
{ |
{ |
1342 |
gui_printf (NULL, "\n"); |
if (ascii_strcasecmp (weechat_commands[i].command_name, argv[0]) == 0) |
1343 |
gui_printf (NULL, "[i]"); |
{ |
|
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " /%s", |
|
|
irc_commands[i].command_name); |
|
|
if (irc_commands[i].arguments && |
|
|
irc_commands[i].arguments[0]) |
|
|
gui_printf (NULL, " %s\n", |
|
|
_(irc_commands[i].arguments)); |
|
|
else |
|
1344 |
gui_printf (NULL, "\n"); |
gui_printf (NULL, "\n"); |
1345 |
if (irc_commands[i].command_description && |
gui_printf (NULL, "[w]"); |
1346 |
irc_commands[i].command_description[0]) |
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " /%s", |
1347 |
gui_printf (NULL, "\n%s\n", |
weechat_commands[i].command_name); |
1348 |
_(irc_commands[i].command_description)); |
if (weechat_commands[i].arguments && |
1349 |
if (irc_commands[i].arguments_description && |
weechat_commands[i].arguments[0]) |
1350 |
irc_commands[i].arguments_description[0]) |
gui_printf (NULL, " %s\n", |
1351 |
gui_printf (NULL, "\n%s\n", |
_(weechat_commands[i].arguments)); |
1352 |
_(irc_commands[i].arguments_description)); |
else |
1353 |
return 0; |
gui_printf (NULL, "\n"); |
1354 |
|
if (weechat_commands[i].command_description && |
1355 |
|
weechat_commands[i].command_description[0]) |
1356 |
|
gui_printf (NULL, "\n%s\n", |
1357 |
|
_(weechat_commands[i].command_description)); |
1358 |
|
if (weechat_commands[i].arguments_description && |
1359 |
|
weechat_commands[i].arguments_description[0]) |
1360 |
|
gui_printf (NULL, "\n%s\n", |
1361 |
|
_(weechat_commands[i].arguments_description)); |
1362 |
|
return 0; |
1363 |
|
} |
1364 |
} |
} |
1365 |
} |
for (i = 0; irc_commands[i].command_name; i++) |
1366 |
irc_display_prefix (NULL, PREFIX_ERROR); |
{ |
1367 |
gui_printf (NULL, |
if ((ascii_strcasecmp (irc_commands[i].command_name, argv[0]) == 0) |
1368 |
_("No help available, \"%s\" is an unknown command\n"), |
&& (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)) |
1369 |
argv[0]); |
{ |
1370 |
|
gui_printf (NULL, "\n"); |
1371 |
|
gui_printf (NULL, "[i]"); |
1372 |
|
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " /%s", |
1373 |
|
irc_commands[i].command_name); |
1374 |
|
if (irc_commands[i].arguments && |
1375 |
|
irc_commands[i].arguments[0]) |
1376 |
|
gui_printf (NULL, " %s\n", |
1377 |
|
_(irc_commands[i].arguments)); |
1378 |
|
else |
1379 |
|
gui_printf (NULL, "\n"); |
1380 |
|
if (irc_commands[i].command_description && |
1381 |
|
irc_commands[i].command_description[0]) |
1382 |
|
gui_printf (NULL, "\n%s\n", |
1383 |
|
_(irc_commands[i].command_description)); |
1384 |
|
if (irc_commands[i].arguments_description && |
1385 |
|
irc_commands[i].arguments_description[0]) |
1386 |
|
gui_printf (NULL, "\n%s\n", |
1387 |
|
_(irc_commands[i].arguments_description)); |
1388 |
|
return 0; |
1389 |
|
} |
1390 |
|
} |
1391 |
|
#ifdef PLUGINS |
1392 |
|
for (ptr_plugin = weechat_plugins; ptr_plugin; |
1393 |
|
ptr_plugin = ptr_plugin->next_plugin) |
1394 |
|
{ |
1395 |
|
for (ptr_cmd_handler = ptr_plugin->cmd_handlers; ptr_cmd_handler; |
1396 |
|
ptr_cmd_handler = ptr_cmd_handler->next_handler) |
1397 |
|
{ |
1398 |
|
if (ascii_strcasecmp (ptr_cmd_handler->command, argv[0]) == 0) |
1399 |
|
{ |
1400 |
|
gui_printf (NULL, "\n"); |
1401 |
|
gui_printf (NULL, "[p]"); |
1402 |
|
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " /%s", |
1403 |
|
ptr_cmd_handler->command); |
1404 |
|
if (ptr_cmd_handler->arguments && |
1405 |
|
ptr_cmd_handler->arguments[0]) |
1406 |
|
gui_printf (NULL, " %s\n", |
1407 |
|
ptr_cmd_handler->arguments); |
1408 |
|
else |
1409 |
|
gui_printf (NULL, "\n"); |
1410 |
|
if (ptr_cmd_handler->description && |
1411 |
|
ptr_cmd_handler->description[0]) |
1412 |
|
gui_printf (NULL, "\n%s\n", |
1413 |
|
ptr_cmd_handler->description); |
1414 |
|
if (ptr_cmd_handler->arguments_description && |
1415 |
|
ptr_cmd_handler->arguments_description[0]) |
1416 |
|
gui_printf (NULL, "\n%s\n", |
1417 |
|
ptr_cmd_handler->arguments_description); |
1418 |
|
return 0; |
1419 |
|
} |
1420 |
|
} |
1421 |
|
} |
1422 |
|
#endif |
1423 |
|
irc_display_prefix (NULL, PREFIX_ERROR); |
1424 |
|
gui_printf (NULL, |
1425 |
|
_("No help available, \"%s\" is an unknown command\n"), |
1426 |
|
argv[0]); |
1427 |
|
break; |
1428 |
} |
} |
1429 |
return 0; |
return 0; |
1430 |
} |
} |
1650 |
} |
} |
1651 |
|
|
1652 |
/* |
/* |
1653 |
* weechat_cmd_perl: list/load/unload Perl scripts |
* weechat_cmd_plugin: list/load/unload WeeChat plugins |
1654 |
*/ |
*/ |
1655 |
|
|
1656 |
int |
int |
1657 |
weechat_cmd_perl (int argc, char **argv) |
weechat_cmd_plugin (int argc, char **argv) |
1658 |
{ |
{ |
1659 |
#ifdef PLUGIN_PERL |
#ifdef PLUGINS |
1660 |
t_plugin_script *ptr_plugin_script; |
t_weechat_plugin *ptr_plugin; |
1661 |
t_plugin_handler *ptr_plugin_handler; |
t_plugin_msg_handler *ptr_msg_handler; |
1662 |
int handler_found, path_length; |
t_plugin_cmd_handler *ptr_cmd_handler; |
|
char *path_script; |
|
1663 |
|
|
1664 |
switch (argc) |
switch (argc) |
1665 |
{ |
{ |
1666 |
case 0: |
case 0: |
1667 |
/* list registered Perl scripts */ |
/* list plugins */ |
1668 |
gui_printf (NULL, "\n"); |
gui_printf (NULL, "\n"); |
1669 |
gui_printf (NULL, _("Registered %s scripts:\n"), "Perl"); |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
1670 |
if (perl_scripts) |
gui_printf (NULL, _("Plugins loaded:\n")); |
1671 |
{ |
for (ptr_plugin = weechat_plugins; ptr_plugin; |
1672 |
for (ptr_plugin_script = perl_scripts; ptr_plugin_script; |
ptr_plugin = ptr_plugin->next_plugin) |
|
ptr_plugin_script = ptr_plugin_script->next_script) |
|
|
{ |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, " %s v%s%s%s\n", |
|
|
ptr_plugin_script->name, |
|
|
ptr_plugin_script->version, |
|
|
(ptr_plugin_script->description[0]) ? " - " : "", |
|
|
ptr_plugin_script->description); |
|
|
} |
|
|
} |
|
|
else |
|
1673 |
{ |
{ |
1674 |
|
/* plugin info */ |
1675 |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
1676 |
gui_printf (NULL, _(" (none)\n")); |
gui_printf (NULL, " %s v%s - %s (%s)\n", |
1677 |
} |
ptr_plugin->name, |
1678 |
|
ptr_plugin->version, |
1679 |
/* list Perl message handlers */ |
ptr_plugin->description, |
1680 |
gui_printf (NULL, "\n"); |
ptr_plugin->filename); |
1681 |
gui_printf (NULL, _("%s message handlers:\n"), "Perl"); |
|
1682 |
handler_found = 0; |
/* message handlers */ |
|
for (ptr_plugin_handler = plugin_msg_handlers; ptr_plugin_handler; |
|
|
ptr_plugin_handler = ptr_plugin_handler->next_handler) |
|
|
{ |
|
|
if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL) |
|
|
{ |
|
|
handler_found = 1; |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, _(" IRC(%s) => %s(%s)\n"), |
|
|
ptr_plugin_handler->name, |
|
|
"Perl", |
|
|
ptr_plugin_handler->function_name); |
|
|
} |
|
|
} |
|
|
if (!handler_found) |
|
|
{ |
|
1683 |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
1684 |
gui_printf (NULL, _(" (none)\n")); |
gui_printf (NULL, _(" message handlers:\n")); |
1685 |
} |
for (ptr_msg_handler = ptr_plugin->msg_handlers; |
1686 |
|
ptr_msg_handler; |
1687 |
/* list Perl command handlers */ |
ptr_msg_handler = ptr_msg_handler->next_handler) |
|
gui_printf (NULL, "\n"); |
|
|
gui_printf (NULL, _("%s command handlers:\n"), "Perl"); |
|
|
handler_found = 0; |
|
|
for (ptr_plugin_handler = plugin_cmd_handlers; ptr_plugin_handler; |
|
|
ptr_plugin_handler = ptr_plugin_handler->next_handler) |
|
|
{ |
|
|
if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL) |
|
1688 |
{ |
{ |
|
handler_found = 1; |
|
1689 |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
1690 |
gui_printf (NULL, _(" Command /%s => %s(%s)\n"), |
gui_printf (NULL, _(" IRC(%s)\n"), |
1691 |
ptr_plugin_handler->name, |
ptr_msg_handler->irc_command); |
|
"Perl", |
|
|
ptr_plugin_handler->function_name); |
|
1692 |
} |
} |
1693 |
} |
if (!ptr_plugin->msg_handlers) |
|
if (!handler_found) |
|
|
{ |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, _(" (none)\n")); |
|
|
} |
|
|
|
|
|
break; |
|
|
case 1: |
|
|
if (ascii_strcasecmp (argv[0], "autoload") == 0) |
|
|
plugin_auto_load (PLUGIN_TYPE_PERL, "perl/autoload"); |
|
|
else if (ascii_strcasecmp (argv[0], "reload") == 0) |
|
|
{ |
|
|
plugin_unload (PLUGIN_TYPE_PERL, NULL); |
|
|
plugin_auto_load (PLUGIN_TYPE_PERL, "perl/autoload"); |
|
|
} |
|
|
else if (ascii_strcasecmp (argv[0], "unload") == 0) |
|
|
plugin_unload (PLUGIN_TYPE_PERL, NULL); |
|
|
break; |
|
|
case 2: |
|
|
if (ascii_strcasecmp (argv[0], "load") == 0) |
|
|
{ |
|
|
/* load Perl script */ |
|
|
if (strstr(argv[1], DIR_SEPARATOR)) |
|
|
path_script = NULL; |
|
|
else |
|
|
{ |
|
|
path_length = strlen (weechat_home) + strlen (argv[1]) + 7; |
|
|
path_script = (char *) malloc (path_length * sizeof (char)); |
|
|
snprintf (path_script, path_length, "%s%s%s%s%s", |
|
|
weechat_home, DIR_SEPARATOR, "perl", |
|
|
DIR_SEPARATOR, argv[1]); |
|
|
} |
|
|
plugin_load (PLUGIN_TYPE_PERL, |
|
|
(path_script) ? path_script : argv[1]); |
|
|
if (path_script) |
|
|
free (path_script); |
|
|
} |
|
|
else |
|
|
{ |
|
|
irc_display_prefix (NULL, PREFIX_ERROR); |
|
|
gui_printf (NULL, |
|
|
_("%s unknown option for \"%s\" command\n"), |
|
|
WEECHAT_ERROR, "perl"); |
|
|
} |
|
|
break; |
|
|
default: |
|
|
irc_display_prefix (NULL, PREFIX_ERROR); |
|
|
gui_printf (NULL, |
|
|
_("%s wrong argument count for \"%s\" command\n"), |
|
|
WEECHAT_ERROR, "perl"); |
|
|
} |
|
|
#else |
|
|
irc_display_prefix (NULL, PREFIX_ERROR); |
|
|
gui_printf (NULL, |
|
|
_("WeeChat was build without Perl support.\n" |
|
|
"Please rebuild WeeChat with " |
|
|
"\"--enable-perl\" option for ./configure script\n")); |
|
|
/* make gcc happy */ |
|
|
(void) argc; |
|
|
(void) argv; |
|
|
#endif /* PLUGIN_PERL */ |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
/* |
|
|
* weechat_cmd_python: list/load/unload Python scripts |
|
|
*/ |
|
|
|
|
|
int |
|
|
weechat_cmd_python (int argc, char **argv) |
|
|
{ |
|
|
#ifdef PLUGIN_PYTHON |
|
|
t_plugin_script *ptr_plugin_script; |
|
|
t_plugin_handler *ptr_plugin_handler; |
|
|
int handler_found, path_length; |
|
|
char *path_script; |
|
|
|
|
|
switch (argc) |
|
|
{ |
|
|
case 0: |
|
|
/* list registered Python scripts */ |
|
|
gui_printf (NULL, "\n"); |
|
|
gui_printf (NULL, _("Registered %s scripts:\n"), "Python"); |
|
|
if (python_scripts) |
|
|
{ |
|
|
for (ptr_plugin_script = python_scripts; ptr_plugin_script; |
|
|
ptr_plugin_script = ptr_plugin_script->next_script) |
|
1694 |
{ |
{ |
1695 |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
1696 |
gui_printf (NULL, " %s v%s%s%s\n", |
gui_printf (NULL, _(" (no message handler)\n")); |
|
ptr_plugin_script->name, |
|
|
ptr_plugin_script->version, |
|
|
(ptr_plugin_script->description[0]) ? " - " : "", |
|
|
ptr_plugin_script->description); |
|
1697 |
} |
} |
1698 |
} |
|
1699 |
else |
/* command handlers */ |
|
{ |
|
1700 |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
1701 |
gui_printf (NULL, _(" (none)\n")); |
gui_printf (NULL, _(" command handlers:\n")); |
1702 |
} |
for (ptr_cmd_handler = ptr_plugin->cmd_handlers; |
1703 |
|
ptr_cmd_handler; |
1704 |
/* list Python message handlers */ |
ptr_cmd_handler = ptr_cmd_handler->next_handler) |
|
gui_printf (NULL, "\n"); |
|
|
gui_printf (NULL, _("%s message handlers:\n"), "Python"); |
|
|
handler_found = 0; |
|
|
for (ptr_plugin_handler = plugin_msg_handlers; ptr_plugin_handler; |
|
|
ptr_plugin_handler = ptr_plugin_handler->next_handler) |
|
|
{ |
|
|
if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PYTHON) |
|
1705 |
{ |
{ |
|
handler_found = 1; |
|
1706 |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
1707 |
gui_printf (NULL, _(" IRC(%s) => %s(%s)\n"), |
gui_printf (NULL, " /%s", |
1708 |
ptr_plugin_handler->name, |
ptr_cmd_handler->command); |
1709 |
"Python", |
if (ptr_cmd_handler->description |
1710 |
ptr_plugin_handler->function_name); |
&& ptr_cmd_handler->description[0]) |
1711 |
|
gui_printf (NULL, " (%s)", |
1712 |
|
ptr_cmd_handler->description); |
1713 |
|
gui_printf (NULL, "\n"); |
1714 |
} |
} |
1715 |
} |
if (!ptr_plugin->cmd_handlers) |
|
if (!handler_found) |
|
|
{ |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, _(" (none)\n")); |
|
|
} |
|
|
|
|
|
/* list Python command handlers */ |
|
|
gui_printf (NULL, "\n"); |
|
|
gui_printf (NULL, _("%s command handlers:\n"), "Python"); |
|
|
handler_found = 0; |
|
|
for (ptr_plugin_handler = plugin_cmd_handlers; ptr_plugin_handler; |
|
|
ptr_plugin_handler = ptr_plugin_handler->next_handler) |
|
|
{ |
|
|
if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PYTHON) |
|
1716 |
{ |
{ |
|
handler_found = 1; |
|
1717 |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
1718 |
gui_printf (NULL, _(" Command /%s => %s(%s)\n"), |
gui_printf (NULL, _(" (no command handler)\n")); |
|
ptr_plugin_handler->name, |
|
|
"Python", |
|
|
ptr_plugin_handler->function_name); |
|
1719 |
} |
} |
1720 |
} |
} |
1721 |
if (!handler_found) |
if (!weechat_plugins) |
1722 |
{ |
{ |
1723 |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
irc_display_prefix (NULL, PREFIX_PLUGIN); |
1724 |
gui_printf (NULL, _(" (none)\n")); |
gui_printf (NULL, _(" (no plugin)\n")); |
1725 |
} |
} |
|
|
|
1726 |
break; |
break; |
1727 |
case 1: |
case 1: |
1728 |
if (ascii_strcasecmp (argv[0], "autoload") == 0) |
/*if (ascii_strcasecmp (argv[0], "autoload") == 0) |
1729 |
plugin_auto_load (PLUGIN_TYPE_PYTHON, "python/autoload"); |
plugin_auto_load (PLUGIN_TYPE_PERL, "perl/autoload"); |
1730 |
else if (ascii_strcasecmp (argv[0], "reload") == 0) |
else if (ascii_strcasecmp (argv[0], "reload") == 0) |
1731 |
{ |
{ |
1732 |
plugin_unload (PLUGIN_TYPE_PYTHON, NULL); |
plugin_unload (PLUGIN_TYPE_PERL, NULL); |
1733 |
plugin_auto_load (PLUGIN_TYPE_PYTHON, "python/autoload"); |
plugin_auto_load (PLUGIN_TYPE_PERL, "perl/autoload"); |
1734 |
} |
} |
1735 |
else if (ascii_strcasecmp (argv[0], "unload") == 0) |
else if (ascii_strcasecmp (argv[0], "unload") == 0) |
1736 |
plugin_unload (PLUGIN_TYPE_PYTHON, NULL); |
plugin_unload (PLUGIN_TYPE_PERL, NULL);*/ |
1737 |
break; |
break; |
1738 |
case 2: |
case 2: |
1739 |
if (ascii_strcasecmp (argv[0], "load") == 0) |
if (ascii_strcasecmp (argv[0], "load") == 0) |
1740 |
{ |
{ |
1741 |
/* load Python script */ |
/* load plugin */ |
1742 |
if (strstr(argv[1], DIR_SEPARATOR)) |
plugin_load (argv[1]); |
|
path_script = NULL; |
|
|
else |
|
|
{ |
|
|
path_length = strlen (weechat_home) + strlen (argv[1]) + 9; |
|
|
path_script = (char *) malloc (path_length * sizeof (char)); |
|
|
snprintf (path_script, path_length, "%s%s%s%s%s", |
|
|
weechat_home, DIR_SEPARATOR, "python", |
|
|
DIR_SEPARATOR, argv[1]); |
|
|
} |
|
|
plugin_load (PLUGIN_TYPE_PYTHON, |
|
|
(path_script) ? path_script : argv[1]); |
|
|
if (path_script) |
|
|
free (path_script); |
|
|
} |
|
|
else |
|
|
{ |
|
|
irc_display_prefix (NULL, PREFIX_ERROR); |
|
|
gui_printf (NULL, |
|
|
_("%s unknown option for \"%s\" command\n"), |
|
|
WEECHAT_ERROR, "python"); |
|
|
} |
|
|
break; |
|
|
default: |
|
|
irc_display_prefix (NULL, PREFIX_ERROR); |
|
|
gui_printf (NULL, |
|
|
_("%s wrong argument count for \"%s\" command\n"), |
|
|
WEECHAT_ERROR, "python"); |
|
|
} |
|
|
#else |
|
|
irc_display_prefix (NULL, PREFIX_ERROR); |
|
|
gui_printf (NULL, |
|
|
_("WeeChat was build without Python support.\n" |
|
|
"Please rebuild WeeChat with " |
|
|
"\"--enable-python\" option for ./configure script\n")); |
|
|
/* make gcc happy */ |
|
|
(void) argc; |
|
|
(void) argv; |
|
|
#endif /* PLUGIN_PYTHON */ |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
|
/* |
|
|
* weechat_cmd_ruby: list/load/unload Ruby scripts |
|
|
*/ |
|
|
|
|
|
int |
|
|
weechat_cmd_ruby (int argc, char **argv) |
|
|
{ |
|
|
#ifdef PLUGIN_RUBY |
|
|
t_plugin_script *ptr_plugin_script; |
|
|
t_plugin_handler *ptr_plugin_handler; |
|
|
int handler_found, path_length; |
|
|
char *path_script; |
|
|
|
|
|
switch (argc) |
|
|
{ |
|
|
case 0: |
|
|
/* list registered Ruby scripts */ |
|
|
gui_printf (NULL, "\n"); |
|
|
gui_printf (NULL, _("Registered %s scripts:\n"), "Ruby"); |
|
|
if (ruby_scripts) |
|
|
{ |
|
|
for (ptr_plugin_script = ruby_scripts; ptr_plugin_script; |
|
|
ptr_plugin_script = ptr_plugin_script->next_script) |
|
|
{ |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, " %s v%s%s%s\n", |
|
|
ptr_plugin_script->name, |
|
|
ptr_plugin_script->version, |
|
|
(ptr_plugin_script->description[0]) ? " - " : "", |
|
|
ptr_plugin_script->description); |
|
|
} |
|
|
} |
|
|
else |
|
|
{ |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, _(" (none)\n")); |
|
|
} |
|
|
|
|
|
/* list Ruby message handlers */ |
|
|
gui_printf (NULL, "\n"); |
|
|
gui_printf (NULL, _("%s message handlers:\n"), "Ruby"); |
|
|
handler_found = 0; |
|
|
for (ptr_plugin_handler = plugin_msg_handlers; ptr_plugin_handler; |
|
|
ptr_plugin_handler = ptr_plugin_handler->next_handler) |
|
|
{ |
|
|
if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_RUBY) |
|
|
{ |
|
|
handler_found = 1; |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, _(" IRC(%s) => %s(%s)\n"), |
|
|
ptr_plugin_handler->name, |
|
|
"Ruby", |
|
|
ptr_plugin_handler->function_name); |
|
|
} |
|
|
} |
|
|
if (!handler_found) |
|
|
{ |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, _(" (none)\n")); |
|
|
} |
|
|
|
|
|
/* list Ruby command handlers */ |
|
|
gui_printf (NULL, "\n"); |
|
|
gui_printf (NULL, _("%s command handlers:\n"), "Ruby"); |
|
|
handler_found = 0; |
|
|
for (ptr_plugin_handler = plugin_cmd_handlers; ptr_plugin_handler; |
|
|
ptr_plugin_handler = ptr_plugin_handler->next_handler) |
|
|
{ |
|
|
if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_RUBY) |
|
|
{ |
|
|
handler_found = 1; |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, _(" Command /%s => %s(%s)\n"), |
|
|
ptr_plugin_handler->name, |
|
|
"Ruby", |
|
|
ptr_plugin_handler->function_name); |
|
|
} |
|
|
} |
|
|
if (!handler_found) |
|
|
{ |
|
|
irc_display_prefix (NULL, PREFIX_PLUGIN); |
|
|
gui_printf (NULL, _(" (none)\n")); |
|
|
} |
|
|
|
|
|
break; |
|
|
case 1: |
|
|
if (ascii_strcasecmp (argv[0], "autoload") == 0) |
|
|
plugin_auto_load (PLUGIN_TYPE_RUBY, "ruby/autoload"); |
|
|
else if (ascii_strcasecmp (argv[0], "reload") == 0) |
|
|
{ |
|
|
plugin_unload (PLUGIN_TYPE_RUBY, NULL); |
|
|
plugin_auto_load (PLUGIN_TYPE_RUBY, "ruby/autoload"); |
|
1743 |
} |
} |
1744 |
else if (ascii_strcasecmp (argv[0], "unload") == 0) |
else if (ascii_strcasecmp (argv[0], "unload") == 0) |
|
plugin_unload (PLUGIN_TYPE_RUBY, NULL); |
|
|
break; |
|
|
case 2: |
|
|
if (ascii_strcasecmp (argv[0], "load") == 0) |
|
1745 |
{ |
{ |
1746 |
/* load Ruby script */ |
/* unload plugin */ |
1747 |
if (strstr(argv[1], DIR_SEPARATOR)) |
plugin_unload_name (argv[1]); |
|
path_script = NULL; |
|
|
else |
|
|
{ |
|
|
path_length = strlen (weechat_home) + strlen (argv[1]) + 9; |
|
|
path_script = (char *) malloc (path_length * sizeof (char)); |
|
|
snprintf (path_script, path_length, "%s%s%s%s%s", |
|
|
weechat_home, DIR_SEPARATOR, "ruby", |
|
|
DIR_SEPARATOR, argv[1]); |
|
|
} |
|
|
plugin_load (PLUGIN_TYPE_RUBY, |
|
|
(path_script) ? path_script : argv[1]); |
|
|
if (path_script) |
|
|
free (path_script); |
|
1748 |
} |
} |
1749 |
else |
else |
1750 |
{ |
{ |
1751 |
irc_display_prefix (NULL, PREFIX_ERROR); |
irc_display_prefix (NULL, PREFIX_ERROR); |
1752 |
gui_printf (NULL, |
gui_printf (NULL, |
1753 |
_("%s unknown option for \"%s\" command\n"), |
_("%s unknown option for \"%s\" command\n"), |
1754 |
WEECHAT_ERROR, "ruby"); |
WEECHAT_ERROR, "plugin"); |
1755 |
} |
} |
1756 |
break; |
break; |
1757 |
default: |
default: |
1758 |
irc_display_prefix (NULL, PREFIX_ERROR); |
irc_display_prefix (NULL, PREFIX_ERROR); |
1759 |
gui_printf (NULL, |
gui_printf (NULL, |
1760 |
_("%s wrong argument count for \"%s\" command\n"), |
_("%s wrong argument count for \"%s\" command\n"), |
1761 |
WEECHAT_ERROR, "ruby"); |
WEECHAT_ERROR, "plugin"); |
1762 |
} |
} |
1763 |
#else |
#else |
1764 |
irc_display_prefix (NULL, PREFIX_ERROR); |
irc_display_prefix (NULL, PREFIX_ERROR); |
1765 |
gui_printf (NULL, |
gui_printf (NULL, |
1766 |
_("WeeChat was build without Ruby support.\n" |
_("Command \"plugin\" is not available, WeeChat was built " |
1767 |
"Please rebuild WeeChat with " |
"without plugins support.\n")); |
|
"\"--enable-ruby\" option for ./configure script\n")); |
|
1768 |
/* make gcc happy */ |
/* make gcc happy */ |
1769 |
(void) argc; |
(void) argc; |
1770 |
(void) argv; |
(void) argv; |
1771 |
#endif /* PLUGIN_RUBY */ |
#endif /* PLUGINS */ |
1772 |
|
|
1773 |
return 0; |
return 0; |
1774 |
} |
} |