futex.2: Rework the description of FUTEX_LOCK_PI2
[man-pages.git] / man3 / confstr.3
blob809355e1b69c667302d10040eb8b3bd85a569424
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified Sat Jul 24 19:53:02 1993 by Rik Faith (faith@cs.unc.edu)
26 .\"
27 .\" FIXME Many more values for 'name' are supported, some of which
28 .\" are documented under 'info confstr'.
29 .\" See <bits/confname.h> for the rest.
30 .\" These should all be added to this page.
31 .\" See also the POSIX.1-2001 specification of confstr()
32 .\"
33 .TH CONFSTR 3  2021-03-22 "GNU" "Linux Programmer's Manual"
34 .SH NAME
35 confstr \- get configuration dependent string variables
36 .SH SYNOPSIS
37 .nf
38 .B #include <unistd.h>
39 .PP
40 .BI "size_t confstr(int " "name" ", char *" buf ", size_t " len );
41 .fi
42 .PP
43 .RS -4
44 Feature Test Macro Requirements for glibc (see
45 .BR feature_test_macros (7)):
46 .RE
47 .PP
48 .BR confstr ():
49 .nf
50     _POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE
51 .fi
52 .SH DESCRIPTION
53 .BR confstr ()
54 gets the value of configuration-dependent string variables.
55 .PP
56 The
57 .I name
58 argument is the system variable to be queried.
59 The following variables are supported:
60 .TP
61 .BR _CS_GNU_LIBC_VERSION " (GNU C library only; since glibc 2.3.2)"
62 A string which identifies the GNU C library version on this system
63 (e.g., "glibc 2.3.4").
64 .TP
65 .BR _CS_GNU_LIBPTHREAD_VERSION " (GNU C library only; since glibc 2.3.2)"
66 A string which identifies the POSIX implementation supplied by this
67 C library (e.g., "NPTL 2.3.4" or "linuxthreads\-0.10").
68 .TP
69 .B _CS_PATH
70 A value for the
71 .B PATH
72 variable which indicates where all the POSIX.2 standard utilities can
73 be found.
74 .PP
76 .I buf
77 is not NULL and
78 .I len
79 is not zero,
80 .BR confstr ()
81 copies the value of the string to
82 .I buf
83 truncated to
84 .I len \- 1
85 bytes if necessary, with a null byte (\(aq\e0\(aq) as terminator.
86 This can be detected by comparing the return value of
87 .BR confstr ()
88 against
89 .IR len .
90 .PP
92 .I len
93 is zero and
94 .I buf
95 is NULL,
96 .BR confstr ()
97 just returns the value as defined below.
98 .SH RETURN VALUE
100 .I name
101 is a valid configuration variable,
102 .BR confstr ()
103 returns the number of bytes (including the terminating null byte)
104 that would be required to hold the entire value of that variable.
105 This value may be greater than
106 .IR len ,
107 which means that the value in
108 .I buf
109 is truncated.
112 .I name
113 is a valid configuration variable,
114 but that variable does not have a value, then
115 .BR confstr ()
116 returns 0.
118 .I name
119 does not correspond to a valid configuration variable,
120 .BR confstr ()
121 returns 0, and
122 .I errno
123 is set to
124 .BR EINVAL .
125 .SH ERRORS
127 .B EINVAL
128 The value of
129 .I name
130 is invalid.
131 .SH ATTRIBUTES
132 For an explanation of the terms used in this section, see
133 .BR attributes (7).
134 .ad l
137 allbox;
138 lbx lb lb
139 l l l.
140 Interface       Attribute       Value
142 .BR confstr ()
143 T}      Thread safety   MT-Safe
147 .sp 1
148 .SH CONFORMING TO
149 POSIX.1-2001, POSIX.1-2008.
150 .SH EXAMPLES
151 The following code fragment determines the path where to find
152 the POSIX.2 system utilities:
154 .in +4n
156 char *pathbuf;
157 size_t n;
159 n = confstr(_CS_PATH, NULL, (size_t) 0);
160 pathbuf = malloc(n);
161 if (pathbuf == NULL)
162     abort();
163 confstr(_CS_PATH, pathbuf, n);
166 .SH SEE ALSO
167 .BR getconf (1),
168 .BR sh (1),
169 .BR exec (3),
170 .BR fpathconf (3),
171 .BR pathconf (3),
172 .BR sysconf (3),
173 .BR system (3)