unbound: dynlibmod/examples/helloworld.c File Reference

unbound 0.1

Macros | Functions
helloworld.c File Reference

This is an example to show how dynamic libraries can be made to work with unbound. More...

`#include "../../config.h"`
`#include "../../util/module.h"`
`#include "../../sldns/parseutil.h"`
`#include "../dynlibmod.h"`

## Functions
int | reply_callback (struct query_info *qinfo, struct module_qstate *qstate, struct reply_info *rep, int rcode, struct edns_data *edns, struct edns_option **opt_list_out, struct comm_reply *repinfo, struct regional *region, struct timeval *start_time, int id, void *callback)
EXPORT int | init (struct module_env *env, int id)
EXPORT void | deinit (struct module_env *env, int id)
EXPORT void | operate (struct module_qstate *qstate, enum module_ev event, int id, struct outbound_entry *entry)
EXPORT void | inform_super (struct module_qstate *qstate, int id, struct module_qstate *super)
EXPORT void | clear (struct module_qstate *qstate, int id)
EXPORT size_t | get_mem (struct module_env *env, int id)

## Detailed Description

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.dll.a to cross-compile a 64-bit Windows DLL. The libunbound.dll.a is produced by the compile step that makes unbound.exe and allows the dynlib dll to access definitions in unbound.exe.