The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
global_lib.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /**
19  * $Id: b271f6e85abb757bb60cf80abe0e87362883f3b0 $
20  *
21  * @file lib/server/global_lib.h
22  * @brief API for initialising and freeing libraries.
23  *
24  * @copyright 2022 The FreeRADIUS server project
25  */
26 RCSIDH(lib_h, "$Id: b271f6e85abb757bb60cf80abe0e87362883f3b0 $")
27 
28 #include <freeradius-devel/server/cf_parse.h>
29 #include <freeradius-devel/util/dl.h>
30 
31 typedef int (*lib_init_t)(void);
32 
33 typedef void (*lib_free_t)(void);
34 
35 /** Structure to define how to initialise libraries with global configuration
36  *
37  */
38 typedef struct {
39  char const *name; //!< Name of library and section within global config
40  conf_parser_t const *config; //!< Config parser for this library's global options
41  void *inst; //!< Module data to parse global config into
42  lib_init_t init; //!< Callback to initialise library
43  lib_free_t free; //!< Callback to free library
45 
47 
48 /*
49  * To be used as terminator in an array of global_lib_autoinst_t
50  */
51 #define GLOBAL_LIB_TERMINATOR &global_lib_terminator
52 
53 int global_lib_auto_instantiate(dl_t const *module, void *symbol, void *user_ctx);
54 
55 void global_lib_autofree(dl_t const *module, void *symbol, void *user_ctx);
56 
57 int global_lib_init(void);
58 
59 int global_lib_instantiate(void);
#define RCSIDH(h, id)
Definition: build.h:482
Defines a CONF_PAIR to C data type mapping.
Definition: cf_parse.h:564
Module handle.
Definition: dl.h:58
void global_lib_autofree(dl_t const *module, void *symbol, void *user_ctx)
lib_free_t free
Callback to free library.
Definition: global_lib.h:43
int global_lib_init(void)
Initialise the global list of external libraries.
Definition: global_lib.c:204
conf_parser_t const * config
Config parser for this library's global options.
Definition: global_lib.h:40
void(* lib_free_t)(void)
Definition: global_lib.h:33
char const * name
Name of library and section within global config.
Definition: global_lib.h:39
const global_lib_autoinst_t global_lib_terminator
Definition: global_lib.c:32
int(* lib_init_t)(void)
Definition: global_lib.h:31
lib_init_t init
Callback to initialise library.
Definition: global_lib.h:42
int global_lib_instantiate(void)
Walk the tree of libraries and instantiate any which are pending.
Definition: global_lib.c:218
int global_lib_auto_instantiate(dl_t const *module, void *symbol, void *user_ctx)
void * inst
Module data to parse global config into.
Definition: global_lib.h:41
Structure to define how to initialise libraries with global configuration.
Definition: global_lib.h:38