/[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.1 by flashcode, Sun Nov 16 19:40:36 2003 UTC revision 1.2 by flashcode, Sun Nov 16 23:46:48 2003 UTC
# Line 27  Line 27 
27  #endif  #endif
28    
29  #include <stdlib.h>  #include <stdlib.h>
30    #include <string.h>
31    #include "../common/weechat.h"
32  #include "plugins.h"  #include "plugins.h"
33    #include "../gui/gui.h"
34    
35  #ifdef PLUGIN_PERL  #ifdef PLUGIN_PERL
36  #include "perl/wee-perl.h"  #include "perl/wee-perl.h"
37  #endif  #endif
38    
39    
40    t_plugin_handler *plugins_msg_handlers = NULL;
41    t_plugin_handler *last_plugin_msg_handler = NULL;
42    t_plugin_handler *plugins_cmd_handlers = NULL;
43    t_plugin_handler *last_plugin_cmd_handler = NULL;
44    
45    
46  /*  /*
47   * plugins_init: initialize all plugins   * plugins_init: initialize all plugins
48   */   */
# Line 93  plugins_unload (int plugin_type, char *s Line 102  plugins_unload (int plugin_type, char *s
102  }  }
103    
104  /*  /*
105     * plugins_msg_handler_add: add a message handler
106     */
107    
108    void
109    plugins_msg_handler_add (int plugin_type, char *message, char *function)
110    {
111        t_plugin_handler *new_plugin_handler;
112        
113        new_plugin_handler = (t_plugin_handler *)malloc (sizeof (t_plugin_handler));
114        if (new_plugin_handler)
115        {
116            new_plugin_handler->plugin_type = plugin_type;
117            new_plugin_handler->name = strdup (message);
118            new_plugin_handler->function_name = strdup (function);
119            
120            /* add new handler to list */
121            new_plugin_handler->prev_handler = last_plugin_msg_handler;
122            new_plugin_handler->next_handler = NULL;
123            if (plugins_msg_handlers)
124                last_plugin_msg_handler->next_handler = new_plugin_handler;
125            else
126                plugins_msg_handlers = new_plugin_handler;
127            last_plugin_msg_handler = new_plugin_handler;
128        }
129        else
130            gui_printf (NULL,
131                        _("%s unable to add handler for \"%s\" message (not enough memory)\n"),
132                        WEECHAT_ERROR, message);
133    }
134    
135    /*
136     * plugins_msg_handler_free: free message handler
137     */
138    
139    void
140    plugins_msg_handler_free (t_plugin_handler *ptr_plugin_handler)
141    {
142        t_plugin_handler *new_plugins_msg_handlers;
143        
144        /* remove handler from list */
145        if (last_plugin_msg_handler == ptr_plugin_handler)
146            last_plugin_msg_handler = ptr_plugin_handler->prev_handler;
147        if (ptr_plugin_handler->prev_handler)
148        {
149            (ptr_plugin_handler->prev_handler)->next_handler = ptr_plugin_handler->next_handler;
150            new_plugins_msg_handlers = plugins_msg_handlers;
151        }
152        else
153            new_plugins_msg_handlers = ptr_plugin_handler->next_handler;
154        
155        if (ptr_plugin_handler->next_handler)
156            (ptr_plugin_handler->next_handler)->prev_handler = ptr_plugin_handler->prev_handler;
157    
158        /* free data */
159        free (ptr_plugin_handler->name);
160        free (ptr_plugin_handler->function_name);
161        free (ptr_plugin_handler);
162        plugins_msg_handlers = new_plugins_msg_handlers;
163    }
164    
165    /*
166     * plugins_remove_all_msg_handlers: remove all message handlers
167     */
168    
169    void
170    plugins_msg_handlers_free_all ()
171    {
172        while (plugins_msg_handlers)
173            plugins_msg_handler_free (plugins_msg_handlers);
174    }
175    
176    /*
177   * plugins_end: shutdown plugin interface   * plugins_end: shutdown plugin interface
178   */   */
179    
180  void  void
181  plugins_end ()  plugins_end ()
182  {  {
183        plugins_msg_handlers_free_all ();
184        
185      #ifdef PLUGIN_PERL      #ifdef PLUGIN_PERL
186      wee_perl_end();      wee_perl_end();
187      #endif      #endif

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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