Added silc_snprintf, silc_vsnprintf, silc_asprintf, silc_vasprintf
[silc.git] / lib / silcutil / silcsnprintf.h
1 /*
2
3   silcsnprintf.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2007 Pekka Riikonen
8
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.
12
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.
17
18 */
19
20 #ifndef SILCSNPRINTF_H
21 #define SILCSNPRINTF_H
22
23 /****f* silcutil/SilcSnprintf/silc_snprintf
24  *
25  * SYNOPSIS
26  *
27  *    int silc_snprintf(char *str, size_t count, const char *fmt, ...);
28  *
29  * DESCRIPTION
30  *
31  *    Outputs string into `str' of maximum of size `count' including the
32  *    trailing '\0' according to the `fmt'.  The `fmt' is equivalent to
33  *    snprintf(3) and printf(3) formatting.  Returns the number of character
34  *    in `str' or negative value on error.
35  *
36  ***/
37 int silc_snprintf(char *str, size_t count, const char *fmt, ...);
38
39 /****f* silcutil/SilcSnprintf/silc_vsnprintf
40  *
41  * SYNOPSIS
42  *
43  *    int silc_vsnprintf(char *str, size_t count, const char *fmt,
44  *                       va_list args)
45  *
46  * DESCRIPTION
47  *
48  *    Same as silc_snprintf but takes the argument for the formatting from
49  *    the `args' variable argument list.
50  *
51  ***/
52 int silc_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
53
54 /****f* silcutil/SilcSnprintf/silc_asprintf
55  *
56  * SYNOPSIS
57  *
58  *    int silc_asprintf(char **ptr, const char *format, ...)
59  *
60  * DESCRIPTION
61  *
62  *    Same as silc_snprintf but allocates a string large enough to hold the
63  *    output including the trailing '\0'.  The caller must free the `ptr'.
64  *
65  ***/
66 int silc_asprintf(char **ptr, const char *format, ...);
67
68 /****f* silcutil/SilcSnprintf/silc_vasprintf
69  *
70  * SYNOPSIS
71  *
72  *    int silc_vasprintf(char **ptr, const char *format, va_list ap)
73  *
74  * DESCRIPTION
75  *
76  *    Same as silc_asprintf but takes the argument from the `ap' variable
77  *    argument list.
78  *
79  ***/
80 int silc_vasprintf(char **ptr, const char *format, va_list ap);
81
82 #endif /* SILCSNPRINTF_H */