OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / LDP_man-pages / release / man3 / confstr.3
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
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 .\" License.
23 .\" Modified Sat Jul 24 19:53:02 1993 by Rik Faith (faith@cs.unc.edu)
24 .\" FIXME Many more values for 'name' are supported, some of which
25 .\"     are documented under 'info confstr'.
26 .\"     See <bits/confname.h> for the rest.
27 .\"     These should all be added to this page.
28 .\"     See also the POSIX.1-2001 specification of confstr()
29 .\"
30 .\" Japanese Version Copyright (c) 1997 Hiroaki Nagoya
31 .\"         all rights reserved.
32 .\" Translated by Hiroaki Nagoya <nagoya@is.titech.ac.jp>
33 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
34 .\" Updated 2006-07-20, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
35 .\"
36 .TH CONFSTR 3  2010-02-03 "GNU" "Linux Programmer's Manual"
37 .SH 名前
38 confstr \- コンフィグレーションに依存した文字列変数の取得
39 .SH 書式
40 .nf
41 .B #include <unistd.h>
42 .sp
43 .BI "size_t confstr(int " "name" ", char *" buf ", size_t " len );
44 .fi
45 .sp
46 .in -4n
47 glibc 向けの機能検査マクロの要件
48 .RB ( feature_test_macros (7)
49 参照):
50 .in
51 .sp
52 .BR confstr ():
53 _POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE
54 .SH 説明
55 .BR confstr ()
56 はコンフィグレーションに依存した文字列変数の値を取得する。
57 .PP
58 引き数
59 .I name
60 は、問い合わせ内容を表すシステム変数である。
61 以下の変数がサポートされている。
62 .TP
63 .BR _CS_GNU_LIBC_VERSION " (GNU C library 限定; glibc 2.3.2 以降)"
64 そのシステムの GNU C ライブラリのバージョンを示す文字列
65 (例えば "glibc 2.3.4")。
66 .TP
67 .BR _CS_GNU_LIBPTHREAD_VERSION " (GNU C library 限定; glibc 2.3.2 以降)"
68 その C ライブラリが提供している POSIX 実装を示す文字列
69 (例えば "NPTL 2.3.4" や "linuxthreads-0.10")。
70 .TP
71 .B _CS_PATH
72 すべての POSIX.2 標準ユーティリティが見つかるような
73 .B PATH
74 の値。
75 .PP
76 .I buf
77 が NULL でなく、かつ
78 .I len
79 が 0 でなければ
80 .BR confstr ()
81 は取得した文字列の内容を
82 .I buf
83 にコピーする。必要ならば長さは
84 .I len \- 1
85 文字に切り捨てられて、NULL バイト (\(aq\\0\(aq) で終端される。
86 末尾が切り捨てられたかどうかを判定するには、
87 .BR confstr ()
88 の返り値を
89 .I len
90 と比較すればよい。
91 .PP
92 .I len
93 が 0 で
94 .I buf
95 が NULL ならば、
96 .BR confstr ()
97 は以下で定義された値 (訳注: 切り捨てる前の、取得した文字列の長さ) を返す。
98 .SH 返り値
99 .I name
100 が有効なコンフィギュレーション変数の場合、
101 .BR confstr ()
102 はその変数の値全体を保持するのに必要であったバイト数を返す
103 (文字列終端のヌルバイトも含む)。この値は
104 .I len
105 より大きいこともある。この場合には、
106 .I buf
107 に格納された値の末尾が切り詰められたことを意味する。
108
109 .I name
110 が有効なコンフィギュレーション変数だが、
111 変数が値を持っていない場合、
112 .BR confstr ()
113 は 0 を返す。
114 .I name
115 が有効なコンフィグレーション変数に対応していなければ、
116 .BR confstr ()
117 は 0 を返し、
118 .I errno
119
120 .B EINVAL
121 を設定する。
122 .SH エラー
123 .TP
124 .B EINVAL
125 .I name
126 の値が不正である。
127 .SH 準拠
128 POSIX.1-2001.
129 .SH 例
130 次の部分的なコードは、 POSIX.2 システムのユーティリティがあるパス
131 を取得するものである。
132 .br
133 .nf
134 .in +4n
135
136 char *pathbuf;
137 size_t n;
138
139 n = confstr(_CS_PATH,NULL,(size_t) 0);
140 pathbuf = malloc(n);
141 if (pathbuf == NULL)
142     abort();
143 confstr(_CS_PATH, pathbuf, n);
144 .in
145 .fi
146 .SH 関連項目
147 .BR sh (1),
148 .BR exec (3),
149 .BR system (3)