1 |
/* |
---|
2 |
* Copyright (c) 2007, 2008, OmniTI Computer Consulting, Inc. |
---|
3 |
* All rights reserved. |
---|
4 |
* |
---|
5 |
* Redistribution and use in source and binary forms, with or without |
---|
6 |
* modification, are permitted provided that the following conditions are |
---|
7 |
* met: |
---|
8 |
* |
---|
9 |
* * Redistributions of source code must retain the above copyright |
---|
10 |
* notice, this list of conditions and the following disclaimer. |
---|
11 |
* * Redistributions in binary form must reproduce the above |
---|
12 |
* copyright notice, this list of conditions and the following |
---|
13 |
* disclaimer in the documentation and/or other materials provided |
---|
14 |
* with the distribution. |
---|
15 |
* * Neither the name OmniTI Computer Consulting, Inc. nor the names |
---|
16 |
* of its contributors may be used to endorse or promote products |
---|
17 |
* derived from this software without specific prior written |
---|
18 |
* permission. |
---|
19 |
* |
---|
20 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
21 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
22 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
23 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
24 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
25 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
26 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
27 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
28 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
29 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
30 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
31 |
*/ |
---|
32 |
|
---|
33 |
#ifndef _NOIT_MODULE_H |
---|
34 |
#define _NOIT_MODULE_H |
---|
35 |
|
---|
36 |
#include "noit_defines.h" |
---|
37 |
#include "utils/noit_hash.h" |
---|
38 |
#include "noit_check.h" |
---|
39 |
|
---|
40 |
#define NOIT_LOADER_MAGIC 0xA7AD7104 |
---|
41 |
#define NOIT_LOADER_ABI_VERSION 4 |
---|
42 |
|
---|
43 |
typedef struct _noit_image { |
---|
44 |
uint32_t magic; |
---|
45 |
uint32_t version; |
---|
46 |
char *name; |
---|
47 |
char *description; |
---|
48 |
char *xml_description; |
---|
49 |
int (*onload)(struct _noit_image *); |
---|
50 |
void *opaque_handle; |
---|
51 |
} noit_image_t; |
---|
52 |
|
---|
53 |
/* onload: is called immediately after the module is loaded and before it |
---|
54 |
* is configured. |
---|
55 |
*/ |
---|
56 |
|
---|
57 |
typedef struct _noit_module_generic { |
---|
58 |
noit_image_t hdr; |
---|
59 |
int (*config)(struct _noit_module_generic *, noit_hash_table *config); |
---|
60 |
int (*init)(struct _noit_module_generic *); |
---|
61 |
} noit_module_generic_t; |
---|
62 |
|
---|
63 |
#define NOIT_GENERIC_MAGIC 0x3FD892A0 |
---|
64 |
#define NOIT_GENERIC_ABI_VERSION 1 |
---|
65 |
|
---|
66 |
typedef struct _noit_module_loader { |
---|
67 |
noit_image_t hdr; |
---|
68 |
int (*config)(struct _noit_module_loader *, noit_hash_table *config); |
---|
69 |
int (*init)(struct _noit_module_loader *); |
---|
70 |
struct _noit_module *(*load)(struct _noit_module_loader *loader, |
---|
71 |
char *module_name, |
---|
72 |
noit_conf_section_t section); |
---|
73 |
} noit_module_loader_t; |
---|
74 |
|
---|
75 |
/* config: is called once to configure the loader itself |
---|
76 |
* init: is called once, post config to initialize the module |
---|
77 |
* load: is called each time the loader is asked to load a module |
---|
78 |
*/ |
---|
79 |
|
---|
80 |
#define NOIT_MODULE_MAGIC 0x4017DA7A |
---|
81 |
#define NOIT_MODULE_ABI_VERSION 3 |
---|
82 |
|
---|
83 |
typedef struct _noit_module { |
---|
84 |
noit_image_t hdr; |
---|
85 |
int (*config)(struct _noit_module *, noit_hash_table *options); |
---|
86 |
int (*init)(struct _noit_module *); |
---|
87 |
int (*initiate_check)(struct _noit_module *, noit_check_t *check, |
---|
88 |
int once, noit_check_t *cause); |
---|
89 |
void (*cleanup)(struct _noit_module *, noit_check_t *); |
---|
90 |
} noit_module_t; |
---|
91 |
|
---|
92 |
/* config: is called to pass the config into the module. |
---|
93 |
* init: is called once to initialize the module |
---|
94 |
* initiate_check: is called so start the module against checks |
---|
95 |
* cleanup: is called if a particular check is stopped |
---|
96 |
*/ |
---|
97 |
|
---|
98 |
#define NOIT_IMAGE_MAGIC(a) ((a)->magic) |
---|
99 |
#define NOIT_IMAGE_VERSION(a) ((a)->version) |
---|
100 |
|
---|
101 |
API_EXPORT(void) |
---|
102 |
noit_module_init(); |
---|
103 |
API_EXPORT(int) |
---|
104 |
noit_module_load_failures(); |
---|
105 |
API_EXPORT(int) |
---|
106 |
noit_module_load(const char *file, const char *name); |
---|
107 |
API_EXPORT(noit_module_t *) |
---|
108 |
noit_module_lookup(const char *name); |
---|
109 |
API_EXPORT(noit_module_t *) |
---|
110 |
noit_blank_module(); |
---|
111 |
API_EXPORT(int) |
---|
112 |
noit_register_module(noit_module_t *mod); |
---|
113 |
|
---|
114 |
API_EXPORT(void *) |
---|
115 |
noit_image_get_userdata(noit_image_t *mod); |
---|
116 |
API_EXPORT(void) |
---|
117 |
noit_image_set_userdata(noit_image_t *mod, void *newdata); |
---|
118 |
API_EXPORT(void *) |
---|
119 |
noit_module_loader_get_userdata(noit_module_loader_t *mod); |
---|
120 |
API_EXPORT(void) |
---|
121 |
noit_module_loader_set_userdata(noit_module_loader_t *mod, void *newdata); |
---|
122 |
API_EXPORT(void *) |
---|
123 |
noit_module_get_userdata(noit_module_t *mod); |
---|
124 |
API_EXPORT(void) |
---|
125 |
noit_module_set_userdata(noit_module_t *mod, void *newdata); |
---|
126 |
API_EXPORT(void) |
---|
127 |
noit_module_print_help(noit_console_closure_t ncct, |
---|
128 |
noit_module_t *module, int examples); |
---|
129 |
|
---|
130 |
#endif |
---|