File: modules_inner.h

package info (click to toggle)
vlc 0.2.92-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,076 kB
  • ctags: 7,147
  • sloc: ansic: 62,829; cpp: 5,824; sh: 2,469; xml: 2,351; makefile: 1,291; python: 503; perl: 19
file content (181 lines) | stat: -rw-r--r-- 6,538 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*****************************************************************************
 * modules_inner.h : Macros used from within a module.
 *****************************************************************************
 * Copyright (C) 2001 VideoLAN
 * $Id: modules_inner.h,v 1.7.2.1 2001/12/11 15:35:08 sam Exp $
 *
 * Authors: Samuel Hocevar <sam@zoy.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Check that we are within a module.
 *****************************************************************************/
#if !( defined( MODULE_NAME ) || defined( MAKE_DEP ) )
#  error "You must define MODULE_NAME before using modules_inner.h !"
#endif

/*****************************************************************************
 * Add a few defines. You do not want to read this section. Really.
 *****************************************************************************/

/* Explanation:
 *
 * if user has #defined MODULE_NAME foo, then we will need:
 * #define MODULE_STRING "foo"
 * #define MODULE_VAR(blah) "VLC_MODULE_foo_blah"
 *
 * and, if BUILTIN is set, we will also need:
 * #define MODULE_FUNC( zog ) module_foo_zog
 *
 * this can't easily be done with the C preprocessor, thus a few ugly hacks.
 */

/* I can't believe I need to do this to change  foo  to  "foo"  */
#define STRINGIFY( z )   UGLY_KLUDGE( z )
#define UGLY_KLUDGE( z ) #z
/* And I need to do _this_ to change  foo bar  to  module_foo_bar  ! */
#define CONCATENATE( y, z ) CRUDE_HACK( y, z )
#define CRUDE_HACK( y, z )  module_##y##_##z

#define MODULE_VAR( z ) "VLC_MODULE_" #z

/* If the module is built-in, then we need to define foo_InitModule instead
 * of InitModule. Same for Activate- and DeactivateModule. */
#ifdef BUILTIN

#   define _M( function ) CONCATENATE( MODULE_NAME, function )

#   define MODULE_INIT_START \
        int CONCATENATE( MODULE_NAME, InitModule ) ( module_t *p_module ) \
        { \
            p_module->psz_name = MODULE_STRING; \
            p_module->psz_version = VERSION;

#   define MODULE_INIT_STOP \
            return( 0 ); \
        }

#   define MODULE_ACTIVATE_START \
        int CONCATENATE( MODULE_NAME, ActivateModule ) ( module_t *p_module ) \
        { \
            p_module->p_functions = \
              ( module_functions_t * )malloc( sizeof( module_functions_t ) ); \
            if( p_module->p_functions == NULL ) \
            { \
                return( -1 ); \
            } \
            p_module->p_config = p_config;

#   define MODULE_ACTIVATE_STOP \
            return( 0 ); \
        }

#   define MODULE_DEACTIVATE_START \
        int CONCATENATE( MODULE_NAME, DeactivateModule )( module_t *p_module ) \
        { \
            free( p_module->p_functions );

#   define MODULE_DEACTIVATE_STOP \
            return( 0 ); \
        }

#else

#   define _M( function )    function

#   define MODULE_INIT_START \
        int InitModule      ( module_t *p_module ) \
        { \
            p_module->psz_name = MODULE_STRING; \
            p_module->psz_version = VERSION;

#   define MODULE_INIT_STOP \
            return( 0 ); \
        }

#   define MODULE_ACTIVATE_START \
        int ActivateModule  ( module_t *p_module ) \
        { \
            p_module->p_functions = \
              ( module_functions_t * )malloc( sizeof( module_functions_t ) ); \
            if( p_module->p_functions == NULL ) \
            { \
                return( -1 ); \
            } \
            p_module->p_config = p_config; \
            p_symbols = p_module->p_symbols;

#   define MODULE_ACTIVATE_STOP \
            return( 0 ); \
        }

#   define MODULE_DEACTIVATE_START \
        int DeactivateModule( module_t *p_module ) \
        { \
            free( p_module->p_functions );

#   define MODULE_DEACTIVATE_STOP \
            return( 0 ); \
        }

#endif

/* Now the real stuff */
#define MODULE_STRING STRINGIFY( MODULE_NAME )

/*****************************************************************************
 * Macros used to build the configuration structure.
 *****************************************************************************/
#ifdef BUILTIN
#   define MODULE_CONFIG_START \
        static module_config_t p_config[] = { \
            { MODULE_CONFIG_ITEM_START, NULL, NULL, NULL, NULL },
#else
#   define MODULE_CONFIG_START \
        module_symbols_t* p_symbols; \
        static module_config_t p_config[] = { \
        { MODULE_CONFIG_ITEM_START, NULL, NULL, NULL, NULL },
#endif

#define MODULE_CONFIG_STOP \
    { MODULE_CONFIG_ITEM_END, NULL, NULL, NULL, NULL } \
};

#define ADD_WINDOW( text ) \
    { MODULE_CONFIG_ITEM_WINDOW, text, NULL, NULL, NULL },
#define ADD_FRAME( text ) \
    { MODULE_CONFIG_ITEM_FRAME, text, NULL, NULL, NULL },
#define ADD_PANE( text ) \
    { MODULE_CONFIG_ITEM_PANE, text, NULL, NULL, NULL },
#define ADD_COMMENT( text ) \
    { MODULE_CONFIG_ITEM_COMMENT, text, NULL, NULL, NULL },
#define ADD_STRING( text, name, p_update ) \
    { MODULE_CONFIG_ITEM_STRING, text, name, NULL, p_update },
#define ADD_FILE( text, name, p_update ) \
    { MODULE_CONFIG_ITEM_FILE, text, name, NULL, p_update },
#define ADD_CHECK( text, name, p_update ) \
    { MODULE_CONFIG_ITEM_CHECK, text, name, NULL, p_update },
#define ADD_CHOOSE( text, name, p_getlist, p_update ) \
    { MODULE_CONFIG_ITEM_CHOOSE, text, name, p_getlist, p_update },
#define ADD_RADIO( text, name, p_getlist, p_update ) \
    { MODULE_CONFIG_ITEM_RADIO, text, name, p_getlist, p_update },
#define ADD_SCALE( text, name, p_getlist, p_update ) \
    { MODULE_CONFIG_ITEM_SCALE, text, name, p_getlist, p_update },
#define ADD_SPIN( text, name, p_getlist, p_update ) \
    { MODULE_CONFIG_ITEM_SPIN, text, name, p_getlist, p_update },