27#include <freeradius-devel/server/base.h>
28#include <freeradius-devel/server/module_rlm.h>
29#include <freeradius-devel/unlang/xlat_func.h>
60 char const *tz = strstr(str,
"UTC");
68 MEM(my_str = talloc_strdup(ctx, str));
69 p = my_str + (tz - str);
72 p = strptime(my_str,
inst->fmt, &tminfo);
74 REDEBUG(
"Failed to parse time string \"%s\" as format '%s'", my_str,
inst->fmt);
88 if (strptime(str,
inst->fmt, &tminfo) == NULL) {
89 REDEBUG(
"Failed to parse time string \"%s\" as format '%s'", str,
inst->fmt);
94 date = timegm(&tminfo);
96 date = mktime(&tminfo);
99 REDEBUG(
"Failed converting parsed time into unix time");
117 if (
gmtime_r(&date, &tminfo) == NULL) {
176 memset(&tminfo, 0,
sizeof(tminfo));
184 if (strcmp(arg->vb_strvalue,
"request") == 0) {
189 if (strcmp(arg->vb_strvalue,
"now") == 0) {
197 if (arg->vb_strvalue[0] ==
'+') {
static int const char * fmt
#define CONF_PARSER_TERMINATOR
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Defines a CONF_PAIR to C data type mapping.
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
static xlat_action_t xlat_date_convert(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in)
Get or convert time and date.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
struct tm * gmtime_r(time_t const *l_clock, struct tm *result)
struct tm * localtime_r(time_t const *l_clock, struct tm *result)
module_instance_t const * mi
Instance of the module being instantiated.
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for instantiation calls.
xlat_t * module_rlm_xlat_register(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, char const *name, xlat_func_t func, fr_type_t return_type)
module_t common
Common fields presented by all modules.
static const conf_parser_t config[]
static xlat_arg_parser_t const xlat_date_convert_args[]
static int mod_bootstrap(module_inst_ctx_t const *mctx)
static xlat_action_t date_encode_strftime(TALLOC_CTX *ctx, fr_dcursor_t *out, rlm_date_t const *inst, request_t *request, char const *fmt, time_t date)
static const conf_parser_t module_config[]
static xlat_action_t date_convert_string(TALLOC_CTX *ctx, fr_dcursor_t *out, request_t *request, const char *str, rlm_date_t const *inst)
size_t inst_size
Size of the module's instance data.
void * data
Module's instance data.
void * boot
Data allocated during the boostrap phase.
static char buff[sizeof("18446744073709551615")+3]
eap_aka_sim_process_conf_t * inst
#define fr_time()
Allow us to arbitrarily manipulate time.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
static int64_t fr_time_to_sec(fr_time_t when)
Convert an fr_time_t (internal time) to number of sec since the unix epoch (wallclock time)
static int64_t fr_unix_time_to_sec(fr_unix_time_t delta)
static fr_unix_time_t fr_unix_time_from_sec(int64_t sec)
bool required
Argument must be present, and non-empty.
#define XLAT_ARG_PARSER_TERMINATOR
@ XLAT_ACTION_FAIL
An xlat function failed.
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
Definition for a single argument consumend by an xlat function.
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
int fr_value_box_strdup(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_dict_attr_t const *enumv, char const *src, bool tainted)
Copy a nul terminated string to a fr_value_box_t.
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.
#define fr_value_box_alloc_null(_ctx)
Allocate a value box for later use with a value assignment function.
static size_t char ** out
module_ctx_t const * mctx
Synthesised module calling ctx.
int xlat_func_args_set(xlat_t *x, xlat_arg_parser_t const args[])
Register the arguments of an xlat.