9c312311 |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2003-2004 Michel Dagenais |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License Version 2 as |
6 | * published by the Free Software Foundation; |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
16 | * MA 02111-1307, USA. |
17 | */ |
18 | |
c5d77517 |
19 | #ifndef MODULES_H |
20 | #define MODULES_H |
21 | |
22 | #include <gmodule.h> |
23 | |
24 | /* lttv modules are shared object files, to be loaded dynamically, which |
25 | interact with the main module to provide additional capabilities. They |
26 | typically register hooks to be called at various places, read and add |
dc877563 |
27 | attributes... |
c5d77517 |
28 | |
dc877563 |
29 | Each lttv module must define a function named "init" with |
30 | the following signature. The init function may itself require other |
31 | modules using lttv_module_require. |
c5d77517 |
32 | |
dc877563 |
33 | It should also define a function named "destroy" to free the |
c5d77517 |
34 | resources reserved during execution. |
35 | |
36 | Most modules will not use the command line arguments passed as init |
37 | arguments. It is easier to simply register command line options |
38 | to be parsed by the main module. However, some modules |
dc877563 |
39 | may require an "early access" to these arguments, for example an embedded |
c5d77517 |
40 | python interpreter module which needs to know the modules written in |
41 | python to load. */ |
42 | |
dc877563 |
43 | typedef struct _LttvModule LttvModule; |
c5d77517 |
44 | |
996acd92 |
45 | typedef void (*LttvModuleInit)(LttvModule *self, int argc, char **argv); |
c5d77517 |
46 | |
dc877563 |
47 | typedef void (*LttvModuleDestroy)(); |
c5d77517 |
48 | |
c5d77517 |
49 | |
dc877563 |
50 | /* Additional module search paths may be defined. */ |
c5d77517 |
51 | |
dc877563 |
52 | void lttv_module_path_add(const char *name); |
c5d77517 |
53 | |
54 | |
dc877563 |
55 | /* Load (or increment its reference count if already loaded) the named module. |
56 | The init function of the module is executed upon loading. */ |
c5d77517 |
57 | |
dc877563 |
58 | LttvModule *lttv_module_load(const char *name, int argc, char **argv); |
c5d77517 |
59 | |
60 | |
dc877563 |
61 | /* Module m depends on the named module. The named module will be loaded, |
62 | remembered by m as a dependent, and unloaded when m is unloaded. */ |
c5d77517 |
63 | |
dc877563 |
64 | LttvModule *lttv_module_require(LttvModule *m, const char *name, int argc, |
65 | char **argv); |
c5d77517 |
66 | |
c5d77517 |
67 | |
dc877563 |
68 | /* Decrement the reference count of the specified module and unload it if 0. |
69 | The destroy function of the module is executed before unloading. |
70 | Dependent modules are unloaded. */ |
c5d77517 |
71 | |
dc877563 |
72 | void lttv_module_unload(LttvModule *m) ; |
c5d77517 |
73 | |
c5d77517 |
74 | |
dc877563 |
75 | /* List the loaded modules. The returned array contains nb elements and |
76 | must be freed with g_free. */ |
c5d77517 |
77 | |
dc877563 |
78 | LttvModule **lttv_module_list(guint *nb); |
c5d77517 |
79 | |
dc877563 |
80 | |
81 | /* Obtain information about a module. The list of dependent module is |
82 | returned and must be freed with g_free. */ |
83 | |
84 | LttvModule **lttv_module_info(LttvModule *m, const char **name, |
85 | guint *ref_count, guint *load_count, guint *nb_dependents); |
c5d77517 |
86 | |
36b3c068 |
87 | char * lttv_module_name(LttvModule *m); |
c5d77517 |
88 | #endif // MODULES_H |