54003395dc85b9a9cc61cf94ca36446db965435d
2 * This file is part of DisOrder
3 * Copyright (C) 2004-2008 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /** @file lib/asprintf.c @brief printf() workalikes */
32 /** @brief vasprintf() workalike without encoding errors
34 * This acts like vasprintf() except that it does not throw an error
35 * if you use a string outside the current locale's encoding rules,
36 * and it uses the memory allocation calls from @ref mem.h.
38 int byte_vasprintf(char **ptrp
,
45 if((n
= byte_vsinkprintf(sink_dynstr(&d
), fmt
, ap
)) >= 0) {
52 /** @brief asprintf() workalike without encoding errors
54 * This acts like asprintf() except that it does not throw an error
55 * if you use a string outside the current locale's encoding rules,
56 * and it uses the memory allocation calls from @ref mem.h.
58 int byte_asprintf(char **ptrp
,
65 n
= byte_vasprintf(ptrp
, fmt
, ap
);
70 /** @brief asprintf() workalike without encoding errors
72 * This acts like asprintf() except that it does not throw an error if
73 * you use a string outside the current locale's encoding rules; it
74 * uses the memory allocation calls from @ref mem.h; and it terminates
75 * the program on error.
77 int byte_xasprintf(char **ptrp
,
84 n
= byte_xvasprintf(ptrp
, fmt
, ap
);
89 /** @brief vasprintf() workalike without encoding errors
91 * This acts like vasprintf() except that it does not throw an error
92 * if you use a string outside the current locale's encoding rules; it
93 * uses the memory allocation calls from @ref mem.h; and it terminates
94 * the program on error.
96 int byte_xvasprintf(char **ptrp
,
101 if((n
= byte_vasprintf(ptrp
, fmt
, ap
)) < 0)
102 fatal(errno
, "error calling byte_vasprintf");