OSDN Git Service

LDP: Update original to LDP v3.68
[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 .TH CONFSTR 3  2014-03-20 "GNU" "Linux Programmer's Manual"
32 .SH NAME
33 confstr \- get configuration dependent string variables
34 .SH SYNOPSIS
35 .nf
36 .B #include <unistd.h>
37 .sp
38 .BI "size_t confstr(int " "name" ", char *" buf ", size_t " len );
39 .fi
40 .sp
41 .in -4n
42 Feature Test Macro Requirements for glibc (see
43 .BR feature_test_macros (7)):
44 .in
45 .sp
46 .BR confstr ():
47 _POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE
48 .SH DESCRIPTION
49 .BR confstr ()
50 gets the value of configuration-dependent string variables.
51 .PP
52 The
53 .I name
54 argument is the system variable to be queried.
55 The following variables are supported:
56 .TP
57 .BR _CS_GNU_LIBC_VERSION " (GNU C library only; since glibc 2.3.2)"
58 A string which identifies the GNU C library version on this system
59 (e.g, "glibc 2.3.4").
60 .TP
61 .BR _CS_GNU_LIBPTHREAD_VERSION " (GNU C library only; since glibc 2.3.2)"
62 A string which identifies the POSIX implementation supplied by this
63 C library (e.g, "NPTL 2.3.4" or "linuxthreads-0.10").
64 .TP
65 .B _CS_PATH
66 A value for the
67 .B PATH
68 variable which indicates where all the POSIX.2 standard utilities can
69 be found.
70 .PP
71 If
72 .I buf
73 is not NULL and
74 .I len
75 is not zero,
76 .BR confstr ()
77 copies the value of the string to
78 .I buf
79 truncated to
80 .I len \- 1
81 bytes if necessary, with a null byte (\(aq\\0\(aq) as terminator.
82 This can be detected by comparing the return value of
83 .BR confstr ()
84 against
85 .IR len .
86 .PP
87 If
88 .I len
89 is zero and
90 .I buf
91 is NULL,
92 .BR confstr ()
93 just returns the value as defined below.
94 .SH RETURN VALUE
95 If
96 .I name
97 is a valid configuration variable,
98 .BR confstr ()
99 returns the number of bytes (including the terminating null byte)
100 that would be required to hold the entire value of that variable.
101 This value may be greater than
102 .IR len ,
103 which means that the value in
104 .I buf
105 is truncated.
106
107 If
108 .I name
109 is a valid configuration variable,
110 but that variable does not have a value, then
111 .BR confstr ()
112 returns 0.
113 If
114 .I name
115 does not correspond to a valid configuration variable,
116 .BR confstr ()
117 returns 0, and
118 .I errno
119 is set to
120 .BR EINVAL .
121 .SH ERRORS
122 .TP
123 .B EINVAL
124 The value of
125 .I name
126 is invalid.
127 .SH CONFORMING TO
128 POSIX.1-2001.
129 .SH EXAMPLE
130 The following code fragment determines the path where to find
131 the POSIX.2 system utilities:
132 .br
133 .nf
134 .in +4n
135
136 char *pathbuf;
137 size_t n;
138
139 n = confstr(_CS_PATH, NULL, (size_t) 0);
140 pathbuf = malloc(n);
141 if (pathbuf == NULL)
142     abort();
143 confstr(_CS_PATH, pathbuf, n);
144 .in
145 .fi
146 .SH SEE ALSO
147 .BR getconf (1),
148 .BR sh (1),
149 .BR exec (3),
150 .BR fpathconf (3)
151 .BR sysconf (3)
152 .BR pathconf (3)
153 .BR system (3)
154 .SH COLOPHON
155 This page is part of release 3.68 of the Linux
156 .I man-pages
157 project.
158 A description of the project,
159 information about reporting bugs,
160 and the latest version of this page,
161 can be found at
162 \%http://www.kernel.org/doc/man\-pages/.