.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Modified Sat Jul 24 19:53:02 1993 by Rik Faith (faith@cs.unc.edu) .\" .\" FIXME Many more values for 'name' are supported, some of which .\" are documented under 'info confstr'. .\" See for the rest. .\" These should all be added to this page. .\" See also the POSIX.1-2001 specification of confstr() .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 Hiroaki Nagoya .\" all rights reserved. .\" Translated by Hiroaki Nagoya .\" Updated 2005-09-06, Akihiro MOTOKI .\" Updated 2006-07-20, Akihiro MOTOKI , LDP v2.36 .\" .TH CONFSTR 3 2020\-06\-09 GNU "Linux Programmer's Manual" .SH 名前 confstr \- コンフィグレーションに依存した文字列変数の取得 .SH 書式 .nf \fB#include \fP .PP \fBsize_t confstr(int \fP\fIname\fP\fB, char *\fP\fIbuf\fP\fB, size_t \fP\fIlen\fP\fB);\fP .fi .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBconfstr\fP(): _POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE .SH 説明 \fBconfstr\fP() はコンフィグレーションに依存した文字列変数の値を取得する。 .PP 引数 \fIname\fP は、問い合わせ内容を表すシステム変数である。 以下の変数がサポートされている。 .TP \fB_CS_GNU_LIBC_VERSION\fP (GNU C library 限定; glibc 2.3.2 以降) そのシステムの GNU C ライブラリのバージョンを示す文字列 (例えば "glibc 2.3.4")。 .TP \fB_CS_GNU_LIBPTHREAD_VERSION\fP (GNU C library 限定; glibc 2.3.2 以降) その C ライブラリが提供している POSIX 実装を示す文字列 (例えば "NPTL 2.3.4" や "linuxthreads\-0.10")。 .TP \fB_CS_PATH\fP すべての POSIX.2 標準ユーティリティが見つかるような \fBPATH\fP の値。 .PP \fIbuf\fP が NULL でなく、かつ \fIlen\fP が 0 でなければ \fBconfstr\fP() は取得 した文字列の内容を \fIbuf\fP にコピーする。必要ならば長さが \fIlen \- 1\fP バイトに切り捨てられて、NULL バイト (\(aq\e0\(aq) で終端される。 末尾が切り捨てられたかどうかを判定するには、 \fBconfstr\fP() の返り値を \fIlen\fP と比較すればよい。 .PP \fIlen\fP が 0 で \fIbuf\fP が NULL ならば、 \fBconfstr\fP() は以下で定義された値 (訳注: 切り捨てる前の、取得した文字列の長さ) を返す。 .SH 返り値 \fIname\fP が有効なコンフィギュレーション変数の場合、 \fBconfstr\fP() はその変数の値全体を保持するのに必要であったバイト数を返す (文字列終端のヌルバイトも含む)。この値は \fIlen\fP より大きいこともある。この場合には、 \fIbuf\fP に格納された値の末尾が切り詰められたことを意味する。 .PP \fIname\fP が有効なコンフィギュレーション変数だが、 変数が値を持っていない場合、 \fBconfstr\fP() は 0 を返す。 \fIname\fP が有効なコンフィグレーション変数に対応していなければ、 \fBconfstr\fP() は 0 を返し、 \fIerrno\fP に \fBEINVAL\fP を設定する。 .SH エラー .TP \fBEINVAL\fP \fIname\fP の値が不正である。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBconfstr\fP() T} Thread safety MT\-Safe .TE .SH 準拠 POSIX.1\-2001, POSIX.1\-2008. .SH 例 次の部分的なコードは、 POSIX.2 システムのユーティリティがあるパス を取得するものである。 .PP .in +4n .EX char *pathbuf; size_t n; n = confstr(_CS_PATH, NULL, (size_t) 0); pathbuf = malloc(n); if (pathbuf == NULL) abort(); confstr(_CS_PATH, pathbuf, n); .EE .in .SH 関連項目 \fBgetconf\fP(1), \fBsh\fP(1), \fBexec\fP(3), \fBfpathconf\fP(3), \fBpathconf\fP(3), \fBsysconf\fP(3), \fBsystem\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。