| 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 2 |
|---|
| 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 |
typedef struct _noit_module_loader { |
|---|
| 26 |
noit_image_t hdr; |
|---|
| 27 |
struct _noit_module *(*load)(struct _noit_module_loader *loader, |
|---|
| 28 |
char *module_name, |
|---|
| 29 |
noit_conf_section_t section); |
|---|
| 30 |
} noit_module_loader_t; |
|---|
| 31 |
|
|---|
| 32 |
#define NOIT_MODULE_MAGIC 0x4017DA7A |
|---|
| 33 |
#define NOIT_MODULE_ABI_VERSION 2 |
|---|
| 34 |
|
|---|
| 35 |
typedef struct _noit_module { |
|---|
| 36 |
noit_image_t hdr; |
|---|
| 37 |
int (*config)(struct _noit_module *, noit_hash_table *options); |
|---|
| 38 |
int (*init)(struct _noit_module *); |
|---|
| 39 |
int (*initiate_check)(struct _noit_module *, noit_check_t *check, |
|---|
| 40 |
int once, noit_check_t *cause); |
|---|
| 41 |
void (*cleanup)(struct _noit_module *, noit_check_t *); |
|---|
| 42 |
} noit_module_t; |
|---|
| 43 |
|
|---|
| 44 |
#define NOIT_IMAGE_MAGIC(a) ((a)->magic) |
|---|
| 45 |
#define NOIT_IMAGE_VERSION(a) ((a)->version) |
|---|
| 46 |
|
|---|
| 47 |
API_EXPORT(void) |
|---|
| 48 |
noit_module_init(); |
|---|
| 49 |
API_EXPORT(int) |
|---|
| 50 |
noit_module_load(const char *file, const char *name); |
|---|
| 51 |
API_EXPORT(noit_module_t *) |
|---|
| 52 |
noit_module_lookup(const char *name); |
|---|
| 53 |
|
|---|
| 54 |
API_EXPORT(void *) |
|---|
| 55 |
noit_image_get_userdata(noit_image_t *mod); |
|---|
| 56 |
API_EXPORT(void) |
|---|
| 57 |
noit_image_set_userdata(noit_image_t *mod, void *newdata); |
|---|
| 58 |
API_EXPORT(void *) |
|---|
| 59 |
noit_module_loader_get_userdata(noit_module_loader_t *mod); |
|---|
| 60 |
API_EXPORT(void) |
|---|
| 61 |
noit_module_loader_set_userdata(noit_module_loader_t *mod, void *newdata); |
|---|
| 62 |
API_EXPORT(void *) |
|---|
| 63 |
noit_module_get_userdata(noit_module_t *mod); |
|---|
| 64 |
API_EXPORT(void) |
|---|
| 65 |
noit_module_set_userdata(noit_module_t *mod, void *newdata); |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
#endif |
|---|