blob: 4b132c4c051e1d035d64a8a300b868b0b438ea81 [file] [log] [blame]
James Kuszmaul82f6c042021-01-17 11:30:16 -08001/**
2 * @file re_mod.h Interface to loadable modules
3 *
4 * Copyright (C) 2010 Creytiv.com
5 */
6
7
8/**
9 * @def MOD_PRE
10 *
11 * Module Prefix
12 *
13 * @def MOD_EXT
14 *
15 * Module Extension
16 */
17#if defined (WIN32)
18#define MOD_PRE ""
19#define MOD_EXT ".dll"
20#else
21#define MOD_PRE ""
22#define MOD_EXT ".so"
23#endif
24
25
26/** Symbol to enable exporting of functions from a module */
27#ifdef WIN32
28#define EXPORT_SYM __declspec(dllexport)
29#else
30#define EXPORT_SYM
31#endif
32
33
34/* ----- Module API ----- */
35
36
37/**
38 * Defines the module initialisation handler
39 *
40 * @return 0 for success, otherwise errorcode
41 */
42typedef int (mod_init_h)(void);
43
44/**
45 * Defines the module close handler
46 *
47 * @return 0 for success, otherwise errorcode
48 */
49typedef int (mod_close_h)(void);
50
51
52struct mod;
53struct re_printf;
54
55
56/** Defines the module export */
57struct mod_export {
58 const char *name; /**< Module name */
59 const char *type; /**< Module type */
60 mod_init_h *init; /**< Module init handler */
61 mod_close_h *close; /**< Module close handler */
62};
63
64
65/* ----- Application API ----- */
66
67void mod_init(void);
68void mod_close(void);
69
70int mod_load(struct mod **mp, const char *name);
71int mod_add(struct mod **mp, const struct mod_export *me);
72struct mod *mod_find(const char *name);
73const struct mod_export *mod_export(const struct mod *m);
74struct list *mod_list(void);
75int mod_debug(struct re_printf *pf, void *unused);