dnsproxy: Only one copy of the relevant buffers will be made to a TCP request
[framework/connectivity/connman.git] / include / plugin.h
1 /*
2  *
3  *  Connection Manager
4  *
5  *  Copyright (C) 2007-2012  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 __CONNMAN_PLUGIN_H
23 #define __CONNMAN_PLUGIN_H
24
25 #include <connman/version.h>
26 #include <connman/log.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #ifndef CONNMAN_API_SUBJECT_TO_CHANGE
33 #error "Please define CONNMAN_API_SUBJECT_TO_CHANGE to acknowledge your \
34 understanding that ConnMan hasn't reached a stable API."
35 #endif
36
37 #define CONNMAN_PLUGIN_PRIORITY_LOW      -100
38 #define CONNMAN_PLUGIN_PRIORITY_DEFAULT     0
39 #define CONNMAN_PLUGIN_PRIORITY_HIGH      100
40
41 /**
42  * SECTION:plugin
43  * @title: Plugin premitives
44  * @short_description: Functions for declaring plugins
45  */
46
47 struct connman_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  * CONNMAN_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  * |[
69  * #include <connman/plugin.h>
70  *
71  * static int example_init(void)
72  * {
73  *      return 0;
74  * }
75  *
76  * static void example_exit(void)
77  * {
78  * }
79  *
80  * CONNMAN_PLUGIN_DEFINE(example, "Example plugin", CONNMAN_VERSION,
81  *                                      example_init, example_exit)
82  * ]|
83  */
84 #ifdef CONNMAN_PLUGIN_BUILTIN
85 #define CONNMAN_PLUGIN_DEFINE(name, description, version, priority, init, exit) \
86                 struct connman_plugin_desc __connman_builtin_ ## name = { \
87                         #name, description, version, priority, init, exit \
88                 };
89 #else
90 #define CONNMAN_PLUGIN_DEFINE(name, description, version, priority, init, exit) \
91                 extern struct connman_debug_desc __start___debug[] \
92                                 __attribute__ ((weak, visibility("hidden"))); \
93                 extern struct connman_debug_desc __stop___debug[] \
94                                 __attribute__ ((weak, visibility("hidden"))); \
95                 extern struct connman_plugin_desc connman_plugin_desc \
96                                 __attribute__ ((visibility("default"))); \
97                 struct connman_plugin_desc connman_plugin_desc = { \
98                         #name, description, version, priority, init, exit, \
99                         __start___debug, __stop___debug \
100                 };
101 #endif
102
103 #ifdef __cplusplus
104 }
105 #endif
106
107 #endif /* __CONNMAN_PLUGIN_H */