The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
print.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /** Functions to produce and parse the FreeRADIUS presentation format
19  *
20  * @file src/lib/util/print.h
21  *
22  * @copyright 2000,2006 The FreeRADIUS server project
23  */
24 RCSIDH(print_h, "$Id: 37f51ebc623b2a2b04f434c897d23e19eae1d401 $")
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <freeradius-devel/build.h>
31 #include <freeradius-devel/missing.h>
32 #include <freeradius-devel/util/talloc.h>
33 
34 #include <stddef.h>
35 #include <stdint.h>
36 
37 size_t fr_utf8_char(uint8_t const *str, ssize_t inlen);
39 char const *fr_utf8_strchr(int *chr_len, char const *str, ssize_t inlen, char const *chr);
40 size_t fr_snprint(char *out, size_t outlen, char const *in, ssize_t inlen, char quote);
41 size_t fr_snprint_len(char const *in, ssize_t inlen, char quote);
42 char *fr_asprint(TALLOC_CTX *ctx, char const *in, ssize_t inlen, char quote);
43 char *fr_vasprintf(TALLOC_CTX *ctx, char const *fmt, va_list ap);
44 char *fr_vasprintf_secure(TALLOC_CTX *ctx, char const *fmt, va_list ap);
45 char *fr_asprintf(TALLOC_CTX *ctx, char const *fmt, ...) CC_HINT(format (printf, 2, 3));
46 ssize_t fr_fprintf(FILE *stream, char const *fmt, ...) CC_HINT(format (printf, 2, 3));
47 
48 #define is_truncated(_ret, _max) ((_ret) >= (size_t)(_max))
49 #define truncate_len(_ret, _max) (((_ret) >= (size_t)(_max)) ? (((size_t)(_max)) - 1) : _ret)
static int const char * fmt
Definition: acutest.h:573
#define RCSIDH(h, id)
Definition: build.h:482
static fr_slen_t in
Definition: dict.h:821
long int ssize_t
Definition: merged_model.c:24
unsigned char uint8_t
Definition: merged_model.c:30
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.
Definition: print.c:227
char * fr_vasprintf(TALLOC_CTX *ctx, char const *fmt, va_list ap)
Definition: print.c:851
ssize_t fr_fprintf(FILE *stream, char const *fmt,...))
Special version of fprintf which implements custom format specifiers.
Definition: print.c:897
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.
Definition: print.c:428
ssize_t fr_utf8_str(uint8_t const *str, ssize_t inlen)
Validate a complete UTF8 string.
Definition: print.c:143
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.
Definition: print.c:39
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.
Definition: print.c:409
char const * fr_utf8_strchr(int *chr_len, char const *str, ssize_t inlen, char const *chr)
Return a pointer to the first UTF8 char in a string.
Definition: print.c:174
char * fr_vasprintf_secure(TALLOC_CTX *ctx, char const *fmt, va_list ap)
Definition: print.c:856
char * fr_asprintf(TALLOC_CTX *ctx, char const *fmt,...))
Special version of asprintf which implements custom format specifiers.
Definition: print.c:874
static size_t char fr_sbuff_t size_t inlen
Definition: value.h:997
int format(printf, 5, 0))
static size_t char ** out
Definition: value.h:997