Merge branch 'topic/mm-fixes' of git://208.110.73.182/silc into silc.1.1.branch
[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 /****h* silcutil/Snprintf
21  *
22  * DESCRIPTION
23  *
24  * Platform independent version of snprintf and other similar string
25  * formatting routines.
26  *
27  ***/
28
29 #ifndef SILCSNPRINTF_H
30 #define SILCSNPRINTF_H
31
32 /****f* silcutil/SilcSnprintf/silc_snprintf
33  *
34  * SYNOPSIS
35  *
36  *    int silc_snprintf(char *str, size_t count, const char *fmt, ...);
37  *
38  * DESCRIPTION
39  *
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.
44  *
45  ***/
46 int silc_snprintf(char *str, size_t count, const char *fmt, ...);
47
48 /****f* silcutil/SilcSnprintf/silc_vsnprintf
49  *
50  * SYNOPSIS
51  *
52  *    int silc_vsnprintf(char *str, size_t count, const char *fmt,
53  *                       va_list args)
54  *
55  * DESCRIPTION
56  *
57  *    Same as silc_snprintf but takes the argument for the formatting from
58  *    the `args' variable argument list.
59  *
60  ***/
61 int silc_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
62
63 /****f* silcutil/SilcSnprintf/silc_asprintf
64  *
65  * SYNOPSIS
66  *
67  *    int silc_asprintf(char **ptr, const char *format, ...)
68  *
69  * DESCRIPTION
70  *
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'.
73  *
74  ***/
75 int silc_asprintf(char **ptr, const char *format, ...);
76
77 /****f* silcutil/SilcSnprintf/silc_vasprintf
78  *
79  * SYNOPSIS
80  *
81  *    int silc_vasprintf(char **ptr, const char *format, va_list ap)
82  *
83  * DESCRIPTION
84  *
85  *    Same as silc_asprintf but takes the argument from the `ap' variable
86  *    argument list.
87  *
88  ***/
89 int silc_vasprintf(char **ptr, const char *format, va_list ap);
90
91 #endif /* SILCSNPRINTF_H */