2019-10-17 09:10:33 -04:00
|
|
|
/*
|
|
|
|
|
* This is an example to show how dynamic libraries can be made to work with
|
|
|
|
|
* unbound. To build a .so file simply run:
|
|
|
|
|
* gcc -I../.. -shared -Wall -Werror -fpic -o helloworld.so helloworld.c
|
|
|
|
|
* And to build for windows, first make unbound with the --with-dynlibmod
|
|
|
|
|
* switch, then use this command:
|
|
|
|
|
* x86_64-w64-mingw32-gcc -m64 -I../.. -shared -Wall -Werror -fpic -o helloworld.dll helloworld.c -L../.. -l:libunbound.a
|
|
|
|
|
* to cross-compile a 64-bit Windows DLL.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "../../config.h"
|
|
|
|
|
#include "../../util/module.h"
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_WINDOWS_H
|
|
|
|
|
#define EXPORT __declspec(dllexport)
|
|
|
|
|
#else
|
|
|
|
|
#define EXPORT
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-10-21 08:20:33 -04:00
|
|
|
EXPORT void init(struct module_env* env, int id) {
|
2019-10-17 09:10:33 -04:00
|
|
|
log_info("Hello world from init");
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-21 08:20:33 -04:00
|
|
|
EXPORT void deinit(struct module_env* env, int id) {
|
2019-10-17 09:10:33 -04:00
|
|
|
log_info("Hello world from deinit");
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-21 08:20:33 -04:00
|
|
|
EXPORT void operate(struct module_qstate* qstate, enum module_ev event, int id, struct outbound_entry* entry) {
|
2019-10-17 09:10:33 -04:00
|
|
|
log_info("Hello world from operate");
|
|
|
|
|
if (event == module_event_new || event == module_event_pass) {
|
|
|
|
|
qstate->ext_state[id] = module_wait_module;
|
|
|
|
|
} else if (event == module_event_moddone) {
|
|
|
|
|
qstate->ext_state[id] = module_finished;
|
|
|
|
|
} else {
|
|
|
|
|
qstate->ext_state[id] = module_error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-21 08:20:33 -04:00
|
|
|
EXPORT void inform_super(struct module_qstate* qstate, int id, struct module_qstate* super) {
|
2019-10-17 09:10:33 -04:00
|
|
|
log_info("Hello world from inform_super");
|
2019-10-21 08:20:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT void clear(struct module_qstate* qstate, int id) {
|
|
|
|
|
log_info("Hello world from clear");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT size_t get_mem(struct module_env* env, int id) {
|
|
|
|
|
log_info("Hello world from get_mem");
|
|
|
|
|
return 0;
|
2019-10-17 09:10:33 -04:00
|
|
|
}
|