Move HUP code to per-module, not global
[freeradius.git] / src / include / modpriv.h
1 /* modpriv.h: Stuff needed by both modules.c and modcall.c, but should not be
2  * accessed from anywhere else.
3  *
4  * Version: $Id$ */
5 #include <freeradius-devel/radiusd.h>
6 #include <freeradius-devel/modules.h>
7
8 #ifndef WITHOUT_LIBLTDL
9 #include "ltdl.h"
10 #else
11 typedef void *lt_dlhandle;
12
13 lt_dlhandle lt_dlopenext(const char *name);
14 void *lt_dlsym(lt_dlhandle handle, const char *symbol);
15
16 #define LTDL_SET_PRELOADED_SYMBOLS(_x)
17 #define lt_dlinit(_x) (0)
18 #define lt_dlclose(_x)
19 #define lt_dlexit(_x)
20 #define lt_dlerror(foo) "Internal error"
21 #define lt_dlsetsearchpath(_x)
22 #endif
23
24 /*
25  *      Keep track of which modules we've loaded.
26  */
27 typedef struct module_entry_t {
28         char                    name[MAX_STRING_LEN];
29         const module_t          *module;
30         lt_dlhandle             handle;
31 } module_entry_t;
32
33 typedef struct fr_module_hup_t fr_module_hup_t;
34
35 /*
36  *      Per-instance data structure, to correlate the modules
37  *      with the instance names (may NOT be the module names!),
38  *      and the per-instance data structures.
39  */
40 typedef struct module_instance_t {
41         char                    name[MAX_STRING_LEN];
42         module_entry_t          *entry;
43         void                    *insthandle;
44 #ifdef HAVE_PTHREAD_H
45         pthread_mutex_t         *mutex;
46 #endif
47         CONF_SECTION            *cs;
48         fr_module_hup_t         *mh;
49 } module_instance_t;
50
51 module_instance_t *find_module_instance(CONF_SECTION *, const char *instname,
52                                         int do_link);
53 int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when);