5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2007 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 /****h* silcutil/Snprintf
24 * Platform independent version of snprintf and other similar string
25 * formatting routines.
29 #ifndef SILCSNPRINTF_H
30 #define SILCSNPRINTF_H
32 /****f* silcutil/SilcSnprintf/silc_snprintf
36 * int silc_snprintf(char *str, size_t count, const char *fmt, ...);
40 * Outputs string into `str' of maximum of size `count' including the
41 * trailing '\0' according to the `fmt'. The `fmt' is equivalent to
42 * snprintf(3) and printf(3) formatting. Returns the number of character
43 * in `str' or negative value on error.
46 int silc_snprintf(char *str, size_t count, const char *fmt, ...);
48 /****f* silcutil/SilcSnprintf/silc_vsnprintf
52 * int silc_vsnprintf(char *str, size_t count, const char *fmt,
57 * Same as silc_snprintf but takes the argument for the formatting from
58 * the `args' variable argument list.
61 int silc_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
63 /****f* silcutil/SilcSnprintf/silc_asprintf
67 * int silc_asprintf(char **ptr, const char *format, ...)
71 * Same as silc_snprintf but allocates a string large enough to hold the
72 * output including the trailing '\0'. The caller must free the `ptr'.
75 int silc_asprintf(char **ptr, const char *format, ...);
77 /****f* silcutil/SilcSnprintf/silc_vasprintf
81 * int silc_vasprintf(char **ptr, const char *format, va_list ap)
85 * Same as silc_asprintf but takes the argument from the `ap' variable
89 int silc_vasprintf(char **ptr, const char *format, va_list ap);
91 #endif /* SILCSNPRINTF_H */