sim: Fix up various coding style violations
[platform/upstream/ofono.git] / include / plugin.h
1 /*
2  *
3  *  oFono - Open Source Telephony
4  *
5  *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
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 St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifndef __OFONO_PLUGIN_H
23 #define __OFONO_PLUGIN_H
24
25 #include <ofono/version.h>
26 #include <ofono/log.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #ifndef OFONO_API_SUBJECT_TO_CHANGE
33 #error "Please define OFONO_API_SUBJECT_TO_CHANGE to acknowledge your \
34 understanding that oFono hasn't reached a stable API."
35 #endif
36
37 #define OFONO_PLUGIN_PRIORITY_LOW      -100
38 #define OFONO_PLUGIN_PRIORITY_DEFAULT     0
39 #define OFONO_PLUGIN_PRIORITY_HIGH      100
40
41 /**
42  * SECTION:plugin
43  * @title: Plugin premitives
44  * @short_description: Functions for declaring plugins
45  */
46
47 struct ofono_plugin_desc {
48         const char *name;
49         const char *description;
50         const char *version;
51         int priority;
52         int (*init) (void);
53         void (*exit) (void);
54         void *debug_start;
55         void *debug_stop;
56 };
57
58 /**
59  * OFONO_PLUGIN_DEFINE:
60  * @name: plugin name
61  * @description: plugin description
62  * @version: plugin version string
63  * @init: init function called on plugin loading
64  * @exit: exit function called on plugin removal
65  *
66  * Macro for defining a plugin descriptor
67  */
68 #ifdef OFONO_PLUGIN_BUILTIN
69 #define OFONO_PLUGIN_DEFINE(name, description, version, priority, init, exit) \
70                 struct ofono_plugin_desc __ofono_builtin_ ## name = { \
71                         #name, description, version, priority, init, exit \
72                 };
73 #else
74 #define OFONO_PLUGIN_DEFINE(name, description, version, priority, init, exit) \
75                 extern struct ofono_debug_desc __start___debug[] \
76                                 __attribute__ ((weak, visibility("hidden"))); \
77                 extern struct ofono_debug_desc __stop___debug[] \
78                                 __attribute__ ((weak, visibility("hidden"))); \
79                 extern struct ofono_plugin_desc ofono_plugin_desc \
80                                 __attribute__ ((visibility("default"))); \
81                 struct ofono_plugin_desc ofono_plugin_desc = { \
82                         #name, description, version, priority, init, exit, \
83                         __start___debug, __stop___debug \
84                 };
85 #endif
86
87 #ifdef __cplusplus
88 }
89 #endif
90
91 #endif /* __OFONO_PLUGIN_H */