diff options
Diffstat (limited to 'doc/grecs_asprintf.3')
-rw-r--r-- | doc/grecs_asprintf.3 | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/doc/grecs_asprintf.3 b/doc/grecs_asprintf.3 new file mode 100644 index 0000000..73be7f0 --- /dev/null +++ b/doc/grecs_asprintf.3 | |||
@@ -0,0 +1,90 @@ | |||
1 | .\" This file is part of grecs -*- nroff -*- | ||
2 | .\" Copyright (C) 2007, 2009-2011 Sergey Poznyakoff | ||
3 | .\" | ||
4 | .\" Grecs is free software; you can redistribute it and/or modify | ||
5 | .\" it under the terms of the GNU General Public License as published by | ||
6 | .\" the Free Software Foundation; either version 3, or (at your option) | ||
7 | .\" any later version. | ||
8 | .\" | ||
9 | .\" Grecs is distributed in the hope that it will be useful, | ||
10 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | .\" GNU General Public License for more details. | ||
13 | .\" | ||
14 | .\" You should have received a copy of the GNU General Public License | ||
15 | .\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. | ||
16 | .\" This file is part of SLB. | ||
17 | .\" Copyright (C) 2011 Sergey Poznyakoff | ||
18 | .\" | ||
19 | .TH GRECS_ASPRINTF 3 "May 4, 2011" "GRECS" "Grecs User Reference" | ||
20 | .SH NAME | ||
21 | grecs_asprintf, grecs_vasprintf \- print to allocated string | ||
22 | .SH SYNOPSIS | ||
23 | .nf | ||
24 | .B #include <grecs.h> | ||
25 | .sp | ||
26 | .BI "int grecs_vasprintf(char " "**pbuf" ", size_t " "*psize" \ | ||
27 | ", const char " "*format" ", " | ||
28 | .ti +17 | ||
29 | .BI "va_list " "ap" ); | ||
30 | .br | ||
31 | .BI "int grecs_asprintf(char " "**pbuf" ", size_t " "*psize" \ | ||
32 | ", const char *" "format" ", ...);" | ||
33 | .SH DESCRIPTION | ||
34 | The functions | ||
35 | .BI grecs_asprintf () | ||
36 | and | ||
37 | .BI grecs_vasprintf () | ||
38 | are analogs of | ||
39 | .BR sprintf (3) | ||
40 | and | ||
41 | .BR vsprintf (3), | ||
42 | except that they operate on dynamically allocated buffers. | ||
43 | .PP | ||
44 | If, on entry to the function, \fB*pbuf\fR is NULL and \fB*psize\fR is | ||
45 | 0, both functions will allocate a buffer large enough to hold the | ||
46 | formatted message and will fill it with the formatted text. | ||
47 | .PP | ||
48 | If \fB*pbuf\fR is not NULL, \fBpsize\fR must point to its actual size. | ||
49 | If that size is not large enough to accomodate the formatted message, | ||
50 | the buffer will be reallocated accordingly, otherwise it will remain | ||
51 | unchanged. | ||
52 | .PP | ||
53 | In both cases, if the buffer has been reallocated, on return | ||
54 | \fBpbuf\fR will contain its new address and \fBpsize\fR its new size. | ||
55 | .PP | ||
56 | For initial allocation, | ||
57 | .BR grecs_malloc (3) | ||
58 | is used. To reallocate memory, both functions use | ||
59 | .BR grecs_realloc (3). | ||
60 | .SH RETURN VALUE | ||
61 | None. If memory allocation fails, a diagnostics is output and the | ||
62 | program is terminated. | ||
63 | .SH "SEE ALSO" | ||
64 | .BR grecs_malloc (3), | ||
65 | .BR grecs_realloc (3). | ||
66 | .SH AUTHORS | ||
67 | Sergey Poznyakoff | ||
68 | .SH "BUG REPORTS" | ||
69 | Report bugs to <gray+grecs@gnu.org.ua>. | ||
70 | .SH COLOPHON | ||
71 | The \fBGrecs\fR library is constantly changing, so this manual page | ||
72 | may be incorrect or out-of-date. For the latest copy of \fBGrecs\fR | ||
73 | documentation, visit <http://www.gnu.org.ua/software/grecs>. | ||
74 | .SH COPYRIGHT | ||
75 | Copyright \(co 2011 Sergey Poznyakoff | ||
76 | .br | ||
77 | .na | ||
78 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> | ||
79 | .br | ||
80 | .ad | ||
81 | This is free software: you are free to change and redistribute it. | ||
82 | There is NO WARRANTY, to the extent permitted by law. | ||
83 | .\" Local variables: | ||
84 | .\" eval: (add-hook 'write-file-hooks 'time-stamp) | ||
85 | .\" time-stamp-start: ".TH [A-Z_][A-Z0-9_]* [0-9] \"" | ||
86 | .\" time-stamp-format: "%:B %:d, %:y" | ||
87 | .\" time-stamp-end: "\"" | ||
88 | .\" time-stamp-line-limit: 20 | ||
89 | .\" end: | ||
90 | |||