#include <freeradius-devel/libradius.h>
#include <ctype.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... | |
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... | |
int | 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... | |
char const * | fr_utf8_strchr (int *chr_len, char const *str, char const *chr) |
Return a pointer to the first UTF8 char in a string. More... | |
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 390 of file print.c.
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.
[in] | in | string to escape. |
[in] | inlen | length of string to escape (lets us deal with embedded NULs) |
[out] | out | where to write the escaped string. |
[out] | outlen | the length of the buffer pointed to by out. |
[in] | quote | the quotation character |
Definition at line 179 of file print.c.
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.
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 371 of file print.c.
int 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.
str | input string. |
inlen | length of input string. May be -1 if str is \0 terminated. |
Definition at line 34 of file print.c.
char const* fr_utf8_strchr | ( | int * | chr_len, |
char const * | str, | ||
char const * | chr | ||
) |
Return a pointer to the first UTF8 char in a string.
[out] | chr_len | Where to write the length of the multibyte char passed in chr (may be NULL). |
[in] | str | Haystack. |
[in] | chr | Multibyte needle. |
Definition at line 140 of file print.c.