#include <freeradius-devel/libradius.h>
#include <ctype.h>
#include <sys/file.h>
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <sys/uio.h>
Go to the source code of this file.
Data Structures | |
struct | fr_talloc_link |
Macros | |
#define | FR_PUT_LE16(a, val) |
#define | NSEC 1000000000 |
#define | USEC 1000000 |
Typedefs | |
typedef struct fr_talloc_link | fr_talloc_link_t |
Functions | |
static int | _fr_disarm_talloc_ctx_free (bool **armed) |
static int | _fr_trigger_talloc_ctx_free (fr_talloc_link_t *trigger) |
static int | _quick_partition (void const *to_sort[], int min, int max, fr_cmp_t cmp) |
int | closefrom (int fd) |
char * | fr_abin2hex (TALLOC_CTX *ctx, uint8_t const *bin, size_t inlen) |
Convert binary data to a hex string. More... | |
size_t | fr_bin2hex (char *hex, uint8_t const *bin, size_t inlen) |
Convert binary data to a hex string. More... | |
int | fr_blocking (UNUSED int fd) |
int | fr_get_time (char const *date_str, time_t *date) |
Convert string in various formats to a time_t. More... | |
size_t | fr_hex2bin (uint8_t *bin, size_t outlen, char const *hex, size_t inlen) |
Convert hex strings to binary data. More... | |
int | fr_nonblock (UNUSED int fd) |
int8_t | fr_pointer_cmp (void const *a, void const *b) |
Compares two pointers. More... | |
void | fr_quick_sort (void const *to_sort[], int min_idx, int max_idx, fr_cmp_t cmp) |
Quick sort an array of pointers using a comparator. More... | |
int | fr_set_signal (int sig, sig_t func) |
Sets a signal handler using sigaction if available, else signal. More... | |
size_t | fr_snprint_uint128 (char *out, size_t outlen, uint128_t const num) |
Write 128bit unsigned integer to buffer. More... | |
uint32_t | fr_strtoul (char const *value, char **end) |
Consume the integer (or hex) portion of a value string. More... | |
int | fr_talloc_link_ctx (TALLOC_CTX *parent, TALLOC_CTX *child) |
Link a parent and a child context, so the child is freed before the parent. More... | |
void | fr_timespec_subtract (struct timespec *out, struct timespec const *end, struct timespec const *start) |
Subtract one timespec from another. More... | |
int | fr_timeval_from_str (struct timeval *out, char const *in) |
Create timeval from a string. More... | |
void | fr_timeval_subtract (struct timeval *out, struct timeval const *end, struct timeval const *start) |
Subtract one timeval from another. More... | |
ssize_t | fr_utf8_to_ucs2 (uint8_t *out, size_t outlen, char const *in, size_t inlen) |
Convert UTF8 string to UCS2 encoding. More... | |
ssize_t | fr_writev (int fd, struct iovec vector[], int iovcnt, struct timeval *timeout) |
Write out a vector to a file descriptor. More... | |
bool | is_integer (char const *value) |
Check whether the string is all numbers. More... | |
bool | is_printable (void const *value, size_t len) |
Check whether the string is made up of printable UTF8 chars. More... | |
bool | is_whitespace (char const *value) |
Check whether the string is all whitespace. More... | |
bool | is_zero (char const *value) |
Check whether the string is all zeros. More... | |
static char * | mystrtok (char **ptr, char const *sep) |
int | rad_lockfd (int fd, int lock_len) |
int | rad_lockfd_nonblock (int fd, int lock_len) |
int | rad_unlockfd (int fd, int lock_len) |
Variables | |
int | fr_debug_lvl = 0 |
static char const | hextab [] = "0123456789abcdef" |
static char const * | months [] |
struct fr_talloc_link |
#define FR_PUT_LE16 | ( | a, | |
val | |||
) |
typedef struct fr_talloc_link fr_talloc_link_t |
|
static |
|
static |
|
static |
int closefrom | ( | int | fd | ) |
char* fr_abin2hex | ( | TALLOC_CTX * | ctx, |
uint8_t const * | bin, | ||
size_t | inlen | ||
) |
Convert binary data to a hex string.
Ascii encoded hex string will not be prefixed with '0x'
[in] | ctx | to alloc buffer in. |
[in] | bin | input. |
[in] | inlen | of bin input. |
Definition at line 278 of file misc.c.
size_t fr_bin2hex | ( | char * | hex, |
uint8_t const * | bin, | ||
size_t | inlen | ||
) |
Convert binary data to a hex string.
Ascii encoded hex string will not be prefixed with '0x'
[out] | hex | Buffer to write hex output. |
[in] | bin | input. |
[in] | inlen | of bin input. |
Definition at line 254 of file misc.c.
int fr_blocking | ( | UNUSED int | fd | ) |
int fr_get_time | ( | char const * | date_str, |
time_t * | date | ||
) |
size_t fr_hex2bin | ( | uint8_t * | bin, |
size_t | outlen, | ||
char const * | hex, | ||
size_t | inlen | ||
) |
Convert hex strings to binary data.
bin | Buffer to write output to. |
outlen | length of output buffer (or length of input string / 2). |
hex | input string. |
inlen | length of the input string |
Definition at line 220 of file misc.c.
int fr_nonblock | ( | UNUSED int | fd | ) |
int8_t fr_pointer_cmp | ( | void const * | a, |
void const * | b | ||
) |
void fr_quick_sort | ( | void const * | to_sort[], |
int | min_idx, | ||
int | max_idx, | ||
fr_cmp_t | cmp | ||
) |
Quick sort an array of pointers using a comparator.
to_sort | array of pointers to sort. |
min_idx | the lowest index (usually 0). |
max_idx | the highest index (usually length of array - 1). |
cmp | the comparison function to use to sort the array elements. |
Definition at line 997 of file misc.c.
int fr_set_signal | ( | int | sig, |
sig_t | func | ||
) |
size_t fr_snprint_uint128 | ( | char * | out, |
size_t | outlen, | ||
uint128_t const | num | ||
) |
uint32_t fr_strtoul | ( | char const * | value, |
char ** | end | ||
) |
int fr_talloc_link_ctx | ( | TALLOC_CTX * | parent, |
TALLOC_CTX * | child | ||
) |
Link a parent and a child context, so the child is freed before the parent.
parent | who's fate the child should share. |
child | bound to parent's lifecycle. |
Definition at line 105 of file misc.c.
void fr_timespec_subtract | ( | struct timespec * | out, |
struct timespec const * | end, | ||
struct timespec const * | start | ||
) |
int fr_timeval_from_str | ( | struct timeval * | out, |
char const * | in | ||
) |
void fr_timeval_subtract | ( | struct timeval * | out, |
struct timeval const * | end, | ||
struct timeval const * | start | ||
) |
ssize_t fr_utf8_to_ucs2 | ( | uint8_t * | out, |
size_t | outlen, | ||
char const * | in, | ||
size_t | inlen | ||
) |
Convert UTF8 string to UCS2 encoding.
[out] | out | Where to write the ucs2 string. |
[in] | outlen | Size of output buffer. |
[in] | in | UTF8 string to convert. |
[in] | inlen | length of UTF8 string. |
Definition at line 580 of file misc.c.
ssize_t fr_writev | ( | int | fd, |
struct iovec | vector[], | ||
int | iovcnt, | ||
struct timeval * | timeout | ||
) |
Write out a vector to a file descriptor.
Wraps writev, calling it as necessary. If timeout is not NULL, timeout is applied to each call that returns EAGAIN or EWOULDBLOCK
fd | to write to. |
vector | to write. |
iovcnt | number of elements in iovec. |
timeout | how long to wait for fd to become writeable before timing out. |
Definition at line 492 of file misc.c.
bool is_integer | ( | char const * | value | ) |
bool is_printable | ( | void const * | value, |
size_t | len | ||
) |
Check whether the string is made up of printable UTF8 chars.
value | to check. |
len | of value. |
Definition at line 329 of file misc.c.
bool is_whitespace | ( | char const * | value | ) |
bool is_zero | ( | char const * | value | ) |
|
static |
int rad_lockfd | ( | int | fd, |
int | lock_len | ||
) |
int rad_lockfd_nonblock | ( | int | fd, |
int | lock_len | ||
) |
int rad_unlockfd | ( | int | fd, |
int | lock_len | ||
) |