]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/confstr.3
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man3 / confstr.3
1 .\" (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 .TH CONFSTR 3 1993-04-17 "GNU" "Linux Programmer's Manual"
30 .SH NAME
31 confstr \- get configuration dependent string variables
32 .SH SYNOPSIS
33 .nf
34 .B #define _POSIX_C_SOURCE 2
35 or
36 .B #define _XOPEN_SOURCE
37 .br
38 .B #include <unistd.h>
39 .sp
40 .BI "size_t confstr(int " "name" ", char *" buf ", size_t " len );
41 .fi
42 .SH DESCRIPTION
43 .BR confstr ()
44 gets the value of configuration-dependent string variables.
45 .PP
46 The
47 .I name
48 argument is the system variable to be queried.
49 The following variables are supported:
50 .TP
51 .BR _CS_GNU_LIBC_VERSION " (GNU C library only; since glibc 2.3.2)"
52 A string which identifies the GNU C library version on this system
53 (e.g, "glibc 2.3.4").
54 .TP
55 .BR _CS_GNU_LIBPTHREAD_VERSION " (GNU C library only; since glibc 2.3.2)"
56 A string which identifies the POSIX implementation supplied by this
57 C library (e.g, "NPTL 2.3.4" or "linuxthreads-0.10").
58 .TP
59 .B _CS_PATH
60 A value for the
61 .B PATH
62 variable which indicates where all the POSIX.2 standard utilities can
63 be found.
64 .PP
65 If
66 .I buf
67 is not NULL and
68 .I len
69 is not zero,
70 .BR confstr ()
71 copies the value of the string to
72 .I buf
73 truncated to
74 .I len \- 1
75 characters if necessary, with a null byte ('\\0') as terminator.
76 This can be detected by comparing the return value of
77 .BR confstr ()
78 against
79 .IR len .
80 .PP
81 If
82 .I len
83 is zero and
84 .I buf
85 is NULL,
86 .BR confstr ()
87 just returns the value as defined below.
88 .SH "RETURN VALUE"
89 If
90 .I name
91 is a valid configuration variable,
92 .BR confstr ()
93 returns the number of bytes (including the terminating null byte)
94 that would be required to hold the entire value of that variable.
95 This value may be greater than
96 .IR len ,
97 which means that the value in
98 .I buf
99 is truncated.
100
101 If
102 .I name
103 is a valid configuration variable,
104 but that variable does not have a value, then
105 .BR confstr ()
106 returns 0.
107 If
108 .I name
109 does not correspond to a valid configuration variable,
110 .BR confstr ()
111 returns 0, and
112 .I errno
113 is set to
114 .BR EINVAL .
115 .SH ERRORS
116 .TP
117 .BR EINVAL
118 If the value of
119 .I name
120 is invalid.
121 .SH EXAMPLE
122 The following code fragment determines the path where to find
123 the POSIX.2 system utilities:
124 .br
125 .nf
126 .in 10
127
128 char *pathbuf; size_t n;
129
130 n = confstr(_CS_PATH,NULL,(size_t)0);
131 if ((pathbuf = malloc(n)) == NULL) abort();
132 confstr(_CS_PATH, pathbuf, n);
133 .SH "CONFORMING TO"
134 POSIX.1-2001
135 .SH "SEE ALSO"
136 .BR sh (1),
137 .BR exec (3),
138 .BR system (3),
139 .BR feature_test_macros (7)