]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/confstr.3
membarrier.2: Remove redundant mention of return value of MEMBARRIER_CMD_SHARED
[thirdparty/man-pages.git] / man3 / confstr.3
CommitLineData
bf5a7247 1.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
fea681da 2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
c08df37a 24.\"
fea681da 25.\" Modified Sat Jul 24 19:53:02 1993 by Rik Faith (faith@cs.unc.edu)
c13182ef 26.\" FIXME Many more values for 'name' are supported, some of which
5984622e 27.\" are documented under 'info confstr'.
c13182ef 28.\" See <bits/confname.h> for the rest.
0359df8c 29.\" These should all be added to this page.
68e1685c 30.\" See also the POSIX.1-2001 specification of confstr()
bea08fec 31.\"
460495ca 32.TH CONFSTR 3 2015-08-08 "GNU" "Linux Programmer's Manual"
fea681da
MK
33.SH NAME
34confstr \- get configuration dependent string variables
35.SH SYNOPSIS
36.nf
fea681da
MK
37.B #include <unistd.h>
38.sp
39.BI "size_t confstr(int " "name" ", char *" buf ", size_t " len );
40.fi
cc4615cc
MK
41.sp
42.in -4n
43Feature Test Macro Requirements for glibc (see
44.BR feature_test_macros (7)):
45.in
46.sp
e313308d
MK
47.BR confstr ():
48_POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE
fea681da 49.SH DESCRIPTION
63aa9df0 50.BR confstr ()
fea681da
MK
51gets the value of configuration-dependent string variables.
52.PP
53The
54.I name
55argument is the system variable to be queried.
56The following variables are supported:
57.TP
5984622e
MK
58.BR _CS_GNU_LIBC_VERSION " (GNU C library only; since glibc 2.3.2)"
59A string which identifies the GNU C library version on this system
60(e.g, "glibc 2.3.4").
61.TP
62.BR _CS_GNU_LIBPTHREAD_VERSION " (GNU C library only; since glibc 2.3.2)"
63A string which identifies the POSIX implementation supplied by this
64C library (e.g, "NPTL 2.3.4" or "linuxthreads-0.10").
65.TP
fea681da
MK
66.B _CS_PATH
67A value for the
68.B PATH
69variable which indicates where all the POSIX.2 standard utilities can
70be found.
71.PP
72If
73.I buf
c13182ef 74is not NULL and
fea681da
MK
75.I len
76is not zero,
63aa9df0 77.BR confstr ()
fea681da
MK
78copies the value of the string to
79.I buf
80truncated to
81.I len \- 1
a00b7454 82bytes if necessary, with a null byte (\(aq\\0\(aq) as terminator.
fea681da 83This can be detected by comparing the return value of
63aa9df0 84.BR confstr ()
fea681da
MK
85against
86.IR len .
87.PP
88If
89.I len
90is zero and
91.I buf
8478ee02 92is NULL,
63aa9df0 93.BR confstr ()
fea681da 94just returns the value as defined below.
47297adb 95.SH RETURN VALUE
fea681da
MK
96If
97.I name
4f43f21f 98is a valid configuration variable,
63aa9df0 99.BR confstr ()
c13182ef 100returns the number of bytes (including the terminating null byte)
4f43f21f
MK
101that would be required to hold the entire value of that variable.
102This value may be greater than
103.IR len ,
104which means that the value in
105.I buf
106is truncated.
107
108If
c13182ef
MK
109.I name
110is a valid configuration variable,
4f43f21f 111but that variable does not have a value, then
01a81d11 112.BR confstr ()
fea681da 113returns 0.
4f43f21f
MK
114If
115.I name
116does not correspond to a valid configuration variable,
117.BR confstr ()
118returns 0, and
119.I errno
c13182ef 120is set to
4f43f21f
MK
121.BR EINVAL .
122.SH ERRORS
01a81d11 123.TP
0daa9e92 124.B EINVAL
078ac12d 125The value of
4f43f21f
MK
126.I name
127is invalid.
a2fac97f
MS
128.SH ATTRIBUTES
129For an explanation of the terms used in this section, see
130.BR attributes (7).
131.TS
132allbox;
133lb lb lb
134l l l.
135Interface Attribute Value
136T{
137.BR confstr ()
138T} Thread safety MT-Safe
139.TE
47297adb 140.SH CONFORMING TO
3e4b12f4 141POSIX.1-2001, POSIX.1-2008.
9b336505 142.SH EXAMPLE
fea681da
MK
143The following code fragment determines the path where to find
144the POSIX.2 system utilities:
145.br
146.nf
088a639b 147.in +4n
fea681da 148
6cd17cde
MK
149char *pathbuf;
150size_t n;
fea681da 151
06f38b2f 152n = confstr(_CS_PATH, NULL, (size_t) 0);
6cd17cde
MK
153pathbuf = malloc(n);
154if (pathbuf == NULL)
155 abort();
fea681da 156confstr(_CS_PATH, pathbuf, n);
088a639b 157.in
c8250206 158.fi
47297adb 159.SH SEE ALSO
7117b535 160.BR getconf (1),
fea681da
MK
161.BR sh (1),
162.BR exec (3),
7117b535
MK
163.BR fpathconf (3)
164.BR sysconf (3)
165.BR pathconf (3)
cc4615cc 166.BR system (3)