Various miscellaneous utility functions.
More...
#include <freeradius-devel/util/dbuff.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/syserror.h>
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/uio.h>
Go to the source code of this file.
|
int | fr_blocking (UNUSED int fd) |
|
int | fr_digest_cmp (uint8_t const *a, uint8_t const *b, size_t length) |
| Do a comparison of two authentication digests by comparing the FULL data.
|
|
int | fr_nonblock (UNUSED int fd) |
|
int8_t | fr_pointer_cmp (void const *a, void const *b) |
| Compares two pointers.
|
|
void | fr_quick_sort (void const *to_sort[], int start, int end, fr_cmp_t cmp) |
| Quick sort an array of pointers using a comparator.
|
|
int | fr_set_signal (int sig, sig_t func) |
| Sets a signal handler using sigaction if available, else signal.
|
|
size_t | fr_snprint_uint128 (char *out, size_t outlen, uint128_t const num) |
| Write 128bit unsigned integer to buffer.
|
|
int | fr_strtoll (int64_t *out, char **end, char const *value) |
| Consume the integer (or hex) portion of a value string.
|
|
int | fr_strtoull (uint64_t *out, char **end, char const *value) |
| Consume the integer (or hex) portion of a value string.
|
|
char * | fr_tolower (char *str) |
|
char * | fr_trim (char const *str, size_t size) |
| Trim whitespace from the end of a string.
|
|
int | fr_unset_signal (int sig) |
| Uninstall a signal for a specific handler.
|
|
ssize_t | fr_utf8_to_ucs2 (uint8_t *out, size_t outlen, char const *in, size_t inlen) |
| Convert UTF8 string to UCS2 encoding.
|
|
static int | rad_lock (int fd, int lock_len, int cmd, int type) |
|
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) |
|
Various miscellaneous utility functions.
- Copyright
- 2000,2006 The FreeRADIUS server project
Definition in file misc.c.
◆ FR_PUT_LE16
#define FR_PUT_LE16 |
( |
|
a, |
|
|
|
val |
|
) |
| |
Value:
Definition at line 36 of file misc.c.
◆ SWAP
Value: do { \
void const *_tmp = to_sort[_a]; \
to_sort[_a] = to_sort[_b]; \
to_sort[_b] = _tmp; \
} while (0)
◆ fr_blocking()
int fr_blocking |
( |
UNUSED int |
fd | ) |
|
◆ fr_digest_cmp()
◆ fr_nonblock()
int fr_nonblock |
( |
UNUSED int |
fd | ) |
|
◆ fr_pointer_cmp()
int8_t fr_pointer_cmp |
( |
void const * |
a, |
|
|
void const * |
b |
|
) |
| |
Compares two pointers.
- Parameters
-
a | first pointer to compare. |
b | second pointer to compare. |
- Returns
- -1 if a < b.
- +1 if b > a.
- 0 if both equal.
Definition at line 417 of file misc.c.
◆ fr_quick_sort()
void fr_quick_sort |
( |
void const * |
to_sort[], |
|
|
int |
start, |
|
|
int |
end, |
|
|
fr_cmp_t |
cmp |
|
) |
| |
Quick sort an array of pointers using a comparator.
- Parameters
-
to_sort | array of pointers to sort. |
start | the lowest index (usually 0). |
end | the length of the array. |
cmp | the comparison function to use to sort the array elements. |
Definition at line 429 of file misc.c.
◆ fr_set_signal()
int fr_set_signal |
( |
int |
sig, |
|
|
sig_t |
func |
|
) |
| |
Sets a signal handler using sigaction if available, else signal.
- Parameters
-
sig | to set handler for. |
func | handler to set. |
Definition at line 47 of file misc.c.
◆ fr_snprint_uint128()
size_t fr_snprint_uint128 |
( |
char * |
out, |
|
|
size_t |
outlen, |
|
|
uint128_t const |
num |
|
) |
| |
Write 128bit unsigned integer to buffer.
- Author
- Alexey Frunze
- Parameters
-
out | where to write result to. |
outlen | size of out. |
num | 128 bit integer. |
Definition at line 369 of file misc.c.
◆ fr_strtoll()
int fr_strtoll |
( |
int64_t * |
out, |
|
|
char ** |
end, |
|
|
char const * |
value |
|
) |
| |
Consume the integer (or hex) portion of a value string.
Allows integer or hex representations of integers (but not octal, as octal is deemed to be confusing).
- Note
- Check for overflow with errno == ERANGE.
- Parameters
-
[out] | out | Result of parsing string as signed 64bit integer. |
[out] | end | pointer to the first non numeric char. |
[in] | value | string to parse. |
- Returns
- integer value.
Definition at line 191 of file misc.c.
◆ fr_strtoull()
int fr_strtoull |
( |
uint64_t * |
out, |
|
|
char ** |
end, |
|
|
char const * |
value |
|
) |
| |
Consume the integer (or hex) portion of a value string.
Allows integer or hex representations of integers (but not octal, as octal is deemed to be confusing).
- Parameters
-
[out] | out | Result of parsing string as unsigned 64bit integer. |
[out] | end | pointer to the first non numeric char. |
[in] | value | string to parse. |
- Returns
- integer value.
Definition at line 160 of file misc.c.
◆ fr_tolower()
char * fr_tolower |
( |
char * |
str | ) |
|
◆ fr_trim()
char * fr_trim |
( |
char const * |
str, |
|
|
size_t |
size |
|
) |
| |
Trim whitespace from the end of a string.
Definition at line 213 of file misc.c.
◆ fr_unset_signal()
int fr_unset_signal |
( |
int |
sig | ) |
|
Uninstall a signal for a specific handler.
man sigaction says these are fine to call from a signal handler.
- Parameters
-
Definition at line 76 of file misc.c.
◆ fr_utf8_to_ucs2()
Convert UTF8 string to UCS2 encoding.
- Note
- Borrowed from src/crypto/ms_funcs.c of wpa_supplicant project (http://hostap.epitest.fi/wpa_supplicant/)
- Parameters
-
[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. |
- Returns
- the size of the UCS2 string written to the output buffer (in bytes).
Definition at line 315 of file misc.c.
◆ rad_lock()
static int rad_lock |
( |
int |
fd, |
|
|
int |
lock_len, |
|
|
int |
cmd, |
|
|
int |
type |
|
) |
| |
|
static |
◆ rad_lockfd()
int rad_lockfd |
( |
int |
fd, |
|
|
int |
lock_len |
|
) |
| |
◆ rad_lockfd_nonblock()
int rad_lockfd_nonblock |
( |
int |
fd, |
|
|
int |
lock_len |
|
) |
| |
◆ rad_unlockfd()
int rad_unlockfd |
( |
int |
fd, |
|
|
int |
lock_len |
|
) |
| |