]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/confstr.3
confstr.3, strcasecmp.3, strcat.3, strcmp.3, strcpy.3, strdup.3, strftime.3, strlen...
[thirdparty/man-pages.git] / man3 / confstr.3
CommitLineData
bf5a7247 1.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
fea681da
MK
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.
c13182ef 11.\"
fea681da
MK
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.
c13182ef 19.\"
fea681da
MK
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)
c13182ef 24.\" FIXME Many more values for 'name' are supported, some of which
5984622e 25.\" are documented under 'info confstr'.
c13182ef 26.\" See <bits/confname.h> for the rest.
0359df8c 27.\" These should all be added to this page.
68e1685c 28.\" See also the POSIX.1-2001 specification of confstr()
e313308d 29.TH CONFSTR 3 2010-02-03 "GNU" "Linux Programmer's Manual"
fea681da
MK
30.SH NAME
31confstr \- get configuration dependent string variables
32.SH SYNOPSIS
33.nf
fea681da
MK
34.B #include <unistd.h>
35.sp
36.BI "size_t confstr(int " "name" ", char *" buf ", size_t " len );
37.fi
cc4615cc
MK
38.sp
39.in -4n
40Feature Test Macro Requirements for glibc (see
41.BR feature_test_macros (7)):
42.in
43.sp
e313308d
MK
44.BR confstr ():
45_POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE
fea681da 46.SH DESCRIPTION
63aa9df0 47.BR confstr ()
fea681da
MK
48gets the value of configuration-dependent string variables.
49.PP
50The
51.I name
52argument is the system variable to be queried.
53The following variables are supported:
54.TP
5984622e
MK
55.BR _CS_GNU_LIBC_VERSION " (GNU C library only; since glibc 2.3.2)"
56A string which identifies the GNU C library version on this system
57(e.g, "glibc 2.3.4").
58.TP
59.BR _CS_GNU_LIBPTHREAD_VERSION " (GNU C library only; since glibc 2.3.2)"
60A string which identifies the POSIX implementation supplied by this
61C library (e.g, "NPTL 2.3.4" or "linuxthreads-0.10").
62.TP
fea681da
MK
63.B _CS_PATH
64A value for the
65.B PATH
66variable which indicates where all the POSIX.2 standard utilities can
67be found.
68.PP
69If
70.I buf
c13182ef 71is not NULL and
fea681da
MK
72.I len
73is not zero,
63aa9df0 74.BR confstr ()
fea681da
MK
75copies the value of the string to
76.I buf
77truncated to
78.I len \- 1
a00b7454 79bytes if necessary, with a null byte (\(aq\\0\(aq) as terminator.
fea681da 80This can be detected by comparing the return value of
63aa9df0 81.BR confstr ()
fea681da
MK
82against
83.IR len .
84.PP
85If
86.I len
87is zero and
88.I buf
8478ee02 89is NULL,
63aa9df0 90.BR confstr ()
fea681da
MK
91just returns the value as defined below.
92.SH "RETURN VALUE"
93If
94.I name
4f43f21f 95is a valid configuration variable,
63aa9df0 96.BR confstr ()
c13182ef 97returns the number of bytes (including the terminating null byte)
4f43f21f
MK
98that would be required to hold the entire value of that variable.
99This value may be greater than
100.IR len ,
101which means that the value in
102.I buf
103is truncated.
104
105If
c13182ef
MK
106.I name
107is a valid configuration variable,
4f43f21f 108but that variable does not have a value, then
01a81d11 109.BR confstr ()
fea681da 110returns 0.
4f43f21f
MK
111If
112.I name
113does not correspond to a valid configuration variable,
114.BR confstr ()
115returns 0, and
116.I errno
c13182ef 117is set to
4f43f21f
MK
118.BR EINVAL .
119.SH ERRORS
01a81d11 120.TP
0daa9e92 121.B EINVAL
4f43f21f
MK
122If the value of
123.I name
124is invalid.
2b2581ee 125.SH "CONFORMING TO"
44a2c328 126POSIX.1-2001.
9b336505 127.SH EXAMPLE
fea681da
MK
128The following code fragment determines the path where to find
129the POSIX.2 system utilities:
130.br
131.nf
088a639b 132.in +4n
fea681da 133
6cd17cde
MK
134char *pathbuf;
135size_t n;
fea681da 136
56e83639 137n = confstr(_CS_PATH,NULL,(size_t) 0);
6cd17cde
MK
138pathbuf = malloc(n);
139if (pathbuf == NULL)
140 abort();
fea681da 141confstr(_CS_PATH, pathbuf, n);
088a639b 142.in
c8250206 143.fi
fea681da
MK
144.SH "SEE ALSO"
145.BR sh (1),
146.BR exec (3),
cc4615cc 147.BR system (3)