1 /*****************************************************************************
2 * modules_inner.h : Macros used from within a module.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: modules_inner.h,v 1.6 2001/03/21 13:42:33 sam Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
25 * Check that we are within a module.
26 *****************************************************************************/
28 # error "You must define MODULE_NAME before using modules_inner.h !"
31 /*****************************************************************************
32 * Add a few defines. You do not want to read this section. Really.
33 *****************************************************************************/
37 * if user has #defined MODULE_NAME foo, then we will need:
38 * #define MODULE_STRING "foo"
39 * #define MODULE_VAR(blah) "VLC_MODULE_foo_blah"
41 * and, if BUILTIN is set, we will also need:
42 * #define MODULE_FUNC( zog ) module_foo_zog
44 * this can't easily be done with the C preprocessor, thus a few ugly hacks.
47 /* I can't believe I need to do this to change « foo » to « "foo" » */
48 #define STRINGIFY( z ) UGLY_KLUDGE( z )
49 #define UGLY_KLUDGE( z ) #z
50 /* And I need to do _this_ to change « foo bar » to « module_foo_bar » ! */
51 #define CONCATENATE( y, z ) CRUDE_HACK( y, z )
52 #define CRUDE_HACK( y, z ) module_##y##_##z
54 #define MODULE_VAR( z ) "VLC_MODULE_" #z
56 /* If the module is built-in, then we need to define foo_InitModule instead
57 * of InitModule. Same for Activate- and DeactivateModule. */
59 # define _M( function ) CONCATENATE( MODULE_NAME, function )
60 # define MODULE_INIT \
61 int CONCATENATE( MODULE_NAME, InitModule ) ( module_t *p_module )
62 # define MODULE_ACTIVATE \
63 int CONCATENATE( MODULE_NAME, ActivateModule ) ( module_t *p_module )
64 # define MODULE_DEACTIVATE \
65 int CONCATENATE( MODULE_NAME, DeactivateModule )( module_t *p_module )
67 # define _M( function ) function
68 # define MODULE_INIT int InitModule ( module_t *p_module )
69 # define MODULE_ACTIVATE int ActivateModule ( module_t *p_module )
70 # define MODULE_DEACTIVATE int DeactivateModule ( module_t *p_module )
73 /* Now the real stuff */
74 #define MODULE_STRING STRINGIFY( MODULE_NAME )
76 /*****************************************************************************
77 * Macros used to build the configuration structure.
78 *****************************************************************************/
79 #define MODULE_CONFIG_START \
80 static module_config_t p_config[] = { \
81 { MODULE_CONFIG_ITEM_START, NULL, NULL, NULL, NULL },
83 #define MODULE_CONFIG_END \
84 { MODULE_CONFIG_ITEM_END, NULL, NULL, NULL, NULL } \
87 #define ADD_WINDOW( text ) \
88 { MODULE_CONFIG_ITEM_WINDOW, text, NULL, NULL, NULL },
89 #define ADD_FRAME( text ) \
90 { MODULE_CONFIG_ITEM_FRAME, text, NULL, NULL, NULL },
91 #define ADD_PANE( text ) \
92 { MODULE_CONFIG_ITEM_PANE, text, NULL, NULL, NULL },
93 #define ADD_COMMENT( text ) \
94 { MODULE_CONFIG_ITEM_COMMENT, text, NULL, NULL, NULL },
95 #define ADD_STRING( text, name, p_update ) \
96 { MODULE_CONFIG_ITEM_STRING, text, name, NULL, p_update },
97 #define ADD_FILE( text, name, p_update ) \
98 { MODULE_CONFIG_ITEM_FILE, text, name, NULL, p_update },
99 #define ADD_CHECK( text, name, p_update ) \
100 { MODULE_CONFIG_ITEM_CHECK, text, name, NULL, p_update },
101 #define ADD_CHOOSE( text, name, p_getlist, p_update ) \
102 { MODULE_CONFIG_ITEM_CHOOSE, text, name, p_getlist, p_update },
103 #define ADD_RADIO( text, name, p_getlist, p_update ) \
104 { MODULE_CONFIG_ITEM_RADIO, text, name, p_getlist, p_update },
105 #define ADD_SCALE( text, name, p_getlist, p_update ) \
106 { MODULE_CONFIG_ITEM_SCALE, text, name, p_getlist, p_update },
107 #define ADD_SPIN( text, name, p_getlist, p_update ) \
108 { MODULE_CONFIG_ITEM_SPIN, text, name, p_getlist, p_update },