root/src/noit_module.h

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

pull help and docs into the console, refs #21

  • 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   4
15
16 typedef struct _noit_image {
17   uint32_t magic;
18   uint32_t version;
19   char *name;
20   char *description;
21   char *xml_description;
22   int (*onload)(struct _noit_image *);
23   void *opaque_handle;
24 } noit_image_t;
25
26 /* onload: is called immediately after the module is loaded and before it
27  *         is configured.
28  */
29
30 typedef struct _noit_module_loader {
31   noit_image_t hdr;
32   int (*config)(struct _noit_module_loader *, noit_hash_table *config);
33   int (*init)(struct _noit_module_loader *);
34   struct _noit_module *(*load)(struct _noit_module_loader *loader,
35                                char *module_name,
36                                noit_conf_section_t section);
37 } noit_module_loader_t;
38
39 /* config:  is called once to configure the loader itself
40  *   init:  is called once, post config to initialize the module
41  *   load:  is called each time the loader is asked to load a module
42  */
43
44 #define NOIT_MODULE_MAGIC         0x4017DA7A
45 #define NOIT_MODULE_ABI_VERSION   3
46
47 typedef struct _noit_module {
48   noit_image_t hdr;
49   int (*config)(struct _noit_module *, noit_hash_table *options);
50   int (*init)(struct _noit_module *);
51   int (*initiate_check)(struct _noit_module *, noit_check_t *check,
52                         int once, noit_check_t *cause);
53   void (*cleanup)(struct _noit_module *, noit_check_t *);
54 } noit_module_t;
55
56 /*         config: is called to pass the config into the module.
57  *           init: is called once to initialize the module
58  * initiate_check: is called so start the module against checks
59  *        cleanup: is called if a particular check is stopped
60  */
61
62 #define NOIT_IMAGE_MAGIC(a)          ((a)->magic)
63 #define NOIT_IMAGE_VERSION(a)        ((a)->version)
64
65 API_EXPORT(void)
66   noit_module_init();
67 API_EXPORT(int)
68   noit_module_load(const char *file, const char *name);
69 API_EXPORT(noit_module_t *)
70   noit_module_lookup(const char *name);
71 API_EXPORT(noit_module_t *)
72   noit_blank_module();
73 API_EXPORT(int)
74   noit_register_module(noit_module_t *mod);
75
76 API_EXPORT(void *)
77   noit_image_get_userdata(noit_image_t *mod);
78 API_EXPORT(void)
79   noit_image_set_userdata(noit_image_t *mod, void *newdata);
80 API_EXPORT(void *)
81   noit_module_loader_get_userdata(noit_module_loader_t *mod);
82 API_EXPORT(void)
83   noit_module_loader_set_userdata(noit_module_loader_t *mod, void *newdata);
84 API_EXPORT(void *)
85   noit_module_get_userdata(noit_module_t *mod);
86 API_EXPORT(void)
87   noit_module_set_userdata(noit_module_t *mod, void *newdata);
88 API_EXPORT(void)
89   noit_module_print_help(noit_console_closure_t ncct,
90                          noit_module_t *module, int examples);
91
92 #endif
Note: See TracBrowser for help on using the browser.