OSDN Git Service

9a6643899925c45ff104c2735f16dcfc648f0287
[linuxjm/LDP_man-pages.git] / draft / man3 / asprintf.3
1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Text fragments inspired by Martin Schulze <joey@infodrom.org>.
24 .\"
25 .\" Japanese Version Copyright (c) 2002 NAKANO Takeo all rights reserved.
26 .\" Translated Mon 14 Jan 2002 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
27 .\"
28 .TH ASPRINTF 3 2001-12-18 "GNU" "Linux Programmer's Manual"
29 .\"O .SH NAME
30 .\"O asprintf, vasprintf \- print to allocated string
31 .SH 名前
32 asprintf, vasprintf \- 文字列を割り当ててそれに出力する
33 .\"O .SH SYNOPSIS
34 .SH 書式
35 .\"O .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
36 .BR "#define _GNU_SOURCE" "         /* feature_test_macros(7) 参照 */"
37 .br
38 .B #include <stdio.h>
39 .sp
40 .BI "int asprintf(char **" strp ", const char *" fmt ", ...);"
41 .sp
42 .BI "int vasprintf(char **" strp ", const char *" fmt ", va_list " ap );
43 .\"O .SH DESCRIPTION
44 .SH 説明
45 .\"O The functions
46 .\"O .BR asprintf ()
47 .\"O and
48 .\"O .BR vasprintf ()
49 .\"O are analogs of
50 .\"O .BR sprintf (3)
51 .\"O and
52 .\"O .BR vsprintf (3),
53 .\"O except that they allocate a string large enough to hold the output
54 .\"O including the terminating null byte,
55 .\"O and return a pointer to it via the first argument.
56 .\"O This pointer should be passed to
57 .\"O .BR free (3)
58 .\"O to release the allocated storage when it is no longer needed.
59 .BR asprintf ()
60 関数と
61 .BR vasprintf ()
62 関数とは、それぞれ
63 .BR sprintf (3)
64 関数と
65 .BR vsprintf (3)
66 関数とに似ているが、
67 出力文字列を (終端の NULL バイトも含めて)
68 保持するのに十分な大きさのメモリを確保し、
69 最初の引数にその文字列へのポインタを返す。
70 このポインタは、不要になったら
71 .BR free (3)
72 に渡し、割り当てられた記憶領域を解放すべきである。
73 .\"O .SH "RETURN VALUE"
74 .SH 返り値
75 .\"O When successful, these functions return the number of bytes printed,
76 .\"O just like
77 .\"O .BR sprintf (3).
78 .\"O If memory allocation wasn't possible, or some other error occurs,
79 .\"O these functions will return \-1, and the contents of
80 .\"O .I strp
81 .\"O is undefined.
82 成功すると、これらの関数は出力されたバイト数を
83 .RB ( sprintf (3)
84 のように) 返す。
85 メモリの割り当てができなかったり、
86 その他エラーが生じると、
87 これらの関数は \-1 を返し、
88 .I strp
89 の内容は未定義となる。
90 .\"O .SH CONFORMING TO
91 .SH 準拠
92 .\"O These functions are GNU extensions, not in C or POSIX.
93 .\"O They are also available under *BSD.
94 .\"O The FreeBSD implementation sets
95 .\"O .I strp
96 .\"O to NULL on error.
97 これらの関数は GNU の拡張であり、C や POSIX のものではない。
98 これらは *BSD でも利用できる。
99 FreeBSD の実装では、エラーの際には
100 .I strp
101 を NULL にセットする。
102 .\"O .SH "SEE ALSO"
103 .SH 関連項目
104 .BR free (3),
105 .BR malloc (3),
106 .BR printf (3)