OSDN Git Service

c39c1db08342bb59261fcc77337b32da5ba8dc2d
[linuxjm/LDP_man-pages.git] / original / man3 / confstr.3
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 .\" FIXME Many more values for 'name' are supported, some of which
27 .\"     are documented under 'info confstr'.
28 .\"     See <bits/confname.h> for the rest.
29 .\"     These should all be added to this page.
30 .\"     See also the POSIX.1-2001 specification of confstr()
31 .\"
32 .TH CONFSTR 3  2014-03-20 "GNU" "Linux Programmer's Manual"
33 .SH NAME
34 confstr \- get configuration dependent string variables
35 .SH SYNOPSIS
36 .nf
37 .B #include <unistd.h>
38 .sp
39 .BI "size_t confstr(int " "name" ", char *" buf ", size_t " len );
40 .fi
41 .sp
42 .in -4n
43 Feature Test Macro Requirements for glibc (see
44 .BR feature_test_macros (7)):
45 .in
46 .sp
47 .BR confstr ():
48 _POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE
49 .SH DESCRIPTION
50 .BR confstr ()
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
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
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
74 is not NULL and
75 .I len
76 is not zero,
77 .BR confstr ()
78 copies the value of the string to
79 .I buf
80 truncated to
81 .I len \- 1
82 bytes if necessary, with a null byte (\(aq\\0\(aq) as terminator.
83 This can be detected by comparing the return value of
84 .BR confstr ()
85 against
86 .IR len .
87 .PP
88 If
89 .I len
90 is zero and
91 .I buf
92 is NULL,
93 .BR confstr ()
94 just returns the value as defined below.
95 .SH RETURN VALUE
96 If
97 .I name
98 is a valid configuration variable,
99 .BR confstr ()
100 returns the number of bytes (including the terminating null byte)
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
109 .I name
110 is a valid configuration variable,
111 but that variable does not have a value, then
112 .BR confstr ()
113 returns 0.
114 If
115 .I name
116 does not correspond to a valid configuration variable,
117 .BR confstr ()
118 returns 0, and
119 .I errno
120 is set to
121 .BR EINVAL .
122 .SH ERRORS
123 .TP
124 .B EINVAL
125 The value of
126 .I name
127 is invalid.
128 .SH CONFORMING TO
129 POSIX.1-2001.
130 .SH EXAMPLE
131 The following code fragment determines the path where to find
132 the POSIX.2 system utilities:
133 .br
134 .nf
135 .in +4n
136
137 char *pathbuf;
138 size_t n;
139
140 n = confstr(_CS_PATH, NULL, (size_t) 0);
141 pathbuf = malloc(n);
142 if (pathbuf == NULL)
143     abort();
144 confstr(_CS_PATH, pathbuf, n);
145 .in
146 .fi
147 .SH SEE ALSO
148 .BR getconf (1),
149 .BR sh (1),
150 .BR exec (3),
151 .BR fpathconf (3)
152 .BR sysconf (3)
153 .BR pathconf (3)
154 .BR system (3)
155 .SH COLOPHON
156 This page is part of release 3.79 of the Linux
157 .I man-pages
158 project.
159 A description of the project,
160 information about reporting bugs,
161 and the latest version of this page,
162 can be found at
163 \%http://www.kernel.org/doc/man\-pages/.