plugin.h
Go to the documentation of this file.
1 /* vim: set ts=2 expandtab: */
2 /**
3  * @file plugin.h
4  * @brief The commotiond plugin loader.
5  *
6  * @author Josh King (jheretic), jking@chambana.net
7  *
8  * @internal
9  * Created 11/04/2013 10:47:37 AM
10  * Compiler gcc/g++
11  * Organization The Open Technology Institute
12  * Copyright Copyright (c) 2013, Josh King
13  *
14  * This file is part of Commotion, Copyright (c) 2013, Josh King
15  *
16  * Commotion is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU Affero General Public License as
18  * published by the Free Software Foundation, either version 3 of the
19  * License, or (at your option) any later version.
20  *
21  * Commotion is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU Affero General Public License for more details.
25  *
26  * You should have received a copy of the GNU Affero General Public License
27  * along with Commotion. If not, see <http://www.gnu.org/licenses/>.
28  *
29  * =====================================================================================
30  */
31 
32 #ifndef _PLUGIN_H
33 #define _PLUGIN_H
34 
35 #include <stdlib.h>
36 #include "obj.h"
37 
38 typedef struct co_plugin_t co_plugin_t;
39 
40 /**
41  * @struct co_plugin_t contains file path, descriptor and name information for plugins
42  */
43 struct co_plugin_t {
44  co_obj_t _header;
45  uint8_t _exttype;
46  uint8_t _len;
47  co_obj_t *name; /**< command name */
48  co_obj_t *filename;
49  co_cb_t shutdown;
50  co_cb_t init;
51  void *handle;
52 } __attribute__((packed));
53 
54 /**
55  * @brief shuts down and closes all plugins
56  */
57 int co_plugins_shutdown(void);
58 
59 /**
60  * @brief starts all loaded plugins
61  */
62 int co_plugins_start(void);
63 
64 /**
65  * @brief initializes global plugin list
66  * @param index_size specifies size of index for plugins list (16 or 32 bit)
67  */
68 int co_plugins_init(size_t index_size);
69 
70 /**
71  * @brief loads all plugins in specified path
72  * @param dir_path directory to load plugins from
73  */
74 int co_plugins_load(const char *dir_path);
75 
76 #endif
Commotion object model.
co_obj_t * name
Definition: plugin.h:47
int co_plugins_shutdown(void)
shuts down and closes all plugins
Definition: plugin.c:63
int co_plugins_start(void)
starts all loaded plugins
Definition: plugin.c:85
Definition: obj.h:131
Definition: plugin.h:43
int co_plugins_init(size_t index_size)
initializes global plugin list
Definition: plugin.c:94
int co_plugins_load(const char *dir_path)
loads all plugins in specified path
Definition: plugin.c:153