]> git.sesse.net Git - vlc/blob - src/modules/modules.h
modules: remove an unused define and assert if we try to add too many shortcuts.
[vlc] / src / modules / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 the VideoLAN team
5  * $Id$
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  * module_bank_t: the module bank
33  *****************************************************************************
34  * This variable is accessed by any function using modules.
35  *****************************************************************************/
36 struct module_bank_t
37 {
38     unsigned         i_usage;
39
40     /* Plugins cache */
41     bool             b_cache;
42     bool             b_cache_dirty;
43
44     int            i_cache;
45     module_cache_t **pp_cache;
46
47     int            i_loaded_cache;
48     module_cache_t **pp_loaded_cache;
49
50     module_t       *head;
51 };
52
53 /*****************************************************************************
54  * Module cache description structure
55  *****************************************************************************/
56 struct module_cache_t
57 {
58     /* Mandatory cache entry header */
59     char       *psz_file;
60     int64_t    i_time;
61     int64_t    i_size;
62
63     /* Optional extra data */
64     module_t *p_module;
65 };
66
67
68 #define MODULE_SHORTCUT_MAX 20
69
70 /* The module handle type. */
71 #if defined(HAVE_DL_DYLD) && !defined(__x86_64__)
72 #   if defined (HAVE_MACH_O_DYLD_H)
73 #       include <mach-o/dyld.h>
74 #   endif
75 typedef NSModule module_handle_t;
76 #elif defined(HAVE_IMAGE_H)
77 typedef int module_handle_t;
78 #elif defined(WIN32) || defined(UNDER_CE)
79 typedef void * module_handle_t;
80 #elif defined(HAVE_DL_DLOPEN)
81 typedef void * module_handle_t;
82 #elif defined(HAVE_DL_SHL_LOAD)
83 typedef shl_t module_handle_t;
84 #endif
85
86 /**
87  * Internal module descriptor
88  */
89 struct module_t
90 {
91     char       *psz_object_name;
92     gc_object_t vlc_gc_data;
93
94     module_t   *next;
95     module_t   *parent;
96     module_t   *submodule;
97     unsigned    submodule_count;
98
99     /** Shortcuts to the module */
100     unsigned    i_shortcuts;
101     char        **pp_shortcuts;
102
103     /*
104      * Variables set by the module to identify itself
105      */
106     char *psz_shortname;                              /**< Module name */
107     char *psz_longname;                   /**< Module descriptive name */
108     char *psz_help;        /**< Long help string for "special" modules */
109
110     char    *psz_capability;                                 /**< Capability */
111     int      i_score;                          /**< Score for the capability */
112
113     bool          b_builtin;  /* Set to true if the module is built in */
114     bool          b_loaded;        /* Set to true if the dll is loaded */
115     bool b_unloadable;                        /**< Can we be dlclosed? */
116     bool b_submodule;                        /**< Is this a submodule? */
117
118     /* Callbacks */
119     int  ( * pf_activate )   ( vlc_object_t * );
120     void ( * pf_deactivate ) ( vlc_object_t * );
121
122     /*
123      * Variables set by the module to store its config options
124      */
125     module_config_t *p_config;             /* Module configuration structure */
126     size_t           confsize;            /* Number of module_config_t items */
127     unsigned int     i_config_items;        /* number of configuration items */
128     unsigned int     i_bool_items;            /* number of bool config items */
129
130     /*
131      * Variables used internally by the module manager
132      */
133     /* Plugin-specific stuff */
134     module_handle_t     handle;                             /* Unique handle */
135     char *              psz_filename;                     /* Module filename */
136     char *              domain;                            /* gettext domain */
137 };
138
139 module_t *vlc_module_create (vlc_object_t *);
140 module_t *vlc_submodule_create (module_t *module);
141
142 void  module_InitBank( vlc_object_t * );
143 #define module_InitBank(a) module_InitBank(VLC_OBJECT(a))
144 void module_LoadPlugins( vlc_object_t * );
145 #define module_LoadPlugins(a) module_LoadPlugins(VLC_OBJECT(a))
146 void module_EndBank( vlc_object_t *, bool );
147 #define module_EndBank(a,b) module_EndBank(VLC_OBJECT(a), b)
148
149 int vlc_bindtextdomain (const char *);
150
151 /* Low-level OS-dependent handler */
152 int  module_Load   (vlc_object_t *, const char *, module_handle_t *);
153 int  module_Call   (vlc_object_t *obj, module_t *);
154 void module_Unload (module_handle_t);
155
156 /* Plugins cache */
157 void   CacheMerge (vlc_object_t *, module_t *, module_t *);
158 void   CacheDelete(vlc_object_t *, const char *);
159 void   CacheLoad  (vlc_object_t *, module_bank_t *, const char *);
160 void   CacheSave  (vlc_object_t *, const char *, module_cache_t *const *, size_t);
161 module_cache_t * CacheFind (module_bank_t *, const char *, int64_t, int64_t);
162
163 #endif /* !LIBVLC_MODULES_H */