The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Functions to produce and parse the FreeRADIUS presentation format. More...
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/base16.h>
#include <freeradius-devel/util/pair.h>
Go to the source code of this file.
Functions | |
char * | fr_asprint (TALLOC_CTX *ctx, char const *in, ssize_t inlen, char quote) |
Escape string that may contain binary data, and write it to a new buffer. More... | |
char * | fr_asprintf (TALLOC_CTX *ctx, char const *fmt,...) |
Special version of asprintf which implements custom format specifiers. More... | |
ssize_t | fr_fprintf (FILE *fp, char const *fmt,...) |
Special version of fprintf which implements custom format specifiers. More... | |
size_t | fr_snprint (char *out, size_t outlen, char const *in, ssize_t inlen, char quote) |
Escape any non printable or non-UTF8 characters in the input string. More... | |
size_t | fr_snprint_len (char const *in, ssize_t inlen, char quote) |
Find the length of the buffer required to fully escape a string with fr_prints. More... | |
size_t | fr_utf8_char (uint8_t const *str, ssize_t inlen) |
Checks for utf-8, taken from http://www.w3.org/International/questions/qa-forms-utf-8. More... | |
fr_slen_t | fr_utf8_str (uint8_t const *str, ssize_t inlen) |
Validate a complete UTF8 string. More... | |
char const * | fr_utf8_strchr (int *out_chr_len, char const *str, ssize_t inlen, char const *chr) |
Return a pointer to the first UTF8 char in a string. More... | |
char * | fr_vasprintf (TALLOC_CTX *ctx, char const *fmt, va_list ap) |
static char * | fr_vasprintf_internal (TALLOC_CTX *ctx, char const *fmt, va_list ap, bool suppress_secrets) |
Special version of vasprintf which implements custom format specifiers. More... | |
char * | fr_vasprintf_secure (TALLOC_CTX *ctx, char const *fmt, va_list ap) |
Functions to produce and parse the FreeRADIUS presentation format.
Definition in file print.c.
char* fr_asprint | ( | TALLOC_CTX * | ctx, |
char const * | in, | ||
ssize_t | inlen, | ||
char | quote | ||
) |
Escape string that may contain binary data, and write it to a new buffer.
This is useful in situations where we expect printable strings as input, but under some conditions may get binary data. A good example is libldap and the arrays of struct berval ldap_get_values_len returns.
[in] | ctx | To allocate new buffer in. |
[in] | in | String to escape. |
[in] | inlen | Length of string. Should be >= 0 if the data may contain embedded \0s. Must be >= 0 if data may not be \0 terminated. If < 0 inlen will be calculated using strlen. |
[in] | quote | the quotation character. |
Definition at line 428 of file print.c.
char* fr_asprintf | ( | TALLOC_CTX * | ctx, |
char const * | fmt, | ||
... | |||
) |
Special version of asprintf which implements custom format specifiers.
[in] | ctx | to allocate buffer in. |
[in] | fmt | string. |
[in] | ... | variadic argument list. |
Definition at line 874 of file print.c.
ssize_t fr_fprintf | ( | FILE * | fp, |
char const * | fmt, | ||
... | |||
) |
Special version of fprintf which implements custom format specifiers.
[in] | fp | to write the result of fmt string. |
[in] | fmt | string. |
[in] | ... | variadic argument list. |
Definition at line 897 of file print.c.
Escape any non printable or non-UTF8 characters in the input string.
[out] | out | where to write the escaped string. |
[out] | outlen | the length of the buffer pointed to by out. |
[in] | in | string to escape. |
[in] | inlen | length of string to escape (lets us deal with embedded NULs) |
[in] | quote | the quotation character |
Definition at line 227 of file print.c.
Find the length of the buffer required to fully escape a string with fr_prints.
Were assuming here that's it's cheaper to figure out the length and do one alloc than repeatedly expand the buffer when we find extra chars which need to be added.
in | string to calculate the escaped length for. | |
inlen | length of the input string, if < 0 strlen will be used to check the length. | |
[in] | quote | the quotation character. |
Definition at line 409 of file print.c.
Checks for utf-8, taken from http://www.w3.org/International/questions/qa-forms-utf-8.
[in] | str | input string. |
[in] | inlen | length of input string. May be -1 if str is \0 terminated. |
Definition at line 39 of file print.c.
Validate a complete UTF8 string.
[in] | str | input string. |
[in] | inlen | length of input string. May be -1 if str is \0 terminated. |
Definition at line 143 of file print.c.
char const* fr_utf8_strchr | ( | int * | out_chr_len, |
char const * | str, | ||
ssize_t | inlen, | ||
char const * | chr | ||
) |
Return a pointer to the first UTF8 char in a string.
[out] | out_chr_len | Where to write the length of the multibyte char passed in chr (may be NULL). |
[in] | str | Haystack. |
[in] | inlen | Length of string (in bytes). Pass -1 to determine the length of the string. |
[in] | chr | Multibyte needle. |
Definition at line 174 of file print.c.
char* fr_vasprintf | ( | TALLOC_CTX * | ctx, |
char const * | fmt, | ||
va_list | ap | ||
) |
|
static |
Special version of vasprintf which implements custom format specifiers.
This breaks strict compatibility with printf but allows us to continue using the static format string and argument type validation.
This same idea is used in Linux for the printk function.
[in] | ctx | to allocate buffer in. |
[in] | fmt | string. |
[in] | ap | variadic argument list. |
[in] | suppress_secrets | as described |
Definition at line 473 of file print.c.