]> git.sesse.net Git - vlc/blob - src/modules/modules.h
Split the over-large module.c
[vlc] / src / modules / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 the VideoLAN team
5  * $Id: modules.h 17958 2006-11-22 17:13:24Z courmisch $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
25 # error This header file can only be included from LibVLC.
26 #endif
27
28 #ifndef __LIBVLC_MODULES_H
29 # define __LIBVLC_MODULES_H 1
30
31
32 /* Number of tries before we unload an unused module */
33 #define MODULE_HIDE_DELAY 50
34
35 /*****************************************************************************
36  * module_bank_t: the module bank
37  *****************************************************************************
38  * This variable is accessed by any function using modules.
39  *****************************************************************************/
40 struct module_bank_t
41 {
42     VLC_COMMON_MEMBERS
43
44     int              i_usage;
45
46     vlc_bool_t       b_main;
47     vlc_bool_t       b_builtins;
48     vlc_bool_t       b_plugins;
49
50     /* Plugins cache */
51     vlc_bool_t     b_cache;
52     vlc_bool_t     b_cache_dirty;
53     vlc_bool_t     b_cache_delete;
54
55     int            i_cache;
56     module_cache_t **pp_cache;
57
58     int            i_loaded_cache;
59     module_cache_t **pp_loaded_cache;
60 };
61
62 /*****************************************************************************
63  * Module cache description structure
64  *****************************************************************************/
65 struct module_cache_t
66 {
67     /* Mandatory cache entry header */
68     char       *psz_file;
69     int64_t    i_time;
70     int64_t    i_size;
71     vlc_bool_t b_junk;
72
73     /* Optional extra data */
74     module_t *p_module;
75     vlc_bool_t b_used;
76 };
77
78
79 #if 0
80 #define MODULE_SHORTCUT_MAX 50
81
82 /* The module handle type. */
83 #if defined(HAVE_DL_DYLD)
84 #   if defined (HAVE_MACH_O_DYLD_H)
85 #       include <mach-o/dyld.h>
86 #   endif
87 typedef NSModule module_handle_t;
88 #elif defined(HAVE_IMAGE_H)
89 typedef int module_handle_t;
90 #elif defined(WIN32) || defined(UNDER_CE)
91 typedef void * module_handle_t;
92 #elif defined(HAVE_DL_DLOPEN)
93 typedef void * module_handle_t;
94 #elif defined(HAVE_DL_SHL_LOAD)
95 typedef shl_t module_handle_t;
96 #endif
97
98 /**
99  * Internal module descriptor
100  */
101 struct module_t
102 {
103     VLC_COMMON_MEMBERS
104
105     /*
106      * Variables set by the module to identify itself
107      */
108     const char *psz_shortname;                              /**< Module name */
109     const char *psz_longname;                   /**< Module descriptive name */
110     const char *psz_help;        /**< Long help string for "special" modules */
111
112     /*
113      * Variables set by the module to tell us what it can do
114      */
115     const char *psz_program; /**< Program name which will activate the module */
116
117     /** Shortcuts to the module */
118     const char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];
119
120     const char    *psz_capability;                           /**< Capability */
121     int      i_score;                          /**< Score for the capability */
122     uint32_t i_cpu;                           /**< Required CPU capabilities */
123
124     vlc_bool_t b_unloadable;                        /**< Can we be dlclosed? */
125     vlc_bool_t b_reentrant;                           /**< Are we reentrant? */
126     vlc_bool_t b_submodule;                        /**< Is this a submodule? */
127
128     /* Callbacks */
129     int  ( * pf_activate )   ( vlc_object_t * );
130     void ( * pf_deactivate ) ( vlc_object_t * );
131
132     /*
133      * Variables set by the module to store its config options
134      */
135     module_config_t *p_config;             /* Module configuration structure */
136     size_t           confsize;            /* Number of module_config_t items */
137     unsigned int     i_config_items;        /* number of configuration items */
138     unsigned int     i_bool_items;            /* number of bool config items */
139
140     /*
141      * Variables used internally by the module manager
142      */
143     /* Plugin-specific stuff */
144     module_handle_t     handle;                             /* Unique handle */
145     char *              psz_filename;                     /* Module filename */
146
147     vlc_bool_t          b_builtin;  /* Set to true if the module is built in */
148     vlc_bool_t          b_loaded;        /* Set to true if the dll is loaded */
149 };
150 #endif
151
152
153 #define module_InitBank(a)     __module_InitBank(VLC_OBJECT(a))
154 void  __module_InitBank        ( vlc_object_t * );
155 #define module_LoadBuiltins(a) __module_LoadBuiltins(VLC_OBJECT(a))
156 void  __module_LoadBuiltins    ( vlc_object_t * );
157 #define module_LoadPlugins(a)  __module_LoadPlugins(VLC_OBJECT(a))
158 void  __module_LoadPlugins     ( vlc_object_t * );
159 #define module_EndBank(a)      __module_EndBank(VLC_OBJECT(a))
160 void  __module_EndBank         ( vlc_object_t * );
161 #define module_ResetBank(a)    __module_ResetBank(VLC_OBJECT(a))
162 void  __module_ResetBank       ( vlc_object_t * );
163
164 /* Low-level OS-dependant handler */
165 int  module_Call   (module_t *);
166 int  module_Load   (vlc_object_t *, const char *, module_handle_t *);
167 void module_Unload (module_handle_t);
168
169 /* Plugins cache */
170 void   CacheMerge (vlc_object_t *, module_t *, module_t *);
171 void   CacheLoad  (vlc_object_t * );
172 void   CacheSave  (vlc_object_t * );
173 module_cache_t * CacheFind (vlc_object_t *, const char *, int64_t, int64_t);
174
175 #endif /* !__LIBVLC_MODULES_H */