]>
Commit | Line | Data |
---|---|---|
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 |
34 | confstr \- 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 | |
43 | Feature 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 |
51 | gets the value of configuration-dependent string variables. |
52 | .PP | |
53 | The | |
54 | .I name | |
55 | argument is the system variable to be queried. | |
56 | The following variables are supported: | |
57 | .TP | |
5984622e MK |
58 | .BR _CS_GNU_LIBC_VERSION " (GNU C library only; since glibc 2.3.2)" |
59 | A 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)" | |
63 | A string which identifies the POSIX implementation supplied by this | |
64 | C library (e.g, "NPTL 2.3.4" or "linuxthreads-0.10"). | |
65 | .TP | |
fea681da MK |
66 | .B _CS_PATH |
67 | A value for the | |
68 | .B PATH | |
69 | variable which indicates where all the POSIX.2 standard utilities can | |
70 | be found. | |
71 | .PP | |
72 | If | |
73 | .I buf | |
c13182ef | 74 | is not NULL and |
fea681da MK |
75 | .I len |
76 | is not zero, | |
63aa9df0 | 77 | .BR confstr () |
fea681da MK |
78 | copies the value of the string to |
79 | .I buf | |
80 | truncated to | |
81 | .I len \- 1 | |
a00b7454 | 82 | bytes if necessary, with a null byte (\(aq\\0\(aq) as terminator. |
fea681da | 83 | This can be detected by comparing the return value of |
63aa9df0 | 84 | .BR confstr () |
fea681da MK |
85 | against |
86 | .IR len . | |
87 | .PP | |
88 | If | |
89 | .I len | |
90 | is zero and | |
91 | .I buf | |
8478ee02 | 92 | is NULL, |
63aa9df0 | 93 | .BR confstr () |
fea681da | 94 | just returns the value as defined below. |
47297adb | 95 | .SH RETURN VALUE |
fea681da MK |
96 | If |
97 | .I name | |
4f43f21f | 98 | is a valid configuration variable, |
63aa9df0 | 99 | .BR confstr () |
c13182ef | 100 | returns the number of bytes (including the terminating null byte) |
4f43f21f MK |
101 | that would be required to hold the entire value of that variable. |
102 | This value may be greater than | |
103 | .IR len , | |
104 | which means that the value in | |
105 | .I buf | |
106 | is truncated. | |
107 | ||
108 | If | |
c13182ef MK |
109 | .I name |
110 | is a valid configuration variable, | |
4f43f21f | 111 | but that variable does not have a value, then |
01a81d11 | 112 | .BR confstr () |
fea681da | 113 | returns 0. |
4f43f21f MK |
114 | If |
115 | .I name | |
116 | does not correspond to a valid configuration variable, | |
117 | .BR confstr () | |
118 | returns 0, and | |
119 | .I errno | |
c13182ef | 120 | is set to |
4f43f21f MK |
121 | .BR EINVAL . |
122 | .SH ERRORS | |
01a81d11 | 123 | .TP |
0daa9e92 | 124 | .B EINVAL |
078ac12d | 125 | The value of |
4f43f21f MK |
126 | .I name |
127 | is invalid. | |
a2fac97f MS |
128 | .SH ATTRIBUTES |
129 | For an explanation of the terms used in this section, see | |
130 | .BR attributes (7). | |
131 | .TS | |
132 | allbox; | |
133 | lb lb lb | |
134 | l l l. | |
135 | Interface Attribute Value | |
136 | T{ | |
137 | .BR confstr () | |
138 | T} Thread safety MT-Safe | |
139 | .TE | |
47297adb | 140 | .SH CONFORMING TO |
3e4b12f4 | 141 | POSIX.1-2001, POSIX.1-2008. |
9b336505 | 142 | .SH EXAMPLE |
fea681da MK |
143 | The following code fragment determines the path where to find |
144 | the POSIX.2 system utilities: | |
145 | .br | |
146 | .nf | |
088a639b | 147 | .in +4n |
fea681da | 148 | |
6cd17cde MK |
149 | char *pathbuf; |
150 | size_t n; | |
fea681da | 151 | |
06f38b2f | 152 | n = confstr(_CS_PATH, NULL, (size_t) 0); |
6cd17cde MK |
153 | pathbuf = malloc(n); |
154 | if (pathbuf == NULL) | |
155 | abort(); | |
fea681da | 156 | confstr(_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) |