diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2003-11-16 19:40:36 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2003-11-16 19:40:36 +0000 |
commit | d4ec2e46aafd0064b62f4bbc8b1bc23565881c0c (patch) | |
tree | 5b827b62e780c342111da241e04a8da6d9de07b7 /src/common | |
parent | fd9512bbbcc2857cd1a3a309d9883d199d60122b (diff) | |
download | weechat-d4ec2e46aafd0064b62f4bbc8b1bc23565881c0c.zip |
Perl plugin support
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/command.c | 77 | ||||
-rw-r--r-- | src/common/command.h | 3 | ||||
-rw-r--r-- | src/common/weechat.c | 15 | ||||
-rw-r--r-- | src/common/weechat.h | 2 | ||||
-rw-r--r-- | src/common/weeconfig.c | 4 |
5 files changed, 84 insertions, 17 deletions
diff --git a/src/common/command.c b/src/common/command.c index 1b0f13464..a427cc7d7 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -34,6 +34,7 @@ #include "weeconfig.h" #include "../irc/irc.h" #include "../gui/gui.h" +#include "../plugins/plugins.h" /* WeeChat internal commands */ @@ -59,6 +60,12 @@ t_weechat_command weechat_commands[] = { "help", N_("display help about commands"), N_("[command]"), N_("command: name of a WeeChat or IRC command"), 0, 1, weechat_cmd_help, NULL }, + { "perl", N_("list/load/unload Perl scripts"), + N_("[load filename] | [unload scriptname]"), + N_("filename: Perl script (file) to load\n" + "scriptname: name of script to unload\n" + "Without argument, /perl command lists all loaded Perl scripts."), + 0, 2, weechat_cmd_perl, NULL }, { "server", N_("list, add or remove servers"), N_("[list] | " "[servername hostname port [-auto | -noauto] [-pwd password] [-nicks nick1 " @@ -531,7 +538,7 @@ exec_weechat_command (t_irc_server *server, char *string) gui_printf (NULL, _("%s wrong argument count for %s command \"%s\" " "(expected: %d arg%s)\n"), - WEECHAT_ERROR, PACKAGE_NAME, + WEECHAT_ERROR, PACKAGE_NAME, command + 1, weechat_commands[i].max_arg, (weechat_commands[i].max_arg > @@ -974,6 +981,64 @@ weechat_cmd_help (int argc, char **argv) } /* + * weechat_cmd_perl: list/load/unload Perl scripts + */ + +int +weechat_cmd_perl (int argc, char **argv) +{ + #ifdef PLUGIN_PERL + switch (argc) + { + case 0: + /* list all Perl scripts */ + /* TODO: get list and display it */ + break; + case 2: + if (strcmp (argv[0], "load") == 0) + { + /* load Perl script */ + plugins_load (PLUGIN_PERL, argv[1]); + } + else + { + if (strcmp (argv[0], "unload") == 0) + { + /* unload Perl script */ + } + else + { + gui_printf (NULL, + _("%s unknown option for \"%s\" command\n"), + WEECHAT_ERROR, "perl"); + } + } + break; + default: + gui_printf (NULL, + _("%s wrong argument count for \"%s\" command\n"), + WEECHAT_ERROR, "perl"); + } + #else + gui_printf (NULL, + _("WeeChat was build without Perl support.\n" + "Please rebuild WeeChat with " + "\"--enable-perl\" option for ./configure script\n"); + #endif + return 0; +} + +/* + * weechat_cmd_save: save options to disk + */ + +int +weechat_cmd_save (int argc, char **argv) +{ + return (config_write ((argc == 1) ? argv[0] : NULL)); +} + +/* * weechat_cmd_server: list, add or remove server(s) */ @@ -1279,16 +1344,6 @@ weechat_cmd_server (int argc, char **argv) } /* - * weechat_cmd_save: set options - */ - -int -weechat_cmd_save (int argc, char **argv) -{ - return (config_write ((argc == 1) ? argv[0] : NULL)); -} - -/* * weechat_cmd_set: set options */ diff --git a/src/common/command.h b/src/common/command.h index 2be48eded..59183f70d 100644 --- a/src/common/command.h +++ b/src/common/command.h @@ -72,8 +72,9 @@ extern int weechat_cmd_clear (int, char **); extern int weechat_cmd_connect (int, char **); extern int weechat_cmd_disconnect (int, char **); extern int weechat_cmd_help (int, char **); -extern int weechat_cmd_server (int, char **); +extern int weechat_cmd_perl (int, char **); extern int weechat_cmd_save (int, char **); +extern int weechat_cmd_server (int, char **); extern int weechat_cmd_set (int, char **); extern int weechat_cmd_unalias (char *); diff --git a/src/common/weechat.c b/src/common/weechat.c index 1fb831987..2efadda8a 100644 --- a/src/common/weechat.c +++ b/src/common/weechat.c @@ -56,6 +56,7 @@ #include "command.h" #include "../irc/irc.h" #include "../gui/gui.h" +#include "../plugins/plugins.h" /* char *display_name; */ @@ -65,11 +66,11 @@ FILE *log_file; /* WeeChat log file (~/.weechat/weechat.log */ /* - * log_printf: displays a message in WeeChat log (~/.weechat/weechat.log) + * wee_log_printf: displays a message in WeeChat log (~/.weechat/weechat.log) */ void -log_printf (char *message, ...) +wee_log_printf (char *message, ...) { static char buffer[4096]; va_list argptr; @@ -271,6 +272,9 @@ main (int argc, char *argv[]) /* init gui */ gui_init (); + /* init plugin interface(s) */ + plugins_init (); + /* Welcome message - yeah! */ if (cfg_look_startup_logo) { @@ -315,7 +319,14 @@ main (int argc, char *argv[]) irc_login (ptr_server); } } + + /* WeeChat main loop */ gui_main_loop (); + + /* end plugin interface(s) */ + plugins_end (); + + /* disconnect from all servers */ server_disconnect_all (); /* save config file */ diff --git a/src/common/weechat.h b/src/common/weechat.h index 75fd56d88..c7a9e63da 100644 --- a/src/common/weechat.h +++ b/src/common/weechat.h @@ -97,7 +97,7 @@ int quit_weechat; extern int quit_weechat; -extern void log_printf (char *, ...); +extern void wee_log_printf (char *, ...); extern void wee_shutdown (); #endif /* weechat.h */ diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index 3a58da127..062735d50 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -948,7 +948,7 @@ config_create_default () } printf (_("%s: creating default config file...\n"), PACKAGE_NAME); - log_printf (_("creating default config file\n")); + wee_log_printf (_("creating default config file\n")); current_time = time (NULL); sprintf (line, _("#\n# %s configuration file, created by " @@ -1081,7 +1081,7 @@ config_write (char *config_name) return -1; } - log_printf (_("saving config to disk\n")); + wee_log_printf (_("saving config to disk\n")); current_time = time (NULL); sprintf (line, _("#\n# %s configuration file, created by " |