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 InitModule foo_InitModule
42 * #define ActivateModule foo_ActivateModule
43 * #define DeactivateModule foo_DeactivateModule
45 * this can't easily be done with the C preprocessor, thus a few ugly hacks.
48 /* I can't believe I need to do this to change « foo » to « "foo" » */
49 #define UGLY_KLUDGE(z) NASTY_CROCK(z)
50 #define NASTY_CROCK(z) #z
51 /* And I need to do _this_ to change « foo bar » to « foo_bar » ! */
52 #define AWFUL_BRITTLE(y,z) CRUDE_HACK(y,z)
53 #define CRUDE_HACK(y,z) y##_##z
55 /* Also, I need to do this to change « blah » to « "VLC_MODULE_foo_blah" » */
56 #define MODULE_STRING UGLY_KLUDGE(MODULE_NAME)
57 #define MODULE_VAR(z) "VLC_MODULE_" UGLY_KLUDGE(MODULE_NAME) "_" #z
59 /* If the module is built-in, then we need to define foo_InitModule instead
60 * of InitModule. Same for Activate- and DeactivateModule. */
62 # define InitModule AWFUL_BRITTLE(MODULE_NAME,InitModule)
63 # define ActivateModule AWFUL_BRITTLE(MODULE_NAME,ActivateModule)
64 # define DeactivateModule AWFUL_BRITTLE(MODULE_NAME,DeactivateModule)
67 /*****************************************************************************
68 * Macros used to build the configuration structure.
69 *****************************************************************************/
70 #define MODULE_CONFIG_START( text ) \
71 static module_config_t p_config[] = { \
72 { MODULE_CONFIG_ITEM_START, text, NULL, NULL, NULL },
74 #define MODULE_CONFIG_END \
75 { MODULE_CONFIG_ITEM_END, NULL, NULL, NULL, NULL } \
78 #define ADD_FRAME( text ) \
79 { MODULE_CONFIG_ITEM_FRAME, text, NULL, NULL, NULL },
80 #define ADD_PANE( text ) \
81 { MODULE_CONFIG_ITEM_PANE, text, NULL, NULL, NULL },
82 #define ADD_COMMENT( text ) \
83 { MODULE_CONFIG_ITEM_COMMENT, text, NULL, NULL, NULL },
84 #define ADD_STRING( text, name, p_update ) \
85 { MODULE_CONFIG_ITEM_STRING, text, name, NULL, p_update },
86 #define ADD_FILE( text, name, p_update ) \
87 { MODULE_CONFIG_ITEM_FILE, text, name, NULL, p_update },
88 #define ADD_CHECK( text, name, p_update ) \
89 { MODULE_CONFIG_ITEM_CHECK, text, name, NULL, p_update },
90 #define ADD_CHOOSE( text, name, p_getlist, p_update ) \
91 { MODULE_CONFIG_ITEM_CHOOSE, text, name, p_getlist, p_update },
92 #define ADD_RADIO( text, name, p_getlist, p_update ) \
93 { MODULE_CONFIG_ITEM_RADIO, text, name, p_getlist, p_update },
94 #define ADD_SCALE( text, name, p_getlist, p_update ) \
95 { MODULE_CONFIG_ITEM_SCALE, text, name, p_getlist, p_update },
96 #define ADD_SPIN( text, name, p_getlist, p_update ) \
97 { MODULE_CONFIG_ITEM_SPIN, text, name, p_getlist, p_update },