]> git.sesse.net Git - vlc/blob - include/modules_inner.h
* Ported Glide and MGA plugins to the new module API. MGA never worked,
[vlc] / include / modules_inner.h
1 /*****************************************************************************
2  * modules_inner.h : Macros used from within a module.
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  *
6  * Authors: Samuel Hocevar <sam@zoy.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Check that we are within a module.
25  *****************************************************************************/
26 #ifndef MODULE_NAME
27 #  error "You must define MODULE_NAME before using modules_inner.h !"
28 #endif
29
30 /*****************************************************************************
31  * Add a few defines. You do not want to read this section. Really.
32  *****************************************************************************/
33
34 /* Explanation:
35  *
36  * if user has #defined MODULE_NAME foo, then we will need:
37  * #define MODULE_STRING "foo"
38  * #define MODULE_VAR(blah) "VLC_MODULE_foo_blah"
39  *
40  * and, if BUILTIN is set, we will also need:
41  * #define MODULE_FUNC( zog ) module_foo_zog
42  *
43  * this can't easily be done with the C preprocessor, thus a few ugly hacks.
44  */
45
46 /* I can't believe I need to do this to change « foo » to « "foo" » */
47 #define UGLY_KLUDGE( z ) NASTY_CROCK( z )
48 #define NASTY_CROCK( z ) #z
49 /* And I need to do _this_ to change « foo bar » to « module_foo_bar » ! */
50 #define AWFUL_BRITTLE( y, z ) CRUDE_HACK( y, z )
51 #define CRUDE_HACK( y, z ) module_##y##_##z
52
53 #define MODULE_VAR( z ) "VLC_MODULE_" #z
54
55 /* If the module is built-in, then we need to define foo_InitModule instead
56  * of InitModule. Same for Activate- and DeactivateModule. */
57 #ifdef BUILTIN
58 #   define _M( function )    AWFUL_BRITTLE( MODULE_NAME, function )
59 #   define MODULE_INIT \
60       int AWFUL_BRITTLE( MODULE_NAME, InitModule )      ( module_t *p_module )
61 #   define MODULE_ACTIVATE \
62       int AWFUL_BRITTLE( MODULE_NAME, ActivateModule )  ( module_t *p_module )
63 #   define MODULE_DEACTIVATE \
64       int AWFUL_BRITTLE( MODULE_NAME, DeactivateModule )( module_t *p_module )
65 #else
66 #   define _M( function )    function
67 #   define MODULE_INIT       int InitModule       ( module_t *p_module )
68 #   define MODULE_ACTIVATE   int ActivateModule   ( module_t *p_module )
69 #   define MODULE_DEACTIVATE int DeactivateModule ( module_t *p_module )
70 #endif
71
72 /* Now the real stuff */
73 #define MODULE_STRING UGLY_KLUDGE( MODULE_NAME )
74
75 /*****************************************************************************
76  * Macros used to build the configuration structure.
77  *****************************************************************************/
78 #define MODULE_CONFIG_START \
79 static module_config_t p_config[] = { \
80     { MODULE_CONFIG_ITEM_START, NULL, NULL, NULL, NULL },
81
82 #define MODULE_CONFIG_END \
83     { MODULE_CONFIG_ITEM_END, NULL, NULL, NULL, NULL } \
84 };
85
86 #define ADD_WINDOW( text ) \
87     { MODULE_CONFIG_ITEM_WINDOW, text, NULL, NULL, NULL },
88 #define ADD_FRAME( text ) \
89     { MODULE_CONFIG_ITEM_FRAME, text, NULL, NULL, NULL },
90 #define ADD_PANE( text ) \
91     { MODULE_CONFIG_ITEM_PANE, text, NULL, NULL, NULL },
92 #define ADD_COMMENT( text ) \
93     { MODULE_CONFIG_ITEM_COMMENT, text, NULL, NULL, NULL },
94 #define ADD_STRING( text, name, p_update ) \
95     { MODULE_CONFIG_ITEM_STRING, text, name, NULL, p_update },
96 #define ADD_FILE( text, name, p_update ) \
97     { MODULE_CONFIG_ITEM_FILE, text, name, NULL, p_update },
98 #define ADD_CHECK( text, name, p_update ) \
99     { MODULE_CONFIG_ITEM_CHECK, text, name, NULL, p_update },
100 #define ADD_CHOOSE( text, name, p_getlist, p_update ) \
101     { MODULE_CONFIG_ITEM_CHOOSE, text, name, p_getlist, p_update },
102 #define ADD_RADIO( text, name, p_getlist, p_update ) \
103     { MODULE_CONFIG_ITEM_RADIO, text, name, p_getlist, p_update },
104 #define ADD_SCALE( text, name, p_getlist, p_update ) \
105     { MODULE_CONFIG_ITEM_SCALE, text, name, p_getlist, p_update },
106 #define ADD_SPIN( text, name, p_getlist, p_update ) \
107     { MODULE_CONFIG_ITEM_SPIN, text, name, p_getlist, p_update },
108