root/src/noit_module.h

Revision fc9516a2d8a7585aaaffbaab77009199ca907c90, 2.7 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

make loaders have configs, add a directory config to lua for pulling scripts, refs #28

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007, 2008, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  */
5
6 #ifndef _NOIT_MODULE_H
7 #define _NOIT_MODULE_H
8
9 #include "noit_defines.h"
10 #include "utils/noit_hash.h"
11 #include "noit_check.h"
12
13 #define NOIT_LOADER_MAGIC         0xA7AD7104
14 #define NOIT_LOADER_ABI_VERSION   3
15
16 typedef struct _noit_image {
17   uint32_t magic;
18   uint32_t version;
19   char *name;
20   char *description;
21   int (*onload)(struct _noit_image *);
22   void *opaque_handle;
23 } noit_image_t;
24
25 /* onload: is called immediately after the module is loaded and before it
26  *         is configured.
27  */
28
29 typedef struct _noit_module_loader {
30   noit_image_t hdr;
31   int (*config)(struct _noit_module_loader *, noit_hash_table *config);
32   int (*init)(struct _noit_module_loader *);
33   struct _noit_module *(*load)(struct _noit_module_loader *loader,
34                                char *module_name,
35                                noit_conf_section_t section);
36 } noit_module_loader_t;
37
38 /* config:  is called once to configure the loader itself
39  *   init:  is called once, post config to initialize the module
40  *   load:  is called each time the loader is asked to load a module
41  */
42
43 #define NOIT_MODULE_MAGIC         0x4017DA7A
44 #define NOIT_MODULE_ABI_VERSION   2
45
46 typedef struct _noit_module {
47   noit_image_t hdr;
48   int (*config)(struct _noit_module *, noit_hash_table *options);
49   int (*init)(struct _noit_module *);
50   int (*initiate_check)(struct _noit_module *, noit_check_t *check,
51                         int once, noit_check_t *cause);
52   void (*cleanup)(struct _noit_module *, noit_check_t *);
53 } noit_module_t;
54
55 /*         config: is called to pass the config into the module.
56  *           init: is called once to initialize the module
57  * initiate_check: is called so start the module against checks
58  *        cleanup: is called if a particular check is stopped
59  */
60
61 #define NOIT_IMAGE_MAGIC(a)          ((a)->magic)
62 #define NOIT_IMAGE_VERSION(a)        ((a)->version)
63
64 API_EXPORT(void)
65   noit_module_init();
66 API_EXPORT(int)
67   noit_module_load(const char *file, const char *name);
68 API_EXPORT(noit_module_t *)
69   noit_module_lookup(const char *name);
70 API_EXPORT(noit_module_t *)
71   noit_blank_module();
72 API_EXPORT(int)
73   noit_register_module(noit_module_t *mod);
74
75 API_EXPORT(void *)
76   noit_image_get_userdata(noit_image_t *mod);
77 API_EXPORT(void)
78   noit_image_set_userdata(noit_image_t *mod, void *newdata);
79 API_EXPORT(void *)
80   noit_module_loader_get_userdata(noit_module_loader_t *mod);
81 API_EXPORT(void)
82   noit_module_loader_set_userdata(noit_module_loader_t *mod, void *newdata);
83 API_EXPORT(void *)
84   noit_module_get_userdata(noit_module_t *mod);
85 API_EXPORT(void)
86   noit_module_set_userdata(noit_module_t *mod, void *newdata);
87
88
89 #endif
Note: See TracBrowser for help on using the browser.