1 /*****************************************************************************
2 * modules_inner.h : Macros used from within a module.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
6 * Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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 *****************************************************************************/
23 /*****************************************************************************
24 * Check that we are within a module.
25 *****************************************************************************/
27 # error "You must define MODULE_NAME before using modules_inner.h !"
30 /*****************************************************************************
31 * Add a few defines. You do not want to read this section. Really.
32 *****************************************************************************/
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"
40 * and, if BUILTIN is set, we will also need:
41 * #define MODULE_FUNC( zog ) module_foo_zog
43 * this can't easily be done with the C preprocessor, thus a few ugly hacks.
46 /* I can't believe I need to do this to change « foo » to « "foo" » */
47 #define STRINGIFY( z ) UGLY_KLUDGE( z )
48 #define UGLY_KLUDGE( z ) #z
49 /* And I need to do _this_ to change « foo bar » to « module_foo_bar » ! */
50 #define CONCATENATE( y, z ) CRUDE_HACK( y, z )
51 #define CRUDE_HACK( y, z ) module_##y##_##z
53 #define MODULE_VAR( z ) "VLC_MODULE_" #z
55 /* If the module is built-in, then we need to define foo_InitModule instead
56 * of InitModule. Same for Activate- and DeactivateModule. */
58 # define _M( function ) CONCATENATE( MODULE_NAME, function )
59 # define MODULE_INIT \
60 int CONCATENATE( MODULE_NAME, InitModule ) ( module_t *p_module )
61 # define MODULE_ACTIVATE \
62 int CONCATENATE( MODULE_NAME, ActivateModule ) ( module_t *p_module )
63 # define MODULE_DEACTIVATE \
64 int CONCATENATE( MODULE_NAME, DeactivateModule )( module_t *p_module )
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 )
72 /* Now the real stuff */
73 #define MODULE_STRING STRINGIFY( MODULE_NAME )
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 },
82 #define MODULE_CONFIG_END \
83 { MODULE_CONFIG_ITEM_END, NULL, NULL, NULL, NULL } \
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 },