a79e4cb02d4bc14f8e5dcff38fbf9a745fad1b17
[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 #ifndef FR_MODPRIV_H
6 #define FR_MODPRIV_H
7
8 #include <freeradius-devel/radiusd.h>
9 #include <freeradius-devel/modules.h>
10
11 /*
12  *      Using the native dlopen() API means that we don't want to use libltdl.
13  */
14 #ifdef WITH_DLOPEN
15 #define WITHOUT_LIBLTDL
16 #endif
17
18 #ifndef WITHOUT_LIBLTDL
19 #include "ltdl.h"
20 #else
21 typedef void *lt_dlhandle;
22
23 lt_dlhandle lt_dlopenext(const char *name);
24 void *lt_dlsym(lt_dlhandle handle, const char *symbol);
25 int lt_dlclose(lt_dlhandle handle);
26 const char *lt_dlerror(void);
27
28 #define LTDL_SET_PRELOADED_SYMBOLS(_x)
29 #define lt_dlinit(_x) (0)
30 #define lt_dlexit(_x)
31 #define lt_dlsetsearchpath(_x)
32 #endif
33
34 /*
35  *      Keep track of which modules we've loaded.
36  */
37 typedef struct module_entry_t {
38         char                    name[MAX_STRING_LEN];
39         const module_t          *module;
40         lt_dlhandle             handle;
41 } module_entry_t;
42
43 typedef struct fr_module_hup_t fr_module_hup_t;
44
45 /*
46  *      Per-instance data structure, to correlate the modules
47  *      with the instance names (may NOT be the module names!),
48  *      and the per-instance data structures.
49  */
50 typedef struct module_instance_t {
51         char                    name[MAX_STRING_LEN];
52         module_entry_t          *entry;
53         void                    *insthandle;
54 #ifdef HAVE_PTHREAD_H
55         pthread_mutex_t         *mutex;
56 #endif
57         CONF_SECTION            *cs;
58         int                     dead;
59         fr_module_hup_t         *mh;
60 } module_instance_t;
61
62 module_instance_t *find_module_instance(CONF_SECTION *, const char *instname,
63                                         int do_link);
64 int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when);
65 #endif  /* FR_MODPRIV_H */