/[weechat]/weechat/src/plugins/plugins.c
ViewVC logotype

Diff of /weechat/src/plugins/plugins.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by flashcode, Thu Jun 16 11:02:19 2005 UTC revision 1.23 by flashcode, Sun Aug 21 16:32:48 2005 UTC
# Line 43  Line 43 
43  #include "python/wee-python.h"  #include "python/wee-python.h"
44  #endif  #endif
45    
46    #ifdef PLUGIN_RUBY
47    #include "ruby/wee-ruby.h"
48    #endif
49    
50    
51  char *plugin_name[3] = { "Perl", "Python", "Ruby" };  char *plugin_name[3] = { "Perl", "Python", "Ruby" };
52    
# Line 115  plugin_auto_load (int plugin_type, char Line 119  plugin_auto_load (int plugin_type, char
119  void  void
120  plugin_init ()  plugin_init ()
121  {  {
122      #ifdef PLUGIN_PERL  #ifdef PLUGIN_PERL
123      wee_perl_init();      wee_perl_init();
124      plugin_auto_load (PLUGIN_TYPE_PERL, "perl/autoload");      plugin_auto_load (PLUGIN_TYPE_PERL, "perl/autoload");
125      #endif  #endif
126            
127      #ifdef PLUGIN_PYTHON  #ifdef PLUGIN_PYTHON
128      wee_python_init();      wee_python_init();
129      plugin_auto_load (PLUGIN_TYPE_PYTHON, "python/autoload");      plugin_auto_load (PLUGIN_TYPE_PYTHON, "python/autoload");
130      #endif  #endif
131    
132    #ifdef PLUGIN_RUBY
133        wee_ruby_init();
134        plugin_auto_load (PLUGIN_TYPE_RUBY, "ruby/autoload");
135    #endif
136  }  }
137    
138  /*  /*
# Line 133  plugin_init () Line 142  plugin_init ()
142  void  void
143  plugin_load (int plugin_type, char *filename)  plugin_load (int plugin_type, char *filename)
144  {  {
145      #ifdef PLUGINS  #ifdef PLUGINS
146      switch (plugin_type)      switch (plugin_type)
147      {      {
148          case PLUGIN_TYPE_PERL:          case PLUGIN_TYPE_PERL:
149              #ifdef PLUGIN_PERL  #ifdef PLUGIN_PERL
150              wee_perl_load (filename);              wee_perl_load (filename);
151              #endif  #endif
152              break;              break;
153          case PLUGIN_TYPE_PYTHON:          case PLUGIN_TYPE_PYTHON:
154              #ifdef PLUGIN_PYTHON  #ifdef PLUGIN_PYTHON
155              wee_python_load (filename);              wee_python_load (filename);
156              #endif  #endif
157              break;              break;
158          case PLUGIN_TYPE_RUBY:          case PLUGIN_TYPE_RUBY:
159              /* TODO: load Ruby script */  #ifdef PLUGIN_RUBY
160                wee_ruby_load (filename);
161    #endif
162              break;              break;
163      }      }
164      #else  #else
165      /* make gcc happy */      /* make gcc happy */
166      (void) plugin_type;      (void) plugin_type;
167      (void) filename;      (void) filename;
168      #endif  #endif /* PLUGINS */
169  }  }
170    
171  /*  /*
# Line 292  plugin_handler_free_all_type (t_plugin_h Line 303  plugin_handler_free_all_type (t_plugin_h
303  void  void
304  plugin_event_msg (char *irc_command, char *server, char *arguments)  plugin_event_msg (char *irc_command, char *server, char *arguments)
305  {  {
306      #ifdef PLUGINS  #ifdef PLUGINS
307      t_plugin_handler *ptr_plugin_handler;      t_plugin_handler *ptr_plugin_handler;
308            
309      for (ptr_plugin_handler = plugin_msg_handlers; ptr_plugin_handler;      for (ptr_plugin_handler = plugin_msg_handlers; ptr_plugin_handler;
# Line 300  plugin_event_msg (char *irc_command, cha Line 311  plugin_event_msg (char *irc_command, cha
311      {      {
312          if (strcasecmp (ptr_plugin_handler->name, irc_command) == 0)          if (strcasecmp (ptr_plugin_handler->name, irc_command) == 0)
313          {          {
314              #ifdef PLUGIN_PERL  #ifdef PLUGIN_PERL
315              if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL)              if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL)
316              {              {
317                  if (ptr_plugin_handler->running == 0)                  if (ptr_plugin_handler->running == 0)
# Line 310  plugin_event_msg (char *irc_command, cha Line 321  plugin_event_msg (char *irc_command, cha
321                      ptr_plugin_handler->running = 0;                      ptr_plugin_handler->running = 0;
322                  }                  }
323              }              }
324              #endif  #endif
325              #ifdef PLUGIN_PYTHON  #ifdef PLUGIN_PYTHON
326              if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PYTHON)              if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PYTHON)
327              {              {
328                  if (ptr_plugin_handler->running == 0)                  if (ptr_plugin_handler->running == 0)
# Line 321  plugin_event_msg (char *irc_command, cha Line 332  plugin_event_msg (char *irc_command, cha
332                      ptr_plugin_handler->running = 0;                      ptr_plugin_handler->running = 0;
333                  }                  }
334              }              }
335              #endif  #endif
336    #ifdef PLUGIN_RUBY
337                if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_RUBY)
338                {
339                    if (ptr_plugin_handler->running == 0)
340                    {
341                        ptr_plugin_handler->running = 1;
342                        wee_ruby_exec (ptr_plugin_handler->function_name, server, arguments);
343                        ptr_plugin_handler->running = 0;
344                    }
345                }
346    #endif
347          }          }
348      }      }
349      #else  #else
350      /* make gcc happy */      /* make gcc happy */
351      (void) irc_command;      (void) irc_command;
352      (void) arguments;      (void) arguments;
353      (void) server;      (void) server;
354      #endif  #endif /* PLUGINS */
355  }  }
356    
357  /*  /*
# Line 339  plugin_event_msg (char *irc_command, cha Line 361  plugin_event_msg (char *irc_command, cha
361  int  int
362  plugin_exec_command (char *user_command, char *server, char *arguments)  plugin_exec_command (char *user_command, char *server, char *arguments)
363  {  {
364      #ifdef PLUGINS  #ifdef PLUGINS
365      t_plugin_handler *ptr_plugin_handler;      t_plugin_handler *ptr_plugin_handler;
366            
367      for (ptr_plugin_handler = plugin_cmd_handlers; ptr_plugin_handler;      for (ptr_plugin_handler = plugin_cmd_handlers; ptr_plugin_handler;
# Line 347  plugin_exec_command (char *user_command, Line 369  plugin_exec_command (char *user_command,
369      {      {
370          if (strcasecmp (ptr_plugin_handler->name, user_command) == 0)          if (strcasecmp (ptr_plugin_handler->name, user_command) == 0)
371          {          {
372              #ifdef PLUGIN_PERL  #ifdef PLUGIN_PERL
373              if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL)              if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PERL)
374              {              {
375                  if (ptr_plugin_handler->running == 0)                  if (ptr_plugin_handler->running == 0)
# Line 357  plugin_exec_command (char *user_command, Line 379  plugin_exec_command (char *user_command,
379                      ptr_plugin_handler->running = 0;                      ptr_plugin_handler->running = 0;
380                  }                  }
381              }              }
382              #endif  #endif
383              #ifdef PLUGIN_PYTHON  #ifdef PLUGIN_PYTHON
384              if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PYTHON)              if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_PYTHON)
385              {              {
386                  if (ptr_plugin_handler->running == 0)                  if (ptr_plugin_handler->running == 0)
# Line 368  plugin_exec_command (char *user_command, Line 390  plugin_exec_command (char *user_command,
390                      ptr_plugin_handler->running = 0;                      ptr_plugin_handler->running = 0;
391                  }                  }
392              }              }
393              #endif  #endif
394    #ifdef PLUGIN_RUBY
395                if (ptr_plugin_handler->plugin_type == PLUGIN_TYPE_RUBY)
396                {
397                    if (ptr_plugin_handler->running == 0)
398                    {
399                        ptr_plugin_handler->running = 1;
400                        wee_ruby_exec (ptr_plugin_handler->function_name, server, arguments);
401                        ptr_plugin_handler->running = 0;
402                    }
403                }
404    #endif
405                            
406              /* command executed */              /* command executed */
407              return 1;              return 1;
408          }          }
409      }      }
410      #else  #else
411      /* make gcc happy */      /* make gcc happy */
412      (void) user_command;      (void) user_command;
413      (void) arguments;      (void) arguments;
414      (void) server;      (void) server;
415      #endif  #endif /* PLUGINS */
416            
417      /* no command executed */      /* no command executed */
418      return 0;      return 0;
# Line 453  plugin_unload (int plugin_type, char *sc Line 486  plugin_unload (int plugin_type, char *sc
486      /* make gcc happy */      /* make gcc happy */
487      (void) scriptname;      (void) scriptname;
488            
489      #ifdef PLUGINS  #ifdef PLUGINS
490      switch (plugin_type)      switch (plugin_type)
491      {      {
492          case PLUGIN_TYPE_PERL:          case PLUGIN_TYPE_PERL:
493              #ifdef PLUGIN_PERL  #ifdef PLUGIN_PERL
494              /* unload one Perl script is not allowed */              /* unload one Perl script is not allowed */
495              wee_perl_end ();              wee_perl_end ();
496              wee_perl_init ();              wee_perl_init ();
497              #endif  #endif
498              break;              break;
499          case PLUGIN_TYPE_PYTHON:          case PLUGIN_TYPE_PYTHON:
500              #ifdef PLUGIN_PYTHON  #ifdef PLUGIN_PYTHON
501              wee_python_end ();              wee_python_end ();
502              wee_python_init ();              wee_python_init ();
503              #endif  #endif
504              break;              break;
505          case PLUGIN_TYPE_RUBY:          case PLUGIN_TYPE_RUBY:
506              /* TODO: unload Ruby scripts */  #ifdef PLUGIN_RUBY
507                wee_ruby_end ();
508                wee_ruby_init ();
509    #endif
510              break;              break;
511      }      }
512      #else  #else
513      /* make gcc happy */      /* make gcc happy */
514      (void) plugin_type;      (void) plugin_type;
515      #endif  #endif /* PLUGINS */
516  }  }
517    
518  /*  /*
# Line 489  plugin_end () Line 525  plugin_end ()
525      plugin_handler_free_all (&plugin_msg_handlers, &last_plugin_msg_handler);      plugin_handler_free_all (&plugin_msg_handlers, &last_plugin_msg_handler);
526      plugin_handler_free_all (&plugin_cmd_handlers, &last_plugin_cmd_handler);      plugin_handler_free_all (&plugin_cmd_handlers, &last_plugin_cmd_handler);
527            
528      #ifdef PLUGIN_PERL  #ifdef PLUGIN_PERL
529      wee_perl_end();      wee_perl_end();
530      #endif  #endif
531            
532      #ifdef PLUGIN_PYTHON  #ifdef PLUGIN_PYTHON
533      wee_python_end();      wee_python_end();
534      #endif      #endif
535    
536    #ifdef PLUGIN_RUBY
537        wee_ruby_end();
538    #endif
539  }  }

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26