]> git.sesse.net Git - vlc/blob - src/modules/entry.c
Initial work on hiding module_t layout from plugins
[vlc] / src / modules / entry.c
1 /*****************************************************************************
2  * entry.c : Callbacks for module entry point
3  *****************************************************************************
4  * Copyright (C) 2001-2007 the VideoLAN team
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20
21 #include <vlc/vlc.h>
22 #include <assert.h>
23
24
25 module_t *vlc_submodule_create (module_t *module)
26 {
27     assert (module != NULL);
28     assert (!module->b_submodule); // subsubmodules are not supported
29
30     module_t *submodule =
31             (module_t *)vlc_object_create (module, VLC_OBJECT_MODULE);
32     if (submodule == NULL)
33         return NULL;
34
35     vlc_object_attach (submodule, module);
36     submodule->b_submodule = VLC_TRUE;
37
38     /* Muahahaha! Heritage! Polymorphism! Ugliness!! */
39     memcpy (submodule->pp_shortcuts, module->pp_shortcuts,
40             sizeof (submodule->pp_shortcuts));
41
42     submodule->psz_object_name = module->psz_object_name;
43     submodule->psz_shortname = module->psz_shortname;
44     submodule->psz_longname = module->psz_longname;
45     submodule->psz_program = module->psz_program;
46     submodule->psz_capability = module->psz_capability;
47     submodule->i_score = module->i_score;
48     submodule->i_cpu = module->i_cpu;
49     submodule->pf_activate = NULL;
50     submodule->pf_deactivate = NULL;
51     return submodule;
52 }
53
54 int vlc_module_set (module_t *module, int propid, void *value)
55 {
56     switch (propid)
57     {
58         case VLC_MODULE_CPU_REQUIREMENT:
59             assert (!module->b_submodule);
60             module->i_cpu |= (int)value;
61             break;
62
63         case VLC_MODULE_SHORTCUT:
64         {
65             unsigned i;
66             for (i = 0; module->pp_shortcuts[i] != NULL; i++);
67             if (i >= MODULE_SHORTCUT_MAX)
68                 return VLC_ENOMEM;
69
70             module->pp_shortcuts[i] = (char *)value;
71             break;
72         }
73
74         case VLC_MODULE_SHORTNAME:
75             module->psz_shortname = (char *)value;
76             break;
77
78         case VLC_MODULE_DESCRIPTION:
79             module->psz_longname = (char *)value;
80             break;
81
82         case VLC_MODULE_HELP:
83             module->psz_help = (char *)value;
84             break;
85
86         case VLC_MODULE_CAPABILITY:
87             module->psz_capability = (char *)value;
88             break;
89
90         case VLC_MODULE_SCORE:
91             module->i_score = (int)value;
92             break;
93
94         case VLC_MODULE_PROGRAM:
95             module->psz_program = (char *)value;
96             break;
97
98         case VLC_MODULE_CB_OPEN:
99             module->pf_activate = (int (*) (vlc_object_t *))value;
100             break;
101
102         case VLC_MODULE_CB_CLOSE:
103             module->pf_deactivate = (void (*) (vlc_object_t *))value;
104             break;
105
106         case VLC_MODULE_UNLOADABLE:
107             module->b_unloadable = (value != NULL);
108             break;
109
110         default:
111             msg_Err (module, "unknown module property %d", propid);
112             msg_Err (module, "LibVLC might be too old to use this module.");
113             return VLC_EGENERIC;
114     }
115     return 0;
116 }