root/src/noit_module.h

Revision 88a71780101cbf23034aa0cb840f9f0368fda2dd, 4.3 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 5 years ago)

fixes #126

  • Property mode set to 100644
Line 
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_loader {
58   noit_image_t hdr;
59   int (*config)(struct _noit_module_loader *, noit_hash_table *config);
60   int (*init)(struct _noit_module_loader *);
61   struct _noit_module *(*load)(struct _noit_module_loader *loader,
62                                char *module_name,
63                                noit_conf_section_t section);
64 } noit_module_loader_t;
65
66 /* config:  is called once to configure the loader itself
67  *   init:  is called once, post config to initialize the module
68  *   load:  is called each time the loader is asked to load a module
69  */
70
71 #define NOIT_MODULE_MAGIC         0x4017DA7A
72 #define NOIT_MODULE_ABI_VERSION   3
73
74 typedef struct _noit_module {
75   noit_image_t hdr;
76   int (*config)(struct _noit_module *, noit_hash_table *options);
77   int (*init)(struct _noit_module *);
78   int (*initiate_check)(struct _noit_module *, noit_check_t *check,
79                         int once, noit_check_t *cause);
80   void (*cleanup)(struct _noit_module *, noit_check_t *);
81 } noit_module_t;
82
83 /*         config: is called to pass the config into the module.
84  *           init: is called once to initialize the module
85  * initiate_check: is called so start the module against checks
86  *        cleanup: is called if a particular check is stopped
87  */
88
89 #define NOIT_IMAGE_MAGIC(a)          ((a)->magic)
90 #define NOIT_IMAGE_VERSION(a)        ((a)->version)
91
92 API_EXPORT(void)
93   noit_module_init();
94 API_EXPORT(int)
95   noit_module_load(const char *file, const char *name);
96 API_EXPORT(noit_module_t *)
97   noit_module_lookup(const char *name);
98 API_EXPORT(noit_module_t *)
99   noit_blank_module();
100 API_EXPORT(int)
101   noit_register_module(noit_module_t *mod);
102
103 API_EXPORT(void *)
104   noit_image_get_userdata(noit_image_t *mod);
105 API_EXPORT(void)
106   noit_image_set_userdata(noit_image_t *mod, void *newdata);
107 API_EXPORT(void *)
108   noit_module_loader_get_userdata(noit_module_loader_t *mod);
109 API_EXPORT(void)
110   noit_module_loader_set_userdata(noit_module_loader_t *mod, void *newdata);
111 API_EXPORT(void *)
112   noit_module_get_userdata(noit_module_t *mod);
113 API_EXPORT(void)
114   noit_module_set_userdata(noit_module_t *mod, void *newdata);
115 API_EXPORT(void)
116   noit_module_print_help(noit_console_closure_t ncct,
117                          noit_module_t *module, int examples);
118
119 #endif
Note: See TracBrowser for help on using the browser.